Various bugfixes.

- Properly handle loading/searching of classes with EvA prefix
- Properly open Main window and set Logger when invoked from within JVM
- New F22Problem
This commit is contained in:
Fabian Becker 2014-10-29 17:42:44 +01:00
parent 668dcb6974
commit 0202692844
20 changed files with 128 additions and 22 deletions

View File

@ -98,6 +98,7 @@ public class EvAInfo {
} }
public static String propDefaultModule() { public static String propDefaultModule() {
return getProperty("DefaultModule"); String defaultModule = getProperty("DefaultModule");
return defaultModule;
} }
} }

View File

@ -406,6 +406,9 @@ public class Main extends JFrame implements OptimizationStateListener {
statusBarControls.setLayout(new BoxLayout(statusBarControls, BoxLayout.LINE_AXIS)); statusBarControls.setLayout(new BoxLayout(statusBarControls, BoxLayout.LINE_AXIS));
statusBarControls.add(Box.createHorizontalGlue()); statusBarControls.add(Box.createHorizontalGlue());
/* Set default logging level to INFO */
Logger.getLogger("eva2").setLevel(Level.INFO);
/* Logging settings drop down */ /* Logging settings drop down */
LoggingLevelLabel loggingOption = new LoggingLevelLabel(); LoggingLevelLabel loggingOption = new LoggingLevelLabel();
@ -490,6 +493,9 @@ public class Main extends JFrame implements OptimizationStateListener {
} else { } else {
if (parentWindow == null) { if (parentWindow == null) {
System.exit(1); System.exit(1);
} else {
this.setVisible(false);
this.dispose();
} }
} }
} }

View File

@ -64,7 +64,7 @@ public class GenericObjectEditor implements PropertyEditor {
* *
* @param className * @param className
* @return * @return
* @see ReflectPackage.getAssignableClassesInPackage * @see ReflectPackage#getAssignableClassesInPackage
*/ */
public static ArrayList<String> getClassesFromClassPath(String className, ArrayList<Class<?>> instances) { public static ArrayList<String> getClassesFromClassPath(String className, ArrayList<Class<?>> instances) {
ArrayList<String> classes = new ArrayList<>(); ArrayList<String> classes = new ArrayList<>();

View File

@ -231,8 +231,8 @@ public abstract class AbstractProblemDouble extends AbstractOptimizationProblem
* *
* @param dim * @param dim
* @return the lower bound of the double range in the given dimension * @return the lower bound of the double range in the given dimension
* @see makeRange() * @see #makeRange()
* @see getRangeUpperBound(int dim) * @see #getRangeUpperBound(int dim)
*/ */
@Override @Override
public double getRangeLowerBound(int dim) { public double getRangeLowerBound(int dim) {
@ -246,8 +246,8 @@ public abstract class AbstractProblemDouble extends AbstractOptimizationProblem
* *
* @param dim * @param dim
* @return the upper bound of the double range in the given dimension * @return the upper bound of the double range in the given dimension
* @see makeRange() * @see #makeRange()
* @see getRangeLowerBound(int dim) * @see #getRangeLowerBound(int dim)
*/ */
@Override @Override
public double getRangeUpperBound(int dim) { public double getRangeUpperBound(int dim) {

View File

@ -88,7 +88,7 @@ public class F10Problem extends AbstractProblemDoubleOffset implements Interface
*/ */
@Override @Override
public String getName() { public String getName() {
return "F10 Problem"; return "Weierstrass-Mandelbrot Fractal";
} }
/** /**

View File

@ -77,7 +77,7 @@ public class F11Problem extends AbstractProblemDoubleOffset implements Interface
*/ */
@Override @Override
public String getName() { public String getName() {
return "F11-Problem"; return "Griewank";
} }
/** /**

View File

@ -73,6 +73,6 @@ public class F12Problem extends AbstractProblemDoubleOffset implements Serializa
*/ */
@Override @Override
public String getName() { public String getName() {
return "F12 Problem"; return "Galar";
} }
} }

View File

@ -108,7 +108,7 @@ public class F13Problem extends AbstractProblemDoubleOffset implements Interface
*/ */
@Override @Override
public String getName() { public String getName() {
return "F13-Problem"; return "Schwefel 2.26";
} }
@Override @Override

View File

@ -88,7 +88,7 @@ public class F1Problem extends AbstractProblemDoubleOffset implements Interface2
*/ */
@Override @Override
public String getName() { public String getName() {
return "F1-Problem"; return "Sphere";
} }
@Override @Override

View File

@ -27,7 +27,7 @@ public class F21Problem extends AbstractProblemDouble implements InterfaceMultim
@Override @Override
public String getName() { public String getName() {
return "Langerman-Function"; return "Langerman";
} }
@Override @Override

View File

@ -0,0 +1,99 @@
package eva2.problems;
import eva2.optimization.strategies.InterfaceOptimizer;
import eva2.tools.math.Mathematics;
import eva2.util.annotation.Description;
/**
* F22 Schwefel 2.22 Problem
*/
@Description(value ="Schwefel 2.22")
public class F22Problem extends AbstractProblemDoubleOffset implements InterfaceHasInitRange, java.io.Serializable {
public F22Problem() {
super();
setDefaultRange(10);
}
public F22Problem(F22Problem b) {
super();
super.cloneObjects(b);
}
public F22Problem(int dim) {
super(dim);
}
public F22Problem(int dim, double defRange) {
this(dim);
setDefaultRange(defRange);
}
/**
* This method returns a deep clone of the problem.
*
* @return the clone
*/
@Override
public Object clone() {
return new F22Problem(this);
}
/**
* This 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.
*/
@Override
public double[] evaluate(double[] x) {
x = rotateMaybe(x);
double[] result = new double[1];
result[0] = yOffset;
double sum = 0.0, product = 1.0;
// add an offset in solution space
for (int i = 0; i < x.length; i++) {
sum += Math.abs(x[i]);
product *= Math.abs(x[i]);
}
result[0] = sum + product;
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.
*/
@Override
public String getStringRepresentationForProblem(InterfaceOptimizer opt) {
StringBuilder sb = new StringBuilder(200);
sb.append("F22 Schwefel 2.22 model:\n");
sb.append("Here the individual codes a vector of real number x and F22(x) is to be minimized.\nParameters:\n");
sb.append("Dimension : ");
sb.append(this.problemDimension);
sb.append("\nNoise level : ");
sb.append(this.getNoise());
return sb.toString();
}
/**
* This method allows the CommonJavaObjectEditorPanel to read the
* name to the current object.
*
* @return The name.
*/
@Override
public String getName() {
return "Schwefel 2.22";
}
/**
* If initialRangeRatio<1, produce a reduced initial range in the negative corner of the range.
*/
@Override
public Object getInitializationRange() {
return makeRange();
}
}

View File

@ -100,7 +100,7 @@ public class F2Problem extends AbstractProblemDoubleOffset implements InterfaceL
*/ */
@Override @Override
public String getName() { public String getName() {
return "F2-Problem"; return "Generalized Rosenbrock";
} }
@Override @Override

View File

@ -69,6 +69,6 @@ public class F3Problem extends AbstractProblemDoubleOffset implements java.io.Se
*/ */
@Override @Override
public String getName() { public String getName() {
return "F3-Problem"; return "Step";
} }
} }

View File

@ -56,7 +56,7 @@ public class F4Problem extends AbstractProblemDoubleOffset implements Serializab
String result = ""; String result = "";
result += "F4 Quadratic Function with noise:\n"; result += "F4 Quadratic Function with noise:\n";
result += "This problem is noisey.\n"; result += "This problem is noisy.\n";
result += "Parameters:\n"; result += "Parameters:\n";
result += "Dimension : " + this.problemDimension + "\n"; result += "Dimension : " + this.problemDimension + "\n";
result += "Noise level : " + this.getNoise() + "\n"; result += "Noise level : " + this.getNoise() + "\n";
@ -73,6 +73,6 @@ public class F4Problem extends AbstractProblemDoubleOffset implements Serializab
*/ */
@Override @Override
public String getName() { public String getName() {
return "F4 Problem"; return "Noisy Quaric";
} }
} }

View File

@ -77,6 +77,6 @@ public class F5Problem extends AbstractProblemDoubleOffset implements Serializab
*/ */
@Override @Override
public String getName() { public String getName() {
return "F5-Problem"; return "Schwefel 1.2";
} }
} }

