void CTimeMode::perform() { for(auto & strategy : CConfManager::getInstance().getStrategies()) { m_csv.add("Size", "Time", "TimeDeviation", "BestCost", "MeanCost","CostDeviation", "CostOptDist", "MeanCostOptDist", "MeanSteps", "StepsDeviation", "MeanNumSolutions", "NumSolutionsDeviation"); std::clog << "--------------- " << strategy << " ---------------" << std::endl; auto algSettings = CConfManager::getInstance().getAlgParameters(strategy); for(auto & instance : instanceMap) { std::shared_ptr<IStrategy> currentAlgorithm ( m_algorithmFactory.create(strategy, instance.second.flows, instance.second.distances, algSettings ) ); m_stopWatch.measureExecutionTime(currentAlgorithm, CConfManager::getInstance().getTimeLimit()); auto cost = currentAlgorithm->getCost(); setStatsCalculators(currentAlgorithm); std::clog << "Instance " <<instance.first <<": " << statsCalculatorMap.at("timeStats").getMean() << " " << cost << std::endl; std::ostream_iterator<int> beginIter(std::clog, " "); auto result = currentAlgorithm->getResult(); std::clog << "Found solution: "; std::copy(result.begin(), result.end(), beginIter); std::clog << std::endl; m_csv.add(instance.second.dimensionSize, statsCalculatorMap.at("timeStats").getMean(), statsCalculatorMap.at("timeStats").getStdDev(), cost, statsCalculatorMap.at("costStats").getMean(), statsCalculatorMap.at("costStats").getStdDev(), cost - instance.second.optimalSolution, statsCalculatorMap.at("costStats").getMean() - instance.second.optimalSolution, statsCalculatorMap.at("stepsStats").getMean(), statsCalculatorMap.at("stepsStats").getStdDev(), statsCalculatorMap.at("reviewedSolutionsStats").getMean(), statsCalculatorMap.at("reviewedSolutionsStats").getStdDev() ); } m_csv.toFile(strategy+".csv"); m_csv.clear(); } }
int Indexer::get_text_from_html(const string& fileAbsolutePath, string& text) { string fileContent; fstream fsFileContent; fsFileContent.open(fileAbsolutePath.c_str(), ios_base::in); if(fsFileContent.fail()) { fsFileContent.close(); cout<<fileAbsolutePath<<" Open Failed"<<endl; fsFileContent.close(); return -1; } istreambuf_iterator<char> beginIter(fsFileContent), endIter; fileContent = string(beginIter, endIter); string tagBefore, tagAfter; size_t posTagBefore, posTagAfter, posStart = 0; if((posTagBefore = find_html_tag(fileContent, tagBefore, posStart)) == string::npos) { return -1; } posStart = posTagBefore + tagBefore.size(); while((posTagAfter = find_html_tag(fileContent, tagAfter, posStart)) != string::npos) { if(posTagAfter - posTagBefore >= tagBefore.size() + 1 && tagBefore.find("<script") == string::npos && tagBefore.find("<style") == string::npos) { string textSegment = fileContent.substr(posTagBefore + tagBefore.size(), posTagAfter - (posTagBefore + tagBefore.size())); text.append(textSegment).append(" "); } posTagBefore = posTagAfter; tagBefore = tagAfter; posStart = posTagBefore + tagBefore.size(); } fsFileContent.close(); return 0; }
int GetMiddleMax(const vector<int>& Array, const int Low,const int Mid, const int High) { auto left_max = Array[Mid - 1]; auto right_max = Array[Mid]; std::reverse_iterator<decltype(Array.begin())> beginIter(Array.begin()+ Mid); std::reverse_iterator<decltype(Array.begin())> endIter(Array.begin() + Low); auto accumulater = [](auto&& beginIter,auto&& endIter,auto&& init,auto&& MaxDirect) { accumulate(beginIter, endIter, init, [&MaxDirect](auto&& Sum, auto&& Element) { Sum += Element; if(Sum > MaxDirect) { MaxDirect = Sum; } return Sum; }); return MaxDirect; }; return accumulater(beginIter, endIter, 0, left_max) + accumulater(Array.begin() + Mid, Array.begin() + High, 0, right_max); }