Moving a basic integer problem from Probs package

This commit is contained in:
Marcel Kronfeld 2011-02-16 10:44:10 +00:00
parent cc95798038
commit 749c75fe2a

View File

@ -0,0 +1,68 @@
package eva2.server.go.problems;
import eva2.server.go.strategies.InterfaceOptimizer;
/**
* The integer hyper-sphere problem.
*
* User: streiche, mkron
*/
public class I1Problem extends AbstractProblemInteger implements java.io.Serializable {
public I1Problem() {
}
public I1Problem(I1Problem o) {
super.cloneObjects(o);
}
/** This method returns a deep clone of the problem.
* @return the clone
*/
public Object clone() {
return (Object) new I1Problem(this);
}
/** Ths method allows you to evaluate a simple bit string to determine the fitness
* @param x The n-dimensional input vector
* @return The m-dimensional output vector.
*/
public double[] eval(int[] x) {
double[] result = new double[1];
result[0] = 0;
for (int i = 0; i < x.length; i++) {
result[0] += Math.pow(x[i], 2);
}
result[0] += 1;
return result;
}
/** This method returns a string describing the optimization problem.
* @param opt The Optimizer that is used or had been used.
* @return The description.
*/
public String getStringRepresentationForProblem(InterfaceOptimizer opt) {
String result = "";
result += "I1 Problem:\n";
result += "Here the individual codes a vector of int numbers x and F1(x)= x^2 is to be minimized.\n";
result += "Parameters:\n";
result += "Dimension : " + this.m_ProblemDimension +"\n";
result += "Solution representation:\n";
return result;
}
/**********************************************************************************************************************
* These are for GUI
*/
public String getName() {
return "I1 Problem";
}
public static String globalInfo() {
return "I1(x) = x^2 is to be minimized.";
}
}