aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/jcgp/JCGP.java46
-rw-r--r--src/jcgp/backend/modules/Module.java2
-rw-r--r--src/jcgp/backend/modules/es/EvolutionaryStrategy.java (renamed from src/jcgp/backend/modules/ea/EvolutionaryAlgorithm.java)6
-rw-r--r--src/jcgp/backend/modules/es/MuPlusLambda.java (renamed from src/jcgp/backend/modules/ea/MuPlusLambda.java)13
-rw-r--r--src/jcgp/backend/modules/es/TournamentSelection.java (renamed from src/jcgp/backend/modules/ea/TournamentSelection.java)4
-rw-r--r--src/jcgp/backend/modules/fitness/DigitalCircuit.java5
-rw-r--r--src/jcgp/backend/modules/fitness/SymbolicRegression.java5
-rw-r--r--src/jcgp/backend/modules/fitness/TestCaseProblem.java4
-rw-r--r--src/jcgp/backend/modules/mutator/Mutator.java2
-rw-r--r--src/jcgp/backend/modules/mutator/PointMutator.java32
-rw-r--r--src/jcgp/backend/population/Chromosome.java4
-rw-r--r--src/jcgp/backend/population/Connection.java2
-rw-r--r--src/jcgp/backend/population/Input.java4
-rw-r--r--src/jcgp/backend/population/Node.java4
-rw-r--r--src/jcgp/backend/population/Output.java10
-rw-r--r--src/jcgp/backend/resources/ModifiableResources.java17
-rw-r--r--src/jcgp/backend/resources/Resources.java36
-rw-r--r--src/jcgp/backend/tests/NodeTests.java34
-rw-r--r--src/jcgp/backend/tests/OutputTests.java12
-rw-r--r--src/jcgp/gui/GUI.java5
-rw-r--r--src/jcgp/gui/console/GUIConsole.java5
-rw-r--r--src/jcgp/gui/dragresize/HorizontalDragResize.java1
-rw-r--r--src/jcgp/gui/dragresize/VerticalDragResize.java1
-rw-r--r--src/jcgp/gui/population/ChromosomePane.java1
-rw-r--r--src/jcgp/gui/settings/SettingsPane.java64
-rw-r--r--src/jcgp/gui/settings/parameters/GUIDoubleParameter.java2
-rw-r--r--src/jcgp/gui/settings/parameters/GUIIntegerParameter.java2
27 files changed, 167 insertions, 156 deletions
diff --git a/src/jcgp/JCGP.java b/src/jcgp/JCGP.java
index a19e085..ee42792 100644
--- a/src/jcgp/JCGP.java
+++ b/src/jcgp/JCGP.java
@@ -2,9 +2,9 @@ package jcgp;
import java.util.ArrayList;
-import jcgp.backend.modules.ea.EvolutionaryAlgorithm;
-import jcgp.backend.modules.ea.MuPlusLambda;
-import jcgp.backend.modules.ea.TournamentSelection;
+import jcgp.backend.modules.es.EvolutionaryStrategy;
+import jcgp.backend.modules.es.MuPlusLambda;
+import jcgp.backend.modules.es.TournamentSelection;
import jcgp.backend.modules.fitness.DigitalCircuit;
import jcgp.backend.modules.fitness.Problem;
import jcgp.backend.modules.fitness.SymbolicRegression;
@@ -49,15 +49,15 @@ public class JCGP {
private Mutator mutator;
// evolutionary algorithms
- private EvolutionaryAlgorithm[] evolutionaryAlgorithms = new EvolutionaryAlgorithm[] {
+ private EvolutionaryStrategy[] evolutionaryStrategies = new EvolutionaryStrategy[] {
new MuPlusLambda(resources),
new TournamentSelection()};
- private EvolutionaryAlgorithm evolutionaryAlgorithm;
+ private EvolutionaryStrategy evolutionaryStrategy;
// problem types
private Problem[] problems = new Problem[] {
- new SymbolicRegression(),
- new DigitalCircuit() };
+ new SymbolicRegression(resources),
+ new DigitalCircuit(resources) };
private Problem problem;
/*
@@ -67,7 +67,7 @@ public class JCGP {
private boolean finished = false;
public JCGP() {
- setEvolutionaryAlgorithm(0);
+ setEvolutionaryStrategy(0);
setMutator(0);
setProblem(0);
@@ -111,16 +111,16 @@ public class JCGP {
/**
* @return the evolutionaryAlgorithms
*/
- public EvolutionaryAlgorithm[] getEvolutionaryAlgorithms() {
- return evolutionaryAlgorithms;
+ public EvolutionaryStrategy[] getEvolutionaryStrategies() {
+ return evolutionaryStrategies;
}
/**
* @return the evolutionaryAlgorithm
*/
- public EvolutionaryAlgorithm getEvolutionaryAlgorithm() {
- return evolutionaryAlgorithm;
+ public EvolutionaryStrategy getEvolutionaryStrategy() {
+ return evolutionaryStrategy;
}
@@ -149,10 +149,10 @@ public class JCGP {
/**
- * @param evolutionaryAlgorithm the evolutionaryAlgorithm to set
+ * @param evolutionaryStrategy the evolutionaryAlgorithm to set
*/
- public void setEvolutionaryAlgorithm(int index) {
- this.evolutionaryAlgorithm = evolutionaryAlgorithms[index];
+ public void setEvolutionaryStrategy(int index) {
+ this.evolutionaryStrategy = evolutionaryStrategies[index];
}
@@ -171,9 +171,9 @@ public class JCGP {
if (resources.getInt("currentGen") < resources.getInt("generations")) {
// we still have generations left to go
- if (problem.isPerfectSolution(population.getChromosome(evolutionaryAlgorithm.getFittestChromosome()))) {
+ if (problem.isPerfectSolution(population.getChromosome(evolutionaryStrategy.getFittestChromosome()))) {
// solution has been found, start next run
- resources.println("Solution found on generation " + resources.getInt("currentGen") + ", chromosome: " + evolutionaryAlgorithm.getFittestChromosome());
+ resources.println("[CGP] Solution found on generation " + resources.getInt("currentGen") + ", chromosome: " + evolutionaryStrategy.getFittestChromosome());
if (resources.getInt("currentRun") < resources.getInt("runs")) {
// there are still runs left
@@ -191,9 +191,9 @@ public class JCGP {
}
} else {
// the run has ended, check if any more runs must be done
- resources.println("Solution not found, highest fitness achieved was "
- + population.getChromosome(evolutionaryAlgorithm.getFittestChromosome()).getFitness()
- + " by chromosome " + evolutionaryAlgorithm.getFittestChromosome());
+ resources.println("[CGP] Solution not found, highest fitness achieved was "
+ + population.getChromosome(evolutionaryStrategy.getFittestChromosome()).getFitness()
+ + " by chromosome " + evolutionaryStrategy.getFittestChromosome());
if (resources.getInt("currentRun") < resources.getInt("runs")) {
// the run has ended but there are still runs left
@@ -209,14 +209,14 @@ public class JCGP {
}
}
- evolutionaryAlgorithm.evolve(population, mutator, (Resources) resources);
+ evolutionaryStrategy.evolve(population, mutator, (Resources) resources);
}
private void report() {
if (resources.getInt("report") > 0) {
if (resources.getInt("currentGen") % resources.getInt("report") == 0) {
- resources.println("Generation: " + resources.getInt("currentGen") + ", fitness: " + population.getChromosome(evolutionaryAlgorithm.getFittestChromosome()).getFitness());
+ resources.println("[CGP] Generation: " + resources.getInt("currentGen") + ", fitness: " + population.getChromosome(evolutionaryStrategy.getFittestChromosome()).getFitness());
}
}
}
@@ -239,7 +239,7 @@ public class JCGP {
resources.set("currentGen", 1);
resources.set("currentRun", 1);
resources.println("-----------------------------");
- resources.println("New experiment");
+ resources.println("New experiment: " + problem.toString());
}
public boolean isFinished() {
diff --git a/src/jcgp/backend/modules/Module.java b/src/jcgp/backend/modules/Module.java
index f2b91b0..8a95737 100644
--- a/src/jcgp/backend/modules/Module.java
+++ b/src/jcgp/backend/modules/Module.java
@@ -4,6 +4,6 @@ import jcgp.backend.resources.parameters.Parameter;
public interface Module {
- public Parameter[] getLocalParameters();
+ public abstract Parameter[] getLocalParameters();
}
diff --git a/src/jcgp/backend/modules/ea/EvolutionaryAlgorithm.java b/src/jcgp/backend/modules/es/EvolutionaryStrategy.java
index 3aca104..1117e99 100644
--- a/src/jcgp/backend/modules/ea/EvolutionaryAlgorithm.java
+++ b/src/jcgp/backend/modules/es/EvolutionaryStrategy.java
@@ -1,13 +1,13 @@
-package jcgp.backend.modules.ea;
+package jcgp.backend.modules.es;
import jcgp.backend.modules.Module;
import jcgp.backend.modules.mutator.Mutator;
import jcgp.backend.population.Population;
import jcgp.backend.resources.Resources;
-public interface EvolutionaryAlgorithm extends Module {
+public interface EvolutionaryStrategy extends Module {
- public abstract void evolve(Population population, Mutator mutator, Resources parameters);
+ public abstract void evolve(Population population, Mutator mutator, Resources resources);
public abstract int getFittestChromosome();
diff --git a/src/jcgp/backend/modules/ea/MuPlusLambda.java b/src/jcgp/backend/modules/es/MuPlusLambda.java
index 0d16111..53fb932 100644
--- a/src/jcgp/backend/modules/ea/MuPlusLambda.java
+++ b/src/jcgp/backend/modules/es/MuPlusLambda.java
@@ -1,4 +1,4 @@
-package jcgp.backend.modules.ea;
+package jcgp.backend.modules.es;
import jcgp.backend.modules.mutator.Mutator;
import jcgp.backend.population.Population;
@@ -15,7 +15,7 @@ import jcgp.backend.resources.parameters.ParameterStatus;
* @author Eduardo Pedroni
*
*/
-public class MuPlusLambda implements EvolutionaryAlgorithm {
+public class MuPlusLambda implements EvolutionaryStrategy {
private int fittestChromosome;
@@ -58,22 +58,27 @@ public class MuPlusLambda implements EvolutionaryAlgorithm {
}
};
}
-
+
@Override
public void evolve(Population population, Mutator mutator, Resources resources) {
// select fittest chromosomes
fittestChromosome = 0;
- for (int i = 1; i < resources.getInt("popSize"); i++) {
+ if (report.get()) resources.reportln("[ES] Selecting fittest chromosome...");
+ for (int i = 0; i < resources.getInt("popSize"); i++) {
+ if (report.get()) resources.reportln("[ES] Chromosome " + i + ", fitness: " + population.getChromosome(i).getFitness());
if (population.getChromosome(i).getFitness() >= population.getChromosome(fittestChromosome).getFitness()) {
fittestChromosome = i;
}
}
+ if (report.get()) resources.reportln("[ES] Selected chromosome: " + fittestChromosome);
// create copies of fittest chromosome, mutate them
for (int i = 0; i < resources.getInt("popSize"); i++) {
if (i != fittestChromosome) {
+ if (report.get()) resources.reportln("[ES] Copying fittest chromosome to population position " + i);
population.copyChromosome(fittestChromosome, i);
+ if (report.get()) resources.reportln("[ES] Mutating copied chromosome");
mutator.mutate(population.getChromosome(i), resources);
}
}
diff --git a/src/jcgp/backend/modules/ea/TournamentSelection.java b/src/jcgp/backend/modules/es/TournamentSelection.java
index baf6704..3954de8 100644
--- a/src/jcgp/backend/modules/ea/TournamentSelection.java
+++ b/src/jcgp/backend/modules/es/TournamentSelection.java
@@ -1,4 +1,4 @@
-package jcgp.backend.modules.ea;
+package jcgp.backend.modules.es;
import java.util.HashMap;
@@ -8,7 +8,7 @@ import jcgp.backend.resources.Resources;
import jcgp.backend.resources.parameters.IntegerParameter;
import jcgp.backend.resources.parameters.Parameter;
-public class TournamentSelection implements EvolutionaryAlgorithm {
+public class TournamentSelection implements EvolutionaryStrategy {
private int fittestChromosome;
diff --git a/src/jcgp/backend/modules/fitness/DigitalCircuit.java b/src/jcgp/backend/modules/fitness/DigitalCircuit.java
index b01bdc5..8677d5f 100644
--- a/src/jcgp/backend/modules/fitness/DigitalCircuit.java
+++ b/src/jcgp/backend/modules/fitness/DigitalCircuit.java
@@ -1,11 +1,12 @@
package jcgp.backend.modules.fitness;
import jcgp.backend.function.BitwiseLogic;
+import jcgp.backend.resources.Resources;
public class DigitalCircuit extends TestCaseProblem<Integer> {
- public DigitalCircuit() {
- super();
+ public DigitalCircuit(Resources resources) {
+ super(resources);
functionSet = new BitwiseLogic();
}
diff --git a/src/jcgp/backend/modules/fitness/SymbolicRegression.java b/src/jcgp/backend/modules/fitness/SymbolicRegression.java
index da2e69e..cb9d1a7 100644
--- a/src/jcgp/backend/modules/fitness/SymbolicRegression.java
+++ b/src/jcgp/backend/modules/fitness/SymbolicRegression.java
@@ -1,11 +1,12 @@
package jcgp.backend.modules.fitness;
import jcgp.backend.function.IntegerArithmetic;
+import jcgp.backend.resources.Resources;
public class SymbolicRegression extends TestCaseProblem<Integer> {
- public SymbolicRegression() {
- super();
+ public SymbolicRegression(Resources resources) {
+ super(resources);
functionSet = new IntegerArithmetic();
}
diff --git a/src/jcgp/backend/modules/fitness/TestCaseProblem.java b/src/jcgp/backend/modules/fitness/TestCaseProblem.java
index 7753e26..4259285 100644
--- a/src/jcgp/backend/modules/fitness/TestCaseProblem.java
+++ b/src/jcgp/backend/modules/fitness/TestCaseProblem.java
@@ -51,7 +51,9 @@ public abstract class TestCaseProblem<U> extends Problem {
private ArrayList<TestCase<U>> testCases;
private IntegerParameter maxFitness;
- public TestCaseProblem() {
+ public TestCaseProblem(Resources resources) {
+ super();
+
maxFitness = new IntegerParameter(0, "Max fitness", true, false) {
@Override
public void validate(int newValue) {
diff --git a/src/jcgp/backend/modules/mutator/Mutator.java b/src/jcgp/backend/modules/mutator/Mutator.java
index ffdd35c..1d5b99a 100644
--- a/src/jcgp/backend/modules/mutator/Mutator.java
+++ b/src/jcgp/backend/modules/mutator/Mutator.java
@@ -6,6 +6,6 @@ import jcgp.backend.resources.Resources;
public interface Mutator extends Module {
- void mutate(Chromosome chromosome, Resources parameters);
+ void mutate(Chromosome chromosome, Resources resources);
}
diff --git a/src/jcgp/backend/modules/mutator/PointMutator.java b/src/jcgp/backend/modules/mutator/PointMutator.java
index 54d5f3d..1f38cfe 100644
--- a/src/jcgp/backend/modules/mutator/PointMutator.java
+++ b/src/jcgp/backend/modules/mutator/PointMutator.java
@@ -1,11 +1,11 @@
package jcgp.backend.modules.mutator;
-import jcgp.backend.function.Function;
import jcgp.backend.population.Chromosome;
import jcgp.backend.population.MutableElement;
import jcgp.backend.population.Node;
import jcgp.backend.population.Output;
import jcgp.backend.resources.Resources;
+import jcgp.backend.resources.parameters.BooleanParameter;
import jcgp.backend.resources.parameters.DoubleParameter;
import jcgp.backend.resources.parameters.Parameter;
import jcgp.backend.resources.parameters.ParameterStatus;
@@ -13,6 +13,7 @@ import jcgp.backend.resources.parameters.ParameterStatus;
public class PointMutator implements Mutator {
private DoubleParameter mutationRate;
+ private BooleanParameter report;
public PointMutator(final Resources resources) {
mutationRate = new DoubleParameter(50, "Percent mutation", false, false) {
@@ -29,23 +30,44 @@ public class PointMutator implements Mutator {
}
}
};
+
+ report = new BooleanParameter(false, "Report") {
+ @Override
+ public void validate(boolean newValue) {
+ // blank
+ }
+ };
}
@Override
public void mutate(Chromosome chromosome, Resources resources) {
int mutations = (int) ((mutationRate.get()) * ((((resources.getDouble("nodes")) + (resources.getDouble("outputs")))) / 100));
+ if (report.get()) resources.reportln("[Mutator] Number of mutations to be performed: " + mutations);
for (int i = 0; i < mutations; i++) {
MutableElement m = chromosome.getRandomMutableElement();
+ if (report.get()) resources.report("[Mutator] Mutation " + i + " selected " + m.toString() + ", ");
if (m instanceof Output) {
+ if (report.get()) resources.report("changed source from " + ((Output) m).getSource().toString() + " ");
+
m.setConnection(0, chromosome.getRandomConnection());
+
+ if (report.get()) resources.reportln("to " + ((Output) m).getSource().toString());
} else if (m instanceof Node) {
int geneType = resources.getRandomInt(1 + resources.getInt("arity"));
if (geneType < 1) {
- Function f = resources.getRandomFunction();
- ((Node) m).setFunction(f);
+ if (report.get()) resources.report("changed function from " + ((Node) m).getFunction().getName() + " ");
+
+ ((Node) m).setFunction(resources.getRandomFunction());
+
+ if (report.get()) resources.reportln("to " + ((Node) m).getFunction().getName());
} else {
- m.setConnection(resources.getRandomInt(resources.getInt("arity")), chromosome.getRandomConnection(((Node) m).getColumn()));
+ int connection = resources.getRandomInt(resources.getInt("arity"));
+ if (report.get()) resources.report("changed connection " + connection + " from " + ((Node) m).getConnection(connection) + " ");
+
+ m.setConnection(connection, chromosome.getRandomConnection(((Node) m).getColumn()));
+
+ if (report.get()) resources.reportln("to " + ((Node) m).getConnection(connection));
}
}
}
@@ -53,7 +75,7 @@ public class PointMutator implements Mutator {
@Override
public Parameter[] getLocalParameters() {
- return new Parameter[] {mutationRate};
+ return new Parameter[] {mutationRate, report};
}
@Override
diff --git a/src/jcgp/backend/population/Chromosome.java b/src/jcgp/backend/population/Chromosome.java
index d438375..bbada14 100644
--- a/src/jcgp/backend/population/Chromosome.java
+++ b/src/jcgp/backend/population/Chromosome.java
@@ -318,7 +318,7 @@ public class Chromosome {
for (int c = 0; c < (resources.getInt("columns")); c++) {
System.out.print("N: (" + r + ", " + c + ") ");
for (int i = 0; i < arity; i++) {
- System.out.print("C" + i + ": (" + nodes[r][c].getConnection(i).getDescription() + ") ");
+ System.out.print("C" + i + ": (" + nodes[r][c].getConnection(i).toString() + ") ");
}
System.out.print("F: " + nodes[r][c].getFunction().getName() + "\t");
}
@@ -326,7 +326,7 @@ public class Chromosome {
}
for (int o = 0; o < (resources.getInt("outputs")); o++) {
- System.out.print("o: " + o + " (" + outputs[o].getSource().getDescription() + ")\t");
+ System.out.print("o: " + o + " (" + outputs[o].getSource().toString() + ")\t");
}
}
diff --git a/src/jcgp/backend/population/Connection.java b/src/jcgp/backend/population/Connection.java
index ea4f10f..cd0f5ce 100644
--- a/src/jcgp/backend/population/Connection.java
+++ b/src/jcgp/backend/population/Connection.java
@@ -3,7 +3,5 @@ package jcgp.backend.population;
public interface Connection {
public Object getValue();
-
- public String getDescription();
}
diff --git a/src/jcgp/backend/population/Input.java b/src/jcgp/backend/population/Input.java
index 83fba07..2661f8c 100644
--- a/src/jcgp/backend/population/Input.java
+++ b/src/jcgp/backend/population/Input.java
@@ -23,7 +23,7 @@ public class Input extends Gene implements Connection {
}
@Override
- public String getDescription() {
- return "i: " + index;
+ public String toString() {
+ return "Input " + index;
}
}
diff --git a/src/jcgp/backend/population/Node.java b/src/jcgp/backend/population/Node.java
index 6960ded..87a2f99 100644
--- a/src/jcgp/backend/population/Node.java
+++ b/src/jcgp/backend/population/Node.java
@@ -106,7 +106,7 @@ public class Node extends Gene implements MutableElement, Connection {
}
@Override
- public String getDescription() {
- return "n: " + row + ", " + column;
+ public String toString() {
+ return "Node [" + row + ", " + column + "]";
}
}
diff --git a/src/jcgp/backend/population/Output.java b/src/jcgp/backend/population/Output.java
index aa94ab6..d876951 100644
--- a/src/jcgp/backend/population/Output.java
+++ b/src/jcgp/backend/population/Output.java
@@ -11,7 +11,6 @@ public class Output extends Gene implements MutableElement {
public Output(Chromosome chromosome, int index) {
this.chromosome = chromosome;
this.index = index;
- //this.source = new SimpleObjectProperty<Connection>();
}
public Object calculate() {
@@ -32,10 +31,6 @@ public class Output extends Gene implements MutableElement {
public Connection getSource() {
return source;
}
-
-// public SimpleObjectProperty<Connection> sourceProperty() {
-// return source;
-// }
public void getActiveNodes(ArrayList<Node> activeNodes) {
if (source instanceof Node) {
@@ -66,4 +61,9 @@ public class Output extends Gene implements MutableElement {
}
return false;
}
+
+ @Override
+ public String toString() {
+ return "Output " + index;
+ }
}
diff --git a/src/jcgp/backend/resources/ModifiableResources.java b/src/jcgp/backend/resources/ModifiableResources.java
index 90c2f03..a221f73 100644
--- a/src/jcgp/backend/resources/ModifiableResources.java
+++ b/src/jcgp/backend/resources/ModifiableResources.java
@@ -40,4 +40,21 @@ public class ModifiableResources extends Resources {
this.console = console;
}
+ /*
+ * Console functionality
+ */
+ public void println(String s) {
+ System.out.println(s);
+ if (console != null) {
+ console.println(s);
+ }
+ }
+
+ public void print(String s) {
+ System.out.print(s);
+ if (console != null) {
+ console.print(s);
+ }
+ }
+
}
diff --git a/src/jcgp/backend/resources/Resources.java b/src/jcgp/backend/resources/Resources.java
index d1f396a..13e0c51 100644
--- a/src/jcgp/backend/resources/Resources.java
+++ b/src/jcgp/backend/resources/Resources.java
@@ -266,31 +266,29 @@ public class Resources {
return functionSet;
}
-// /*
-// * Test cases
-// */
-// public TestCase getTestCase(int index) {
-// return testCases[index];
-// }
-//
-// public int getTestCaseCount() {
-// return testCases.length;
-// }
-
/*
* Console functionality
+ * These are affected by parameter report
*/
- public void println(String s) {
- System.out.println(s);
- if (console != null) {
- console.println(s);
+ public void reportln(String s) {
+ if (getInt("report") > 0) {
+ if (getInt("currentGen") % getInt("report") == 0) {
+ System.out.println(s);
+ if (console != null) {
+ console.println(s);
+ }
+ }
}
}
- public void print(String s) {
- System.out.print(s);
- if (console != null) {
- console.print(s);
+ public void report(String s) {
+ if (getInt("report") > 0) {
+ if (getInt("currentGen") % getInt("report") == 0) {
+ System.out.print(s);
+ if (console != null) {
+ console.print(s);
+ }
+ }
}
}
} \ No newline at end of file
diff --git a/src/jcgp/backend/tests/NodeTests.java b/src/jcgp/backend/tests/NodeTests.java
index 2294816..e8fe02f 100644
--- a/src/jcgp/backend/tests/NodeTests.java
+++ b/src/jcgp/backend/tests/NodeTests.java
@@ -57,13 +57,6 @@ public class NodeTests {
// hardcode a value
return arg1;
}
-
- @Override
- public String getDescription() {
- // blank
- return null;
- }
-
},
new Connection() {
@@ -72,13 +65,6 @@ public class NodeTests {
// hardcode a value
return arg2;
}
-
- @Override
- public String getDescription() {
- // blank
- return null;
- }
-
}});
}
@@ -144,13 +130,6 @@ public class NodeTests {
// blank
return 0;
}
-
- @Override
- public String getDescription() {
- // blank
- return null;
- }
-
};
conn1 = new Connection() {
@@ -159,13 +138,6 @@ public class NodeTests {
// blank
return 0;
}
-
- @Override
- public String getDescription() {
- // blank
- return null;
- }
-
};
Function function = new Function() {
@@ -201,12 +173,6 @@ public class NodeTests {
// blank
return 0;
}
-
- @Override
- public String getDescription() {
- // blank
- return null;
- }
};
node.setConnection(resources.getRandomInt(resources.getInt("arity")), conn2);
diff --git a/src/jcgp/backend/tests/OutputTests.java b/src/jcgp/backend/tests/OutputTests.java
index b2bc7ec..afe44a7 100644
--- a/src/jcgp/backend/tests/OutputTests.java
+++ b/src/jcgp/backend/tests/OutputTests.java
@@ -52,12 +52,6 @@ public class OutputTests {
// test value
return outputValue;
}
-
- @Override
- public String getDescription() {
- // blank
- return null;
- }
});
assertTrue("Incorrect evaluation.", ((Integer) output.calculate()) == outputValue);
@@ -73,12 +67,6 @@ public class OutputTests {
// blank
return 0;
}
-
- @Override
- public String getDescription() {
- // blank
- return null;
- }
};
output.setConnection(0, newConn);
diff --git a/src/jcgp/gui/GUI.java b/src/jcgp/gui/GUI.java
index 8f28884..eaca077 100644
--- a/src/jcgp/gui/GUI.java
+++ b/src/jcgp/gui/GUI.java
@@ -174,14 +174,15 @@ public class GUI extends Application {
jcgp.reset();
populationPane.remakeTabs(jcgp.getPopulation(), jcgp.getResources());
settingsPane.revalidateParameters();
+ settingsPane.updateControls(false, jcgp.isFinished());
console.flush();
}
}
private void runningMode(boolean value) {
populationPane.setDisable(value);
- settingsPane.runningMode(value);
-
+ settingsPane.updateControls(value, jcgp.isFinished());
+
if (value) {
populationPane.unlockOutputs();
if (settingsPane.isResetRequired()) {
diff --git a/src/jcgp/gui/console/GUIConsole.java b/src/jcgp/gui/console/GUIConsole.java
index 694f1a5..55291aa 100644
--- a/src/jcgp/gui/console/GUIConsole.java
+++ b/src/jcgp/gui/console/GUIConsole.java
@@ -7,7 +7,7 @@ import jcgp.gui.GUI;
public class GUIConsole extends AnchorPane implements Console {
- private TextArea textArea = new TextArea("Welcome to JCGP!");
+ private TextArea textArea = new TextArea("Welcome to JCGP!\n");
private StringBuffer printBuffer = new StringBuffer();
@@ -24,12 +24,11 @@ public class GUIConsole extends AnchorPane implements Console {
setPrefHeight(GUI.CONSOLE_HEIGHT);
getChildren().add(textArea);
-
}
@Override
public void println(String s) {
- printBuffer.append("\n" + s);
+ printBuffer.append(s + "\n");
}
@Override
diff --git a/src/jcgp/gui/dragresize/HorizontalDragResize.java b/src/jcgp/gui/dragresize/HorizontalDragResize.java
index d580878..3acfd4a 100644
--- a/src/jcgp/gui/dragresize/HorizontalDragResize.java
+++ b/src/jcgp/gui/dragresize/HorizontalDragResize.java
@@ -10,7 +10,6 @@ import jcgp.gui.GUI;
*
* http://andrewtill.blogspot.co.uk/2012/12/dragging-to-resize-javafx-region.html
*
- * @author eddy
*
*/
public class HorizontalDragResize {
diff --git a/src/jcgp/gui/dragresize/VerticalDragResize.java b/src/jcgp/gui/dragresize/VerticalDragResize.java
index 32a7526..8d79a2e 100644
--- a/src/jcgp/gui/dragresize/VerticalDragResize.java
+++ b/src/jcgp/gui/dragresize/VerticalDragResize.java
@@ -10,7 +10,6 @@ import jcgp.gui.GUI;
*
* http://andrewtill.blogspot.co.uk/2012/12/dragging-to-resize-javafx-region.html
*
- * @author eddy
*
*/
public class VerticalDragResize {
diff --git a/src/jcgp/gui/population/ChromosomePane.java b/src/jcgp/gui/population/ChromosomePane.java
index cba58d2..841c18a 100644
--- a/src/jcgp/gui/population/ChromosomePane.java
+++ b/src/jcgp/gui/population/ChromosomePane.java
@@ -63,7 +63,6 @@ public class ChromosomePane extends ScrollPane {
}
content.getChildren().addAll(guiNodes[r]);
}
-
// outputs
guiOutputs = new GUIOutput[resources.getInt("outputs")];
for (int i = 0; i < guiOutputs.length; i++) {
diff --git a/src/jcgp/gui/settings/SettingsPane.java b/src/jcgp/gui/settings/SettingsPane.java
index 5b23bdd..d7ffd79 100644
--- a/src/jcgp/gui/settings/SettingsPane.java
+++ b/src/jcgp/gui/settings/SettingsPane.java
@@ -17,7 +17,7 @@ import javafx.scene.text.Font;
import javafx.scene.text.Text;
import jcgp.JCGP;
import jcgp.backend.function.FunctionSet;
-import jcgp.backend.modules.ea.EvolutionaryAlgorithm;
+import jcgp.backend.modules.es.EvolutionaryStrategy;
import jcgp.backend.modules.fitness.Problem;
import jcgp.backend.modules.mutator.Mutator;
import jcgp.backend.resources.parameters.Parameter;
@@ -103,26 +103,26 @@ public class SettingsPane extends AnchorPane {
private void initialiseEAParameters(final JCGP cgp) {
eaPane = new VBox(2);
- Text header = new Text("Evolutionary Algorithm");
+ Text header = new Text("Evolutionary Strategy");
header.setFont(Font.font("Arial", 14));
header.setUnderline(true);
- final ComboBox<EvolutionaryAlgorithm> eaCBox = new ComboBox<EvolutionaryAlgorithm>();
- eaCBox.getItems().addAll(cgp.getEvolutionaryAlgorithms());
- eaCBox.getSelectionModel().select(cgp.getEvolutionaryAlgorithm());
+ final ComboBox<EvolutionaryStrategy> eaCBox = new ComboBox<EvolutionaryStrategy>();
+ eaCBox.getItems().addAll(cgp.getEvolutionaryStrategies());
+ eaCBox.getSelectionModel().select(cgp.getEvolutionaryStrategy());
eaCBox.prefWidthProperty().bind(mainContainer.widthProperty());
final VBox eaParameters = new VBox();
eaParameters.setSpacing(2);
- if (cgp.getEvolutionaryAlgorithm().getLocalParameters() != null) {
- refreshParameters(cgp.getEvolutionaryAlgorithm().getLocalParameters(), eaParameters);
+ if (cgp.getEvolutionaryStrategy().getLocalParameters() != null) {
+ refreshParameters(cgp.getEvolutionaryStrategy().getLocalParameters(), eaParameters);
}
eaCBox.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
- cgp.setEvolutionaryAlgorithm(eaCBox.getSelectionModel().getSelectedIndex());
+ cgp.setEvolutionaryStrategy(eaCBox.getSelectionModel().getSelectedIndex());
if (eaCBox.getSelectionModel().getSelectedItem().getLocalParameters() != null) {
refreshParameters(eaCBox.getSelectionModel().getSelectedItem().getLocalParameters(), eaParameters);
}
@@ -147,7 +147,7 @@ public class SettingsPane extends AnchorPane {
final VBox mutatorParameters = new VBox();
mutatorParameters.setSpacing(2);
- if (cgp.getEvolutionaryAlgorithm().getLocalParameters() != null) {
+ if (cgp.getEvolutionaryStrategy().getLocalParameters() != null) {
refreshParameters(cgp.getMutator().getLocalParameters(), mutatorParameters);
}
@@ -168,7 +168,7 @@ public class SettingsPane extends AnchorPane {
private void initialiseProblemTypeParameters(final JCGP cgp, final GUI gui) {
problemPane= new VBox(2);
- Text header = new Text("Problem type");
+ Text header = new Text("Problem Type");
header.setFont(Font.font("Arial", 14));
header.setUnderline(true);
@@ -205,6 +205,10 @@ public class SettingsPane extends AnchorPane {
}
private void createControls(final JCGP cgp, final GUI gui) {
+ Text header = new Text("Experiment controls");
+ header.setFont(Font.font("Arial", 14));
+ header.setUnderline(true);
+
final VBox controls = new VBox(2);
controls.setFillWidth(true);
@@ -241,7 +245,7 @@ public class SettingsPane extends AnchorPane {
HBox.setHgrow(reset, Priority.ALWAYS);
reset.setMaxWidth(Double.MAX_VALUE);
- controls.getChildren().add(flowButtons);
+ controls.getChildren().addAll(header, flowButtons);
mainContainer.getChildren().add(controls);
}
@@ -255,7 +259,6 @@ public class SettingsPane extends AnchorPane {
vb.getChildren().clear();
for (int i = 0; i < newParameters.length; i++) {
GUIParameter gp = GUIParameter.create(newParameters[i], this);
-
parameters.add(gp);
vb.getChildren().add(gp);
}
@@ -289,17 +292,17 @@ public class SettingsPane extends AnchorPane {
- public void runningMode(boolean value) {
- baseParameterPane.setDisable(value);
- eaPane.setDisable(value);
- mutatorPane.setDisable(value);
- problemPane.setDisable(value);
- step.setDisable(value);
- reset.setDisable(value);
-
- runPause.setText(value ? "Pause" : "Run");
- }
-
+// public void runningMode(boolean value) {
+// baseParameterPane.setDisable(value);
+// eaPane.setDisable(value);
+// mutatorPane.setDisable(value);
+// problemPane.setDisable(value);
+// step.setDisable(value);
+// reset.setDisable(value);
+//
+// runPause.setText(value ? "Pause" : "Run");
+// }
+//
/**
*
* @return true if the experiment needs to be reset, false otherwise.
@@ -335,6 +338,19 @@ public class SettingsPane extends AnchorPane {
public void applyParameters() {
for (GUIParameter parameter : parameters) {
parameter.applyValue();
- }
+ }
+ }
+
+ public void updateControls(boolean running, boolean finished) {
+ baseParameterPane.setDisable(running);
+ eaPane.setDisable(running);
+ mutatorPane.setDisable(running);
+ problemPane.setDisable(running);
+
+ runPause.setText(running ? "Pause" : "Run");
+ runPause.setDisable(finished);
+ step.setDisable(running || finished);
+ reset.setDisable(running);
+
}
}
diff --git a/src/jcgp/gui/settings/parameters/GUIDoubleParameter.java b/src/jcgp/gui/settings/parameters/GUIDoubleParameter.java
index eecff2d..4a8e0e1 100644
--- a/src/jcgp/gui/settings/parameters/GUIDoubleParameter.java
+++ b/src/jcgp/gui/settings/parameters/GUIDoubleParameter.java
@@ -34,7 +34,7 @@ public class GUIDoubleParameter extends GUIParameter {
name.wrappingWidthProperty().bind(widthProperty().divide(2));
- ((TextField) valueControl).setEditable(!parameter.isMonitor());
+ ((TextField) valueControl).setDisable(parameter.isMonitor());
// bind if monitor, else set changelistener
if (parameter.isMonitor()) {
diff --git a/src/jcgp/gui/settings/parameters/GUIIntegerParameter.java b/src/jcgp/gui/settings/parameters/GUIIntegerParameter.java
index 9c84c6a..204e7a2 100644
--- a/src/jcgp/gui/settings/parameters/GUIIntegerParameter.java
+++ b/src/jcgp/gui/settings/parameters/GUIIntegerParameter.java
@@ -34,7 +34,7 @@ public class GUIIntegerParameter extends GUIParameter {
name.wrappingWidthProperty().bind(widthProperty().divide(2));
- ((TextField) valueControl).setEditable(!parameter.isMonitor());
+ ((TextField) valueControl).setDisable(parameter.isMonitor());
// bind if monitor, else set listeners
if (parameter.isMonitor()) {