Evaluates a solution

@param solution The solution to evaluate
359077
@Override
  public void evaluate(DoubleSolution solution) {

    int numberOfVariables_ = solution.getNumberOfVariables();
    int numberOfObjectives_ = solution.getNumberOfObjectives();

    double[] x = new double[numberOfVariables_];
    double[] f = new double[numberOfObjectives_];

    for (int i = 0; i < numberOfVariables_; i++) {
      x[i] = solution.getVariableValue(i);
    }

    // evaluate zi,t1i,t2i,t3i,t4i,yi
    double[] z = new double[numberOfVariables_];
    double[] t1 = new double[numberOfVariables_];
    double[] t2 = new double[numberOfVariables_];
    double[] t3 = new double[numberOfVariables_];
    double[] t4 = new double[numberOfObjectives_];
    double[] y = new double[numberOfObjectives_];
    double sub1 = 0, sub2 = 0;
    int lb = 0, ub = 0;
    for (int i = 0; i < K10; i++) {
      z[i] = x[i] / (2 * i + 2);
      t1[i] = z[i];
      t2[i] = t1[i];
      t3[i] = Math.pow(t2[i], 0.02);
    }
    for (int i = K10; i < numberOfVariables_; i++) {
      z[i] = x[i] / (2 * i + 2);
      t1[i] = Math.abs(z[i] - 0.35) / (Math.abs(Math.floor(0.35 - z[i]) + 0.35));
      t2[i] = 0.8 + 0.8 * (0.75 - t1[i]) * Math.min(0, Math.floor(t1[i] - 0.75)) / 0.75
          - 0.2 * (t1[i] - 0.85) * Math.min(0, Math.floor(0.85 - t1[i])) / 0.15;
      t2[i] = Math.round(t2[i] * 1000000) / 1000000.0;
      t3[i] = Math.pow(t2[i], 0.02);
    }
    for (int i = 0; i < numberOfObjectives_ - 1; i++) {
      sub1 = 0;
      sub2 = 0;
      lb = i * K10 / (numberOfObjectives_ - 1) + 1;
      ub = (i + 1) * K10 / (numberOfObjectives_ - 1);
      for (int j = lb - 1; j < ub; j++) {
        sub1 += (2 * (j + 1) * t3[j]);
        sub2 += (2 * (j + 1));
      }
      t4[i] = sub1 / sub2;
    }
    lb = K10 + 1;
    ub = numberOfVariables_;
    sub1 = 0;
    sub2 = 0;
    for (int j = lb - 1; j < ub; j++) {
      sub1 += (2 * (j + 1) * t3[j]);
      sub2 += (2 * (j + 1));
    }
    t4[numberOfObjectives_ - 1] = sub1 / sub2;
    for (int i = 0; i < numberOfObjectives_ - 1; i++) {
      y[i] = (t4[i] - 0.5) * Math.max(1, t4[numberOfObjectives_ - 1]) + 0.5;
    }
    y[numberOfObjectives_ - 1] = t4[numberOfObjectives_ - 1];

    // evaluate fm,fm-1,...,2,f1
    double subf1 = 1;
    f[numberOfObjectives_ - 1] = y[numberOfObjectives_ - 1] + 2 * numberOfObjectives_ * (1 - y[0]
        - Math.cos(10 * Math.PI * y[0] + Math.PI / 2) / (10 * Math.PI));
    for (int i = numberOfObjectives_ - 2; i > 0; i--) {
      subf1 *= (1 - Math.cos(Math.PI * y[numberOfObjectives_ - i - 2] / 2));
      f[i] = y[numberOfObjectives_ - 1] + 2 * (i + 1) * subf1 * (1 - Math
          .sin(Math.PI * y[numberOfObjectives_ - i - 1] / 2));
    }
    f[0] = y[numberOfObjectives_ - 1] + 2 * subf1 * (1 - Math
        .cos(Math.PI * y[numberOfObjectives_ - 2] / 2));

    for (int i = 0; i < numberOfObjectives_; i++) {
      solution.setObjective(i, f[i]);
    }
  }
