repetitionConstraints.cpp 540 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#include "repetitionConstraints.h"

#include "model/course.h"

std::pair<bool, double> ConstraintsRepetition::integrityCheck(Cursus indiv)
{
    int nbOfRepetition = 0;

    for(int i = 0; i < indiv.size(); i++)
    {
        for(int j = i+1; j < indiv.size(); j++)
        {
            if(indiv.at(i) == indiv.at(j))
                nbOfRepetition++;
        }
    }
    bool isOK = nbOfRepetition == 0;
    double metric = 1 - ( ( (double) nbOfRepetition * 2) / (double)indiv.size() );
    return std::pair<bool, double>(isOK, metric);
}