Exemplo n.º 1
0
void analyze(TTPOutputSet bestFront, TTPOutputSet front) {

    vector<vector<double>> solutionFront = convertTTPOutput(front);
    vector<vector<double>> trueFront = convertTTPOutput(bestFront);

    Hypervolume hv;
    double hvValue = hv.hypervolume(solutionFront, trueFront, trueFront[0].size());


    Spread spread;
    double spreadValue = spread.spread(solutionFront, trueFront, trueFront[0].size());

    InvertedGenerationalDistance igd;
    double igdValue = igd.invertedGenerationalDistance(solutionFront, trueFront, trueFront[0].size());


    Epsilon eps;
    double epsValue = eps.epsilon(solutionFront, trueFront, trueFront[0].size());


    cout << "hv: " << hvValue << endl;
    cout << "spread: " << spreadValue << endl;
    cout << "igd: " << igdValue << endl;
    cout << "eps: " << epsValue << endl;


}
Exemplo n.º 2
0
void ExperimentReport::generateQualityIndicators() {


  if ((!isSingleObjective_) && (paretoFrontDirectory_.empty())) {
    generateReferenceFronts();
  }

  // TODO: Check if it is possible to use QualityIndicator class instead each independent class.
  // Problem: knowing number of objectives of each problem

  if (indicatorList_.size() > 0) {

    cout << "PF file: " << paretoFrontDirectory_ << endl;

    for (int algorithmIndex=0; algorithmIndex<algorithmNameList_.size(); algorithmIndex++) {

      string algorithmDirectory;
      algorithmDirectory = experimentBaseDirectory_ + "/data/" + algorithmNameList_[algorithmIndex] + "/";

      for (int problemIndex=0; problemIndex<problemList_.size(); problemIndex++) {

        string problemDirectory = algorithmDirectory + problemList_[problemIndex];
        string paretoFrontPath;

        if (!isSingleObjective_) {

          if (paretoFrontDirectory_.empty()) {

            string referenceFrontDirectory = experimentBaseDirectory_ + "/referenceFronts";
            paretoFrontPath = referenceFrontDirectory + "/" + problemList_[problemIndex] + ".rf";

          } else {
            paretoFrontPath = paretoFrontDirectory_ + "/" + paretoFrontFile_[problemIndex];
          } // if

        } // if

        for (int indicatorIndex = 0; indicatorIndex < indicatorList_.size(); indicatorIndex++) {


          resetFile(problemDirectory + "/" + indicatorList_[indicatorIndex]);

          if (indicatorList_[indicatorIndex].compare("FIT")==0) {

            string solutionFrontFile = problemDirectory + "/FUN";
            string qualityIndicatorFile = problemDirectory;

            Fitness * indicators = new Fitness();
            vector< vector<double> > solutionFront =
                indicators->utils_->readFront(solutionFrontFile);
            qualityIndicatorFile = qualityIndicatorFile + "/FIT";
            indicators->fitness(solutionFront, qualityIndicatorFile);
            delete indicators;

          } else {

            for (int numRun=0; numRun<independentRuns_; numRun++) {

              stringstream outputParetoFrontFilePath;
              outputParetoFrontFilePath << problemDirectory << "/FUN_" << numRun;
              string solutionFrontFile = outputParetoFrontFilePath.str();
              string qualityIndicatorFile = problemDirectory;
              double value;

              cout << "ExperimentReport: Quality indicator: " << indicatorList_[indicatorIndex] << endl;

              if (indicatorList_[indicatorIndex].compare("HV")==0) {

                Hypervolume * indicators = new Hypervolume();
                vector< vector<double> > solutionFront =
                    indicators->utils_->readFront(solutionFrontFile);
                vector< vector<double> > trueFront =
                    indicators->utils_->readFront(paretoFrontPath);
                value = indicators->hypervolume(solutionFront, trueFront, trueFront[0].size());
                delete indicators;
                qualityIndicatorFile = qualityIndicatorFile + "/HV";
              }
              if (indicatorList_[indicatorIndex].compare("SPREAD")==0) {
                Spread * indicators = new Spread();
                vector< vector<double> > solutionFront =
                    indicators->utils_->readFront(solutionFrontFile);
                vector< vector<double> > trueFront =
                    indicators->utils_->readFront(paretoFrontPath);
                value = indicators->spread(solutionFront, trueFront, trueFront[0].size());
                delete indicators;
                qualityIndicatorFile = qualityIndicatorFile + "/SPREAD";
              }
              if (indicatorList_[indicatorIndex].compare("IGD")==0) {
                InvertedGenerationalDistance * indicators = new InvertedGenerationalDistance();
                vector< vector<double> > solutionFront =
                    indicators->utils_->readFront(solutionFrontFile);
                vector< vector<double> > trueFront =
                    indicators->utils_->readFront(paretoFrontPath);
                value = indicators->invertedGenerationalDistance(solutionFront, trueFront, trueFront[0].size());
                delete indicators;
                qualityIndicatorFile = qualityIndicatorFile + "/IGD";
              }
              if (indicatorList_[indicatorIndex].compare("EPSILON")==0) {
                Epsilon * indicators = new Epsilon();
                vector< vector<double> > solutionFront =
                    indicators->utils_->readFront(solutionFrontFile);
                vector< vector<double> > trueFront =
                    indicators->utils_->readFront(paretoFrontPath);
                value = indicators->epsilon(solutionFront, trueFront, trueFront[0].size());
                delete indicators;
                qualityIndicatorFile = qualityIndicatorFile + "/EPSILON";
              }

              cout << "ExperimentReport: Quality indicator file: " << qualityIndicatorFile << endl;

              if (qualityIndicatorFile.compare(problemDirectory)!=0) {
                std::fstream out(qualityIndicatorFile.c_str(),
                    std::ios::out | std::ios::app);
                out << value << endl;
                out.close();
              } // if

            } // for

          } // if
        } // for
      } // for
    } // for
  } // if
} // generateQualityIndicators