1321670
@Override public void run() {
    int evaluations;
    List<S> solutionSet, offSpringSolutionSet;

    //Initialize the variables
    solutionSet = new ArrayList<>(populationSize);
    archive = new ArrayList<>(archiveSize);
    evaluations = 0;

    //-> Create the initial solutionSet
    S newSolution;
    for (int i = 0; i < populationSize; i++) {
      newSolution = problem.createSolution();
      problem.evaluate(newSolution);
      evaluations++;
      solutionSet.add(newSolution);
    }

    while (evaluations < maxEvaluations) {
      List<S> union = new ArrayList<>();
      union.addAll(solutionSet);
      union.addAll(archive);
      calculateFitness(union);
      archive = union;

      while (archive.size() > populationSize) {
        removeWorst(archive);
      }
      // Create a new offspringPopulation
      offSpringSolutionSet = new ArrayList<>(populationSize);
      S parent1;
      S parent2;
      while (offSpringSolutionSet.size() < populationSize) {
        int j = 0;
        do {
          j++;
          parent1 = selectionOperator.execute(archive);
        } while (j < IBEA.TOURNAMENTS_ROUNDS);
        int k = 0;
        do {
          k++;
          parent2 = selectionOperator.execute(archive);
        } while (k < IBEA.TOURNAMENTS_ROUNDS);

        List<S> parents = new ArrayList<>(2);
        parents.add(parent1);
        parents.add(parent2);

        //make the crossover
        List<S> offspring = crossoverOperator.execute(parents);
        mutationOperator.execute(offspring.get(0));
        problem.evaluate(offspring.get(0));
        //problem.evaluateConstraints(offSpring[0]);
        offSpringSolutionSet.add(offspring.get(0));
        evaluations++;
      }
      solutionSet = offSpringSolutionSet;
    }
  }
383664
@Override
  public void evaluate(DoubleSolution solution) {

    int numberOfVariables_ = solution.getNumberOfVariables();
    int numberOfObjectives = solution.getNumberOfObjectives();

    double[] x = new double[numberOfVariables_];
    double[] f = new double[numberOfObjectives];

    for (int i = 0; i < numberOfVariables_; i++) {
      x[i] = solution.getVariableValue(i);
    }

    // check if the point is infeasible
    boolean infeasible = false;
    infeasible = if_infeasible(x);
    while (infeasible) {
      //re-generate a random variable
      for (int i = 0; i < numberOfVariables_; i++) {
        x[i] = generV(getLowerBound(i), getUpperBound(i));
        solution.setVariableValue(i, x[i]);
      }
      infeasible = if_infeasible(x);
    }

    // evaluate f1,...m-1
    for (int i = 0; i < M9 - 1; i++) {
      if (r_polyline9[i][0] == 1) {
        f[i] = Math.abs(x[0] - r_polyline9[i][1]);
      } else {
        f[i] = Math.abs((r_polyline9[i][1] * x[0] - x[1] + r_polyline9[i][2])) / Math
            .sqrt(Math.pow(r_polyline9[i][1], 2) + 1);
      }
    }
    // evaluate fm
    if (r_polyline9[M9 - 1][0] == 1) {
      f[M9 - 1] = Math.abs(x[0] - r_polyline9[M9 - 1][1]);
    } else {
      f[M9 - 1] = Math.abs((r_polyline9[M9 - 1][1] * x[0] - x[1] + r_polyline9[M9 - 1][2])) / Math
          .sqrt(Math.pow(r_polyline9[M9 - 1][1], 2) + 1);
    }

    for (int i = 0; i < numberOfObjectives; i++) {
      solution.setObjective(i, f[i]);
    }

  }
