From 67ace66f66ffaa00e1bd1495c0d406c801e59c5c Mon Sep 17 00:00:00 2001 From: Eduardo Pedroni Date: Mon, 7 Apr 2014 10:04:05 +0100 Subject: Refactored problem types --- src/jcgp/gui/settings/SettingsPane.java | 45 ++++++++++++++++----------------- 1 file changed, 22 insertions(+), 23 deletions(-) (limited to 'src/jcgp/gui') diff --git a/src/jcgp/gui/settings/SettingsPane.java b/src/jcgp/gui/settings/SettingsPane.java index 8c707d3..5b23bdd 100644 --- a/src/jcgp/gui/settings/SettingsPane.java +++ b/src/jcgp/gui/settings/SettingsPane.java @@ -14,12 +14,11 @@ import javafx.scene.layout.HBox; import javafx.scene.layout.Priority; import javafx.scene.layout.VBox; import javafx.scene.text.Font; -import javafx.scene.text.FontSmoothingType; import javafx.scene.text.Text; import jcgp.JCGP; import jcgp.backend.function.FunctionSet; import jcgp.backend.modules.ea.EvolutionaryAlgorithm; -import jcgp.backend.modules.fitness.FitnessFunction; +import jcgp.backend.modules.fitness.Problem; import jcgp.backend.modules.mutator.Mutator; import jcgp.backend.resources.parameters.Parameter; import jcgp.gui.GUI; @@ -28,7 +27,7 @@ import jcgp.gui.settings.parameters.GUIParameter; public class SettingsPane extends AnchorPane { private VBox mainContainer; - private VBox baseParameterPane, eaPane, mutatorPane, ffPane, nfPane; + private VBox baseParameterPane, eaPane, mutatorPane, problemPane; private Button runPause = new Button("Run"), step = new Button("Step"), reset = new Button("Reset"); @@ -95,7 +94,7 @@ public class SettingsPane extends AnchorPane { parameters.add(GUIParameter.create(cgp.getResources().getParameter("seed"), this)); parameters.add(GUIParameter.create(cgp.getResources().getParameter("report"), this)); - parameters.add(GUIParameter.create(cgp.getResources().getParameter("maxFitness"), this)); + //parameters.add(GUIParameter.create(cgp.getResources().getParameter("maxFitness"), this)); baseParameterPane.getChildren().addAll(parameters); mainContainer.getChildren().add(baseParameterPane); @@ -138,7 +137,6 @@ public class SettingsPane extends AnchorPane { mutatorPane = new VBox(2); Text header = new Text("Mutator"); - header.setFontSmoothingType(FontSmoothingType.LCD); header.setFont(Font.font("Arial", 14)); header.setUnderline(true); @@ -156,7 +154,7 @@ public class SettingsPane extends AnchorPane { mutatorCBox.setOnAction(new EventHandler() { @Override public void handle(ActionEvent event) { - cgp.setEvolutionaryAlgorithm(mutatorCBox.getSelectionModel().getSelectedIndex()); + cgp.setMutator(mutatorCBox.getSelectionModel().getSelectedIndex()); if (mutatorCBox.getSelectionModel().getSelectedItem().getLocalParameters() != null) { refreshParameters(mutatorCBox.getSelectionModel().getSelectedItem().getLocalParameters(), mutatorParameters); } @@ -168,39 +166,41 @@ public class SettingsPane extends AnchorPane { } private void initialiseProblemTypeParameters(final JCGP cgp, final GUI gui) { - ffPane= new VBox(2); + problemPane= new VBox(2); Text header = new Text("Problem type"); header.setFont(Font.font("Arial", 14)); header.setUnderline(true); - final ComboBox ffCBox = new ComboBox(); - ffCBox.getItems().addAll(cgp.getFitnessFunctions()); - ffCBox.getSelectionModel().select(cgp.getFitnessFunction()); + final ComboBox ffCBox = new ComboBox(); + ffCBox.getItems().addAll(cgp.getProblems()); + ffCBox.getSelectionModel().select(cgp.getProblem()); ffCBox.prefWidthProperty().bind(mainContainer.widthProperty()); final VBox ffParameters = new VBox(); ffParameters.setSpacing(2); - if (cgp.getFitnessFunction().getLocalParameters() != null) { - refreshParameters(cgp.getFitnessFunction().getLocalParameters(), ffParameters); + if (cgp.getProblem().getLocalParameters() != null) { + refreshParameters(cgp.getProblem().getLocalParameters(), ffParameters); } + final VBox nodeFunctions = new VBox(); + nodeFunctions.setSpacing(2); + refreshFunctions(cgp.getResources().getFunctionSet(), nodeFunctions, gui); + ffCBox.setOnAction(new EventHandler() { @Override public void handle(ActionEvent event) { - cgp.setEvolutionaryAlgorithm(ffCBox.getSelectionModel().getSelectedIndex()); + cgp.setProblem(ffCBox.getSelectionModel().getSelectedIndex()); if (ffCBox.getSelectionModel().getSelectedItem().getLocalParameters() != null) { - refreshParameters(ffCBox.getSelectionModel().getSelectedItem().getLocalParameters(), ffParameters); - } + refreshParameters(cgp.getProblem().getLocalParameters(), ffParameters); + refreshFunctions(cgp.getProblem().getFunctionSet(), nodeFunctions, gui); + } + gui.reset(); } }); - final VBox nfParameters = new VBox(); - nfParameters.setSpacing(2); - refreshFunctions(cgp.getResources().getFunctionSet(), nfParameters, gui); - - ffPane.getChildren().addAll(header, ffCBox, ffParameters, nfParameters); - mainContainer.getChildren().add(ffPane); + problemPane.getChildren().addAll(header, ffCBox, ffParameters, nodeFunctions); + mainContainer.getChildren().add(problemPane); } @@ -293,8 +293,7 @@ public class SettingsPane extends AnchorPane { baseParameterPane.setDisable(value); eaPane.setDisable(value); mutatorPane.setDisable(value); - ffPane.setDisable(value); - nfPane.setDisable(value); + problemPane.setDisable(value); step.setDisable(value); reset.setDisable(value); -- cgit v1.2.3