aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/gui
diff options
context:
space:
mode:
authorEduardo Pedroni <ep625@york.ac.uk>2014-04-13 10:41:25 +0100
committerEduardo Pedroni <ep625@york.ac.uk>2014-04-13 10:41:25 +0100
commite7d7e8506a511d78f9e323ac09587f79ad503f42 (patch)
tree8d87a718af29470b5bb8e5dfeb0ce18865f185cb /src/jcgp/gui
parentdbae5ce2e0765f229e11b692a2aba570286980f4 (diff)
Performance suddenly decreased, looking into why
Diffstat (limited to 'src/jcgp/gui')
-rw-r--r--src/jcgp/gui/GUI.java7
-rw-r--r--src/jcgp/gui/population/ChromosomePane.java9
-rw-r--r--src/jcgp/gui/population/GUIGene.java2
-rw-r--r--src/jcgp/gui/population/PopulationPane.java20
-rw-r--r--src/jcgp/gui/settings/SettingsPane.java20
-rw-r--r--src/jcgp/gui/settings/testcase/TestCaseTable.java22
6 files changed, 54 insertions, 26 deletions
diff --git a/src/jcgp/gui/GUI.java b/src/jcgp/gui/GUI.java
index 6d87de1..e7a4a23 100644
--- a/src/jcgp/gui/GUI.java
+++ b/src/jcgp/gui/GUI.java
@@ -169,13 +169,13 @@ public class GUI extends Application {
reset();
}
populationPane.unlockOutputs();
-
jcgp.nextGeneration();
console.flush();
populationPane.updateGenes();
populationPane.relockOutputs();
settingsPane.revalidateParameters();
+ settingsPane.updateControls(false, jcgp.isFinished());
}
}
@@ -185,7 +185,6 @@ public class GUI extends Application {
jcgp.reset();
populationPane.remakeTabs();
settingsPane.revalidateParameters();
- System.out.println("[reset] call: " + jcgp.isFinished());
settingsPane.updateControls(false, jcgp.isFinished());
console.flush();
}
@@ -231,4 +230,8 @@ public class GUI extends Application {
public void hideGeneValues() {
populationPane.hideValues();
}
+
+ public void setEvaluating(boolean value) {
+ populationPane.setEvaluating(value);
+ }
}
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;
+ }
}
diff --git a/src/jcgp/gui/settings/SettingsPane.java b/src/jcgp/gui/settings/SettingsPane.java
index 9fcee8f..2ab9650 100644
--- a/src/jcgp/gui/settings/SettingsPane.java
+++ b/src/jcgp/gui/settings/SettingsPane.java
@@ -211,14 +211,15 @@ public class SettingsPane extends AnchorPane {
public void handle(ActionEvent event) {
jcgp.setProblem(problemCBox.getSelectionModel().getSelectedIndex());
if (jcgp.getProblem().getLocalParameters() != null) {
- showTestCaseContainer.getChildren().clear();
refreshParameters(jcgp.getProblem().getLocalParameters(), problemParameters);
- refreshFunctions(jcgp.getProblem().getFunctionSet(), nodeFunctions, gui);
- testCaseTable.close();
- if (jcgp.getProblem() instanceof TestCaseProblem) {
- showTestCaseContainer.getChildren().add(showTestCaseButton);
- testCaseTable = new TestCaseTable((TestCaseProblem<Object>) jcgp.getProblem(), gui);
- }
+ }
+ testCaseTable.close();
+ gui.setEvaluating(false);
+ refreshFunctions(jcgp.getProblem().getFunctionSet(), nodeFunctions, gui);
+ showTestCaseContainer.getChildren().clear();
+ if (jcgp.getProblem() instanceof TestCaseProblem) {
+ showTestCaseContainer.getChildren().add(showTestCaseButton);
+ testCaseTable = new TestCaseTable((TestCaseProblem<Object>) jcgp.getProblem(), gui);
}
gui.reset();
}
@@ -396,10 +397,12 @@ public class SettingsPane extends AnchorPane {
*/
public void revalidateParameters() {
runPause.setDisable(false);
+ step.setDisable(false);
for (GUIParameter<?> parameter : parameters) {
parameter.validate();
if (parameter.requiresReset()) {
runPause.setDisable(true);
+ step.setDisable(true);
}
}
}
@@ -429,10 +432,11 @@ public class SettingsPane extends AnchorPane {
problemPane.setDisable(running);
runPause.setText(running ? "Pause" : "Run");
- System.out.println("[updateControls] run pause disable: " + finished);
runPause.setDisable(finished);
step.setDisable(running || finished);
reset.setDisable(running);
+
+ testCaseTable.getTable().setDisable(running);
}
public TestCaseTable getTestCaseTable() {
diff --git a/src/jcgp/gui/settings/testcase/TestCaseTable.java b/src/jcgp/gui/settings/testcase/TestCaseTable.java
index 7e72cbd..b84f9ab 100644
--- a/src/jcgp/gui/settings/testcase/TestCaseTable.java
+++ b/src/jcgp/gui/settings/testcase/TestCaseTable.java
@@ -27,10 +27,12 @@ import jcgp.gui.GUI;
*/
public class TestCaseTable extends Stage {
+ private TableView<TestCase<Object>> table;
+
public TestCaseTable(final TestCaseProblem<Object> problem, final GUI gui) {
super();
- TableView<TestCase<Object>> tv = new TableView<TestCase<Object>>();
+ table = new TableView<TestCase<Object>>();
ObservableList<TestCase<Object>> testCaseList = problem.getTestCases();
ArrayList<TableColumn<TestCase<Object>, String>> inputs = new ArrayList<TableColumn<TestCase<Object>, String>>(problem.getInputCount());
@@ -48,7 +50,7 @@ public class TestCaseTable extends Stage {
}
});
tc.setSortable(false);
- tc.prefWidthProperty().bind(tv.widthProperty().divide(problem.getInputCount() + problem.getOutputCount()));
+ tc.prefWidthProperty().bind(table.widthProperty().divide(problem.getInputCount() + problem.getOutputCount()));
}
for (int o = 0; o < problem.getOutputCount(); o++) {
@@ -62,15 +64,15 @@ public class TestCaseTable extends Stage {
}
});
tc.setSortable(false);
- tc.prefWidthProperty().bind(tv.widthProperty().divide(problem.getInputCount() + problem.getOutputCount()));
+ tc.prefWidthProperty().bind(table.widthProperty().divide(problem.getInputCount() + problem.getOutputCount()));
}
- tv.getColumns().addAll(inputs);
- tv.getColumns().addAll(outputs);
+ table.getColumns().addAll(inputs);
+ table.getColumns().addAll(outputs);
- tv.setItems(testCaseList);
+ table.setItems(testCaseList);
- tv.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<TestCase<Object>>() {
+ table.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<TestCase<Object>>() {
@Override
public void changed(
ObservableValue<? extends TestCase<Object>> observable, TestCase<Object> oldValue, TestCase<Object> newValue) {
@@ -85,6 +87,10 @@ public class TestCaseTable extends Stage {
}
});
- setScene(new Scene(tv));
+ setScene(new Scene(table));
+ }
+
+ public TableView<TestCase<Object>> getTable() {
+ return table;
}
}