374395
@Override
  public void evaluate(IntegerDoubleSolution solution) {
    int approximationToN;
    int approximationToM ;

    approximationToN = 0;
    approximationToM = 0;

    for (int i = 0; i < solution.getNumberOfIntegerVariables(); i++) {
      int value = solution.getVariableValue(i).intValue() ;
      approximationToN += Math.abs(valueN - value) ;
      approximationToM += Math.abs(valueM - value) ;
    }

    for (int i = solution.getNumberOfIntegerVariables(); i < (solution.getNumberOfIntegerVariables()+solution.getNumberOfDoubleVariables()); i++) {
      double value = solution.getVariableValue(i).doubleValue() ;
      approximationToN += Math.abs(valueN - value) ;
      approximationToM += Math.abs(valueM - value) ;
    }

    solution.setObjective(0, approximationToN);
    solution.setObjective(1, approximationToM);
  }
596301
private void evaluateConstraints(DoubleSolution solution) {
    double [] constraint = new double[this.getNumberOfConstraints()];
    double[] x = new double[getNumberOfVariables()] ;

    for (int i = 0; i < getNumberOfVariables(); i++) {
      x[i] = solution.getVariableValue(i) ;
    }

    double x1, x2, x3, x4;
    int var=0;
    int con=0;

    // restricciones de relaciÃƒÂ³n de forma en las paredes b/t
    for (int gr=0; gr<numberOfGroupElements_;gr++){

      var+=Groups_[gr][VARIABLES];
      con+=Groups_[gr][CONSTRAINT];

      if (Groups_[gr][SHAPE]==CIRCLE){
        x1=x[var-1]; // diameter
      }
      else if (Groups_[gr][SHAPE]==HOLE_CIRCLE){
        x1=x[var-2]; // diameter
        x2=x[var-1]; // tickness plate

        double ratio=x1/x2;
        if(ratio<x2/x1) ratio=x2/x1;
        constraint[con-1]=-ratio+Groups_[gr][RATIO_YZ]; // relaciÃƒÂ³n entre altura y base
      }
      else if (Groups_[gr][SHAPE]==RECTANGLE){
        x1=x[var-2]; // higth (y axis)
        x2=x[var-1]; // witdth (z axis)

        double ratio = x1/x2;
        constraint[con-2]=+ratio-Groups_[gr][RATIO_YZ]*0.75; // relaciÃƒÂ³n entre altura y base maxima
        constraint[con-1]=-ratio+Groups_[gr][RATIO_YZ]*1.5; // relaciÃƒÂ³n entre altura y base minima

      }

      else if (Groups_[gr][SHAPE]==HOLE_RECTANGLE){
        x1=x[var-4]; // height (y axis)
        x2=x[var-3]; // width (z axis)
        x3=x[var-2]; // tickness along Y axis => tickness of width  plate
        x4=x[var-1]; // tickness along Z axis => tickness of heigth plate

        double ratio=x1/x2;
        constraint[con-4]=+ratio-Groups_[gr][RATIO_YZ]*0.75; // relaciÃƒÂ³n entre altura y base maxima
        constraint[con-3]=-ratio+Groups_[gr][RATIO_YZ]*1.25; // relaciÃƒÂ³n entre altura y base minima

        double tb1=-x3*15+x1;
        double tb2=+x3*30-x1;
        double ta1=-x4*10+x2;
        double ta2=+x4*20-x2;
        //double ta2=-x2/x4+27;//0.3*Math.sqrt(Groups_[gr][E_]/(Groups_[gr][STRESS])); // relaciÃƒÂ³n entre espesor de la placa y altura de lados
        constraint[con-2]=Math.min(tb1, tb2);//-x1/x3+1.12*Math.sqrt(Groups_[gr][E_]/(Groups_[gr][STRESS]*2)); // relaciÃƒÂ³n entre espesor de la placa y altura de lados
        constraint[con-1]=Math.min(ta1, ta2);//-x2/x4+1.12*Math.sqrt(Groups_[gr][E_]/(Groups_[gr][STRESS]*2.0)); // relaciÃƒÂ³n entre espesor de la placa y altura de lados

      }

      else if (Groups_[gr][SHAPE]==I_SINGLE){
        x1=x[var-4]; // height (y axis)
        x2=x[var-3]; // width (Z axis)
        x3=x[var-2]; // tickness along Y axis => tickness of width  plate
        x4=x[var-1]; // tickness along Z axis => tickness of heigth plate

        double ratio=x1/x2;
        constraint[con-4]=+ratio-Groups_[gr][RATIO_YZ]*0.75; // relaciÃƒÂ³n entre altura y base maxima
        constraint[con-3]=-ratio+Groups_[gr][RATIO_YZ]*1.25; // relaciÃƒÂ³n entre altura y base minima

        double tb1=-x3*15+x1;
        double tb2=+x3*30-x1;
        double ta1=-x4*10+x2;
        double ta2=+x4*20-x2;

        //double tb1=-x3*20+x1;
        //double tb2=-x1/x3+35;//0.6*Math.sqrt(Groups_[gr][E_]/(Groups_[gr][STRESS])); // relaciÃƒÂ³n entre espesor de la placa y altura de lados
        //double ta1=-x4*15+x2;
        //double ta2=-x2/x4+27;//0.3*Math.sqrt(Groups_[gr][E_]/(Groups_[gr][STRESS])); // relaciÃƒÂ³n entre espesor de la placa y altura de lados
        constraint[con-2]=Math.min(tb1, tb2);//-x1/x3+1.12*Math.sqrt(Groups_[gr][E_]/(Groups_[gr][STRESS]*2)); // relaciÃƒÂ³n entre espesor de la placa y altura de lados
        constraint[con-1]=Math.min(ta1, ta2);//-x2/x4+1.12*Math.sqrt(Groups_[gr][E_]/(Groups_[gr][STRESS]*2.0)); // relaciÃƒÂ³n entre espesor de la placa y altura de lados

      }

      else if (Groups_[gr][SHAPE]==I_DOUBLE){
        x1=x[var-4]; // height (y axis)
        x2=x[var-3]; // width (Z axis)
        x3=x[var-2]; // tickness along Y axis => tickness of width  plate
        x4=x[var-1]; // tickness along Z axis => tickness of heigth plate
        double ratio=x1/x2;
        constraint[con-4]=-ratio+Groups_[gr][RATIO_YZ]; // relaciÃƒÂ³n entre altura y base maxima
        constraint[con-3]=+ratio-Groups_[gr][RATIO_YZ]*0.85; // /2.0 relaciÃƒÂ³n entre altura y base minima
        constraint[con-2]=-x1/x3+1.12*Math.sqrt(Groups_[gr][E_]/(Groups_[gr][STRESS])); // relaciÃƒÂ³n entre espesor de la placa y altura de lados
        constraint[con-1]=-x2/x4+0.35*Math.sqrt(Groups_[gr][E_]/(Groups_[gr][STRESS_CUT]*2.0)); // relaciÃƒÂ³n entre espesor de la placa y altura de lados
      }
      else if (Groups_[gr][SHAPE]==H_SINGLE){
        x1=x[var-4]; // height (y axis)
        x2=x[var-3]; // width (Z axis)
        x3=x[var-2]; // tickness along Y axis => tickness of width  plate
        x4=x[var-1]; // tickness along Z axis => tickness of heigth plate
        double ratio=x1/x2;
        constraint[con-4]=-ratio+Groups_[gr][RATIO_YZ]*0.85; // /2.0 relaciÃƒÂ³n entre altura y base maxima
        constraint[con-3]=+ratio-Groups_[gr][RATIO_YZ]; // relaciÃƒÂ³n entre altura y base minima
        constraint[con-2]=-x1/x3+0.35*Math.sqrt(Groups_[gr][E_]/(Groups_[gr][STRESS_CUT]*2.0)); // relaciÃƒÂ³n entre espesor de la placa y altura de lados
        constraint[con-1]=-x2/x4+1.12*Math.sqrt(Groups_[gr][E_]/(Groups_[gr][STRESS]*2.0)); // relaciÃƒÂ³n entre espesor de la placa y altura de lados
      }
      else if (Groups_[gr][SHAPE]==H_DOUBLE){
        x1=x[var-4]; // height (y axis)
        x2=x[var-3]; // width (Z axis)
        x3=x[var-2]; // thickness along Y axis => thickness of width  plate
        x4=x[var-1]; // thickness along Z axis => thickness of heigth plate
        double ratio=x1/x2;
        constraint[con-4]=-ratio+Groups_[gr][RATIO_YZ]*0.1; // 2.0 relaciÃƒÂ³n entre altura y base maxima
        constraint[con-3]=+ratio-Groups_[gr][RATIO_YZ]; // relaciÃƒÂ³n entre altura y base minima
        constraint[con-2]=-x1/x3+1.12*Math.sqrt(Groups_[gr][E_]/(Groups_[gr][STRESS_CUT]*2.0)); // relaciÃƒÂ³n entre espesor de la placa y altura de lados
        constraint[con-1]=-x2/x4+1.12*Math.sqrt(Groups_[gr][E_]/(Groups_[gr][STRESS]*2.0)); // relaciÃƒÂ³n entre espesor de la placa y altura de lados
      }
      else if (Groups_[gr][SHAPE]==L_SINGLE){
        x1=x[var-4]; // height (y axis)
        x2=x[var-3]; // width (Z axis)
        x3=x[var-2]; // thickness along Y axis => thickness of width  plate
        x4=x[var-1]; // thickness along Z axis => thickness heigth plate
        double ratio=x1/x2;
        constraint[con-4]=-ratio+Groups_[gr][RATIO_YZ]; // ratio between height and base
        constraint[con-3]=+ratio-Groups_[gr][RATIO_YZ]; // relaciÃƒÂ³n entre altura y base minima
        constraint[con-2]=-x1/x3+1.12*Math.sqrt(Groups_[gr][E_]/(Groups_[gr][STRESS]*2.0)); // relaciÃƒÂ³n entre espesor de la placa y altura de lados
        constraint[con-1]=-x2/x4+1.12*Math.sqrt(Groups_[gr][E_]/(Groups_[gr][STRESS]*2.0)); // relaciÃƒÂ³n entre espesor de la placa y altura de lados
      }
      else if (Groups_[gr][SHAPE]==L_DOUBLE){
        x1=x[var-4]; // height (y axis)
        x2=x[var-3]; // width (Z axis)
        x3=x[var-2]; // tickness along Y axis => tickness of width  plate
        x4=x[var-1]; // tickness along Z axis => tickness of heigth plate
        double ratio=x1/x2;
        constraint[con-4]=-ratio+Groups_[gr][RATIO_YZ]; // relaciÃƒÂ³n entre altura y base maxima
        constraint[con-3]=+ratio-Groups_[gr][RATIO_YZ]; // relaciÃƒÂ³n entre altura y base minima
        constraint[con-2]=-x1/x3+1.12*Math.sqrt(Groups_[gr][E_]/(Groups_[gr][STRESS]*2.0)); // relaciÃƒÂ³n entre espesor de la placa y altura de lados
        constraint[con-1]=-x2/x4+1.12*Math.sqrt(Groups_[gr][E_]/(Groups_[gr][STRESS]*2.0)); // relaciÃƒÂ³n entre espesor de la placa y altura de lados
      }
      else if (Groups_[gr][SHAPE]==T_SINGLE){
        x1=x[var-4]; // height (y axis)
        x2=x[var-3]; // width (Z axis)
        x3=x[var-2]; // tickness along Y axis => tickness of width  plate
        x4=x[var-1]; // tickness along Z axis => tickness of heigth plate
        double ratio=x1/x2;
        constraint[con-4]=-ratio+Groups_[gr][RATIO_YZ]; // relaciÃƒÂ³n entre altura y base maxima
        constraint[con-3]=+ratio-Groups_[gr][RATIO_YZ]*0.9; // 2.0 relaciÃƒÂ³n entre altura y base minima
        constraint[con-2]=-x1/x3+1.12*Math.sqrt(Groups_[gr][E_]/(Groups_[gr][STRESS]*2.0)); // relaciÃƒÂ³n entre espesor de la placa y altura de lados
        constraint[con-1]=-x2/x4+1.12*Math.sqrt(Groups_[gr][E_]/(Groups_[gr][STRESS]*2.0)); // relaciÃƒÂ³n entre espesor de la placa y altura de lados
      }
      else if (Groups_[gr][SHAPE]==T_DOUBLE){
        x1=x[var-4]; // height (y axis)
        x2=x[var-3]; // width (Z axis)
        x3=x[var-2]; // tickness along Y axis => tickness of width  plate
        x4=x[var-1]; // tickness along Z axis => tickness of heigth plate
        double ratio=x1/x2;
        constraint[con-4]=-ratio+Groups_[gr][RATIO_YZ]; // relaciÃƒÂ³n entre altura y base maxima
        constraint[con-3]=+ratio-Groups_[gr][RATIO_YZ]*0.9; // 2.0 relaciÃƒÂ³n entre altura y base minima
        constraint[con-2]=-x1/x3+1.12*Math.sqrt(Groups_[gr][E_]/(Groups_[gr][STRESS]*2.0)); // relaciÃƒÂ³n entre espesor de la placa y altura de lados
        constraint[con-1]=-x2/x4+1.12*Math.sqrt(Groups_[gr][E_]/(Groups_[gr][STRESS]*2.0)); // relaciÃƒÂ³n entre espesor de la placa y altura de lados
      }
      else{
        System.out.println("Error in constraint: transverse section not considerated for: " + gr + " group") ;
      }
    } // next gr

/*
    // LONGITUD TOTAL DE LA VIGA
    double l=0;
    for(int ba=0; ba<numberOfElements_; ba++){
        l+=Element_[ba][2];
    }
*/

    // RESTRICCIONES POR TENSIÃ“N
    for(int hi=0; hi<numberOfWeigthHypothesis_; hi++){
      for(int gr=0; gr<numberOfGroupElements_; gr++){

        // RESTRICCIONES DEBIDO A LA TENSIÃƒÂ³N DE TRACCIÃƒÂ³N
        constraint[con]=(-StrainMax_[gr][hi]+Groups_[gr][STRESS]); // -StrainMax_[gr][hi]*1.001+Groups_[gr][STRESS]
        con += 1;

        //constraint[con]=(-StrainMax_[gr][hi]+Groups_[gr][STRESS]*0.50); // -StrainMax_[gr][hi]*1.001+Groups_[gr][STRESS]
        //con += 1;

        // RESTRICCIONES DEBIDO A LA TENSIÃƒÂ³N DE COMPRESIÃƒÂ³N
        constraint[con]=(+StrainMin_[gr][hi]-Groups_[gr][COMPRESSION]); // +StrainMin_[gr][hi]*0.999-Groups_[gr][COMPRESSION]
        con += 1;

        //constraint[con]=(+StrainMin_[gr][hi]+Groups_[gr][COMPRESSION]*0.50); // +StrainMin_[gr][hi]*0.999-Groups_[gr][COMPRESSION]
        //con += 1;

        // RESTRICCIONES DEBIDO A LA TENSIÃƒâ€œN DE CORTE
        constraint[con]=(-StrainCutMax_[gr][hi]+Groups_[gr][STRESS_CUT]); // -StrainCutMax_[gr][hi]*1.001+Groups_[gr][STRESS_CUT]
        con += 1;
      }
    }


    for(int hi=0; hi<numberOfWeigthHypothesis_; hi++){
      // constraint of node displacement structure
      double deltaN=0;
      for(int i=0;i<nodeCheck_.length;i++){
        double xn=DisplacementNodes_[numberOfLibertyDegree_ * (int)nodeCheck_[i][0]+aX_][hi];
        double yn=DisplacementNodes_[numberOfLibertyDegree_ * (int)nodeCheck_[i][0]+aY_][hi];
        double zn=DisplacementNodes_[numberOfLibertyDegree_ * (int)nodeCheck_[i][0]+aZ_][hi];
        deltaN= Math.sqrt(Math.pow(xn,2)+Math.pow(yn,2)+Math.pow(zn,2));
        constraint[con]= (-deltaN +nodeCheck_[i][1]);
        con+=1;
      }
    }

    //constraint[0]=Math.sqrt(Math.pow(x, 2)+Math.pow(y, 2)+Math.pow(z, 2))+0.005;
    //descenso mÃƒÂ¡ximo en un nudo
    //constraint[1]=StrainResidual_[0][hi];


    double total = 0.0;
    //int number = 0;
    for (int i = 0; i < this.getNumberOfConstraints(); i++)
      if (constraint[i]<0.0){
        total+=constraint[i];
        //number++;
      }
    overallConstraintViolationDegree.setAttribute(solution, total);
    //solution.setOverallConstraintViolationDegree(total);
    //solution.setNumberOfViolatedConstraint(number);

  }
