Skip to content
Snippets Groups Projects
Commit 6f6e2f2a authored by BrunoDatoMeneses's avatar BrunoDatoMeneses
Browse files

ENH: void detection

parent e60f62a5
Branches
No related tags found
2 merge requests!3Merge masters,!2Merge dev into develop
...@@ -735,7 +735,7 @@ public class Context extends AmoebaAgent { ...@@ -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)) ); 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 { ...@@ -744,14 +744,14 @@ public class Context extends AmoebaAgent {
return new EndogenousRequest(request, bounds, 7, new ArrayList<Context>(Arrays.asList(this,ctxt)), REQUEST.OVERLAP); 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)) ); getEnvironment().trace(TRACE_LEVEL.INFORM, new ArrayList<String>(Arrays.asList("VOID", ""+this,""+ctxt)) );
HashMap<Percept, Double> request = boundsToRequest(bounds); HashMap<Percept, Double> request = boundsToRequest(bounds);
if(request != null) { 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); return new EndogenousRequest(request, bounds, 5, new ArrayList<Context>(Arrays.asList(this,ctxt)), REQUEST.VOID);
} }
} }
......
...@@ -2387,16 +2387,21 @@ public class Head extends AmoebaAgent { ...@@ -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; boolean test;
for(Context ctxt : activatedNeighborsContexts) { for(Context ctxt : activatedNeighborsContexts) {
test = true; test = true;
for(Percept pct : getAmas().getPercepts()) { for(Percept pct : getAmas().getPercepts()) {
// test = test && ctxt.getRanges().get(pct).contains2(request.get(pct)); // test = test && ctxt.getRanges().get(pct).contains2(request.get(pct));
test = test && ctxt.getRanges().get(pct).contains(request.get(pct), pct.getMappingErrorAllowedMin()); 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) { if(test) {
return false; return false;
} }
......
...@@ -77,7 +77,7 @@ public class Main implements Runnable { ...@@ -77,7 +77,7 @@ public class Main implements Runnable {
Configuration.plotMilliSecondsUpdate = 20000; Configuration.plotMilliSecondsUpdate = 20000;
AMOEBA amoeba = new AMOEBA(); 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); amoeba.setStudiedSystem(studiedSystem);
IBackupSystem backupSystem = new BackupSystem(amoeba); IBackupSystem backupSystem = new BackupSystem(amoeba);
File file = new File("resources/threeDimensionsLauncherUnity.xml"); File file = new File("resources/threeDimensionsLauncherUnity.xml");
......
...@@ -13,6 +13,9 @@ import experiments.F_XY_System; ...@@ -13,6 +13,9 @@ import experiments.F_XY_System;
import experiments.XmlConfigGenerator; import experiments.XmlConfigGenerator;
import fr.irit.smac.amak.Configuration; import fr.irit.smac.amak.Configuration;
import gui.AmoebaWindow; import gui.AmoebaWindow;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.scene.control.Slider;
import kernel.AMOEBA; import kernel.AMOEBA;
import kernel.StudiedSystem; import kernel.StudiedSystem;
import kernel.backup.BackupSystem; import kernel.backup.BackupSystem;
...@@ -27,17 +30,17 @@ import kernel.backup.SaveHelperImpl; ...@@ -27,17 +30,17 @@ import kernel.backup.SaveHelperImpl;
public class F_N_Launcher implements Serializable { 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 double learningSpeed = 0.01;
public static final int regressionPoints = 100; public static final int regressionPoints = 100;
public static final int dimension = 2; public static final int dimension = 2;
public static final double spaceSize = 50.0 ; public static final double spaceSize = 50.0 ;
public static final int nbOfModels = 3 ; public static final int nbOfModels = 3 ;
public static final int normType = 2 ; 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 boolean limitedToSpaceZone = true;
//public static final double mappingErrorAllowed = 0.07; // BIG SQUARE //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 explorationIncrement = 1.0 ;
public static final double explorationWidht = 0.5 ; public static final double explorationWidht = 0.5 ;
...@@ -67,7 +70,7 @@ public class F_N_Launcher implements Serializable { ...@@ -67,7 +70,7 @@ public class F_N_Launcher implements Serializable {
Configuration.plotMilliSecondsUpdate = 20000; Configuration.plotMilliSecondsUpdate = 20000;
AMOEBA amoeba = new AMOEBA(); 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); amoeba.setStudiedSystem(studiedSystem);
IBackupSystem backupSystem = new BackupSystem(amoeba); IBackupSystem backupSystem = new BackupSystem(amoeba);
File file = new File("resources/twoDimensionsLauncher.xml"); File file = new File("resources/twoDimensionsLauncher.xml");
...@@ -80,6 +83,21 @@ public class F_N_Launcher implements Serializable { ...@@ -80,6 +83,21 @@ public class F_N_Launcher implements Serializable {
amoeba.data.numberOfPointsForRegression = regressionPoints; amoeba.data.numberOfPointsForRegression = regressionPoints;
amoeba.getEnvironment().setMappingErrorAllowed(mappingErrorAllowed); 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(); studiedSystem.playOneStep();
amoeba.learn(studiedSystem.getOutput()); amoeba.learn(studiedSystem.getOutput());
......
...@@ -42,6 +42,8 @@ public class F_N_Manager implements StudiedSystem{ ...@@ -42,6 +42,8 @@ public class F_N_Manager implements StudiedSystem{
HashMap<String,Double> selfRequest; HashMap<String,Double> selfRequest;
boolean activeLearning = false; boolean activeLearning = false;
double noiseRange;
/** The world. */ /** The world. */
Random generator; Random generator;
...@@ -54,13 +56,14 @@ public class F_N_Manager implements StudiedSystem{ ...@@ -54,13 +56,14 @@ public class F_N_Manager implements StudiedSystem{
private static final double gaussianVariance = 10; 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; this.spaceSize= size;
dimension = dim; dimension = dim;
numberOfModels = nbOfModels; numberOfModels = nbOfModels;
normType = nrmType; normType = nrmType;
x = new Double[dimension]; x = new Double[dimension];
noiseRange = noise;
spaceLimited = limiteToSpace; spaceLimited = limiteToSpace;
//gaussianCoef = Math.random()*2000; //gaussianCoef = Math.random()*2000;
...@@ -277,7 +280,7 @@ public class F_N_Manager implements StudiedSystem{ ...@@ -277,7 +280,7 @@ public class F_N_Manager implements StudiedSystem{
if(subzone == 1) { if(subzone == 1) {
/* Disques */ /* Disques */
return modelN(xRequest); return modelN(xRequest) ;
}else if (subzone == 2) { }else if (subzone == 2) {
/* Gaussian model */ /* Gaussian model */
return gaussianModel(xRequest, subZoneCenter3D(2), gaussianCoef, gaussianVariance); return gaussianModel(xRequest, subZoneCenter3D(2), gaussianCoef, gaussianVariance);
......
package kernel;
import java.io.Serializable;
public enum SITUATION implements Serializable {
LEARN,
REQUEST,
CONCURENCE,
INCOMPETENCE
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment