From 878cdb7211a81cfbef739e947fbfe0f47624b6aa Mon Sep 17 00:00:00 2001 From: BrunoDatoMeneses <bruno.dato.meneses@gmail.com> Date: Thu, 19 Sep 2019 12:24:26 +0200 Subject: [PATCH] FIX: vui init --- AMAKFX/src/fr/irit/smac/amak/Amas.java | 3 +- AMAKFX/src/fr/irit/smac/amak/ui/VUIMulti.java | 6 +- .../F_N_LauncherMultiUI.java | 136 +++++++++--------- AMOEBAonAMAK/src/gui/AmoebaMultiUIWindow.java | 2 +- 4 files changed, 78 insertions(+), 69 deletions(-) diff --git a/AMAKFX/src/fr/irit/smac/amak/Amas.java b/AMAKFX/src/fr/irit/smac/amak/Amas.java index f56acaf8..b08568dd 100644 --- a/AMAKFX/src/fr/irit/smac/amak/Amas.java +++ b/AMAKFX/src/fr/irit/smac/amak/Amas.java @@ -166,7 +166,8 @@ public class Amas<E extends Environment> implements Schedulable { amasMultiUIWindow = window; vuiMulti = vui; - vuiMulti.addTabbedDefaultPanel(amasMultiUIWindow); + amasMultiUIWindow.addTabbedPanel(vuiMulti.title, vuiMulti.getPanel()); + //vuiMulti.addTabbedDefaultPanel(amasMultiUIWindow); executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(Configuration.allowedSimultaneousAgentsExecution); diff --git a/AMAKFX/src/fr/irit/smac/amak/ui/VUIMulti.java b/AMAKFX/src/fr/irit/smac/amak/ui/VUIMulti.java index 501a6d6c..326c1608 100644 --- a/AMAKFX/src/fr/irit/smac/amak/ui/VUIMulti.java +++ b/AMAKFX/src/fr/irit/smac/amak/ui/VUIMulti.java @@ -41,6 +41,9 @@ import javafx.scene.text.TextAlignment; * */ public class VUIMulti { + + public String title; + /** * The toolbar of the VUI. */ @@ -178,8 +181,9 @@ public class VUIMulti { * @param title * The title used for the vui */ - private VUIMulti(String title) { + private VUIMulti(String titleValue) { + this.title = titleValue; Semaphore done = new Semaphore(0); RunLaterHelper.runLater(() -> { panel = new BorderPane(); diff --git a/AMOEBAonAMAK/src/experiments/nDimensionsLaunchers/F_N_LauncherMultiUI.java b/AMOEBAonAMAK/src/experiments/nDimensionsLaunchers/F_N_LauncherMultiUI.java index 7b501249..a4286772 100644 --- a/AMOEBAonAMAK/src/experiments/nDimensionsLaunchers/F_N_LauncherMultiUI.java +++ b/AMOEBAonAMAK/src/experiments/nDimensionsLaunchers/F_N_LauncherMultiUI.java @@ -70,7 +70,6 @@ public class F_N_LauncherMultiUI extends Application implements Serializable { VUIMulti amoebaVUI = VUIMulti.get("2D"); AmoebaMultiUIWindow amoebaUI = new AmoebaMultiUIWindow("ELLSA", amoebaVUI); AMOEBA amoeba = new AMOEBA(amoebaUI, amoebaVUI); - StudiedSystem studiedSystem = new F_N_Manager(spaceSize, dimension, nbOfModels, normType, randomExploration, explorationIncrement,explorationWidht,limitedToSpaceZone, oracleNoiseRange); amoeba.setStudiedSystem(studiedSystem); IBackupSystem backupSystem = new BackupSystem(amoeba); @@ -101,86 +100,91 @@ public class F_N_LauncherMultiUI extends Application implements Serializable { studiedSystem.playOneStep(); amoeba.learn(studiedSystem.getOutput()); + studiedSystem.playOneStep(); + amoeba.learn(studiedSystem.getOutput()); + studiedSystem.playOneStep(); + amoeba.learn(studiedSystem.getOutput()); + studiedSystem.playOneStep(); + amoeba.learn(studiedSystem.getOutput()); - VUIMulti amoebaVUI2 = VUIMulti.get("2D"); - AmoebaMultiUIWindow amoebaUI2 = new AmoebaMultiUIWindow("ELLSA", amoebaVUI2); - AMOEBA amoeba2 = new AMOEBA(amoebaUI2, amoebaVUI2); - - StudiedSystem studiedSystem2 = new F_N_Manager(spaceSize, dimension, nbOfModels, normType, randomExploration, explorationIncrement,explorationWidht,limitedToSpaceZone, oracleNoiseRange); - amoeba2.setStudiedSystem(studiedSystem2); - IBackupSystem backupSystem2 = new BackupSystem(amoeba2); - File file2 = new File("resources/twoDimensionsLauncher.xml"); - backupSystem2.load(file2); - - amoeba2.saver = new SaveHelperImpl(amoeba2); - amoeba2.allowGraphicalScheduler(true); - amoeba2.setRenderUpdate(true); - amoeba2.data.learningSpeed = learningSpeed; - amoeba2.data.numberOfPointsForRegression = regressionPoints; - amoeba2.getEnvironment().setMappingErrorAllowed(mappingErrorAllowed); - // Exemple for adding a tool in the toolbar - Slider slider2 = new Slider(0.01, 0.1, mappingErrorAllowed); - slider2.setShowTickLabels(true); - slider2.setShowTickMarks(true); + long start = System.currentTimeMillis(); + for (int i = 0; i < 100; ++i) { + System.out.println(i); + studiedSystem.playOneStep(); + amoeba.learn(studiedSystem.getOutput()); + } + long end = System.currentTimeMillis(); + System.out.println("Done in : " + (end - start) ); + - slider2.valueProperty().addListener(new ChangeListener<Number>() { - @Override - public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) { - System.out.println("new Value "+newValue); - mappingErrorAllowed = (double)newValue; - amoeba2.getEnvironment().setMappingErrorAllowed(mappingErrorAllowed); - } - }); - amoebaUI2.addToolbar(slider2); +// VUIMulti amoebaVUI2 = VUIMulti.get("2D"); +// AmoebaMultiUIWindow amoebaUI2 = new AmoebaMultiUIWindow("ELLSA", amoebaVUI2); +// AMOEBA amoeba2 = new AMOEBA(amoebaUI2, amoebaVUI2); +// +// StudiedSystem studiedSystem2 = new F_N_Manager(spaceSize, dimension, nbOfModels, normType, randomExploration, explorationIncrement,explorationWidht,limitedToSpaceZone, oracleNoiseRange); +// amoeba2.setStudiedSystem(studiedSystem2); +// IBackupSystem backupSystem2 = new BackupSystem(amoeba2); +// File file2 = new File("resources/twoDimensionsLauncher.xml"); +// backupSystem2.load(file2); +// +// amoeba2.saver = new SaveHelperImpl(amoeba2); +// amoeba2.allowGraphicalScheduler(true); +// amoeba2.setRenderUpdate(true); +// amoeba2.data.learningSpeed = learningSpeed; +// amoeba2.data.numberOfPointsForRegression = regressionPoints; +// amoeba2.getEnvironment().setMappingErrorAllowed(mappingErrorAllowed); +// +// // Exemple for adding a tool in the toolbar +// Slider slider2 = new Slider(0.01, 0.1, mappingErrorAllowed); +// slider2.setShowTickLabels(true); +// slider2.setShowTickMarks(true); +// +// slider2.valueProperty().addListener(new ChangeListener<Number>() { +// @Override +// public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) { +// System.out.println("new Value "+newValue); +// mappingErrorAllowed = (double)newValue; +// amoeba2.getEnvironment().setMappingErrorAllowed(mappingErrorAllowed); +// } +// }); +// amoebaUI2.addToolbar(slider2); +// +// studiedSystem2.playOneStep(); +// amoeba2.learn(studiedSystem2.getOutput()); - studiedSystem2.playOneStep(); - amoeba2.learn(studiedSystem2.getOutput()); +// try { +// Thread.sleep(2000) ; +// } catch (InterruptedException e) { +// // gestion de l'erreur +// } +// +// long start = System.currentTimeMillis(); +// for (int i = 0; i < nbCycle; ++i) { +// studiedSystem.playOneStep(); +// amoeba.learn(studiedSystem.getOutput()); +// } +// long end = System.currentTimeMillis(); +// System.out.println("Done in : " + (end - start) ); + } + + @Override + public void stop() throws Exception { + super.stop(); + System.exit(0); } public static void launch() throws IOException{ + - // Set AMAK configuration before creating an AMOEBA - - - AMOEBA amoeba = new AMOEBA(null, VUIMulti.get("2D")); - StudiedSystem studiedSystem = new F_N_Manager(spaceSize, dimension, nbOfModels, normType, randomExploration, explorationIncrement,explorationWidht,limitedToSpaceZone, oracleNoiseRange); - amoeba.setStudiedSystem(studiedSystem); - IBackupSystem backupSystem = new BackupSystem(amoeba); - File file = new File("resources/twoDimensionsLauncher.xml"); - backupSystem.load(file); - - - amoeba.saver = new SaveHelperImpl(amoeba); - amoeba.allowGraphicalScheduler(true); - amoeba.setRenderUpdate(true); - amoeba.data.learningSpeed = learningSpeed; - amoeba.data.numberOfPointsForRegression = regressionPoints; - amoeba.getEnvironment().setMappingErrorAllowed(mappingErrorAllowed); - - // Exemple for adding a tool in the toolbar - Slider slider = new Slider(0.01, 0.1, mappingErrorAllowed); - slider.setShowTickLabels(true); - slider.setShowTickMarks(true); - - slider.valueProperty().addListener(new ChangeListener<Number>() { - @Override - public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) { - System.out.println("new Value "+newValue); - mappingErrorAllowed = (double)newValue; - amoeba.getEnvironment().setMappingErrorAllowed(mappingErrorAllowed); - } - }); - AmoebaWindow.addToolbar(slider); - studiedSystem.playOneStep(); - amoeba.learn(studiedSystem.getOutput()); + /* AUTOMATIC */ // long start = System.currentTimeMillis(); diff --git a/AMOEBAonAMAK/src/gui/AmoebaMultiUIWindow.java b/AMOEBAonAMAK/src/gui/AmoebaMultiUIWindow.java index d290c44a..19d89a81 100644 --- a/AMOEBAonAMAK/src/gui/AmoebaMultiUIWindow.java +++ b/AMOEBAonAMAK/src/gui/AmoebaMultiUIWindow.java @@ -58,7 +58,7 @@ public class AmoebaMultiUIWindow extends AmasMultiUIWindow{ mainVUI.setDefaultView(200, 0, 0); - addTabbedPanel("2D VUI", mainVUI.getPanel()); + //addTabbedPanel("2D VUI", mainVUI.getPanel()); // scheduler toolbar schedulerToolbar = new SchedulerToolbar("AMOEBA", amoeba.getScheduler()); -- GitLab