760922
public void evaluate(PermutationSolution<Integer> solution){
    double fitness1   ;
    double fitness2   ;

    fitness1 = 0.0 ;
    fitness2 = 0.0 ;

    for (int i = 0; i < (numberOfCities - 1); i++) {
      int x ;
      int y ;

      x = solution.getVariableValue(i) ;
      y = solution.getVariableValue(i+1) ;

      fitness1 += distanceMatrix[x][y] ;
      fitness2 += costMatrix[x][y];
    }
    int firstCity ;
    int lastCity  ;

    firstCity = solution.getVariableValue(0) ;
    lastCity = solution.getVariableValue(numberOfCities - 1) ;

    fitness1 += distanceMatrix[firstCity][lastCity] ;
    fitness2 += costMatrix[firstCity][lastCity];

    solution.setObjective(0, fitness1);
    solution.setObjective(1, fitness2);
  }
377020
public double evalG(DoubleSolution solution) {
    double g = 0.0;
    for (int var = 1; var < solution.getNumberOfVariables(); var++) {
      g += Math.pow(solution.getVariableValue(var), 2.0) +
        -10.0 * Math.cos(4.0 * Math.PI * solution.getVariableValue(var));
    }

    double constant = 1.0 + 10.0 * (solution.getNumberOfVariables() - 1);
    return g + constant;
  }
