diff --git a/AMOEBAonAMAK/src/agents/context/Context.java b/AMOEBAonAMAK/src/agents/context/Context.java index fb9f6cd7621d11556c28e6b77e824eb110ba7bb3..4d063929a2cf0b399d2bb69f65bac1794d772d63 100644 --- a/AMOEBAonAMAK/src/agents/context/Context.java +++ b/AMOEBAonAMAK/src/agents/context/Context.java @@ -735,7 +735,7 @@ public class Context extends AmoebaAgent { } - if (overlapCounts == getAmas().getPercepts().size()) { + if (overlapCounts == getAmas().getPercepts().size() && getAmas().getCycle() > 500) { getEnvironment().trace(TRACE_LEVEL.INFORM, new ArrayList<String>(Arrays.asList(getAmas().getPercepts().size() + "OVERLAPS", ""+this,""+ctxt)) ); @@ -744,14 +744,14 @@ public class Context extends AmoebaAgent { return new EndogenousRequest(request, bounds, 7, new ArrayList<Context>(Arrays.asList(this,ctxt)), REQUEST.OVERLAP); } } - else if(overlapCounts == getAmas().getPercepts().size()-1 && voidDistances.size() == 1) { + else if(overlapCounts == getAmas().getPercepts().size()-1 && voidDistances.size() == 1 && getAmas().getCycle() > 750) { getEnvironment().trace(TRACE_LEVEL.INFORM, new ArrayList<String>(Arrays.asList("VOID", ""+this,""+ctxt)) ); HashMap<Percept, Double> request = boundsToRequest(bounds); if(request != null) { - if(getAmas().getHeadAgent().isVoid(request)) { + if(getAmas().getHeadAgent().isRealVoid(request)) { return new EndogenousRequest(request, bounds, 5, new ArrayList<Context>(Arrays.asList(this,ctxt)), REQUEST.VOID); } } diff --git a/AMOEBAonAMAK/src/agents/head/Head.java b/AMOEBAonAMAK/src/agents/head/Head.java index 67ee372989737495fddef7f94a5b661bda635f0d..5789134305efa694fbcae78e459771194b5086f7 100644 --- a/AMOEBAonAMAK/src/agents/head/Head.java +++ b/AMOEBAonAMAK/src/agents/head/Head.java @@ -2387,16 +2387,21 @@ public class Head extends AmoebaAgent { } } - public boolean isVoid(HashMap<Percept, Double> request) { + public boolean isRealVoid(HashMap<Percept, Double> request) { boolean test; for(Context ctxt : activatedNeighborsContexts) { + + test = true; for(Percept pct : getAmas().getPercepts()) { // test = test && ctxt.getRanges().get(pct).contains2(request.get(pct)); test = test && ctxt.getRanges().get(pct).contains(request.get(pct), pct.getMappingErrorAllowedMin()); } + + getEnvironment().trace(TRACE_LEVEL.DEBUG, new ArrayList<String>(Arrays.asList("IS REAL VOID",ctxt.getName(), "-->", ""+!test))); + if(test) { return false; } diff --git a/AMOEBAonAMAK/src/experiments/UnityLauncher/Main.java b/AMOEBAonAMAK/src/experiments/UnityLauncher/Main.java index 3198f183a3be69539d05feb8f83773625927ce37..099acfb8fc051ddd4d8bdc9e921b199dc79844f7 100644 --- a/AMOEBAonAMAK/src/experiments/UnityLauncher/Main.java +++ b/AMOEBAonAMAK/src/experiments/UnityLauncher/Main.java @@ -77,7 +77,7 @@ public class Main implements Runnable { Configuration.plotMilliSecondsUpdate = 20000; AMOEBA amoeba = new AMOEBA(); - StudiedSystem studiedSystem = new F_N_Manager(spaceSize, dimension, nbOfModels, normType, randomExploration, explorationIncrement,explorationWidht,limitedToSpaceZone); + 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/threeDimensionsLauncherUnity.xml"); diff --git a/AMOEBAonAMAK/src/experiments/nDimensionsLaunchers/F_N_Launcher.java b/AMOEBAonAMAK/src/experiments/nDimensionsLaunchers/F_N_Launcher.java index 603a383547e5e06f82035c77577b7fccd3d5add9..5aa71ae3f027219b4f0a0071d7e5fd31b4966c74 100644 --- a/AMOEBAonAMAK/src/experiments/nDimensionsLaunchers/F_N_Launcher.java +++ b/AMOEBAonAMAK/src/experiments/nDimensionsLaunchers/F_N_Launcher.java @@ -13,6 +13,9 @@ import experiments.F_XY_System; import experiments.XmlConfigGenerator; import fr.irit.smac.amak.Configuration; import gui.AmoebaWindow; +import javafx.beans.value.ChangeListener; +import javafx.beans.value.ObservableValue; +import javafx.scene.control.Slider; import kernel.AMOEBA; import kernel.StudiedSystem; import kernel.backup.BackupSystem; @@ -27,17 +30,17 @@ import kernel.backup.SaveHelperImpl; public class F_N_Launcher implements Serializable { - public static final double oracleNoiseRange = 0.0; + 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 = 3 ; public static final int normType = 2 ; - public static final boolean randomExploration = true; + public static final boolean randomExploration = false; public static final boolean limitedToSpaceZone = true; //public static final double mappingErrorAllowed = 0.07; // BIG SQUARE - public static final double mappingErrorAllowed = 0.03; // MULTI + public static double mappingErrorAllowed = 0.03; // MULTI public static final double explorationIncrement = 1.0 ; public static final double explorationWidht = 0.5 ; @@ -67,7 +70,7 @@ public class F_N_Launcher implements Serializable { Configuration.plotMilliSecondsUpdate = 20000; AMOEBA amoeba = new AMOEBA(); - StudiedSystem studiedSystem = new F_N_Manager(spaceSize, dimension, nbOfModels, normType, randomExploration, explorationIncrement,explorationWidht,limitedToSpaceZone); + 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"); @@ -80,6 +83,21 @@ public class F_N_Launcher implements Serializable { 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()); diff --git a/AMOEBAonAMAK/src/experiments/nDimensionsLaunchers/F_N_Manager.java b/AMOEBAonAMAK/src/experiments/nDimensionsLaunchers/F_N_Manager.java index ce809ad6bd79c88649c68651a4afbcdfd958b450..c04433037688523231e3cac332f93d7329c16bd1 100644 --- a/AMOEBAonAMAK/src/experiments/nDimensionsLaunchers/F_N_Manager.java +++ b/AMOEBAonAMAK/src/experiments/nDimensionsLaunchers/F_N_Manager.java @@ -42,6 +42,8 @@ public class F_N_Manager implements StudiedSystem{ HashMap<String,Double> selfRequest; boolean activeLearning = false; + double noiseRange; + /** The world. */ Random generator; @@ -54,13 +56,14 @@ public class F_N_Manager implements StudiedSystem{ private static final double gaussianVariance = 10; - public F_N_Manager(double size, int dim, int nbOfModels, int nrmType, boolean rndExploration, double explIncrement, double explnVariation, boolean limiteToSpace) { + public F_N_Manager(double size, int dim, int nbOfModels, int nrmType, boolean rndExploration, double explIncrement, double explnVariation, boolean limiteToSpace, double noise) { this.spaceSize= size; dimension = dim; numberOfModels = nbOfModels; normType = nrmType; x = new Double[dimension]; + noiseRange = noise; spaceLimited = limiteToSpace; //gaussianCoef = Math.random()*2000; @@ -277,7 +280,7 @@ public class F_N_Manager implements StudiedSystem{ if(subzone == 1) { /* Disques */ - return modelN(xRequest); + return modelN(xRequest) ; }else if (subzone == 2) { /* Gaussian model */ return gaussianModel(xRequest, subZoneCenter3D(2), gaussianCoef, gaussianVariance); diff --git a/AMOEBAonAMAK/src/kernel/SITUATION.java b/AMOEBAonAMAK/src/kernel/SITUATION.java new file mode 100644 index 0000000000000000000000000000000000000000..46f38af74deb95e6667969036072e08859a55b78 --- /dev/null +++ b/AMOEBAonAMAK/src/kernel/SITUATION.java @@ -0,0 +1,12 @@ +package kernel; + +import java.io.Serializable; + +public enum SITUATION implements Serializable { + + LEARN, + REQUEST, + CONCURENCE, + INCOMPETENCE + +}