From af3e5827a4ad9ff8e370a8e8062f83be0afc6e77 Mon Sep 17 00:00:00 2001 From: Marcel Kronfeld Date: Thu, 28 Aug 2008 13:24:14 +0000 Subject: [PATCH] Population is now in sync with mk branch --- .../server/go/populations/Population.java | 148 +++++++++--------- 1 file changed, 77 insertions(+), 71 deletions(-) diff --git a/src/eva2/server/go/populations/Population.java b/src/eva2/server/go/populations/Population.java index 65b8e324..7f114887 100644 --- a/src/eva2/server/go/populations/Population.java +++ b/src/eva2/server/go/populations/Population.java @@ -1,6 +1,7 @@ package eva2.server.go.populations; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.PriorityQueue; @@ -234,6 +235,20 @@ public class Population extends ArrayList implements PopulationInterface, Clonea public void SetFunctionCalls(int d) { this.m_FunctionCalls = d; } + + /** + * To initialize (or invalidate) all current fitness values, this method sets them + * to the given array. + * + * @param f + */ + public void setAllFitnessValues(double[] f) { + AbstractEAIndividual indy; + for (int i=0; i size())) EVAERROR.errorMsgOnce("Invalid pop size in DistractingPopulation:getCenterWeighted!"); + double[] centerPos = AbstractEAIndividual.getDoublePosition(getEAIndividual(0)); + Mathematics.svMult(weights[0], centerPos, centerPos); + for (int i=1; i hashes = getIndyHashSums(); - - if (evaluationTimeHashes == null) return false; - else return ((hashes.head().equals(evaluationTimeHashes.head())) && (hashes.tail().equals(evaluationTimeHashes.tail())) && (evaluationTimeModCount == modCount)); - } +// /** +// * Check whether the population at the current state has been marked as +// * evaluated. This allows to avoid double evaluations. +// * +// * @return true if the population has been marked as evaluated in its current state, else false +// */ +// public boolean isEvaluated() { +// if (evaluationTimeModCount != modCount) return false; +// Pair hashes = getIndyHashSums(); +// +// if (evaluationTimeHashes == null) return false; +// else return ((hashes.head().equals(evaluationTimeHashes.head())) && (hashes.tail().equals(evaluationTimeHashes.tail())) && (evaluationTimeModCount == modCount)); +// } - /** - * Mark the population at the current state as evaluated. Changes to the modCount or hashes of individuals - * will invalidate the mark. - * - * @see isEvaluated() - */ - public void setEvaluated() { - evaluationTimeModCount = modCount; - evaluationTimeHashes = getIndyHashSums(); - } +// /** +// * Mark the population at the current state as evaluated. Changes to the modCount or hashes of individuals +// * will invalidate the mark. +// * +// * @see isEvaluated() +// */ +// public void setEvaluated() { +// evaluationTimeModCount = modCount; +// evaluationTimeHashes = getIndyHashSums(); +// } - private Pair getIndyHashSums() { - int hashSum = 0, hashSumAbs = 0; - int hash; - for (int i=0; i getIndyHashSums() { +// int hashSum = 0, hashSumAbs = 0; +// int hash; +// for (int i=0; i