1329716
@Override
  public void evaluate(DoubleSolution solution) {
    double [] f = new double[getNumberOfObjectives()];
    f[0] = solution.getVariableValue(0) ;
    f[1] = (1.0 + solution.getVariableValue(1))/solution.getVariableValue(0);
    
    solution.setObjective(0,f[0]);
    solution.setObjective(1,f[1]);

    this.evaluateConstraints(solution);
  }
1303053
private void evaluateConstraints(DoubleSolution solution)  {
    double[] constraint = new double[this.getNumberOfConstraints()];

    double x1 = solution.getVariableValue(0);
    double x2 = solution.getVariableValue(1);
        
    constraint[0] = -x2 - (4.0 * x1) + 4.0  ;
    constraint[1] = x1 + 1.0 ;
    constraint[2] = x2 - x1 + 2.0 ;

    double overallConstraintViolation = 0.0;
    int violatedConstraints = 0;
    for (int i = 0; i < getNumberOfConstraints(); i++) {
      if (constraint[i]<0.0){
        overallConstraintViolation+=constraint[i];
        violatedConstraints++;
      }
    }

    overallConstraintViolationDegree.setAttribute(solution, overallConstraintViolation);
    numberOfViolatedConstraints.setAttribute(solution, violatedConstraints);
  }
