Merging MKron branch rev 76
This commit is contained in:
@@ -45,7 +45,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
||||
private boolean logParents = true;
|
||||
// heritage is to contain a list of all parents of the individual
|
||||
private Long[] parentIDs = null;
|
||||
private AbstractEAIndividual[] parentTree = null;
|
||||
transient private AbstractEAIndividual[] parentTree = null;
|
||||
|
||||
protected double[] m_Fitness = new double[1];
|
||||
private double m_ConstraintViolation = 0;
|
||||
|
@@ -222,6 +222,14 @@ public class SimpleProblemWrapper extends AbstractOptimizationProblem {
|
||||
setSimpleProblem(getSimpleProblem());
|
||||
}
|
||||
|
||||
public void setIndividualTemplate(AbstractEAIndividual indy) {
|
||||
m_Template = indy;
|
||||
}
|
||||
|
||||
public String individualTemplateTipText() {
|
||||
return "Set the individual properties for the optimization";
|
||||
}
|
||||
|
||||
/////////// for GUI
|
||||
|
||||
/** This method returns a string describing the optimization problem.
|
||||
|
@@ -28,7 +28,13 @@ public class GOParameters extends AbstractGOParameters implements InterfaceGOPar
|
||||
*/
|
||||
public static GOParameters getInstance() {
|
||||
if (TRACE) System.out.println("GOParameters getInstance 1");
|
||||
GOParameters Instance = (GOParameters) Serializer.loadObject("GOParameters.ser");
|
||||
GOParameters Instance = null;
|
||||
try {
|
||||
Instance = (GOParameters) Serializer.loadObject("GOParameters.ser");
|
||||
} catch(Exception e) {
|
||||
System.err.println("Error loading GOParameters!");
|
||||
Instance = null;
|
||||
}
|
||||
if (TRACE) System.out.println("GOParameters getInstance 2");
|
||||
if (Instance == null) Instance = new GOParameters();
|
||||
return Instance;
|
||||
|
@@ -139,7 +139,13 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo
|
||||
EVAERROR.clearMsgCache();
|
||||
while (isOptRunning()) {
|
||||
setPriority(3);
|
||||
if (saveParams) goParams.saveInstance();
|
||||
if (saveParams) {
|
||||
try {
|
||||
goParams.saveInstance();
|
||||
} catch(Exception e) {
|
||||
System.err.println("Error on saveInstance!");
|
||||
}
|
||||
}
|
||||
resPop = optimize("Run");
|
||||
setPriority(1);
|
||||
}
|
||||
|
@@ -148,16 +148,39 @@ public class Mathematics {
|
||||
* if x and y have different dimensions an exception is
|
||||
* thrown.
|
||||
*/
|
||||
public static double dist(double[] x, double[] y, int root) throws Exception {
|
||||
public static double dist(double[] x, double[] y, int root) {
|
||||
if (x.length != y.length)
|
||||
throw new Exception("The vecotors x and y must have the same dimension");
|
||||
if (root == 0) throw new Exception("There is no 0-root!");
|
||||
throw new RuntimeException("The vectors x and y must have the same dimension");
|
||||
if (root == 0) throw new RuntimeException("There is no 0-root!");
|
||||
double d = 0;
|
||||
for (int i = 0; i < x.length; i++)
|
||||
d += Math.pow(Math.abs(x[i] - y[i]), root);
|
||||
return Math.pow(d, (double) 1 / root);
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes the euclidian distance function.
|
||||
*
|
||||
* @param x
|
||||
* a vector
|
||||
* @param y
|
||||
* another vector
|
||||
* @param root
|
||||
* what kind of distance funktion
|
||||
* @return the distance of x and y
|
||||
* @throws Exception
|
||||
* if x and y have different dimensions an exception is
|
||||
* thrown.
|
||||
*/
|
||||
public static double euclidianDist(double[] x, double[] y) {
|
||||
if (x.length != y.length)
|
||||
throw new RuntimeException("The vectors x and y must have the same dimension");
|
||||
double d = 0;
|
||||
for (int i = 0; i < x.length; i++)
|
||||
d += Math.pow(Math.abs(x[i] - y[i]), 2);
|
||||
return Math.sqrt(d);
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes the relative distance of vector x to vector y. Therefore the
|
||||
* difference of x[i] and y[i] is divided by y[i] for every i. If y[i] is
|
||||
|
Reference in New Issue
Block a user