Major commit, see changelog in JOpt-Notes.txt

This commit is contained in:
Marcel Kronfeld
2008-02-26 17:31:52 +00:00
parent 260d6e89ae
commit 3a18cedcc6
96 changed files with 4543 additions and 2905 deletions

View File

@@ -0,0 +1,30 @@
package simpleprobs;
/**
* A simple interface to easily include new optimization problems in Java into the
* JavaEvA framework.
*
* @author mkron
*
*/
public interface InterfaceSimpleProblem<T> {
/**
* Evaluate a double vector representing a possible problem solution as
* part of an individual in the JavaEvA framework. This makes up the
* target function to be evaluated.
*
* @param x a double vector to be evaluated
* @return the fitness vector assigned to x as to the target function
*/
public double[] eval(T x);
/**
* Return the problem dimension.
*
* @return the problem dimension
*/
public int getProblemDimension();
}

View File

@@ -0,0 +1,23 @@
package simpleprobs;
import java.util.BitSet;
public class SimpleB1 extends SimpleProblemBinary {
public String globalInfo() {
return "A simple B1 implementation, minimize bits in a binary vector.";
}
public double[] eval(BitSet b) {
double[] result = new double[1];
int fitness = 0;
for (int i = 0; i < getProblemDimension(); i++) if (b.get(i)) fitness++;
result[0] = fitness;
return result;
}
public int getProblemDimension() {
return 20;
}
}

View File

@@ -0,0 +1,27 @@
package simpleprobs;
public class SimpleF1 extends SimpleProblemDouble {
public String globalInfo() {
return "A simple F1 implementation, find the minimum of a hyper parabola.";
}
public double[] eval(double[] x) {
double res[] = new double[1];
// this defines the dimension of the fitness vector, which should be always the same
double sum = 0;
// calculate the fitness value
for (int i=0; i<getProblemDimension(); i++) {
sum += (x[i]*x[i]);
}
// setting the return vector and return it
res[0] = Math.sqrt(sum);
return res;
}
public int getProblemDimension() {
return 20;
}
}

View File

@@ -0,0 +1,10 @@
package simpleprobs;
import java.io.Serializable;
import java.util.BitSet;
public abstract class SimpleProblemBinary implements InterfaceSimpleProblem<BitSet>, Serializable {
public String globalInfo() {
return "A simple binary problem. Override globalInfo() to insert more information.";
}
}

View File

@@ -0,0 +1,9 @@
package simpleprobs;
import java.io.Serializable;
public abstract class SimpleProblemDouble implements InterfaceSimpleProblem<double[]>, Serializable {
public String globalInfo() {
return "A simple double valued problem. Override globalInfo() to insert more information.";
}
}