예제 #1
1
 public double evaluate(Vector x) {
   double sum = 0.0;
   for (int i = 0; i < getDimension(); ++i) {
     sum += Math.floor(x.getReal(i) + 0.5) * Math.floor(x.getReal(i) + 0.5);
   }
   return sum;
 }
예제 #2
0
 public static void main(String[] args) {
   int dim = 10;
   Bohachevsky b = new Bohachevsky(-15, 15, dim);
   Vector v = new Vector(dim);
   for (int i = 0; i < dim; i++) v.setReal(i, 15);
   System.out.println("f(" + v + ") = " + b.evaluate(v));
 }
예제 #3
0
 public double evaluate(Vector input) {
   double sum = 0.0;
   for (int i = 0; i < getDimension() - 1; ++i) {
     double x = input.getReal(i);
     double y = input.getReal(i + 1);
     sum +=
         x * x
             + 2 * y * y
             - 0.3 * Math.cos(3 * Math.PI * x)
             - 0.4 * Math.cos(4 * Math.PI * y)
             + 0.7;
   }
   return sum;
 }
예제 #4
0
 public double evaluate(Vector x) {
   return (x.getReal(0) * x.getReal(0) + x.getReal(1) * x.getReal(1));
 }