diff --git a/AMOEBAonAMAK/src/agents/context/Context.java b/AMOEBAonAMAK/src/agents/context/Context.java index 9504f902830cfb5cc18e78c8e439661a4ec06816..758792156bdb0e3ae40f72cee8d5f301e2cdd4a6 100644 --- a/AMOEBAonAMAK/src/agents/context/Context.java +++ b/AMOEBAonAMAK/src/agents/context/Context.java @@ -23,6 +23,10 @@ import ncs.NCS; import utils.Pair; import utils.TRACE_LEVEL; + + + + /** * The core agent of AMOEBA. * @@ -68,6 +72,9 @@ public class Context extends AmoebaAgent { public boolean fusionned = false; public boolean isInNeighborhood = false; + static final int VOID_CYCLE_START = 0; + static final int OVERLAP_CYCLE_START = 0; + public Context(AMOEBA amoeba) { super(amoeba); buildContext(); @@ -232,7 +239,7 @@ public class Context extends AmoebaAgent { if(getAmas().getHeadAgent().lastEndogenousRequest.getType() == REQUEST.VOID) { double startRange = getAmas().getHeadAgent().lastEndogenousRequest.getBounds().get(p).getA(); double endRange = getAmas().getHeadAgent().lastEndogenousRequest.getBounds().get(p).getB(); - System.out.println(startRange + " " + endRange); + //System.out.println(startRange + " " + endRange); getAmas().getEnvironment() .trace(TRACE_LEVEL.INFORM, new ArrayList<String>(Arrays.asList("Range creation by VOID", this.getName(), p.getName(), getAmas().getHeadAgent().meanNeighborhoodRaduises.get(p).toString()))); r = new Range(this, startRange, endRange, 0, true, true, p, getAmas().getHeadAgent().minMeanNeighborhoodStartIncrements, getAmas().getHeadAgent().minMeanNeighborhoodEndIncrements); @@ -630,7 +637,7 @@ public class Context extends AmoebaAgent { for (Percept pct : getAmas().getPercepts()) { currentDistance = this.distance(ctxt, pct); - if(currentDistance<-pct.getMappingErrorAllowedMin() && getAmas().getCycle()>250) { + if(currentDistance<-pct.getMappingErrorAllowedMin() && getAmas().getCycle()>OVERLAP_CYCLE_START) { getEnvironment().trace(TRACE_LEVEL.DEBUG,new ArrayList<String>(Arrays.asList("OVERLAP",pct.getName(), ""+this,""+ctxt)) ); overlapCounts+=1; overlapDistances.put(pct, Math.abs(currentDistance)); @@ -640,7 +647,7 @@ public class Context extends AmoebaAgent { } - if (currentDistance > pct.getMappingErrorAllowedMin() && getAmas().getCycle()>500) { + if (currentDistance > pct.getMappingErrorAllowedMin() && getAmas().getCycle()>VOID_CYCLE_START) { getEnvironment().trace(TRACE_LEVEL.DEBUG,new ArrayList<String>(Arrays.asList("VOID",pct.getName(), ""+this,""+ctxt, "distance", ""+currentDistance)) ); voidDistances.put(pct, currentDistance); bounds.put(pct, this.voidBounds(ctxt, pct)); @@ -652,7 +659,7 @@ public class Context extends AmoebaAgent { } - if (overlapCounts == getAmas().getPercepts().size() && getAmas().getCycle() > 250) { + if (overlapCounts == getAmas().getPercepts().size() && getAmas().getCycle() > OVERLAP_CYCLE_START) { getEnvironment().trace(TRACE_LEVEL.INFORM, new ArrayList<String>(Arrays.asList(getAmas().getPercepts().size() + "OVERLAPS", ""+this,""+ctxt)) ); @@ -678,7 +685,7 @@ public class Context extends AmoebaAgent { } } - else if(overlapCounts == getAmas().getPercepts().size()-1 && voidDistances.size() == 1 && getAmas().getCycle() > 500) { + else if(overlapCounts == getAmas().getPercepts().size()-1 && voidDistances.size() == 1 && getAmas().getCycle() > VOID_CYCLE_START) { getEnvironment().trace(TRACE_LEVEL.INFORM, new ArrayList<String>(Arrays.asList("VOID", ""+this,""+ctxt)) ); diff --git a/AMOEBAonAMAK/src/agents/head/Head.java b/AMOEBAonAMAK/src/agents/head/Head.java index 16684af32c6acc73ad196913333007522d806e18..e9cd39f20ecde87beb29684b399bce65a89941e4 100644 --- a/AMOEBAonAMAK/src/agents/head/Head.java +++ b/AMOEBAonAMAK/src/agents/head/Head.java @@ -348,7 +348,7 @@ public class Head extends AmoebaAgent { getEnvironment().trace(TRACE_LEVEL.DEBUG, new ArrayList<String>(Arrays.asList("\n\n"))); getAmas().data.executionTimes[0]=System.currentTimeMillis(); - getEnvironment().trace(TRACE_LEVEL.INFORM, new ArrayList<String>(Arrays.asList("------------------------------------------------------------------------------------" + getEnvironment().trace(TRACE_LEVEL.CYCLE, new ArrayList<String>(Arrays.asList("------------------------------------------------------------------------------------" + "---------------------------------------- PLAY WITH ORACLE"))); if (activatedContexts.size() > 0) { @@ -464,6 +464,7 @@ public class Head extends AmoebaAgent { // } // } + @@ -552,7 +553,7 @@ public class Head extends AmoebaAgent { */ private void playWithoutOracle() { - getEnvironment().trace(TRACE_LEVEL.INFORM, new ArrayList<String>(Arrays.asList("------------------------------------------------------------------------------------" + getEnvironment().trace(TRACE_LEVEL.CYCLE, new ArrayList<String>(Arrays.asList("------------------------------------------------------------------------------------" + "---------------------------------------- PLAY WITHOUT ORACLE"))); logger().debug("HEAD without oracle", "Nombre de contextes activés: " + activatedContexts.size()); @@ -1279,7 +1280,7 @@ public class Head extends AmoebaAgent { if(getAmas().data.oracleValue>0) { - System.out.println(activatedContext.getName()); + //System.out.println(activatedContext.getName()); REINFORCEMENT ? } diff --git a/AMOEBAonAMAK/src/experiments/F_XY_System.java b/AMOEBAonAMAK/src/experiments/F_XY_System.java index 42897851276311ddec61ba99286aa73334231878..d2ebc1a8fc27319bb7cb2de89416d8d16c686682 100644 --- a/AMOEBAonAMAK/src/experiments/F_XY_System.java +++ b/AMOEBAonAMAK/src/experiments/F_XY_System.java @@ -107,4 +107,22 @@ public class F_XY_System implements StudiedSystem { // TODO Auto-generated method stub } + + @Override + public Double getActiveRequestCounts() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Double getSelfRequestCounts() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Double getRandomRequestCounts() { + // TODO Auto-generated method stub + return null; + } } \ No newline at end of file diff --git a/AMOEBAonAMAK/src/experiments/benchmark/NDimCube.java b/AMOEBAonAMAK/src/experiments/benchmark/NDimCube.java index 25e9bfc9ad8b04a2d47a7723424a98796dfa0de6..88e5e7075c9ea2dc43233895433ddaeeb96f73cb 100644 --- a/AMOEBAonAMAK/src/experiments/benchmark/NDimCube.java +++ b/AMOEBAonAMAK/src/experiments/benchmark/NDimCube.java @@ -154,4 +154,22 @@ public class NDimCube implements StudiedSystem{ // TODO Auto-generated method stub } + + @Override + public Double getActiveRequestCounts() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Double getSelfRequestCounts() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Double getRandomRequestCounts() { + // TODO Auto-generated method stub + return null; + } } \ No newline at end of file diff --git a/AMOEBAonAMAK/src/experiments/nDimensionsLaunchers/F_N_Launcher.java b/AMOEBAonAMAK/src/experiments/nDimensionsLaunchers/F_N_Launcher.java index 2f5c64163ebf134e1df6f05d9827411049e2eee0..2bb7df9c576c824ef81c488f80701aed001cff63 100644 --- a/AMOEBAonAMAK/src/experiments/nDimensionsLaunchers/F_N_Launcher.java +++ b/AMOEBAonAMAK/src/experiments/nDimensionsLaunchers/F_N_Launcher.java @@ -1,9 +1,14 @@ package experiments.nDimensionsLaunchers; + import java.io.File; import java.io.IOException; import java.io.Serializable; import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.OptionalDouble; import experiments.FILE; import fr.irit.smac.amak.Configuration; @@ -17,9 +22,11 @@ import javafx.scene.control.Slider; import javafx.stage.Stage; import kernel.AMOEBA; import kernel.StudiedSystem; +import kernel.World; import kernel.backup.BackupSystem; import kernel.backup.IBackupSystem; import kernel.backup.SaveHelperImpl; +import utils.TRACE_LEVEL; /** @@ -38,12 +45,13 @@ public class F_N_Launcher extends Application implements Serializable { public static final boolean randomExploration = true; public static final boolean limitedToSpaceZone = true; //public static final double mappingErrorAllowed = 0.07; // BIG SQUARE - public static double mappingErrorAllowed = 0.03; // MULTI + public static double mappingErrorAllowed = 0.05; // MULTI public static final double explorationIncrement = 1.0 ; public static final double explorationWidht = 0.5 ; public static final boolean setActiveLearning = true ; - public static final boolean setSelfLearning = true ; + public static final boolean setSelfLearning = false ; public static final int nbCycle = 1000; + public static final int nbTest = 10; @@ -62,101 +70,76 @@ public class F_N_Launcher extends Application implements Serializable { // Set AMAK configuration before creating an AMOEBA Configuration.multiUI=true; - Configuration.commandLineMode = false; + Configuration.commandLineMode = true; Configuration.allowedSimultaneousAgentsExecution = 1; - Configuration.waitForGUI = true; + Configuration.waitForGUI = false; Configuration.plotMilliSecondsUpdate = 20000; - VUIMulti amoebaVUI = new VUIMulti("2D"); - AmoebaMultiUIWindow amoebaUI = new AmoebaMultiUIWindow("ELLSA", amoebaVUI); - AMOEBA amoeba = new AMOEBA(amoebaUI, amoebaVUI); + HashMap<String, ArrayList<Double>> data = new HashMap<String, ArrayList<Double>>(); + + List<String> dataStrings = Arrays.asList("mappingScore", "randomRequests", "activeRequests","nbAgents"); + + for (String dataName : dataStrings){ + data.put(dataName, new ArrayList<Double>()); + } + + for (int i = 0; i < nbTest; ++i) { + System.out.print(i + " "); + ellsaTest( data); + } + System.out.println(""); + + + + + + + for (String dataName : dataStrings){ + OptionalDouble averageScore = data.get(dataName).stream().mapToDouble(a->a).average(); + Double deviationScore = data.get(dataName).stream().mapToDouble(a->Math.pow((a-averageScore.getAsDouble()),2)).sum(); + System.out.println("[" + dataName +" AVERAGE] " + averageScore.getAsDouble()); + System.out.println("[" + dataName +" DEVIATION] " +Math.sqrt(deviationScore/data.get(dataName).size())); + } + + + + } + + + private void ellsaTest(HashMap<String, ArrayList<Double>> data) { + AMOEBA amoeba = new AMOEBA(null, null); 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, amoebaUI); - amoeba.allowGraphicalScheduler(true); - amoeba.setRenderUpdate(true); + amoeba.allowGraphicalScheduler(false); + amoeba.setRenderUpdate(false); amoeba.data.learningSpeed = learningSpeed; amoeba.data.numberOfPointsForRegression = regressionPoints; amoeba.data.isActiveLearning = setActiveLearning; amoeba.data.isSelfLearning = setSelfLearning; amoeba.getEnvironment().setMappingErrorAllowed(mappingErrorAllowed); + amoeba.setRenderUpdate(false); + + World.minLevel = TRACE_LEVEL.ERROR; + + + + + + for (int i = 0; i < nbCycle; ++i) { + amoeba.cycle(); + } - // 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); - } - }); - amoebaUI.addToolbar(slider); - - studiedSystem.playOneStep(); - amoeba.learn(studiedSystem.getOutput()); - - /* AUTOMATIC */ -// 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) ); -// -// start = System.currentTimeMillis(); -// for (int i = 0; i < nbCycle; ++i) { -// studiedSystem.playOneStep(); -// amoeba.request(studiedSystem.getOutput()); -// } -// end = System.currentTimeMillis(); -// System.out.println("Done in : " + (end - start) ); - - -// /* XP PIERRE */ -// -// String fileName = fileName(new ArrayList<String>(Arrays.asList("GaussiennePierre"))); -// -// FILE Pierrefile = new FILE("Pierre",fileName); -// for (int i = 0; i < nbCycle; ++i) { -// studiedSystem.playOneStep(); -// amoeba.learn(studiedSystem.getOutput()); -// if(amoeba.getHeadAgent().isActiveLearning()) { -// studiedSystem.setActiveLearning(true); -// studiedSystem.setSelfRequest(amoeba.getHeadAgent().getSelfRequest()); -// -// } -// } -// -// for (int i = 0; i < 10; ++i) { -// studiedSystem.playOneStep(); -// System.out.println(studiedSystem.getOutput()); -// System.out.println(amoeba.request(studiedSystem.getOutput())); -// -// -// } -// -// Pierrefile.write(new ArrayList<String>(Arrays.asList("ID contexte","Coeff Cte","Coeff X0","Coeff X1","Min Value","Max Value"))); -// -// for(Context ctxt : amoeba.getContexts()) { -// -// writeMessage(Pierrefile, ctxt.toStringArrayPierre()); -// -// } -// -// -// Pierrefile.close(); + data.get("mappingScore").add(amoeba.getHeadAgent().criticalities.getCriticality("spatialCriticality")); + data.get("randomRequests").add(studiedSystem.getRandomRequestCounts()); + data.get("activeRequests").add(studiedSystem.getActiveRequestCounts()); + data.get("nbAgents").add((double)amoeba.getContexts().size()); } diff --git a/AMOEBAonAMAK/src/experiments/nDimensionsLaunchers/F_N_LauncherUI.java b/AMOEBAonAMAK/src/experiments/nDimensionsLaunchers/F_N_LauncherUI.java new file mode 100644 index 0000000000000000000000000000000000000000..c161535948db343636f1f8dd03eb486dfde5e043 --- /dev/null +++ b/AMOEBAonAMAK/src/experiments/nDimensionsLaunchers/F_N_LauncherUI.java @@ -0,0 +1,196 @@ +package experiments.nDimensionsLaunchers; + +import java.io.File; +import java.io.IOException; +import java.io.Serializable; +import java.util.ArrayList; + +import experiments.FILE; +import fr.irit.smac.amak.Configuration; +import fr.irit.smac.amak.ui.VUIMulti; +import gui.AmoebaMultiUIWindow; +import gui.AmoebaWindow; +import javafx.application.Application; +import javafx.beans.value.ChangeListener; +import javafx.beans.value.ObservableValue; +import javafx.scene.control.Slider; +import javafx.stage.Stage; +import kernel.AMOEBA; +import kernel.StudiedSystem; +import kernel.backup.BackupSystem; +import kernel.backup.IBackupSystem; +import kernel.backup.SaveHelperImpl; + + +/** + * The Class BadContextLauncherEasy. + */ +public class F_N_LauncherUI extends Application implements Serializable { + + + public static final double oracleNoiseRange = 0.5; + public static final double learningSpeed = 0.01; + public static final int regressionPoints = 100; + public static final int dimension = 2; + public static final double spaceSize = 50.0 ; + public static final int nbOfModels = 2 ; + public static final int normType = 2 ; + public static final boolean randomExploration = true; + public static final boolean limitedToSpaceZone = true; + //public static final double mappingErrorAllowed = 0.07; // BIG SQUARE + public static double mappingErrorAllowed = 0.05; // MULTI + public static final double explorationIncrement = 1.0 ; + public static final double explorationWidht = 0.5 ; + public static final boolean setActiveLearning = true ; + public static final boolean setSelfLearning = false ; + public static final int nbCycle = 1000; + + + + public static void main(String[] args) throws IOException { + + + Application.launch(args); + + + } + + + @Override + public void start(Stage arg0) throws Exception { + + + // Set AMAK configuration before creating an AMOEBA + Configuration.multiUI=true; + Configuration.commandLineMode = false; + Configuration.allowedSimultaneousAgentsExecution = 1; + Configuration.waitForGUI = true; + Configuration.plotMilliSecondsUpdate = 20000; + + VUIMulti amoebaVUI = new VUIMulti("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); + File file = new File("resources/twoDimensionsLauncher.xml"); + backupSystem.load(file); + + amoeba.saver = new SaveHelperImpl(amoeba, amoebaUI); + + amoeba.allowGraphicalScheduler(true); + amoeba.setRenderUpdate(true); + amoeba.data.learningSpeed = learningSpeed; + amoeba.data.numberOfPointsForRegression = regressionPoints; + amoeba.data.isActiveLearning = setActiveLearning; + amoeba.data.isSelfLearning = setSelfLearning; + amoeba.getEnvironment().setMappingErrorAllowed(mappingErrorAllowed); + + for (int i = 0; i < nbCycle; ++i) { + amoeba.cycle(); + } + + + // 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); +// } +// }); +// amoebaUI.addToolbar(slider); + + //studiedSystem.playOneStep(); + //amoeba.learn(studiedSystem.getOutput()); + + + + + /* AUTOMATIC */ +// 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) ); +// +// start = System.currentTimeMillis(); +// for (int i = 0; i < nbCycle; ++i) { +// studiedSystem.playOneStep(); +// amoeba.request(studiedSystem.getOutput()); +// } +// end = System.currentTimeMillis(); +// System.out.println("Done in : " + (end - start) ); + + +// /* XP PIERRE */ +// +// String fileName = fileName(new ArrayList<String>(Arrays.asList("GaussiennePierre"))); +// +// FILE Pierrefile = new FILE("Pierre",fileName); +// for (int i = 0; i < nbCycle; ++i) { +// studiedSystem.playOneStep(); +// amoeba.learn(studiedSystem.getOutput()); +// if(amoeba.getHeadAgent().isActiveLearning()) { +// studiedSystem.setActiveLearning(true); +// studiedSystem.setSelfRequest(amoeba.getHeadAgent().getSelfRequest()); +// +// } +// } +// +// for (int i = 0; i < 10; ++i) { +// studiedSystem.playOneStep(); +// System.out.println(studiedSystem.getOutput()); +// System.out.println(amoeba.request(studiedSystem.getOutput())); +// +// +// } +// +// Pierrefile.write(new ArrayList<String>(Arrays.asList("ID contexte","Coeff Cte","Coeff X0","Coeff X1","Min Value","Max Value"))); +// +// for(Context ctxt : amoeba.getContexts()) { +// +// writeMessage(Pierrefile, ctxt.toStringArrayPierre()); +// +// } +// +// +// Pierrefile.close(); + + } + + + + public static String fileName(ArrayList<String> infos) { + String fileName = ""; + + for(String info : infos) { + fileName += info + "_"; + } + + return fileName; + } + + public static void writeMessage(FILE file, ArrayList<String> message) { + + file.initManualMessage(); + + for(String m : message) { + file.addManualMessage(m); + } + + file.sendManualMessage(); + + } + + + + +} diff --git a/AMOEBAonAMAK/src/experiments/nDimensionsLaunchers/F_N_Manager.java b/AMOEBAonAMAK/src/experiments/nDimensionsLaunchers/F_N_Manager.java index b0dba480054498eff35623f4579419d662bdf8e2..4bfe1f86c2d5e9b384d58736ea2eed8c4bb63b46 100644 --- a/AMOEBAonAMAK/src/experiments/nDimensionsLaunchers/F_N_Manager.java +++ b/AMOEBAonAMAK/src/experiments/nDimensionsLaunchers/F_N_Manager.java @@ -51,7 +51,31 @@ public class F_N_Manager implements StudiedSystem{ double explorationIncrement; double explorationMaxVariation; + private Double activeRequestCounts = 0.0; + private Double selfRequestCounts = 0.0; + private Double randomRequestCounts = 0.0; + public Double getActiveRequestCounts() { + return activeRequestCounts; + } + + + + + public Double getSelfRequestCounts() { + return selfRequestCounts; + } + + + + + public Double getRandomRequestCounts() { + return randomRequestCounts; + } + + + + /* Parameters */ private static final double gaussianCoef = 1000; private static final double gaussianVariance = 10; @@ -97,6 +121,28 @@ public class F_N_Manager implements StudiedSystem{ modelCoefs2[dimension] = (int) (Math.random() * 500 - 255); + //printModels(nbOfModels); + + + + randomExploration= rndExploration; + + explorationVector = new double[dimension]; + for(int i = 0 ; i < dimension ; i++) { + explorationVector[i] = Math.random() - 0.5; + } + double vectorNorm = normeP(explorationVector, 2); + for(int i = 0 ; i < dimension ; i++) { + explorationVector[i] /= vectorNorm; + } + + + explorationIncrement = explIncrement; + explorationMaxVariation = explnVariation; + } + + + private void printModels(int nbOfModels) { System.out.println("ZONE 1 DISKS"); for(int nb = 0; nb<nbOfModels; nb++) { System.out.print(modelCoefs[nb][dimension] + "\t"); @@ -123,23 +169,6 @@ public class F_N_Manager implements StudiedSystem{ } System.out.println(""); System.out.println(""); - - - - randomExploration= rndExploration; - - explorationVector = new double[dimension]; - for(int i = 0 ; i < dimension ; i++) { - explorationVector[i] = Math.random() - 0.5; - } - double vectorNorm = normeP(explorationVector, 2); - for(int i = 0 ; i < dimension ; i++) { - explorationVector[i] /= vectorNorm; - } - - - explorationIncrement = explIncrement; - explorationMaxVariation = explnVariation; } @@ -160,12 +189,14 @@ public class F_N_Manager implements StudiedSystem{ for(int i = 0 ; i < dimension ; i++) { x[i] = selfRequest.get("px" + i); } + selfRequestCounts++; } else if(activeLearning) { for(int i = 0 ; i < dimension ; i++) { x[i] = selfRequest.get("px" + i); } + activeRequestCounts ++; } else { @@ -174,9 +205,10 @@ public class F_N_Manager implements StudiedSystem{ for(int i = 0 ; i < dimension ; i++) { x[i] = (generator.nextDouble() - 0.5) * spaceSize * 4; } + randomRequestCounts++; } - System.out.println("[PLAY ONE STEP] " + "selfLearning " + selfLearning + " activeLearning " + activeLearning); + //System.out.println("[PLAY ONE STEP] " + "selfLearning " + selfLearning + " activeLearning " + activeLearning); return null; } @@ -286,13 +318,13 @@ public class F_N_Manager implements StudiedSystem{ /* Disc */ - //return (xRequest[0]*xRequest[0] + xRequest[1]*xRequest[1] < spaceSize*spaceSize ) ? model1(xRequest[0],xRequest[1]) : model2(xRequest[0],xRequest[1]); + return (xRequest[0]*xRequest[0] + xRequest[1]*xRequest[1] < spaceSize*spaceSize ) ? model1(xRequest[0],xRequest[1]) : model2(xRequest[0],xRequest[1]); /* Square */ //return (xRequest[0] > -spaceSize && xRequest[0] < spaceSize && xRequest[0] < spaceSize && xRequest[1] > -spaceSize) ? model1(xRequest[0],xRequest[1]) : model2(xRequest[0],xRequest[1]) ; /* Triangle */ - return (xRequest[0] > xRequest[1]) ? model1(xRequest[0],xRequest[1]) : model2(xRequest[0],xRequest[1]); + //return (xRequest[0] > xRequest[1]) ? model1(xRequest[0],xRequest[1]) : model2(xRequest[0],xRequest[1]); /* Split */ //return ( xRequest[0] <= 0 ) ? model1(xRequest[0],xRequest[1]) : model2(xRequest[0],xRequest[1]); @@ -584,7 +616,7 @@ private double[] subZoneCenter3D(int nb) { activeLearning=false; } //out.put("oracle",result); - System.out.println("[GET OUTPUT] " +out); + //System.out.println("[GET OUTPUT] " +out); return out; } @@ -718,7 +750,7 @@ private double[] subZoneCenter3D(int nb) { public void setSelfRequest(HashMap<Percept, Double> request){ HashMap<String,Double> newRequest = new HashMap<String,Double>(); - System.out.println("[SET SELF REQUEST] " +request); + //System.out.println("[SET SELF REQUEST] " +request); for(Percept pct : request.keySet()) { newRequest.put(pct.getName(), request.get(pct)); diff --git a/AMOEBAonAMAK/src/experiments/reinforcement/WithStudiedSystem/ReinforcementManager2D.java b/AMOEBAonAMAK/src/experiments/reinforcement/WithStudiedSystem/ReinforcementManager2D.java index 56f3dc2dac3ffd382b692002544eafcf8775d770..befc780052a0b7820db460cc83228d873dfced39 100644 --- a/AMOEBAonAMAK/src/experiments/reinforcement/WithStudiedSystem/ReinforcementManager2D.java +++ b/AMOEBAonAMAK/src/experiments/reinforcement/WithStudiedSystem/ReinforcementManager2D.java @@ -523,6 +523,39 @@ public class ReinforcementManager2D implements StudiedSystem{ } + + + + + + @Override + public Double getActiveRequestCounts() { + // TODO Auto-generated method stub + return null; + } + + + + + + + @Override + public Double getSelfRequestCounts() { + // TODO Auto-generated method stub + return null; + } + + + + + + + @Override + public Double getRandomRequestCounts() { + // TODO Auto-generated method stub + return null; + } + diff --git a/AMOEBAonAMAK/src/kernel/StudiedSystem.java b/AMOEBAonAMAK/src/kernel/StudiedSystem.java index 88ec60c66a966bc527bfc14404444a68c96d08fd..d69a549f838e5746da2ec52524d9f9bd63e9c428 100644 --- a/AMOEBAonAMAK/src/kernel/StudiedSystem.java +++ b/AMOEBAonAMAK/src/kernel/StudiedSystem.java @@ -10,6 +10,8 @@ import agents.percept.Percept; * */ public interface StudiedSystem extends Serializable{ + + /** * Tell the StudiedSystem to advance its simulation of one step @@ -47,5 +49,20 @@ public interface StudiedSystem extends Serializable{ public void setControlModels(HashMap<String, AMOEBA> controlModels); public void setControl(boolean value); + + public Double getActiveRequestCounts() ; + + + + + + public Double getSelfRequestCounts() ; + + + + + public Double getRandomRequestCounts() ; + + } diff --git a/AMOEBAonAMAK/src/kernel/World.java b/AMOEBAonAMAK/src/kernel/World.java index c065a4d45e09c4096d630031b43138dc24c51056..01d9346e77fba479ca986ffbcaf0c6f4af729ef7 100644 --- a/AMOEBAonAMAK/src/kernel/World.java +++ b/AMOEBAonAMAK/src/kernel/World.java @@ -34,6 +34,8 @@ public class World extends Environment { + + public static TRACE_LEVEL minLevel = TRACE_LEVEL.INFORM; private AMOEBA amoeba; diff --git a/AMOEBAonAMAK/src/utils/TRACE_LEVEL.java b/AMOEBAonAMAK/src/utils/TRACE_LEVEL.java index bc2da4ad5f98cbdfc9969723dcc707528bba233d..0a1ce9acaae6c2bbd136cf3256c730dd628410b1 100644 --- a/AMOEBAonAMAK/src/utils/TRACE_LEVEL.java +++ b/AMOEBAonAMAK/src/utils/TRACE_LEVEL.java @@ -1,7 +1,7 @@ package utils; public enum TRACE_LEVEL { - ERROR(200), NCS(100), EVENT(50), STATE(40), INFORM(20), DEBUG(0); + ERROR(200), CYCLE(150), NCS(100), EVENT(50), STATE(40), INFORM(20), DEBUG(0); private final int order;