/** * Evaluates a solution * * @param solution The solution to evaluate * @throws JMException */ public void evaluate(Solution solution) throws JMException { Variable[] variable = solution.getDecisionVariables(); double[] f = new double[numberOfObjectives_]; f[0] = variable[0].getValue(); f[1] = variable[1].getValue(); solution.setObjective(0, f[0]); solution.setObjective(1, f[1]); } // evaluate
/** * Evaluates a solution * * @param solution The solution to evaluate * @throws JMException */ public void evaluate(Solution solution) throws JMException { Variable[] gen = solution.getDecisionVariables(); Vector<Double> x = new Vector<Double>(numberOfVariables_); Vector<Double> y = new Vector<Double>(numberOfObjectives_); for (int i = 0; i < numberOfVariables_; i++) { x.addElement(gen[i].getValue()); y.addElement(0.0); } // for LZ09_.objective(x, y); for (int i = 0; i < numberOfObjectives_; i++) solution.setObjective(i, y.get(i)); } // evaluate
/** * Evaluates the constraint overhead of a solution * * @param solution The solution * @throws JMException */ public void evaluateConstraints(Solution solution) throws JMException { double[] constraint = new double[this.getNumberOfConstraints()]; double x1 = solution.getDecisionVariables()[0].getValue(); double x2 = solution.getDecisionVariables()[1].getValue(); constraint[0] = (x1 * x1 + x2 * x2 - 1.0 - 0.1 * Math.cos(16.0 * Math.atan(x1 / x2))); constraint[1] = -2.0 * ((x1 - 0.5) * (x1 - 0.5) + (x2 - 0.5) * (x2 - 0.5) - 0.5); int number = 0; double total = 0.0; for (int i = 0; i < this.getNumberOfConstraints(); i++) if (constraint[i] < 0.0) { number++; total += constraint[i]; } solution.setOverallConstraintViolation(total); solution.setNumberOfViolatedConstraint(number); } // evaluateConstraints