diff options
author | Eduardo Pedroni <ep625@york.ac.uk> | 2014-04-13 10:41:25 +0100 |
---|---|---|
committer | Eduardo Pedroni <ep625@york.ac.uk> | 2014-04-13 10:41:25 +0100 |
commit | e7d7e8506a511d78f9e323ac09587f79ad503f42 (patch) | |
tree | 8d87a718af29470b5bb8e5dfeb0ce18865f185cb /src/jcgp/gui/population | |
parent | dbae5ce2e0765f229e11b692a2aba570286980f4 (diff) |
Performance suddenly decreased, looking into why
Diffstat (limited to 'src/jcgp/gui/population')
-rw-r--r-- | src/jcgp/gui/population/ChromosomePane.java | 9 | ||||
-rw-r--r-- | src/jcgp/gui/population/GUIGene.java | 2 | ||||
-rw-r--r-- | src/jcgp/gui/population/PopulationPane.java | 20 |
3 files changed, 23 insertions, 8 deletions
diff --git a/src/jcgp/gui/population/ChromosomePane.java b/src/jcgp/gui/population/ChromosomePane.java index 0279d09..4a47f34 100644 --- a/src/jcgp/gui/population/ChromosomePane.java +++ b/src/jcgp/gui/population/ChromosomePane.java @@ -26,12 +26,13 @@ public class ChromosomePane extends ScrollPane { private int rows, columns; private boolean target = false; - private boolean evaluating = false; + private PopulationPane parent; - public ChromosomePane(Chromosome chromosome, GUI gui) { + public ChromosomePane(Chromosome chromosome, GUI gui, PopulationPane parent) { super(); final Resources resources = gui.getExperiment().getResources(); + this.parent = parent; rows = resources.rows(); columns = resources.columns(); @@ -143,7 +144,6 @@ public class ChromosomePane extends ScrollPane { } public void setInputs(Object[] values) { - evaluating = true; for (int i = 0; i < guiInputs.length; i++) { guiInputs[i].setValue(values[i]); guiInputs[i].updateText(); @@ -167,7 +167,6 @@ public class ChromosomePane extends ScrollPane { } public void hideValues() { - evaluating = false; for (int i = 0; i < guiInputs.length; i++) { guiInputs[i].updateText(); } @@ -185,6 +184,6 @@ public class ChromosomePane extends ScrollPane { * @return the evaluating */ public boolean isEvaluating() { - return evaluating; + return parent.isEvaluating(); } } diff --git a/src/jcgp/gui/population/GUIGene.java b/src/jcgp/gui/population/GUIGene.java index 5ce839e..c41261d 100644 --- a/src/jcgp/gui/population/GUIGene.java +++ b/src/jcgp/gui/population/GUIGene.java @@ -12,7 +12,7 @@ import jcgp.backend.population.Gene; public abstract class GUIGene extends Group { - public static final double NODE_RADIUS = 30; + public static final double NODE_RADIUS = 35; public static final double SPACING = 15; public static final double THETA = Math.PI / 1.4; diff --git a/src/jcgp/gui/population/PopulationPane.java b/src/jcgp/gui/population/PopulationPane.java index 64b61c4..28b0ad9 100644 --- a/src/jcgp/gui/population/PopulationPane.java +++ b/src/jcgp/gui/population/PopulationPane.java @@ -10,6 +10,8 @@ import jcgp.gui.GUI; public class PopulationPane extends TabPane { private GUI gui; + private TestCase<Object> currentTestCase; + private boolean evaluating = false; public PopulationPane(GUI gui) { super(); @@ -25,7 +27,7 @@ public class PopulationPane extends TabPane { Tab tab; ChromosomePane cp; for (int i = 0; i < jcgp.getResources().populationSize(); i++) { - cp = new ChromosomePane(jcgp.getPopulation().getChromosome(i), gui); + cp = new ChromosomePane(jcgp.getPopulation().getChromosome(i), gui, this); tab = new Tab("Chr " + i); tab.setContent(cp); getTabs().add(tab); @@ -33,6 +35,9 @@ public class PopulationPane extends TabPane { } public void updateGenes() { + if (evaluating) { + evaluateTestCase(currentTestCase); + } for (int i = 0; i < getChildrenUnmodifiable().size(); i++) { ((ChromosomePane) getTabs().get(i).getContent()).updateGenes(); } @@ -51,8 +56,10 @@ public class PopulationPane extends TabPane { } public void evaluateTestCase(TestCase<Object> testCase) { - if (gui.getExperiment().getProblem() instanceof TestCaseProblem) { + if (gui.getExperiment().getProblem() instanceof TestCaseProblem && testCase != null) { + currentTestCase = testCase; if (testCase.getInputs().length == gui.getExperiment().getResources().inputs()) { + evaluating = true; for (int i = 0; i < getTabs().size(); i++) { ((ChromosomePane) getTabs().get(i).getContent()).setInputs(testCase.getInputs()); } @@ -64,8 +71,17 @@ public class PopulationPane extends TabPane { } public void hideValues() { + evaluating = false; for (int i = 0; i < getTabs().size(); i++) { ((ChromosomePane) getTabs().get(i).getContent()).hideValues(); } } + + public boolean isEvaluating() { + return evaluating; + } + + public void setEvaluating(boolean value) { + evaluating = value; + } } |