coins/ExecuteCoins.cpp
/**
 * @brief: Executes the algorithm using SingleThreading. Is the most simple implementation
 *           for this specific case and should be used to analyze what is happening.
 *         First we generate an input and answers txt file in twelvecoins.generate.
 *         We then load both files into vectors so that their entire x amount of inputs
 *           can be iterated upon.
 */
@brief: Executes the algorithm using SingleThreading. Is the most simple implementation
for this specific case and should be used to analyze what is happening.
First we generate an input and answers txt file in twelvecoins.generate.
We then load both files into vectors so that their entire x amount of inputs
can be iterated upon.
@brief : Executes the algorithm using SingleThreading . Is the most simple implementation for this specific case and should be used to analyze what is happening . First we generate an input and answers txt file in twelvecoins . generate . We then load both files into vectors so that their entire x amount of inputs can be iterated upon .
results ExecuteCoins::initializeSingle(params p)
{
    if (p.generateNew) twelvecoins.generate(p.count);
    std::vector<std::vector<int>> inpVect = twelvecoins.initInput();
    std::vector<coin> ansVect = twelvecoins.initAnswers();
    int size = std::min((int)ansVect.size(),p.count);
    int i = 0;
    auto startTotal = std::chrono::high_resolution_clock::now();
    for (std::vector<std::vector<int>>::iterator it = inpVect.begin() ; it != inpVect.end() && i < size; ++it, ++i) {
        std::vector<int> arr = *it;
        auto startAlgo = std::chrono::high_resolution_clock::now();
        coin out = twelvecoins.exec(arr);
        auto stopAlgo = std::chrono::high_resolution_clock::now();
        durationExec += std::chrono::duration_cast<std::chrono::microseconds>(stopAlgo - startAlgo);
        numCorrect += twelvecoins.validate(out,ansVect.at(i));
    }
    auto stopTotal = std::chrono::high_resolution_clock::now();
    durationTotal = std::chrono::duration_cast<std::chrono::microseconds>(stopTotal - startTotal);
    r.correct = numCorrect;
    r.algoDuration = durationExec;
    r.functDuration = durationTotal;
    return r;
}
results ExecuteCoins :: initializeSingle ( params p ) { if ( p . generateNew ) twelvecoins . generate ( p . count ) ; std :: vector < std :: vector < int > > inpVect = twelvecoins . initInput ( ) ; std :: vector < coin > ansVect = twelvecoins . initAnswers ( ) ; int size = std :: min ( ( int ) ansVect . size ( ) , p . count ) ; int i = 0 ; auto startTotal = std :: chrono :: high_resolution_clock :: now ( ) ; for ( std :: vector < std :: vector < int > > :: iterator it = inpVect . begin ( ) ; it != inpVect . end ( ) && i < size ; ++ it , ++ i ) { std :: vector < int > arr = * it ; auto startAlgo = std :: chrono :: high_resolution_clock :: now ( ) ; coin out = twelvecoins . exec ( arr ) ; auto stopAlgo = std :: chrono :: high_resolution_clock :: now ( ) ; durationExec += std :: chrono :: duration_cast < std :: chrono :: microseconds > ( stopAlgo - startAlgo ) ; numCorrect += twelvecoins . validate ( out , ansVect . at ( i ) ) ; } auto stopTotal = std :: chrono :: high_resolution_clock :: now ( ) ; durationTotal = std :: chrono :: duration_cast < std :: chrono :: microseconds > ( stopTotal - startTotal ) ; r . correct = numCorrect ; r . algoDuration = durationExec ; r . functDuration = durationTotal ; return r ; }
@brief: Executes the algorithm using SingleThreading.
@brief : Executes the algorithm using SingleThreading .
// Execute the algo