View File

@ -97,7 +97,7 @@ public class F6Problem extends AbstractProblemDoubleOffset
*/ */
@Override @Override
public String getName() { public String getName() {
return "F6-Problem"; return "Generalized Rastrigin";
} }
/** /**

View File

@ -118,7 +118,7 @@ public class F7Problem extends AbstractProblemDoubleOffset implements Serializab
*/ */
@Override @Override
public String getName() { public String getName() {
return "F7 Problem"; return "Changing Sphere";
} }
/** /**

View File

@ -112,7 +112,7 @@ public class F8Problem extends AbstractProblemDoubleOffset
*/ */
@Override @Override
public String getName() { public String getName() {
return "F8-Problem"; return "Ackley";
} }
@Override @Override

View File

@ -69,6 +69,6 @@ public class F9Problem extends AbstractProblemDoubleOffset implements java.io.Se
*/ */
@Override @Override
public String getName() { public String getName() {
return "F9 Problem"; return "Weighted Sphere";
} }
} }

View File

@ -228,7 +228,7 @@ public class ReflectPackage {
// Skip JARs that don't start with the EvA substring. // Skip JARs that don't start with the EvA substring.
// This improves performance a lot when having a lot of JARs on the classpath // This improves performance a lot when having a lot of JARs on the classpath
int index = aDynCP.lastIndexOf(System.getProperty("file.separator")); int index = aDynCP.lastIndexOf(System.getProperty("file.separator"));
if (index != -1 && !aDynCP.substring(0, index).contains("EvA")) { if (index != -1 && !aDynCP.substring(index).contains("EvA")) {
continue; continue;
} }
getClassesFromJarFltr(set, aDynCP, pkg, includeSubs, reqSuperCls); getClassesFromJarFltr(set, aDynCP, pkg, includeSubs, reqSuperCls);