Example #1
0
double ZDT5::evalG(Solution * solution) {
  double res = 0.0;
  Binary * variable ;

  for (int i = 1; i < numberOfVariables_; i++) {
  	variable = (Binary *)(solution->getDecisionVariables()[i]) ;
    res += evalV(variable->cardinality());
  }

  return res;
}
Example #2
0
/**
 * Evaluates a solution
 * @param solution The solution to evaluate
 */
void ZDT5::evaluate(Solution *solution) {
  Binary * variable ;
  int    counter  ;

  variable = (Binary *)(solution->getDecisionVariables()[0]) ;

  fx_[0]        = 1 + variable->cardinality();

  double g    = evalG(solution)  ;
  double h    = evalH(fx_[0],g)  ;
  fx_[1]        = h * g          ;

  solution->setObjective(0,fx_[0]);
  solution->setObjective(1,fx_[1]);


} // evaluate