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;
|
private boolean logParents = true;
|
||||||
// heritage is to contain a list of all parents of the individual
|
// heritage is to contain a list of all parents of the individual
|
||||||
private Long[] parentIDs = null;
|
private Long[] parentIDs = null;
|
||||||
private AbstractEAIndividual[] parentTree = null;
|
transient private AbstractEAIndividual[] parentTree = null;
|
||||||
|
|
||||||
protected double[] m_Fitness = new double[1];
|
protected double[] m_Fitness = new double[1];
|
||||||
private double m_ConstraintViolation = 0;
|
private double m_ConstraintViolation = 0;
|
||||||
|
@@ -221,7 +221,15 @@ public class SimpleProblemWrapper extends AbstractOptimizationProblem {
|
|||||||
public void hideHideable() {
|
public void hideHideable() {
|
||||||
setSimpleProblem(getSimpleProblem());
|
setSimpleProblem(getSimpleProblem());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setIndividualTemplate(AbstractEAIndividual indy) {
|
||||||
|
m_Template = indy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String individualTemplateTipText() {
|
||||||
|
return "Set the individual properties for the optimization";
|
||||||
|
}
|
||||||
|
|
||||||
/////////// for GUI
|
/////////// for GUI
|
||||||
|
|
||||||
/** This method returns a string describing the optimization problem.
|
/** This method returns a string describing the optimization problem.
|
||||||
|
@@ -28,7 +28,13 @@ public class GOParameters extends AbstractGOParameters implements InterfaceGOPar
|
|||||||
*/
|
*/
|
||||||
public static GOParameters getInstance() {
|
public static GOParameters getInstance() {
|
||||||
if (TRACE) System.out.println("GOParameters getInstance 1");
|
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 (TRACE) System.out.println("GOParameters getInstance 2");
|
||||||
if (Instance == null) Instance = new GOParameters();
|
if (Instance == null) Instance = new GOParameters();
|
||||||
return Instance;
|
return Instance;
|
||||||
|
@@ -139,7 +139,13 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo
|
|||||||
EVAERROR.clearMsgCache();
|
EVAERROR.clearMsgCache();
|
||||||
while (isOptRunning()) {
|
while (isOptRunning()) {
|
||||||
setPriority(3);
|
setPriority(3);
|
||||||
if (saveParams) goParams.saveInstance();
|
if (saveParams) {
|
||||||
|
try {
|
||||||
|
goParams.saveInstance();
|
||||||
|
} catch(Exception e) {
|
||||||
|
System.err.println("Error on saveInstance!");
|
||||||
|
}
|
||||||
|
}
|
||||||
resPop = optimize("Run");
|
resPop = optimize("Run");
|
||||||
setPriority(1);
|
setPriority(1);
|
||||||
}
|
}
|
||||||
|
@@ -148,16 +148,39 @@ public class Mathematics {
|
|||||||
* if x and y have different dimensions an exception is
|
* if x and y have different dimensions an exception is
|
||||||
* thrown.
|
* 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)
|
if (x.length != y.length)
|
||||||
throw new Exception("The vecotors x and y must have the same dimension");
|
throw new RuntimeException("The vectors x and y must have the same dimension");
|
||||||
if (root == 0) throw new Exception("There is no 0-root!");
|
if (root == 0) throw new RuntimeException("There is no 0-root!");
|
||||||
double d = 0;
|
double d = 0;
|
||||||
for (int i = 0; i < x.length; i++)
|
for (int i = 0; i < x.length; i++)
|
||||||
d += Math.pow(Math.abs(x[i] - y[i]), root);
|
d += Math.pow(Math.abs(x[i] - y[i]), root);
|
||||||
return Math.pow(d, (double) 1 / 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
|
* 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
|
* 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