diff --git a/src/eva2/server/go/individuals/AbstractEAIndividual.java b/src/eva2/server/go/individuals/AbstractEAIndividual.java index 78222638..c66afde6 100644 --- a/src/eva2/server/go/individuals/AbstractEAIndividual.java +++ b/src/eva2/server/go/individuals/AbstractEAIndividual.java @@ -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; diff --git a/src/eva2/server/go/problems/SimpleProblemWrapper.java b/src/eva2/server/go/problems/SimpleProblemWrapper.java index 73a7a6c0..38ec97df 100644 --- a/src/eva2/server/go/problems/SimpleProblemWrapper.java +++ b/src/eva2/server/go/problems/SimpleProblemWrapper.java @@ -221,7 +221,15 @@ public class SimpleProblemWrapper extends AbstractOptimizationProblem { public void hideHideable() { 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. diff --git a/src/eva2/server/modules/GOParameters.java b/src/eva2/server/modules/GOParameters.java index 2e2734ad..748beb34 100644 --- a/src/eva2/server/modules/GOParameters.java +++ b/src/eva2/server/modules/GOParameters.java @@ -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; diff --git a/src/eva2/server/modules/Processor.java b/src/eva2/server/modules/Processor.java index 8c9195b7..ace2018c 100644 --- a/src/eva2/server/modules/Processor.java +++ b/src/eva2/server/modules/Processor.java @@ -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); } diff --git a/src/eva2/tools/Mathematics.java b/src/eva2/tools/Mathematics.java index f52b2c23..be9ec322 100644 --- a/src/eva2/tools/Mathematics.java +++ b/src/eva2/tools/Mathematics.java @@ -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