aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/JCGP.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/jcgp/JCGP.java')
-rw-r--r--src/jcgp/JCGP.java46
1 files changed, 23 insertions, 23 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() {