631342
@Override
    public WeightedIndexEvaluation evaluate(SolutionType solution, DataType data) {
        // initialize evaluation object
        WeightedIndexEvaluation eval = new WeightedIndexEvaluation();
        // add evaluations produced by contained objectives
        weights.keySet().forEach(obj -> {
            // evaluate solution using objective
            Evaluation objEval = obj.evaluate(solution, data);
            // flip weight sign if minimizing
            double w = weights.get(obj);
            if(obj.isMinimizing()){
                w = -w;
            }
            // register in weighted index evaluation
            eval.addEvaluation(obj, objEval, w);
        });
        // return weighted index evaluation
        return eval;
    }
430885
@Override
    public void evaluate(BinarySolution solution) {
    int counterOnes;
    int counterZeroes;

    counterOnes = 0;
    counterZeroes = 0;

    BitSet bitset = solution.getVariableValue(0) ;

    for (int i = 0; i < bitset.length(); i++) {
      if (bitset.get(i)) {
        counterOnes++;
      } else {
        counterZeroes++;
      }
    }

    // OneZeroMax is a maximization problem: multiply by -1 to minimize
    solution.setObjective(0, -1.0 * counterOnes);
    solution.setObjective(1, -1.0 * counterZeroes);
  }
259412
function(expression){
      var t = this,
          value = null;

      // Evaluate the expression
      try {
        value = eval(expression);
      } catch (e) {
        var err = 'Unable to evaluate expression: "' + expression + '"';
        logger.error('evaluate', err);
        throw new Error(err);
      }

      // Return the value
      return value;
    }
