From 5b10b4b6ed0c979c114d2511925a6a7570cc3bc8 Mon Sep 17 00:00:00 2001 From: Marcel Kronfeld Date: Tue, 1 Feb 2011 12:43:04 +0000 Subject: [PATCH] Minor addition to GI individual --- .../individuals/GIIndividualIntegerData.java | 17 +++++++-- .../distancemetric/GenotypeMetricBitSet.java | 4 +++ .../server/go/populations/Population.java | 35 ++++++++++++------- 3 files changed, 41 insertions(+), 15 deletions(-) diff --git a/src/eva2/server/go/individuals/GIIndividualIntegerData.java b/src/eva2/server/go/individuals/GIIndividualIntegerData.java index 7662f6f7..6f58a6f6 100644 --- a/src/eva2/server/go/individuals/GIIndividualIntegerData.java +++ b/src/eva2/server/go/individuals/GIIndividualIntegerData.java @@ -21,7 +21,7 @@ public class GIIndividualIntegerData extends AbstractEAIndividual implements Int protected int[] m_Genotype; public GIIndividualIntegerData() { - this.m_MutationProbability = 0.1; + this.m_MutationProbability = 0.2; this.m_MutationOperator = new MutateDefault(); this.m_CrossoverProbability = 0.7; this.m_CrossoverOperator = new CrossoverGIDefault(); @@ -276,7 +276,20 @@ public class GIIndividualIntegerData extends AbstractEAIndividual implements Int public void defaultInit(InterfaceOptimizationProblem prob) { int[][] range = m_Range; - if ((prob != null) && (prob instanceof InterfaceHasInitRange) && (((InterfaceHasInitRange)prob).getInitRange()!=null)) range = (int[][])((InterfaceHasInitRange)prob).getInitRange(); + if ((prob != null) && (prob instanceof InterfaceHasInitRange) && (((InterfaceHasInitRange)prob).getInitRange()!=null)) { + Object rng = ((InterfaceHasInitRange)prob).getInitRange(); + if (rng instanceof double[][]) { + double[][] dblRng = (double[][])rng; + range = new int[dblRng.length][dblRng[0].length]; + for (int i=0; i maxDist) maxDist = d; + for (int i = 0; i < pop.size(); i++) { + for (int j = i+1; j < pop.size(); j++) { + try { + if (metric == null) { + if (pop.get(i) instanceof InterfaceESIndividual) { + // short cut if the distance may directly work on the genotype + d = EuclideanMetric.euclideanDistance(AbstractEAIndividual.getDoublePositionShallow(pop.get(i)), + AbstractEAIndividual.getDoublePositionShallow(pop.get(j))); + } else { + d = PhenotypeMetric.dist(pop.get(i), pop.get(j)); + } + } else { + d = metric.distance((AbstractEAIndividual)pop.get(i), (AbstractEAIndividual)pop.get(j)); + } + } catch (Exception e) { + EVAERROR.errorMsgOnce("Exception when calculating population measures ... possibly no double position available?"); + d = 0; + } + distSum += d; + if (d < minDist) minDist = d; + if (d > maxDist) maxDist = d; } } res[1] = minDist;