From ca71d0e34ba19bb53e37bc34c31a5cdfafd36b7b Mon Sep 17 00:00:00 2001 From: BrunoDatoMeneses <bruno.dato.meneses@gmail.com> Date: Thu, 19 Sep 2019 16:11:46 +0200 Subject: [PATCH] ADD: new minimal mains for amoeba --- AMOEBAonAMAK/src/experiments/MinimalMain.java | 22 ---------- .../MinimalMainCommandLineMode.java | 40 +++++++++++++++++++ .../src/experiments/MinimalMainUI.java | 40 +++++++++++++++++++ 3 files changed, 80 insertions(+), 22 deletions(-) delete mode 100644 AMOEBAonAMAK/src/experiments/MinimalMain.java create mode 100644 AMOEBAonAMAK/src/experiments/MinimalMainCommandLineMode.java create mode 100644 AMOEBAonAMAK/src/experiments/MinimalMainUI.java diff --git a/AMOEBAonAMAK/src/experiments/MinimalMain.java b/AMOEBAonAMAK/src/experiments/MinimalMain.java deleted file mode 100644 index b9b0bde3..00000000 --- a/AMOEBAonAMAK/src/experiments/MinimalMain.java +++ /dev/null @@ -1,22 +0,0 @@ -package experiments; - -import kernel.AMOEBA; -import kernel.StudiedSystem; - -/** - * The most minimal main possible producing a functioning amoeba. - * @author Hugo - * - */ -public class MinimalMain { - - public static void main(String[] args) throws InterruptedException { - // create a system to be studied - StudiedSystem studiedSystem = new F_XY_System(50.0); - // create the amoeba - // Make sure the path to the config file is correct. - AMOEBA amoeba = new AMOEBA("resources/twoDimensionsLauncher.xml", studiedSystem); - // a window should have appeared, allowing you to control and visualize the amoeba. - } - -} diff --git a/AMOEBAonAMAK/src/experiments/MinimalMainCommandLineMode.java b/AMOEBAonAMAK/src/experiments/MinimalMainCommandLineMode.java new file mode 100644 index 00000000..d57dfb6f --- /dev/null +++ b/AMOEBAonAMAK/src/experiments/MinimalMainCommandLineMode.java @@ -0,0 +1,40 @@ +package experiments; + +import fr.irit.smac.amak.Configuration; +import kernel.AMOEBA; +import kernel.StudiedSystem; + +/** + * The most minimal main possible producing a functioning amoeba. + * @author Hugo + * + */ +public class MinimalMainCommandLineMode { + + public static void main(String[] args) throws InterruptedException { + + Configuration.commandLineMode = true; + + // create a system to be studied + StudiedSystem studiedSystem = new F_XY_System(50.0); + // create the amoeba + // Make sure the path to the config file is correct. + AMOEBA amoeba = new AMOEBA(null,null,"resources/twoDimensionsLauncher.xml", studiedSystem); + // a window should have appeared, allowing you to control and visualize the amoeba. + + // Learning and Request example + long start = System.currentTimeMillis(); + for (int i = 0; i < 1001; ++i) { + studiedSystem.playOneStep(); + amoeba.learn(studiedSystem.getOutput()); + } + long end = System.currentTimeMillis(); + System.out.println("Done in : " + (end - start) + " ms"); + + for (int i = 0; i < 10; ++i) { + studiedSystem.playOneStep(); + System.out.println(amoeba.request(studiedSystem.getOutput())); + } + } + +} diff --git a/AMOEBAonAMAK/src/experiments/MinimalMainUI.java b/AMOEBAonAMAK/src/experiments/MinimalMainUI.java new file mode 100644 index 00000000..07459694 --- /dev/null +++ b/AMOEBAonAMAK/src/experiments/MinimalMainUI.java @@ -0,0 +1,40 @@ +package experiments; + +import fr.irit.smac.amak.Configuration; +import kernel.AMOEBA; +import kernel.StudiedSystem; + +/** + * The most minimal main possible producing a functioning amoeba. + * @author Hugo + * + */ +public class MinimalMainUI {//TODO + + public static void main(String[] args) throws InterruptedException { + + Configuration.commandLineMode = false; + + // create a system to be studied + StudiedSystem studiedSystem = new F_XY_System(50.0); + // create the amoeba + // Make sure the path to the config file is correct. + AMOEBA amoeba = new AMOEBA(null,null,"resources/twoDimensionsLauncher.xml", studiedSystem); + // a window should have appeared, allowing you to control and visualize the amoeba. + + // Learning and Request example + long start = System.currentTimeMillis(); + for (int i = 0; i < 1001; ++i) { + studiedSystem.playOneStep(); + amoeba.learn(studiedSystem.getOutput()); + } + long end = System.currentTimeMillis(); + System.out.println("Done in : " + (end - start) + " ms"); + + for (int i = 0; i < 10; ++i) { + studiedSystem.playOneStep(); + System.out.println(amoeba.request(studiedSystem.getOutput())); + } + } + +} -- GitLab