652700
@SuppressWarnings("unchecked")
  public S execute(S solution) {
    int best;
    evaluations = 0;
    numberOfNonComparableSolutions = 0;

    int rounds = improvementRounds;

    int i = 0;
    while (i < rounds) {
      S mutatedSolution = mutationOperator.execute((S) solution.copy());

      problem.evaluate(mutatedSolution);
      evaluations++;
      if (problem.getNumberOfConstraints() > 0) {
        best = constraintComparator.compare(mutatedSolution, solution);
        if (best == 0) {
          best = comparator.compare(mutatedSolution, solution);
        }
      } else {
        best = comparator.compare(mutatedSolution, solution);
      }

      if (best == -1) {
        solution = mutatedSolution;
        numberOfImprovements++;
      } else if (best == 1) {
        // Current solution is best
      } else {
        numberOfNonComparableSolutions++;

        if (randomGenerator.getRandomValue() < 0.5) {
          solution = mutatedSolution;
        }
      }
      i++;
    }
    return (S) solution.copy();
  }
1205643
public S execute(List<S> solutionList) {
    if (null == solutionList) {
      throw new JMetalException("The solution list is null") ;
    } else if (solutionList.isEmpty()) {
      throw new JMetalException("The solution list is empty") ;
    }

    List<S> list = SolutionListUtils.selectNRandomDifferentSolutions(1, solutionList);

    return list.get(0) ;
  }
981971
public IntegerSolution execute(IntegerSolution solution) throws JMetalException {
    if (null == solution) {
      throw new JMetalException("Null parameter") ;
    }

    doMutation(mutationProbability, solution);
    return solution;
  }
60950
@Override public void referenceSetUpdate(DoubleSolution solution) {
    if (refSet1Test(solution)) {
      for (DoubleSolution solutionInRefSet2 : referenceSet2) {
        double aux = SolutionUtils.distanceBetweenSolutionsInObjectiveSpace(solution, solutionInRefSet2);
        DoubleSolution auxSolution = solutionInRefSet2;
        if (aux < distanceToSolutionListAttribute.getAttribute(auxSolution)) {
          distanceToSolutionListAttribute.setAttribute(auxSolution, aux);
        }
      }
    } else {
      refSet2Test(solution);
    }
  }
1345167
public void registerExpressionEvaluator(String expression, Callable<String> evaluator) {
        expressionEvaluators.put(expression, evaluator);
    }