void File::parseStrategies(TiXmlNode* s){ int tries; s->ToElement()->QueryIntAttribute("tries",&tries); for(TiXmlElement* pElem=s->FirstChild()->ToElement();pElem != NULL; pElem=pElem->NextSiblingElement()){ string type = pElem->Attribute("type"); // Strategy to add with memoization option Strategy *s = NULL; if(type.compare("doe") == 0){ s = new DesignOfExperiments(); s->setDoeSize(128); } else if(type.compare("random_greedy") == 0){ s = new RandomGreedy(); } else if(type.compare("hill_climbing") == 0){ s = new HillClimbing(); } else if(type.compare("genetic") == 0){ s = new Genetic(); } // Always memoization s->setMemo(true); // Add to list int intValue; string strValue; double doubValue; if(pElem->QueryIntAttribute("doesize",&intValue) != TIXML_NO_ATTRIBUTE){ s->setDoeSize(intValue); } if(pElem->QueryValueAttribute("onlynew",&strValue) != TIXML_NO_ATTRIBUTE){ bool newRandom = to_bool(strValue); s->setOnlyNewRandom(newRandom); } if(pElem->QueryValueAttribute("random",&strValue) != TIXML_NO_ATTRIBUTE){ bool randomInit = to_bool(strValue); s->setRandomInit(randomInit); } // if(pElem->QueryValueAttribute("memoization",&strValue) != TIXML_NO_ATTRIBUTE){ // bool memo = to_bool(strValue); // s->setMemo(memo); // } if(pElem->QueryValueAttribute("limit_energy",&doubValue) != TIXML_NO_ATTRIBUTE){ limit_t l; l.amountType = ENERGY; l.amount = doubValue; s->setLimited(true); s->setLimitType(l); s->setMemo(true); } if(pElem->QueryValueAttribute("limit_duration",&doubValue) != TIXML_NO_ATTRIBUTE){ limit_t l; l.amountType = DURATION; l.amount = doubValue; s->setLimited(true); s->setLimitType(l); s->setMemo(true); } if(pElem->QueryValueAttribute("limit_memory",&doubValue) != TIXML_NO_ATTRIBUTE){ limit_t l; l.amountType = MEMORY; l.amount = doubValue; s->setLimited(true); s->setLimitType(l); s->setMemo(true); } if(pElem->QueryValueAttribute("hit_percent",&doubValue) != TIXML_NO_ATTRIBUTE){ s->fillToHitPercent = true; s->setHitPercentGoal(doubValue); s->setMemo(true); } if(pElem->QueryValueAttribute("doeLimits",&strValue) != TIXML_NO_ATTRIBUTE){ bool doeLimits = to_bool(strValue); s->setDoeLimits(doeLimits); s->setDoeSize(128); } //tfunc format (line|cons|temp)tp1[:tp2] Ex: "line|5.0|1.0" if(pElem->QueryValueAttribute("tfunc",&strValue) != TIXML_NO_ATTRIBUTE){ string func,tp1_str,tp2_str; temp_func function; int delim; float tp1 = 0,tp2 = 0; // Function is first 4 characters func = strValue.substr(0,4); strValue = strValue.substr(4+1,strValue.length()-4-1); // One parameter function if(func.compare("cons") == 0){ function = CONSTANT; tp1_str = strValue.c_str(); } // Two parameter function else{ if(func.compare("line") == 0){ function = LINEAR; } else if(func.compare("expo") == 0){ function = EXPONENTIAL; } else { // What the heck is this? cout << "Unknown temperature function: " << func << endl; exit(1); } // Find delimiter and use it to return tp1 and tp2 delim = strValue.find(':'); tp1_str = strValue.substr(0,delim-0); tp2_str = strValue.substr(delim+1,strValue.length()-delim); tp2 = std::atof(tp2_str.c_str()); } tp1 = std::atof(tp1_str.c_str()); s->setTempFunc(function,tp1,tp2); } s->setSeed(seed); s->setTries(tries); strategies.push_back(const_strategy_ptr(s)); } }