int  main(int  argc, char  *argv[])
{
  FILE      *file1, *file2;
  double    **front1, **front2, **front3;
  int       sizeFront1, sizeFront2, sizeFront3;
  int       redSizeFront1, redSizeFront2, redSizeFront3;
  double    volFront1, volFront2, volFront3;
  int       noObjectives;

  /* check parameters */
  if (argc < 3)  ERROR("missing arguments");
  sscanf(argv[1], "%d", &noObjectives);
  if (noObjectives < 2)  ERROR("invalid argument");
  file1 = fopen(argv[2], "r");
  if (file1 == NULL)  ERROR("cannot open file");
  if (argc == 4) {
    file2 = fopen(argv[3], "r");
    if (file2 == NULL)  ERROR("cannot open file");
  }
  /* read in data */
  sizeFront1 = ReadFront(&front1, file1, noObjectives);
  fclose(file1);
  if (argc == 4) {
    sizeFront2 = ReadFront(&front2, file2, noObjectives);
    sizeFront3 = MergeFronts(&front3, front1, sizeFront1, front2, sizeFront2,
			     noObjectives);
    fclose(file2);
  }
  /* calculate dominated hypervolume */
  redSizeFront1 = FilterNondominatedSet(front1, sizeFront1, noObjectives);
  volFront1 = CalculateHypervolume(front1, redSizeFront1, noObjectives);
  printf("%.10f ", volFront1);
  if (argc ==4 ) {
    redSizeFront2 = FilterNondominatedSet(front2, sizeFront2, noObjectives);
    volFront2 = CalculateHypervolume(front2, redSizeFront2, noObjectives);
    printf("%.10f ", volFront2);
    redSizeFront3 = FilterNondominatedSet(front3, sizeFront3, noObjectives);
    volFront3 = CalculateHypervolume(front3, redSizeFront3, noObjectives);
    printf("%.10f %.10f", volFront3 - volFront2,
	   volFront3 - volFront1);
  }
  DeallocateFront(front1, sizeFront1);
  if (argc ==4 ) {
    DeallocateFront(front2, sizeFront2);
    DeallocateFront(front3, sizeFront3);
  }
  printf("\n");
}
Beispiel #2
0
double  CalculateHypervolume(double  *front[], int  noPoints,
			     int  noObjectives)
{
  int     n;
  double  volume, distance;

  volume = 0;
  distance = 0;
  n = noPoints;
  while (n > 0) {
    int     noNondominatedPoints;
    double  tempVolume, tempDistance;

    noNondominatedPoints = FilterNondominatedSet(front, n, noObjectives - 1);
    tempVolume = 0;
    if (noObjectives < 3) {
      if (noNondominatedPoints < 1)  ERROR("run-time error");
      tempVolume = front[0][0];
    }
    else
      tempVolume = CalculateHypervolume(front, noNondominatedPoints,
					noObjectives - 1);
    tempDistance = SurfaceUnchangedTo(front, n, noObjectives - 1);
    volume += tempVolume * (tempDistance - distance);
    distance = tempDistance;
    n = ReduceNondominatedSet(front, n, noObjectives - 1, distance);
  }
  return volume;
} /* CalculateHypervolume */
Beispiel #3
0
                void operator()(const BO& bo, const AggregatorFunction&)
                {
                    if (bo.observations().empty())
                        return;
                    if (!bo.stats_enabled())
                        return;
                    // convert the data to C arrays
                    double** data = new double* [bo.observations().size()];
                    for (size_t i = 0; i < bo.observations().size(); ++i) {
                        size_t dim = bo.observations()[i].size();
                        data[i] = new double[dim];
                        for (size_t k = 0; k < dim; ++k)
                            data[i][k] = bo.observations()[i](k) + Params::stat_hyper_volume::ref(k);
                    }
                    // call the hypervolume by Zitzler
                    int noObjectives = bo.observations()[0].size();
                    int redSizeFront1 = FilterNondominatedSet(data, bo.observations().size(), noObjectives);
                    double hv = CalculateHypervolume(data, redSizeFront1, noObjectives);

                    // write
                    this->_create_log_file(bo, "hypervolume.dat");
                    (*this->_log_file) << bo.current_iteration() << "\t" << hv << std::endl;

                    // free data
                    for (size_t i = 0; i < bo.observations().size(); ++i)
                        delete[] data[i];
                    delete[] data;
                }
Beispiel #4
0
void  incr_hv(double* hv_i, double* A, size_t numelA, size_t nObjs)
{
  //FILE      *file1, *file2;
  double    **front1;
  int       sizeFront1 = numelA;
  int       redSizeFront1;
  double    volFront1;
  int       noObjectives=nObjs;

  /* populate the front*/
  populateFront(&front1, A, numelA, noObjectives);
  /* calculate dominated hypervolume */
  redSizeFront1 = FilterNondominatedSet(front1, sizeFront1, noObjectives);
  volFront1 = CalculateHypervolume(front1, redSizeFront1, noObjectives);
  printf("%.10f ", volFront1);
}