diff options
Diffstat (limited to 'src/jcgp/CGP.java')
-rw-r--r-- | src/jcgp/CGP.java | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/src/jcgp/CGP.java b/src/jcgp/CGP.java index 1004001..16d2be7 100644 --- a/src/jcgp/CGP.java +++ b/src/jcgp/CGP.java @@ -3,6 +3,7 @@ package jcgp; import java.util.HashMap; import java.util.Random; +import javafx.beans.property.Property; import javafx.beans.property.SimpleIntegerProperty; import jcgp.modules.ea.EvolutionaryAlgorithm; import jcgp.modules.ea.StandardEA; @@ -19,7 +20,6 @@ import jcgp.parameters.BooleanParameter; import jcgp.parameters.DoubleParameter; import jcgp.parameters.IntegerParameter; import jcgp.parameters.Parameter; -import jcgp.parameters.Parameters; import jcgp.population.Population; public class CGP { @@ -66,14 +66,14 @@ public class CGP { private Population population; - private static HashMap<String, Parameter> parameters = new HashMap<String, Parameter>(); + private HashMap<String, Parameter> parameters = new HashMap<String, Parameter>(); public CGP() { createBaseParameters(); - for (int i = 0; i < Parameters.getTotalGenerations(); i++) { + for (int i = 0; i < (int) get("generations"); i++) { - ((SimpleIntegerProperty) get("currentGen").getValue()).set(i); + set("currentGen", ((int) get("currentGen")) + 1); fitnessFunction.evaluate(population); evolutionaryAlgorithm.evolve(population, mutator); @@ -123,15 +123,28 @@ public class CGP { // } // Parameter methods - public static void registerParameter(String key, Parameter value) { + public void register(String key, Parameter value) { parameters.put(key, value); } - public static Parameter get(String key) { - return parameters.get(key); + /** + * @param key + * @return + */ + public Object get(String key) { + return parameters.get(key).getValue(); } - public static boolean contains(String key) { + public void set(String key, Object value) { + parameters.get(key).setValue(value); + } + + @SuppressWarnings("rawtypes") + public Property getProperty(String key) { + return parameters.get(key).valueProperty(); + } + + public boolean contains(String key) { return parameters.containsKey(key); } |