diff --git a/AMOEBA3/src/experiments/twoDimensionsLaunchers/F_XY_Launcher.java b/AMOEBA3/src/experiments/twoDimensionsLaunchers/F_XY_Launcher.java
index 33f1cdd3d62a0d3bec579a3af022322abb57d7fe..3ad417d9047d5f288dfcfabd0b6e156b1a3faac2 100644
--- a/AMOEBA3/src/experiments/twoDimensionsLaunchers/F_XY_Launcher.java
+++ b/AMOEBA3/src/experiments/twoDimensionsLaunchers/F_XY_Launcher.java
@@ -64,6 +64,7 @@ public class F_XY_Launcher implements Serializable {
 			}
 			else if(amoeba.getPlayOneStep()) {
 				
+				amoeba.setPlayOneStep(false);
 				/*Random samples of the studied system */
 				f_XY_Manager.playOneStep(0);
 				
@@ -72,7 +73,7 @@ public class F_XY_Launcher implements Serializable {
 				
 				i++;
 				
-				amoeba.setPlayOneStep(false);
+				
 			}
 			
 		}
diff --git a/AMOEBA3/src/mas/agents/AbstractPair.java b/AMOEBA3/src/mas/agents/AbstractPair.java
index 2f83817773f60b46900c13be476c0a83fee27731..05ef1a33606c82693cf29a8abeb943b843aa1ff4 100644
--- a/AMOEBA3/src/mas/agents/AbstractPair.java
+++ b/AMOEBA3/src/mas/agents/AbstractPair.java
@@ -2,8 +2,8 @@ package mas.agents;
 
 public class AbstractPair<A,B> {
 
-	public final A a;
-    public final B b;
+	public  A a;
+    public  B b;
 
     public AbstractPair(A a, B b) {
         this.a = a;
@@ -17,6 +17,14 @@ public class AbstractPair<A,B> {
     public B getB() {
     	return b;
     }
+    
+    public void setA(A a) {
+    	 this.a = a;
+    }
+    
+    public void setB(B b) {
+   	 this.b = b;
+   }
 }
 
 
diff --git a/AMOEBA3/src/mas/agents/context/Context.java b/AMOEBA3/src/mas/agents/context/Context.java
index b88d8d0828196cd3fc3fcadd9bdb58b9f197f645..a4bf7bbb2afda25b2e7137cb547f2eea2db96826 100644
--- a/AMOEBA3/src/mas/agents/context/Context.java
+++ b/AMOEBA3/src/mas/agents/context/Context.java
@@ -16,6 +16,7 @@ import org.apache.commons.math3.util.Pair;
 import mas.kernel.Config;
 import mas.kernel.World;
 import mas.ncs.NCS;
+import mas.agents.AbstractPair;
 import mas.agents.Agent;
 import mas.agents.percept.Percept;
 import mas.agents.head.Head;
@@ -62,6 +63,10 @@ public class Context extends AbstractContext implements Serializable,Cloneable{
 	private HashMap<Percept, Boolean> perceptValidities = new HashMap<Percept, Boolean>();
 	private HashMap<Percept, Boolean> perceptNeighborhoodValidities = new HashMap<Percept, Boolean>();
 	
+	private ArrayList<Percept> nonValidPercepts = new ArrayList<Percept>();
+	private ArrayList<Percept> nonValidNeightborPercepts = new ArrayList<Percept>();
+	
+	
 	public HashMap<Context, HashMap<Percept, Boolean>> contextOverlapsByPercept = new HashMap<Context, HashMap<Percept, Boolean>>();
 	public HashMap<Context, HashMap<Percept, Boolean>> contextOverlapsByPerceptSave = new HashMap<Context, HashMap<Percept, Boolean>>();
 	public HashMap<Context,String> overlaps = new HashMap<Context,String>();
@@ -93,9 +98,9 @@ public class Context extends AbstractContext implements Serializable,Cloneable{
 	public Context(World world, Head head, Context bestNearestContext) {
 		super(world);
 		buildContext(head, bestNearestContext);
-		System.out.println("=======================================================================" +this.getName() + " <-- " + bestNearestContext.getName());
-		System.out.println(this.toStringFull());
-		System.out.println(bestNearestContext.toStringFull());
+		//System.out.println("=======================================================================" +this.getName() + " <-- " + bestNearestContext.getName());
+		//System.out.println(this.toStringFull());
+		//System.out.println(bestNearestContext.toStringFull());
 	}
 	
 	private void buildContext (Head headAgent, Context bestNearestContext) {
@@ -115,18 +120,15 @@ public class Context extends AbstractContext implements Serializable,Cloneable{
 			ctxt.addContext(this);
 		}
 		
+		
+		
 		for (Percept v : var) {
 			Range r;
-			Double maxRadius = world.getScheduler().getHeadAgent().getMaxRadiusForContextCreation(v);
-			Double length;
-			if(maxRadius!= null) {
-				length = 2*maxRadius;
-			}
-			else {
-				length = Math.abs(v.getMinMaxDistance()) * 0.2;
-			}
 			
-			r = new Range(this, v.getValue() - length, v.getValue() + length, 0, true, true, v, world);
+			
+			Double radius = getMaxRadiusForContextCreation(v);
+			
+			r = new Range(this, v.getValue() - radius, v.getValue() + radius, 0, true, true, v, world);
 			ranges.put(v, r);
 			ranges.get(v).setValue(v.getValue());
 			sendExpressMessage(null, MessageType.REGISTER, v);
@@ -205,6 +207,17 @@ public class Context extends AbstractContext implements Serializable,Cloneable{
 		
 		overlaps =  new HashMap<Context,String>();
 	}
+	
+	
+	
+	Double getMaxRadiusForContextCreation(Percept pct) {
+		Double maxRadius = world.getScheduler().getHeadAgent().getMaxRadiusForContextCreation(pct);
+		//System.out.println("MAX RADIUS FOR CONTEXT CREATION "  + pct.getName() + " " + maxRadius + " / " + (maxRadius/pct.getRadiusContextForCreation()));
+		return maxRadius;
+		
+		//return Math.abs(pct.getMinMaxDistance()) * world.contextCreationPercentage;
+	}
+	
 	/**
 	 * Builds the context.
 	 *
@@ -228,18 +241,65 @@ public class Context extends AbstractContext implements Serializable,Cloneable{
 			ctxt.addContext(this);
 		}
 		
+		HashMap<Percept,Double> maxRadiusesForContextCreation = new HashMap<Percept,Double>();
+		AbstractPair<Percept, Double> betterRadius = new AbstractPair<Percept, Double>(null,Double.NEGATIVE_INFINITY);
+		AbstractPair<Percept, Double> worstRadius = new AbstractPair<Percept, Double>(null,Double.POSITIVE_INFINITY);
+		
+		for(Percept pct : var) {
+			double maxRadius = getMaxRadiusForContextCreation(pct);
+			double maxRadiusRatio = maxRadius / pct.getRadiusContextForCreation();
+			maxRadiusesForContextCreation.put(pct, maxRadiusRatio);
+			
+			if(maxRadiusRatio > betterRadius.getB()) {
+				betterRadius.setA(pct);
+				betterRadius.setB(maxRadiusRatio);
+			}
+			if(maxRadiusRatio < worstRadius.getB()) {
+				worstRadius.setA(pct);
+				worstRadius.setB(maxRadiusRatio);
+			}
+		}
+		
+		
+		
 		for (Percept v : var) {
 			Range r;
-
-			Double maxRadius = world.getScheduler().getHeadAgent().getMaxRadiusForContextCreation(v);
-			Double length;
-			if(maxRadius!= null) {
-				length = 2*maxRadius;
+			Double radius;
+			
+			
+			if(world.getScheduler().getHeadAgent().getActivatedNeighborsContexts().size() == 1) {
+				if(betterRadius.getB() < 1.0 ) {
+					if(betterRadius.getA() == v){
+						radius = maxRadiusesForContextCreation.get(v)*v.getRadiusContextForCreation();
+					}
+					else {
+						radius = v.getRadiusContextForCreation();
+					}
+				}
+				else {
+					radius = maxRadiusesForContextCreation.get(v)*v.getRadiusContextForCreation();
+				}
 			}
 			else {
-				length = Math.abs(v.getMinMaxDistance()) * 0.2;
+				if(worstRadius.getA() == v){
+					radius = maxRadiusesForContextCreation.get(v)*v.getRadiusContextForCreation();
+				}
+				else {
+					radius = v.getRadiusContextForCreation();
+				}
 			}
-			r = new Range(this, v.getValue() - length, v.getValue() + length, 0, true, true, v, world);
+
+
+			//System.out.println("MAX RADIUS FOR CONTEXT CREATION AFTER TEST"  + v.getName() + " " + radius + " / " + (radius/v.getRadiusContextForCreation()));
+
+			AbstractPair<Double, Double> radiuses = world.getScheduler().getHeadAgent().getMaxRadiusesForContextCreation(v);
+			
+			System.out.println("MAX RADIUS FOR CONTEXT CREATION "  + v.getName() + " < " + radiuses.getA() + " , "  + radiuses.getB() + " > / < " + (radiuses.getA()/v.getRadiusContextForCreation()) + " , " + (radiuses.getB()/v.getRadiusContextForCreation()) + " >");
+			
+			r = new Range(this, v.getValue() - radiuses.getA(), v.getValue() + radiuses.getB(), 0, true, true, v, world);
+			
+			
+			//r = new Range(this, v.getValue() - radius, v.getValue() + radius, 0, true, true, v, world);
 			ranges.put(v, r);
 			ranges.get(v).setValue(v.getValue());
 			sendExpressMessage(null, MessageType.REGISTER, v);
@@ -248,6 +308,10 @@ public class Context extends AbstractContext implements Serializable,Cloneable{
 			v.addContextProjection(this);
 			v.addContextSortedRanges(this);
 		}
+		
+		displayRanges();
+		expand();
+		
 		localModel = this.world.buildLocalModel(this);
 		firstPoint.setProposition(this.headAgent.getOracleValue());
 		experiments.add(firstPoint);
@@ -281,6 +345,180 @@ public class Context extends AbstractContext implements Serializable,Cloneable{
 		}
 		
 		overlaps =  new HashMap<Context,String>();
+		
+		System.out.println("NEW CONTEXT " + this.getName());
+		displayRanges();
+		
+	}
+	
+	public void displayRanges() {
+		for(Percept pct : ranges.keySet()) {
+			System.out.println(pct.getName() + " [ " + ranges.get(pct).getStart() + " , " + ranges.get(pct).getEnd() + " ]");
+		}
+	}
+	
+	public ArrayList<Context> getContextsOnAPerceptDirectionFromContextsNeighbors(ArrayList<Context> contextNeighbors, Percept pctDirection){
+		ArrayList<Context> contexts = new ArrayList<Context>();
+		
+		boolean test = true;
+		for(Context ctxtNeigbor: contextNeighbors) {
+			for(Percept pct : ranges.keySet()) {
+				if(pct!=pctDirection) {
+					test = test && ( this.ranges.get(pct).distance(ctxtNeigbor.getRanges().get(pct))<0);
+				}
+				
+				
+			}
+			if(test) {
+				contexts.add(ctxtNeigbor);
+			}
+		}
+		
+		
+		return contexts;
+	}
+	
+	public ArrayList<Context> getContextsOnAPerceptDirectionFromContextsNeighbors(ArrayList<Context> contextNeighbors, Percept pctDirection, SpatialContext expandingContext){
+		ArrayList<Context> contexts = new ArrayList<Context>();
+		
+		boolean test = true;
+		for(Context ctxtNeigbor: contextNeighbors) {
+			for(Percept pct : ranges.keySet()) {
+				if(pct!=pctDirection) {
+					System.out.println("DISTANCE " + ctxtNeigbor.getName()+ " " + pct.getName()+ " " +  expandingContext.distance(pct, ctxtNeigbor.getRanges().get(pct)) + " " + ( expandingContext.distance(pct, ctxtNeigbor.getRanges().get(pct))<0)) ;
+					test = test && ( expandingContext.distance(pct, ctxtNeigbor.getRanges().get(pct))<-0.0001);
+				}
+				
+				
+			}
+			if(test) {
+				contexts.add(ctxtNeigbor);
+			}
+			
+			test = true;
+		}
+		
+		
+		return contexts;
+	}
+	
+	public void expand() {
+		
+		ArrayList<Context> neighborsOnOneDirection;
+		HashMap<Percept,SpatialContext>  alternativeContexts = new HashMap<Percept,SpatialContext>();
+		double maxVolume = this.getVolume();
+		double currentVolume;
+		SpatialContext maxVolumeSpatialContext = null;
+
+		for(Percept fixedPct: ranges.keySet()) {
+			alternativeContexts.put(fixedPct, new SpatialContext(this));
+
+			System.out.println("FIXED PERCEPT :"  + fixedPct.getName());
+			
+			for(Percept pctDirectionForExpanding: ranges.keySet()) {
+
+				
+				if(pctDirectionForExpanding != fixedPct) {
+					
+					System.out.println("DIRECTION PERCEPT :"  + pctDirectionForExpanding.getName());
+					
+					System.out.println("ALL NEIGHBORS");
+					for(Context ct : world.getScheduler().getHeadAgent().getActivatedNeighborsContexts()) {
+						System.out.println(ct.getName());
+					}
+					
+					neighborsOnOneDirection = getContextsOnAPerceptDirectionFromContextsNeighbors(world.getScheduler().getHeadAgent().getActivatedNeighborsContexts(), pctDirectionForExpanding, alternativeContexts.get(fixedPct));
+					
+					
+					System.out.println("NEIGHBORS THROUGH " + pctDirectionForExpanding.getName());
+					for(Context ct : neighborsOnOneDirection) {
+						System.out.println(ct.getName());
+					}
+					
+					
+					AbstractPair<Double,Double> expandingRadiuses = getMaxExpansionsForContextExpansionAfterCreation(neighborsOnOneDirection, pctDirectionForExpanding);
+					System.out.println("START : " + expandingRadiuses.getA() + " END " + expandingRadiuses.getB());
+					alternativeContexts.get(fixedPct).expandEnd(pctDirectionForExpanding, expandingRadiuses.getB());
+					alternativeContexts.get(fixedPct).expandStart(pctDirectionForExpanding, expandingRadiuses.getA());
+				}
+			}
+			
+			currentVolume = alternativeContexts.get(fixedPct).getVolume();
+			if(currentVolume>maxVolume) {
+				maxVolume = currentVolume;
+				maxVolumeSpatialContext = alternativeContexts.get(fixedPct);
+			}
+			
+		}
+		if(maxVolumeSpatialContext != null) {
+			matchSpatialContextRanges(maxVolumeSpatialContext);
+		}
+		
+		
+	}
+	
+	public void matchSpatialContextRanges(SpatialContext biggerContextForCreation) {
+		
+		for(Percept pct : ranges.keySet()) {
+			
+			double startExpansion = Math.abs(ranges.get(pct).getStart()-biggerContextForCreation.getStart(pct));
+			double endExpansion = Math.abs(ranges.get(pct).getEnd()-biggerContextForCreation.getEnd(pct));
+			System.out.println("EXPANSION "  + pct.getName() +" < " + startExpansion + " , "  + endExpansion + " > / < " +pct.getMin() + " , " +pct.getMax() + " >");
+			
+			ranges.get(pct).setStart(biggerContextForCreation.getStart(pct));
+			ranges.get(pct).setEnd(biggerContextForCreation.getEnd(pct));
+			
+		}
+		
+	}
+	
+	public AbstractPair<Double,Double> getMaxExpansionsForContextExpansionAfterCreation(ArrayList<Context> contextNeighborsInOneDirection, Percept pct) {
+		//AbstractPair<Double,Double> maxRadiuses = new AbstractPair<Double,Double>(pct.getRadiusContextForCreation(),pct.getRadiusContextForCreation());
+		AbstractPair<Double,Double> maxExpansions = new AbstractPair<Double,Double>(Math.abs(pct.getMin()- ranges.get(pct).getStart()),Math.abs(pct.getMax()-ranges.get(pct).getEnd()));
+
+		//System.out.println("EXPANSION MIN MAX "  + pct.getName() +" " + pct.getValue() + " < " + pct.getMin() + " , "  + pct.getMax() + " > / < " + Math.abs(pct.getMin()- pct.getValue()) + " , " + Math.abs(pct.getMax()-pct.getValue()) + " >");
+		
+		double currentStartExpansion;
+		double currentEndExpansion;
+		
+			
+		//for(Context ctxt:partialNeighborContexts.get(pct)) {
+		for(Context ctxt: contextNeighborsInOneDirection) {			
+			
+			System.out.println("DISTANCE " + pct.getName() + " " + ctxt.getRanges().get(pct).centerDistance(pct.getValue()));
+			if(ctxt.getRanges().get(pct).centerDistance(pct.getValue()) < 0) {
+				// End radius
+				
+				currentEndExpansion = ctxt.getRanges().get(pct).distance(ranges.get(pct));
+				System.out.println("DISTANCE 2 " + pct.getName() + " " + ctxt.getRanges().get(pct).distance(ranges.get(pct)));
+				//System.out.println(ctxt.getName() + " " + pct.getName() + " " + currentRadius + " " + maxRadius);
+				if(currentEndExpansion < maxExpansions.getB() && currentEndExpansion >= -0.00001 ) {
+					if(Math.abs(currentEndExpansion)<0.0001) {
+						currentEndExpansion = 0.0;
+					}
+					maxExpansions.setB(currentEndExpansion); 
+				}
+			}
+			
+			if(ctxt.getRanges().get(pct).centerDistance(pct.getValue()) > 0) {
+				// Start radius
+				currentStartExpansion = ctxt.getRanges().get(pct).distance(ranges.get(pct));
+				//System.out.println(ctxt.getName() + " " + pct.getName() + " " + currentRadius + " " + maxRadius);
+				if(currentStartExpansion < maxExpansions.getA() && currentStartExpansion >= -0.00001 ) {
+					if(Math.abs(currentStartExpansion)<0.0001) {
+						currentEndExpansion = 0.0;
+					}
+					maxExpansions.setA(currentStartExpansion); 
+				}
+			}
+
+			
+			
+		}
+		
+		return maxExpansions;
+		
+		
 	}
 	
 	/**
@@ -385,7 +623,7 @@ public class Context extends AbstractContext implements Serializable,Cloneable{
 				activations--;
 
 				if (activations < 0)  {
-					//system.out.println("Activation lower than 0 : exit");
+					////System.out.println("Activation lower than 0 : exit");
 					System.exit(-2);
 				}
 				if (valid) {
@@ -417,20 +655,42 @@ public class Context extends AbstractContext implements Serializable,Cloneable{
 		
 		super.play();
 		
-		if(computeValidityByPercepts()) {
-			if(world.getScheduler().getTick() == 119) {
-				//system.out.println("CONTEXT NEW VALIDITY :" + this.getName());
-			}
+		System.out.println("}}}}}}}}}}}}}}}}}}}}}}}}}}} NON VALIDITY");
+		for(Percept pct : nonValidPercepts) {
+			System.out.println(pct.getName());
+		}
+		
+		if(nonValidPercepts.size() == 0) {
+
 			sendMessage(getActionProposal(), MessageType.PROPOSAL, headAgent);
 			Config.print("Message envoy�", 4);
-			////system.out.println("Valid context by Percepts "+this.name);
+			//////System.out.println("Valid context by Percepts "+this.name);
+		}
+		else if(nonValidPercepts.size() == 1){
+			world.getScheduler().getHeadAgent().addPartiallyActivatedContext(nonValidPercepts.get(0), this);
 		}
 		
-		if(computeNeighborhoodValidityByPercepts()) {
+		
+		if(nonValidNeightborPercepts.size() == 0) {
+			
+			//System.out.println("VALID NEIGHBOR : " + this.getName());
+
+			System.out.println(world.getScheduler().getTick() + " " + this.getName() + " " + "VALID");
 			world.getScheduler().getHeadAgent().addRequestNeighbor(this);
 		}
+		else if(nonValidNeightborPercepts.size() == 1){
+			world.getScheduler().getHeadAgent().addPartialRequestNeighborContext(nonValidNeightborPercepts.get(0),this);
+			System.out.println(world.getScheduler().getTick() + " " + this.getName() + " " + "PARTIALLY VALID" + " " + nonValidNeightborPercepts.get(0).getName());
+		}
 		
 		
+
+		
+
+		
+
+		//assert computeValidityByPercepts() == (nonValidPercepts.size() == 0) : "Erreur Valid Non Valid";
+		
 		
 		this.activations = 0;
 		this.valid = false;
@@ -444,6 +704,11 @@ public class Context extends AbstractContext implements Serializable,Cloneable{
 			perceptNeighborhoodValidities.put(percept, false);
 		}
 		
+		
+		
+		nonValidPercepts.clear();
+		//nonValidNeightborPercepts.clear();
+		
 		//ENDO
 //		for (Percept v : ranges.keySet()) {
 //			if (ranges.get(v).isTooSmall()){
@@ -466,14 +731,47 @@ public class Context extends AbstractContext implements Serializable,Cloneable{
 		Random rand = new Random();
 		
 //		if( this.getConfidence()  <= 0 && tickCreation + 125 < world.getScheduler().getTick() ) {
-//			System.out.println(world.getScheduler().getTick() +" " + this.getName()+ " " + "solveNCS_Uselessness");
+//			//System.out.println(world.getScheduler().getTick() +" " + this.getName()+ " " + "solveNCS_Uselessness");
 //			world.raiseNCS(NCS.CONTEXT_USELESSNESS);
 //			this.die();
 //		}
 		
 		
+	}
+	
+	public void updateRequestNeighborState(){ //faire le update dans le head attention partial et full
+		
+		if(nonValidNeightborPercepts.size() == 0) {
+			
+			//System.out.println("VALID NEIGHBOR : " + this.getName());
+
+			
+			world.getScheduler().getHeadAgent().addRequestNeighbor(this);
+		}
+		else {
+			world.getScheduler().getHeadAgent().removeRequestNeighbor(this);
+		}
+		
+	}
+	
+	public void updateActivatedContexts(){ //faire le update dans le head attention partial et full
+		
+		if(nonValidPercepts.size() == 0) {
+			
+			//System.out.println("VALID NEIGHBOR : " + this.getName());
+
+			
+			world.getScheduler().getHeadAgent().addActivatedContext(this);
+		}
+		else {
+			world.getScheduler().getHeadAgent().removeActivatedContext(this);
+		}
+		
 	}
 
+	public void clearNonValidPerceptNeighbors() {
+		nonValidNeightborPercepts.clear();
+	}
 
 	private void NCSDetections() {
 		
@@ -483,13 +781,13 @@ public class Context extends AbstractContext implements Serializable,Cloneable{
 	}
 	
 	public void displayOtherContextsDistances() {
-		//system.out.println("Other Context Distances : " + this.getName());
+		////System.out.println("Other Context Distances : " + this.getName());
 		for(Context ctxt :otherContextsDistancesByPercept.keySet()) {
 			//system.out.print(ctxt.getName() + " ");
 			for(Percept pct : otherContextsDistancesByPercept.get(ctxt).keySet()) {
 				//system.out.print(pct.getName() + " " + otherContextsDistancesByPercept.get(ctxt).get(pct).getFirst() + " " + otherContextsDistancesByPercept.get(ctxt).get(pct).getSecond() + " ");
 			}
-			//system.out.println(" ");
+			////System.out.println(" ");
 		}
 	}
 	
@@ -522,7 +820,7 @@ public class Context extends AbstractContext implements Serializable,Cloneable{
 	 * @param head the head
 	 */
 	public void solveNCS_IncompetentHead(Head head) {
-		System.out.println(world.getScheduler().getTick() +" " + this.getName()+ " " +"solveNCS_IncompetentHead");
+		//System.out.println(world.getScheduler().getTick() +" " + this.getName()+ " " +"solveNCS_IncompetentHead");
 		world.raiseNCS(NCS.HEAD_INCOMPETENT);
 		growRanges();
 	}
@@ -533,7 +831,7 @@ public class Context extends AbstractContext implements Serializable,Cloneable{
 	 * @param head the head
 	 */
 	public void solveNCS_Concurrence(Head head) {
-		System.out.println(world.getScheduler().getTick() +" " + this.getName()+ " " + "solveNCS_Concurrence");
+		//System.out.println(world.getScheduler().getTick() +" " + this.getName()+ " " + "solveNCS_Concurrence");
 		world.raiseNCS(NCS.CONTEXT_CONCURRENCE);
 		this.shrinkRangesToJoinBorders( head.getBestContext());
 	}
@@ -544,7 +842,7 @@ public class Context extends AbstractContext implements Serializable,Cloneable{
 	 * @param head the head
 	 */
 	private void solveNCS_Uselessness(Head head) {
-		System.out.println(world.getScheduler().getTick() +" " + this.getName()+ " " + "solveNCS_Uselessness");
+		//System.out.println(world.getScheduler().getTick() +" " + this.getName()+ " " + "solveNCS_Uselessness");
 		world.raiseNCS(NCS.CONTEXT_USELESSNESS);
 		this.die();
 	}
@@ -555,7 +853,7 @@ public class Context extends AbstractContext implements Serializable,Cloneable{
 	 * @param head the head
 	 */
 	private void solveNCS_ConflictInexact(Head head) {
-		System.out.println(world.getScheduler().getTick() +" " + this.getName()+ " " + "solveNCS_ConflictInexact");
+		//System.out.println(world.getScheduler().getTick() +" " + this.getName()+ " " + "solveNCS_ConflictInexact");
 		world.raiseNCS(NCS.CONTEXT_CONFLICT_INEXACT);
 		if(true) {
 			confidence--;
@@ -571,7 +869,7 @@ public class Context extends AbstractContext implements Serializable,Cloneable{
 	 */
 	private void solveNCS_Conflict(Head head) {
 
-		System.out.println(world.getScheduler().getTick() +" " + this.getName()+ " " + "solveNCS_Conflict");
+		//System.out.println(world.getScheduler().getTick() +" " + this.getName()+ " " + "solveNCS_Conflict");
 		world.raiseNCS(NCS.CONTEXT_CONFLICT_FALSE);		
 		
 		if (head.getNewContext() == this) {
@@ -589,19 +887,19 @@ public class Context extends AbstractContext implements Serializable,Cloneable{
 			//Percept p = getPerceptWithLargerImpactOnAVT(percepts);
 			//Percept p = getPerceptWithLesserImpactOnAVT(percepts);
 			Percept p;
-			//system.out.println((head.isContextFromPropositionWasSelected() && head.getCriticity() <= head.getErrorAllowed()) + "head.isContextFromPropositionWasSelected() && head.getCriticity() <= head.getErrorAllowed()");
+			////System.out.println((head.isContextFromPropositionWasSelected() && head.getCriticity() <= head.getErrorAllowed()) + "head.isContextFromPropositionWasSelected() && head.getCriticity() <= head.getErrorAllowed()");
 			if (head.isContextFromPropositionWasSelected() && head.getCriticity() <= head.getErrorAllowed()){
 				
 					p = this.getPerceptWithLesserImpactOnVolumeNotIncludedIn2(percepts, head.getBestContext());
 
 				
-				//system.out.println((p == null) + "p == null");
+				////System.out.println((p == null) + "p == null");
 					
 				if (p == null) {
-					System.out.println(world.getScheduler().getTick() +" " + this.getName()+ " " + "solveNCS_ConflictAndDie");
+					//System.out.println(world.getScheduler().getTick() +" " + this.getName()+ " " + "solveNCS_ConflictAndDie");
 					this.die();
 				}else {	
-					//system.out.println(p.getName());
+					////System.out.println(p.getName());
 					//ranges.get(p).matchBorderWith(head.getBestContext());
 					ranges.get(p).adaptTowardsBorder(head.getBestContext());
 				}
@@ -645,7 +943,7 @@ public class Context extends AbstractContext implements Serializable,Cloneable{
 		double volumeLost = Double.MAX_VALUE;
 		double vol = 1.0;
 		
-		System.out.println("PerceptWithLesserImpactOnVolumeNotIncludedIn ...");
+		//System.out.println("PerceptWithLesserImpactOnVolumeNotIncludedIn ...");
 		for (Percept percept : containingRanges) {
 			
 
@@ -654,28 +952,28 @@ public class Context extends AbstractContext implements Serializable,Cloneable{
 				
 				if (!(otherRanges.getStart() <= ranges.get(percept).getStart() &&   ranges.get(percept).getEnd() <= otherRanges.getEnd())) {
 					
-					System.out.println(percept.getName());
+					//System.out.println(percept.getName());
 					
 					
 					if (ranges.get(percept).getNearestLimit(percept.getValue()) == false) {
-						System.out.println("end simu : " + ranges.get(percept).simulateNegativeAVTFeedbackEnd(percept.getValue()) + " start : " + ranges.get(percept).getStart());
+						//System.out.println("end simu : " + ranges.get(percept).simulateNegativeAVTFeedbackEnd(percept.getValue()) + " start : " + ranges.get(percept).getStart());
 						vol = ranges.get(percept).simulateNegativeAVTFeedbackEnd(percept.getValue()) - ranges.get(percept).getStart();
 					} else {
-						System.out.println("end : " + ranges.get(percept).getEnd() + " start simu : " + ranges.get(percept).simulateNegativeAVTFeedbackStart(percept.getValue()));
+						//System.out.println("end : " + ranges.get(percept).getEnd() + " start simu : " + ranges.get(percept).simulateNegativeAVTFeedbackStart(percept.getValue()));
 						vol = ranges.get(percept).getEnd() - ranges.get(percept).simulateNegativeAVTFeedbackStart(percept.getValue());
 					}
 					
 					
-					System.out.println("Vol1 : " + vol);
+					//System.out.println("Vol1 : " + vol);
 					
 					for (Percept p2 : ranges.keySet()) {
 						if (!ranges.get(p2).isPerceptEnum() && p2 != percept) {
-							System.out.println(p2.getName());
+							//System.out.println(p2.getName());
 							vol *= ranges.get(p2).getLenght();
-							System.out.println(p2.getName() + " " + ranges.get(p2).getLenght() + " " + getName());
+							//System.out.println(p2.getName() + " " + ranges.get(p2).getLenght() + " " + getName());
 						}
 					}
-					System.out.println("Vol2 : " + vol);
+					//System.out.println("Vol2 : " + vol);
 					
 					
 					if (vol < volumeLost) {
@@ -684,7 +982,7 @@ public class Context extends AbstractContext implements Serializable,Cloneable{
 					}
 					
 					
-					System.out.println("Vol lost : " + volumeLost + "percept " + p.getName());
+					//System.out.println("Vol lost : " + volumeLost + "percept " + p.getName());
 					
 				}
 				
@@ -703,7 +1001,7 @@ public class Context extends AbstractContext implements Serializable,Cloneable{
 		double volumeLost = Double.MAX_VALUE;
 		double vol = 1.0;
 		
-		//system.out.println("LESSER ...");
+		////System.out.println("LESSER ...");
 		for (Percept percept : containingRanges) {
 			
 
@@ -712,29 +1010,29 @@ public class Context extends AbstractContext implements Serializable,Cloneable{
 				
 				if (!(otherRanges.getStart() <= ranges.get(percept).getStart() &&   ranges.get(percept).getEnd() <= otherRanges.getEnd())) {
 					
-					//system.out.println(percept.getName());
+					////System.out.println(percept.getName());
 					
 					
 					vol = Math.abs( Math.abs(otherRanges.getCenter() - ranges.get(percept).getCenter()) - otherRanges.getRadius() - ranges.get(percept).getRadius());
 //					if (ranges.get(percept).getNearestLimit(percept.getValue()) == false) {
-//						//system.out.println("end simu : " + ranges.get(percept).simulateNegativeAVTFeedbackMax(percept.getValue()) + " start : " + ranges.get(percept).getStart());
+//						////System.out.println("end simu : " + ranges.get(percept).simulateNegativeAVTFeedbackMax(percept.getValue()) + " start : " + ranges.get(percept).getStart());
 //						vol = percept.getValue() - ranges.get(percept).getStart();
 //					} else {
-//						//system.out.println("end : " + ranges.get(percept).getEnd() + " start simu : " + ranges.get(percept).simulateNegativeAVTFeedbackMin(percept.getValue()));
+//						////System.out.println("end : " + ranges.get(percept).getEnd() + " start simu : " + ranges.get(percept).simulateNegativeAVTFeedbackMin(percept.getValue()));
 //						vol = ranges.get(percept).getEnd() - percept.getValue();
 //					}
 					
 					
-					//system.out.println("Vol1 : " + vol);
+					////System.out.println("Vol1 : " + vol);
 					
 					for (Percept p2 : ranges.keySet()) {
 						if (!ranges.get(p2).isPerceptEnum() && p2 != percept) {
-							//system.out.println(p2.getName());
+							////System.out.println(p2.getName());
 							vol *= ranges.get(p2).getLenght();
-							//system.out.println(p2.getName() + " " + ranges.get(p2).getLenght() + " " + getName());
+							////System.out.println(p2.getName() + " " + ranges.get(p2).getLenght() + " " + getName());
 						}
 					}
-					//system.out.println("Vol2 : " + vol);
+					////System.out.println("Vol2 : " + vol);
 					
 					
 					if (vol < volumeLost) {
@@ -743,7 +1041,7 @@ public class Context extends AbstractContext implements Serializable,Cloneable{
 					}
 					
 					
-					//system.out.println("Vol lost : " + volumeLost);
+					////System.out.println("Vol lost : " + volumeLost);
 					
 				}
 				
@@ -762,7 +1060,7 @@ public class Context extends AbstractContext implements Serializable,Cloneable{
 		double volumeLost3 = Double.MAX_VALUE;
 		double vol3 = 1.0;
 		
-		System.out.println("LESSER ...");
+		//System.out.println("LESSER ...");
 		for (Percept percept : containingRanges) {
 			
 
@@ -771,7 +1069,7 @@ public class Context extends AbstractContext implements Serializable,Cloneable{
 				
 				if (!(otherRanges.getStart() <= ranges.get(percept).getStart() &&   ranges.get(percept).getEnd() <= otherRanges.getEnd())) {
 					
-					System.out.println(percept.getName());
+					//System.out.println(percept.getName());
 					
 					
 					if(percept.contextOrder(this, otherContext)) {
@@ -780,17 +1078,17 @@ public class Context extends AbstractContext implements Serializable,Cloneable{
 					else if(percept.contextOrder(otherContext, this)) {
 						vol3 = Math.abs(percept.getEndRangeProjection(otherContext) - percept.getStartRangeProjection(this));
 					}
-					System.out.println("vol3 : " + vol3);
+					//System.out.println("vol3 : " + vol3);
 					
 					
 					for (Percept p2 : ranges.keySet()) {
 						if (!ranges.get(p2).isPerceptEnum() && p2 != percept) {
-							//system.out.println(p2.getName());
+							////System.out.println(p2.getName());
 							vol3 *= ranges.get(p2).getLenght();
-							//system.out.println(p2.getName() + " " + ranges.get(p2).getLenght() + " " + getName());
+							////System.out.println(p2.getName() + " " + ranges.get(p2).getLenght() + " " + getName());
 						}
 					}
-					//system.out.println("vol3 : " + vol3);
+					////System.out.println("vol3 : " + vol3);
 					
 					
 					if (vol3 < volumeLost3) {
@@ -798,7 +1096,7 @@ public class Context extends AbstractContext implements Serializable,Cloneable{
 						p3 = percept;
 					}
 					
-					//system.out.println("Vol3 lost : " + volumeLost3);
+					////System.out.println("Vol3 lost : " + volumeLost3);
 					
 				}
 				
@@ -807,7 +1105,7 @@ public class Context extends AbstractContext implements Serializable,Cloneable{
 			
 			
 		}
-		if(p3 != null) {System.out.println("p3 : " + p3.getName());
+		if(p3 != null) {//System.out.println("p3 : " + p3.getName());
 
 		}
 		
@@ -877,7 +1175,7 @@ public class Context extends AbstractContext implements Serializable,Cloneable{
 				}
 			}
 		}
-		//system.out.println("percept " + p.getName());
+		////System.out.println("percept " + p.getName());
 		return p;
 	}
 	
@@ -916,7 +1214,7 @@ private Percept getPerceptWithLesserImpactOnVolume(ArrayList<Percept> containing
 	}
 
 }
-	//system.out.println("percept " + p.getName());
+	////System.out.println("percept " + p.getName());
 	return p;
 }
 
@@ -938,7 +1236,7 @@ private Percept getPerceptWithLesserImpactOnVolume2(ArrayList<Percept> containin
 	}
 
 }
-	//system.out.println("percept " + p.getName());
+	////System.out.println("percept " + p.getName());
 	return p;
 }
 
@@ -1241,7 +1539,7 @@ private Percept getPerceptWithLesserImpactOnVolume2(ArrayList<Percept> containin
 		if (formulaLocalModel != null) {
 			s += "Local model : " + this.formulaLocalModel + "\n";
 		} else {
-			s += "Local model : " + localModel.getFormula(this) + "\n";
+			//s += "Local model : " + localModel.getFormula(this) + "\n"; // Provoque erreur pas assez de donn�es (0 lignes) pour 3 pr�dicteurs
 		}
 		
 		s += "\n";
@@ -1395,7 +1693,7 @@ private Percept getPerceptWithLesserImpactOnVolume2(ArrayList<Percept> containin
 		Double influence = 1.0;
 		
 		for(Percept pct : situation.keySet()) {
-			////system.out.println("INFLUTEST " + getInfluenceByPerceptSituation(pct, situation.get(pct)));
+			//////System.out.println("INFLUTEST " + getInfluenceByPerceptSituation(pct, situation.get(pct)));
 			influence *= getInfluenceByPerceptSituationWithConfidence(pct, situation.get(pct));
 		}
 		
@@ -1410,7 +1708,7 @@ private Percept getPerceptWithLesserImpactOnVolume2(ArrayList<Percept> containin
 		Double influence = 1.0;
 		
 		for(Percept pct : situation.keySet()) {
-			////system.out.println("INFLUTEST " + getInfluenceByPerceptSituation(pct, situation.get(pct)));
+			//////System.out.println("INFLUTEST " + getInfluenceByPerceptSituation(pct, situation.get(pct)));
 			influence *= getInfluenceByPerceptSituation(pct, situation.get(pct));
 		}
 		
@@ -1422,7 +1720,7 @@ private Percept getPerceptWithLesserImpactOnVolume2(ArrayList<Percept> containin
 		Double currentInfluence = 0.0;
 		
 		for(Percept pct : situation.keySet()) {
-			////system.out.println("INFLUTEST " + getInfluenceByPerceptSituation(pct, situation.get(pct)));
+			//////System.out.println("INFLUTEST " + getInfluenceByPerceptSituation(pct, situation.get(pct)));
 			currentInfluence = getInfluenceByPerceptSituationWithConfidence(pct, situation.get(pct));
 			if(currentInfluence < worstInfluence) {
 				worstInfluence = currentInfluence;
@@ -1437,7 +1735,7 @@ private Percept getPerceptWithLesserImpactOnVolume2(ArrayList<Percept> containin
 		Double currentInfluence = 0.0;
 		
 		for(Percept pct : situation.keySet()) {
-			////system.out.println("INFLUTEST " + getInfluenceByPerceptSituation(pct, situation.get(pct)));
+			//////System.out.println("INFLUTEST " + getInfluenceByPerceptSituation(pct, situation.get(pct)));
 			currentInfluence = getInfluenceByPerceptSituation(pct, situation.get(pct));
 			if(currentInfluence < worstInfluence) {
 				worstInfluence = currentInfluence;
@@ -1486,6 +1784,8 @@ private Percept getPerceptWithLesserImpactOnVolume2(ArrayList<Percept> containin
 		return volume;
 	}
 	
+
+	
 	public double getWorstRange() {
 		Double volume = Double.POSITIVE_INFINITY;
 		
@@ -1512,7 +1812,7 @@ private Percept getPerceptWithLesserImpactOnVolume2(ArrayList<Percept> containin
 	 * Update experiments.
 	 */
 	private void updateExperiments() {
-	//	//system.out.println("Update experiments");
+	//	////System.out.println("Update experiments");
 		ArrayList<Percept> var = world.getAllPercept();
 		maxActivationsRequired = var.size();
 		Experiment exp = new Experiment();
@@ -1586,11 +1886,11 @@ private Percept getPerceptWithLesserImpactOnVolume2(ArrayList<Percept> containin
 	 * @param head the head
 	 */
 	public void growRanges() {
-		//system.out.println("Grow " + this.getName() );
+		////System.out.println("Grow " + this.getName() );
 		ArrayList<Percept> allPercepts = world.getAllPercept();
 		for (Percept pct : allPercepts) {
 			boolean contain = ranges.get(pct).contains(pct.getValue()) == 0 ;
-			//system.out.println(pct.getName() + " " + contain);
+			////System.out.println(pct.getName() + " " + contain);
 			if (!contain) {
 				ranges.get(pct).adapt(pct.getValue());
 				//ranges.get(pct).extend(pct.getValue(), pct);
@@ -1620,7 +1920,7 @@ private Percept getPerceptWithLesserImpactOnVolume2(ArrayList<Percept> containin
 		Percept perceptWithLesserImpact = getPerceptWithLesserImpactOnVolumeNotIncludedIn2(containingRanges,bestContext);
 		//Percept perceptWithLesserImpact = getPerceptWithLesserImpactOnVolumeNotIncludedIn2(containingRanges,bestContext);
 		if (perceptWithLesserImpact == null) {
-			System.out.println(world.getScheduler().getTick() + "shrinkRangesToJoinBordersAndDie");
+			//System.out.println(world.getScheduler().getTick() + "shrinkRangesToJoinBordersAndDie");
 			this.die();
 		}else {
 			//ranges.get(perceptWithLesserImpact).matchBorderWithBestContext(bestContext);
@@ -1651,7 +1951,7 @@ private Percept getPerceptWithLesserImpactOnVolume2(ArrayList<Percept> containin
 			ctxt.removeContext(this);
 		}
 		
-		////system.out.println("DIED : " + this.getName());
+		//////System.out.println("DIED : " + this.getName());
 		localModel.die();
 		super.die();
 		
@@ -1688,22 +1988,53 @@ private Percept getPerceptWithLesserImpactOnVolume2(ArrayList<Percept> containin
 	public Boolean computeValidityByPercepts() {
 		Boolean test = true;
 		for(Percept percept : perceptValidities.keySet()) {
-			////system.out.println(percept.getName()+"--->"+perceptValidities.get(percept));
+			//////System.out.println(percept.getName()+"--->"+perceptValidities.get(percept));
 			test = test && perceptValidities.get(percept);
 		}
 		return test;
 	}
 	
+	
+
+	
 	public Boolean computeNeighborhoodValidityByPercepts() {
 		Boolean test = true;
 		for(Percept percept : perceptNeighborhoodValidities.keySet()) {
-			////system.out.println(percept.getName()+"--->"+perceptNeighborhoodValidities.get(percept));
+			//////System.out.println(percept.getName()+"--->"+perceptNeighborhoodValidities.get(percept));
 			test = test && perceptNeighborhoodValidities.get(percept);
 		}
 		return test;
 	}
 	
 	
+	public void addNonValidPercept(Percept pct) {
+		nonValidPercepts.add(pct);
+	}
+	
+	public ArrayList<Percept> getNonValidPercepts() {
+		return nonValidPercepts;
+	}
+	
+	public void removeNonValidPercept(Percept pct) {
+		nonValidPercepts.remove(pct);
+	}
+	
+	
+	
+	public void addNonValidNeighborPercept(Percept pct) {
+		
+		nonValidNeightborPercepts.add(pct);
+		
+	}
+	
+	public ArrayList<Percept> getNonValidNeighborPercepts() {
+		
+		return nonValidNeightborPercepts;
+	}
+
+	public void removeNonValidNeighborPercept(Percept pct) {
+		nonValidNeightborPercepts.remove(pct);
+	}
 	
 	
 	public Boolean computeOverlapsByPercepts() {
@@ -1727,7 +2058,7 @@ private Percept getPerceptWithLesserImpactOnVolume2(ArrayList<Percept> containin
 				HashMap<Percept,HashMap<String,Double>> overlapRanges = new HashMap<Percept,HashMap<String,Double>>();
 				for(Percept percept : ranges.keySet()) {
 					overlapRanges.put(percept, new HashMap<String,Double>());
-					//system.out.println("CONTEXT 1" + context.getName() + " CONTEXT2" + this.getName());
+					////System.out.println("CONTEXT 1" + context.getName() + " CONTEXT2" + this.getName());
 					double startRange = percept.getOverlapRangesBetweenContexts(this, context).get("start");
 					double endRange = percept.getOverlapRangesBetweenContexts(this, context).get("end");
 					overlapRanges.get(percept).put("start", startRange);
@@ -1844,7 +2175,7 @@ private Percept getPerceptWithLesserImpactOnVolume2(ArrayList<Percept> containin
 	
 	public void computeNearestNeighbour() {
 		
-		////system.out.println("VOISINS : " + neighbours.size());
+		//////System.out.println("VOISINS : " + neighbours.size());
 		for(Context neighbourContext : neighbours) {
 			
 			
@@ -1881,7 +2212,7 @@ private Percept getPerceptWithLesserImpactOnVolume2(ArrayList<Percept> containin
 			double perceptPosition = 0d; 
 			double perceptWidth = 0d;
 			
-			////system.out.println(context.getName() + "\n" +contextOverlapsByPerceptSave);
+			//////System.out.println(context.getName() + "\n" +contextOverlapsByPerceptSave);
 			if(contextOverlapsByPerceptSave.get(context).get(percept)) {
 	
 				
@@ -1905,7 +2236,7 @@ private Percept getPerceptWithLesserImpactOnVolume2(ArrayList<Percept> containin
 					perceptWidth = ctxtEnd - thisStart;
 				}
 				else {
-					//system.out.println("PROBLEM !!!!!!!!!!!!!!!!! Void detection" );
+					////System.out.println("PROBLEM !!!!!!!!!!!!!!!!! Void detection" );
 				}
 				
 
@@ -1930,7 +2261,7 @@ private Percept getPerceptWithLesserImpactOnVolume2(ArrayList<Percept> containin
 					voidWidth.put(percept, perceptWidth);
 				}
 				else {
-					//system.out.println("NO VOID !");
+					////System.out.println("NO VOID !");
 					noVoid = true;
 				}
 			}
@@ -2074,7 +2405,9 @@ private Percept getPerceptWithLesserImpactOnVolume2(ArrayList<Percept> containin
 	}
 
 	
-
+	public double distance(Percept pct, double value) {
+		return this.ranges.get(pct).distance(value);
+	}
 
 
 	 
diff --git a/AMOEBA3/src/mas/agents/context/Range.java b/AMOEBA3/src/mas/agents/context/Range.java
index cbb98a30235e05e3c9824f3ff8aed6bd7a8075ce..149cdf6da8caeddbf1a5c12366efdfab26235e1b 100644
--- a/AMOEBA3/src/mas/agents/context/Range.java
+++ b/AMOEBA3/src/mas/agents/context/Range.java
@@ -112,8 +112,8 @@ public class Range implements Serializable, Comparable, Cloneable {
 //		this.AVT_deltaEnd = (end - start) * AVT_minRatio + 0.0001;
 		this.AVT_deltaStart = getLenght() * 0.2 + 0.0001;
 		this.AVT_deltaEnd = getLenght() * 0.2 + 0.0001;
-		System.out.println(world.getScheduler().getTick() + "\t" + context.getName() + "\t" + percept.getName()+ "\t" + "Creation" + "\t" + "START" + "\t" + AVT_deltaStart);
-		System.out.println(world.getScheduler().getTick() + "\t" + context.getName() + "\t" + percept.getName()+ "\t" + "Creation" + "\t" + "END" + "\t" + AVT_deltaEnd);
+		//System.out.println(world.getScheduler().getTick() + "\t" + context.getName() + "\t" + percept.getName()+ "\t" + "Creation" + "\t" + "START" + "\t" + AVT_deltaStart);
+		//System.out.println(world.getScheduler().getTick() + "\t" + context.getName() + "\t" + percept.getName()+ "\t" + "Creation" + "\t" + "END" + "\t" + AVT_deltaEnd);
 		
 
 	}
@@ -284,40 +284,40 @@ public class Range implements Serializable, Comparable, Cloneable {
 	 */
 	private void adaptEndUsingAVT(double oracleValue) {
 
-		System.out.print(world.getScheduler().getTick() + "\t" + context.getName() + "\t" + percept.getName()+ "\t" + " AdaptEndUsingAVT");
+		//System.out.print(world.getScheduler().getTick() + "\t" + context.getName() + "\t" + percept.getName()+ "\t" + " AdaptEndUsingAVT");
 		
 		if (contains(oracleValue) == 0.0) {  //If value is contained, it's a negative feedback for AVT (ie : we must exclude the value)
 
-			System.out.print( "\tContained : True" );
+			//System.out.print( "\tContained : True" );
 
 			if (AVT_lastFeedbackEnd == 1) {
 				AVT_deltaEnd *= AVT_deceleration;
-				System.out.print(" AVT_deceleration AVT_deltaEnd : " + "\t" +  AVT_deltaEnd);
+				//System.out.print(" AVT_deceleration AVT_deltaEnd : " + "\t" +  AVT_deltaEnd);
 			} else {
 				AVT_deltaEnd *= AVT_acceleration;
-				System.out.print(" AVT_acceleration AVT_deltaEnd : " + "\t" +  AVT_deltaEnd);
+				//System.out.print(" AVT_acceleration AVT_deltaEnd : " + "\t" +  AVT_deltaEnd);
 			}
 			this.setEnd(end - AVT_deltaEnd);
 
 			
-			System.out.print("\tAVT_lastFeedbackEn\t" + AVT_lastFeedbackEnd);
+			//System.out.print("\tAVT_lastFeedbackEn\t" + AVT_lastFeedbackEnd);
 			AVT_lastFeedbackEnd = -1;
-			System.out.print("\t" + AVT_lastFeedbackEnd + "\n");
+			//System.out.print("\t" + AVT_lastFeedbackEnd + "\n");
 
 		} else {
-			System.out.print( "\tContained : False" );
+			//System.out.print( "\tContained : False" );
 			if (AVT_lastFeedbackEnd == 1) {
 				AVT_deltaEnd *= AVT_acceleration;
-				System.out.print(" AVT_acceleration AVT_deltaEnd : " + "\t" +  AVT_deltaEnd);
+				//System.out.print(" AVT_acceleration AVT_deltaEnd : " + "\t" +  AVT_deltaEnd);
 			} else {
 				AVT_deltaEnd *= AVT_deceleration;
-				System.out.print(" AVT_deceleration AVT_deltaEnd : " + "\t" +  AVT_deltaEnd);
+				//System.out.print(" AVT_deceleration AVT_deltaEnd : " + "\t" +  AVT_deltaEnd);
 			}
 			this.setEnd(end + AVT_deltaEnd);
 
-			System.out.print("\tAVT_lastFeedbackEn\t" + AVT_lastFeedbackEnd);
+			//System.out.print("\tAVT_lastFeedbackEn\t" + AVT_lastFeedbackEnd);
 			AVT_lastFeedbackEnd = 1;
-			System.out.print("\t" + AVT_lastFeedbackEnd + "\n");
+			//System.out.print("\t" + AVT_lastFeedbackEnd + "\n");
 		}		
 
 		
@@ -325,28 +325,28 @@ public class Range implements Serializable, Comparable, Cloneable {
 	
 	public void endogenousAdaptEndUsingAVT() {
 
-		System.out.print(world.getScheduler().getTick() + "\t" + context.getName() + "\t" + percept.getName()+ "\t" + " AdaptEndUsingAVT");
+		//System.out.print(world.getScheduler().getTick() + "\t" + context.getName() + "\t" + percept.getName()+ "\t" + " AdaptEndUsingAVT");
 		
 		AVT_deltaEnd *= AVT_deceleration;
-		System.out.print(" AVT_deceleration AVT_deltaEnd : " + "\t" +  AVT_deltaEnd);
+		//System.out.print(" AVT_deceleration AVT_deltaEnd : " + "\t" +  AVT_deltaEnd);
 		
-		System.out.print("\tAVT_lastFeedbackEn\t" + AVT_lastFeedbackEnd);
+		//System.out.print("\tAVT_lastFeedbackEn\t" + AVT_lastFeedbackEnd);
 		AVT_lastFeedbackEnd = 0;
-		System.out.print("\t" + AVT_lastFeedbackEnd + "\n");
+		//System.out.print("\t" + AVT_lastFeedbackEnd + "\n");
 
 		
 	}
 	
 	public void endogenousAdaptStartUsingAVT() {
 
-		System.out.print(world.getScheduler().getTick() + "\t" + context.getName() + "\t" + percept.getName()+ "\t" + " AdaptEndUsingAVT");
+		//System.out.print(world.getScheduler().getTick() + "\t" + context.getName() + "\t" + percept.getName()+ "\t" + " AdaptEndUsingAVT");
 		
 		AVT_deltaStart *= AVT_deceleration;
-		System.out.print(" AVT_deceleration AVT_deltaStart : " + "\t" +  AVT_deltaStart);
+		//System.out.print(" AVT_deceleration AVT_deltaStart : " + "\t" +  AVT_deltaStart);
 		
-		System.out.print("\tAVT_lastFeedbackStart\t" + AVT_lastFeedbackStart);
+		//System.out.print("\tAVT_lastFeedbackStart\t" + AVT_lastFeedbackStart);
 		AVT_lastFeedbackStart = 0;
-		System.out.print("\t" + AVT_lastFeedbackStart + "\n");
+		//System.out.print("\t" + AVT_lastFeedbackStart + "\n");
 
 		
 	}
@@ -377,40 +377,40 @@ public class Range implements Serializable, Comparable, Cloneable {
 	 */
 	private void adaptStartUsingAVT(double oracleValue) {
 
-		System.out.print(world.getScheduler().getTick() + "\t" + context.getName() + "\t" + percept.getName()+ "\t" + " AdaptStartUsingAVT");
+		//System.out.print(world.getScheduler().getTick() + "\t" + context.getName() + "\t" + percept.getName()+ "\t" + " AdaptStartUsingAVT");
 		
 		
 		if (contains(oracleValue) == 0.0) {  //If value is contained, it's a negative feedback for AVT (ie : we must exclude the value)
 
-			System.out.print( "\tContained : True" );
+			//System.out.print( "\tContained : True" );
 			if (AVT_lastFeedbackStart == 1) {
 				AVT_deltaStart *= AVT_deceleration;
-				System.out.print(" AVT_deceleration AVT_deltaStart : " + "\t" +  AVT_deltaStart);
+				//System.out.print(" AVT_deceleration AVT_deltaStart : " + "\t" +  AVT_deltaStart);
 			} else {
 				AVT_deltaStart *= AVT_acceleration;
-				System.out.print(" AVT_acceleration AVT_deltaStart : " + "\t" +  AVT_deltaStart);
+				//System.out.print(" AVT_acceleration AVT_deltaStart : " + "\t" +  AVT_deltaStart);
 			}
 			this.setStart(start + AVT_deltaStart);
 
-			System.out.print("\tAVT_lastFeedbackStart\t" + AVT_lastFeedbackStart);
+			//System.out.print("\tAVT_lastFeedbackStart\t" + AVT_lastFeedbackStart);
 			AVT_lastFeedbackStart = -1;
-			System.out.print("\t" + AVT_lastFeedbackStart + "\n");
+			//System.out.print("\t" + AVT_lastFeedbackStart + "\n");
 
 		} else {
 
-			System.out.print( "\tContained : False" );
+			//System.out.print( "\tContained : False" );
 			if (AVT_lastFeedbackStart == 1) {
 				AVT_deltaStart *= AVT_acceleration;
-				System.out.print(" AVT_acceleration AVT_deltaStart : " + "\t" +  AVT_deltaStart);
+				//System.out.print(" AVT_acceleration AVT_deltaStart : " + "\t" +  AVT_deltaStart);
 			} else {
 				AVT_deltaStart *= AVT_deceleration;
-				System.out.print(" AVT_deceleration AVT_deltaStart : " + "\t" +  AVT_deltaStart);
+				//System.out.print(" AVT_deceleration AVT_deltaStart : " + "\t" +  AVT_deltaStart);
 			}
 			this.setStart(start - AVT_deltaStart);
 
-			System.out.print("\tAVT_lastFeedbackStart\t" + AVT_lastFeedbackStart);
+			//System.out.print("\tAVT_lastFeedbackStart\t" + AVT_lastFeedbackStart);
 			AVT_lastFeedbackStart = 1;
-			System.out.print("\t" + AVT_lastFeedbackStart + "\n");
+			//System.out.print("\t" + AVT_lastFeedbackStart + "\n");
 		}		
 
 	}
@@ -447,12 +447,12 @@ public class Range implements Serializable, Comparable, Cloneable {
 	 */
 	public double simulateNegativeAVTFeedbackStart(double oracleValue) {
 		
-		System.out.print(world.getScheduler().getTick() + "\t" + context.getName() + "\t" + percept.getName()+ "\t" );
+		//System.out.print(world.getScheduler().getTick() + "\t" + context.getName() + "\t" + percept.getName()+ "\t" );
 		if (AVT_lastFeedbackStart == 1) {
-			System.out.println("simulateNegativeAVTFeedbackStart :" + Math.abs(AVT_deltaStart * AVT_deceleration) + "\t" + "AVT_deltaStart : " + "\t" +  AVT_deltaStart);
+			//System.out.println("simulateNegativeAVTFeedbackStart :" + Math.abs(AVT_deltaStart * AVT_deceleration) + "\t" + "AVT_deltaStart : " + "\t" +  AVT_deltaStart);
 			return start + (AVT_deltaStart * AVT_deceleration);
 		} else {
-			System.out.println("simulateNegativeAVTFeedbackStart :" + Math.abs(AVT_deltaStart * AVT_acceleration) + "\t" + "AVT_deltaStart : " + "\t" +  AVT_deltaStart);
+			//System.out.println("simulateNegativeAVTFeedbackStart :" + Math.abs(AVT_deltaStart * AVT_acceleration) + "\t" + "AVT_deltaStart : " + "\t" +  AVT_deltaStart);
 			return start + (AVT_deltaStart * AVT_acceleration);
 		}
 
@@ -466,12 +466,12 @@ public class Range implements Serializable, Comparable, Cloneable {
 	 */
 	public double simulateNegativeAVTFeedbackEnd(double oracleValue) {
 		
-		System.out.print(world.getScheduler().getTick() + "\t" + context.getName() + "\t" + percept.getName()+ "\t" );
+		//System.out.print(world.getScheduler().getTick() + "\t" + context.getName() + "\t" + percept.getName()+ "\t" );
 		if (AVT_lastFeedbackEnd == 1) {
-			System.out.println("simulateNegativeAVTFeedbackEnd :" + Math.abs(AVT_deltaEnd * AVT_deceleration) + "\t" + "AVT_deltaEnd : " + "\t" +  AVT_deltaEnd);
+			//System.out.println("simulateNegativeAVTFeedbackEnd :" + Math.abs(AVT_deltaEnd * AVT_deceleration) + "\t" + "AVT_deltaEnd : " + "\t" +  AVT_deltaEnd);
 			return end - (AVT_deltaEnd * AVT_deceleration);
 		} else {
-			System.out.println("simulateNegativeAVTFeedbackEnd :" + Math.abs(AVT_deltaEnd * AVT_acceleration) + "\t" + "AVT_deltaEnd : " + "\t" +  AVT_deltaEnd);
+			//System.out.println("simulateNegativeAVTFeedbackEnd :" + Math.abs(AVT_deltaEnd * AVT_acceleration) + "\t" + "AVT_deltaEnd : " + "\t" +  AVT_deltaEnd);
 			return end - (AVT_deltaEnd * AVT_acceleration);
 		}
 
@@ -487,7 +487,7 @@ public class Range implements Serializable, Comparable, Cloneable {
 	 */
 	public boolean isTooSmall() {
 		if((end - start) < mininimalRange && (end - start)>0) {
-			System.out.println("����������������������������� mininimalRange :" + mininimalRange + " ~~~ " + (end - start));
+			//System.out.println("����������������������������� mininimalRange :" + mininimalRange + " ~~~ " + (end - start));
 		}
 		
 		return (end - start) < mininimalRange && !this.isPerceptEnum();
@@ -582,13 +582,13 @@ public class Range implements Serializable, Comparable, Cloneable {
 	}
 	
 	public void matchBorderWithBestContext(Context bestContext) {
-		System.out.println("Match border " + percept.getName());
+		//System.out.println("Match border " + percept.getName());
 		
 		Range bestContextRanges = bestContext.getRanges().get(percept);
 		
 		if (bestContextRanges.getStart() <= this.start &&  this.end <= bestContextRanges.getEnd() ) {
 			
-			System.out.println(context.getName() + " DIES");
+			//System.out.println(context.getName() + " DIES");
 			this.context.die();
 			
 		} else {
@@ -605,13 +605,13 @@ public class Range implements Serializable, Comparable, Cloneable {
 	
 	public void adaptTowardsBorder(Context bestContext) {
 		
-		System.out.println("Adapt towards border " + percept.getName());
+		//System.out.println("Adapt towards border " + percept.getName());
 		
 		Range bestContextRanges = bestContext.getRanges().get(percept);
 		
 		if (bestContextRanges.getStart() <= this.start &&  this.end <= bestContextRanges.getEnd() ) {
 			
-			System.out.println(context.getName() + " DIES");
+			//System.out.println(context.getName() + " DIES");
 			this.context.die();
 			
 		} else {
@@ -878,9 +878,9 @@ public class Range implements Serializable, Comparable, Cloneable {
 		return this.compareTo(o);
 	}
 	
-	private void setStart(double newStartValue) {
+	public void setStart(double newStartValue) {
 		if(context !=null && percept !=null) {
-			System.out.println(context.getName() + " " + percept.getName() + " START " + (Math.abs(newStartValue-this.start)));
+			//System.out.println(context.getName() + " " + percept.getName() + " START " + (Math.abs(newStartValue-this.start)));
 		}
 		this.start = newStartValue;
 		if(world != null) {
@@ -892,13 +892,42 @@ public class Range implements Serializable, Comparable, Cloneable {
 			this.percept.updateContextProjectionStart(this.context);
 			this.percept.updateSortedRanges(this.context, "start");
 			context.getWorld().getScheduler().addLastmodifiedContext(context);
+			
+			if(!this.contains(percept.getValue(), world.getNeighborhood(context, percept))) {
+			//if(!this.contains(percept.getValue(), percept.getRadiusContextForCreation())) {
+				if(!this.context.getNonValidNeighborPercepts().contains(this.percept)) {
+					this.context.addNonValidNeighborPercept(this.percept);
+				}
+			}
+			else {
+				if(this.context.getNonValidNeighborPercepts().contains(this.percept)) {
+					this.context.removeNonValidNeighborPercept(this.percept);
+				}
+			}
+			
+			this.context.updateRequestNeighborState();
+			
+			if(!this.contains2(percept.getValue())) {
+					if(!this.context.getNonValidPercepts().contains(this.percept)) {
+						this.context.addNonValidPercept(this.percept);
+					}
+				}
+				else {
+					if(this.context.getNonValidPercepts().contains(this.percept)) {
+						this.context.removeNonValidPercept(this.percept);
+					}
+				}
+			
+			this.context.updateActivatedContexts();
+			
+			
 		}
 		
 	}
 	
-	private void setEnd(double newEndValue) {
+	public void setEnd(double newEndValue) {
 		if(context !=null && percept !=null ) {
-			System.out.println(context.getName() + " " + percept.getName() + " END " + (Math.abs(newEndValue-this.end)));
+			//System.out.println(context.getName() + " " + percept.getName() + " END " + (Math.abs(newEndValue-this.end)));
 		}
 		
 		this.end = newEndValue;
@@ -913,8 +942,43 @@ public class Range implements Serializable, Comparable, Cloneable {
 			this.percept.updateSortedRanges(this.context, "end");
 			context.getWorld().getScheduler().addLastmodifiedContext(context);
 			
+			if(!this.contains(percept.getValue(), world.getNeighborhood(context, percept))) {
+			//if(!this.contains(percept.getValue(), percept.getRadiusContextForCreation())) {
+				if(!this.context.getNonValidNeighborPercepts().contains(this.percept)) {
+					this.context.addNonValidNeighborPercept(this.percept);
+				}
+			}
+			else {
+				if(this.context.getNonValidNeighborPercepts().contains(this.percept)) {
+					this.context.removeNonValidNeighborPercept(this.percept);
+				}
+			}
+			
+			this.context.updateRequestNeighborState();
+			
+			if(!this.contains2(percept.getValue())) {
+				if(!this.context.getNonValidPercepts().contains(this.percept)) {
+					this.context.addNonValidPercept(this.percept);
+				}
+			}
+			else {
+				if(this.context.getNonValidPercepts().contains(this.percept)) {
+					this.context.removeNonValidPercept(this.percept);
+				}
+			}
+		
+		this.context.updateActivatedContexts();
 		}
 	}
+	
+	public boolean contains(Double value, Double neighborhood) {
+		System.out.println(context.getName() +" "+ percept.getName() + " " + value + " " + (start - neighborhood) + " " + start + " " + end + " " + (end + neighborhood));
+		return Math.abs(value - getCenter()) < (getRadius() + neighborhood );
+	}
+	
+	public boolean contains2(Double value) {
+		return Math.abs(value - getCenter()) < getRadius() ;
+	}
 
 	public Range clone() throws CloneNotSupportedException{
 		return (Range)super.clone();
@@ -944,6 +1008,10 @@ public class Range implements Serializable, Comparable, Cloneable {
 		return Math.abs(this.getCenter() - value) - this.getRadius() ;
 	}
 	
+	public double centerDistance(double value) {
+		return value - this.getCenter();
+	}
+	
 	private double overlapDistance(Range otherRange) {
 		
 		double distanceBetweenRanges = distance(otherRange);
diff --git a/AMOEBA3/src/mas/agents/context/SpatialContext.java b/AMOEBA3/src/mas/agents/context/SpatialContext.java
new file mode 100644
index 0000000000000000000000000000000000000000..69d3d9cc4d74fdb561a33452eb3c3ed78cc85ff5
--- /dev/null
+++ b/AMOEBA3/src/mas/agents/context/SpatialContext.java
@@ -0,0 +1,77 @@
+package mas.agents.context;
+
+import java.util.HashMap;
+
+import mas.agents.AbstractPair;
+import mas.agents.percept.Percept;
+
+public class SpatialContext {
+
+	private HashMap<Percept, AbstractPair<Double, Double>> ranges = new HashMap<Percept, AbstractPair<Double, Double>>();
+	
+	
+	
+	public SpatialContext(Context ctxt) {
+		
+		for(Percept pct : ctxt.getRanges().keySet()) {
+			ranges.put(pct, new  AbstractPair<Double, Double>(ctxt.getRanges().get(pct).getStart(), ctxt.getRanges().get(pct).getEnd()));
+		}
+		
+	}
+	
+	public void setRange(Percept pct, AbstractPair<Double, Double> range) {
+		ranges.put(pct, range);
+	}
+	
+	public AbstractPair<Double, Double> getRange(Percept pct){
+		return ranges.get(pct);
+	}
+	
+	
+	public double getVolume() {
+		double volume = 1.0;
+		for(Percept pct : ranges.keySet()) {
+			volume *= 2*getRadius(pct);
+		}
+		return volume;
+	}
+	
+	public double getRadius(Percept pct) {
+		return Math.abs(getEnd(pct) - getStart(pct))/2;
+	}
+	
+	public double getCenter(Percept pct) {
+		return (getEnd(pct) + getStart(pct))/2;
+	}
+	
+	public double getEnd(Percept pct) {
+		return ranges.get(pct).getB();
+	}
+	
+	public void setEnd(Percept pct, double value) {
+		ranges.get(pct).setB(value);
+	}
+	
+	public void expandEnd(Percept pct, double value) {
+		ranges.get(pct).setB(getEnd(pct) + value);
+	}
+	
+	public double getStart(Percept pct) {
+		return ranges.get(pct).getA();
+	}
+	
+	public void setStart(Percept pct, double value) {
+		ranges.get(pct).setA(value);
+	}
+	
+	public void expandStart(Percept pct, double value) {
+		ranges.get(pct).setA(getStart(pct) - value);
+	}
+	
+	public double distance(Percept pct, Range otherRange) {
+		
+		return Math.abs(this.getCenter(pct) - otherRange.getCenter()) - this.getRadius(pct) - otherRange.getRadius();
+	}
+}
+
+
diff --git a/AMOEBA3/src/mas/agents/head/Head.java b/AMOEBA3/src/mas/agents/head/Head.java
index 23777c8847e5551c93465db7e5678fec1c750ee2..2d39d63c6e7dac040d6ff7080d04a069d391302c 100644
--- a/AMOEBA3/src/mas/agents/head/Head.java
+++ b/AMOEBA3/src/mas/agents/head/Head.java
@@ -38,8 +38,13 @@ public class Head extends AbstractHead implements Cloneable{
 	
 	private ArrayList<Context> activatedContexts = new ArrayList<Context>();
 	private ArrayList<Context> activatedNeighborsContexts = new ArrayList<Context>();
+	
+	private HashMap<Percept,ArrayList<Context>> partiallyActivatedContexts = new HashMap<Percept,ArrayList<Context>>();
+	private HashMap<Percept,ArrayList<Context>> partialNeighborContexts = new HashMap<Percept,ArrayList<Context>>();
+	
+	
 	private ArrayList<Context> contextsNeighborsByInfluence = new ArrayList<Context>();
-	private HashMap<Percept,ArrayList<Context>> partialyActivatedContexts = new HashMap<Percept,ArrayList<Context>>();
+	
 	private HashMap<Percept,Pair<Context,Context>> requestSurroundings = new HashMap<Percept,Pair<Context,Context>>();
 	private HashMap<Percept,Pair<Context,Context>> sharedIncompetenceContextPairs = new HashMap<Percept,Pair<Context,Context>>();
 	
@@ -175,7 +180,8 @@ public class Head extends AbstractHead implements Cloneable{
 		minConfidence = Double.POSITIVE_INFINITY;
 		
 		for(Percept pct : this.world.getScheduler().getPercepts()) {
-			partialyActivatedContexts.put(pct, new ArrayList<Context>());
+			partiallyActivatedContexts.put(pct, new ArrayList<Context>());
+			partialNeighborContexts.put(pct, new ArrayList<Context>());
 			requestSurroundings.put(pct, new Pair<Context,Context>(null,null));
 			sharedIncompetenceContextPairs.put(pct, new Pair<Context,Context>(null,null));
 			}
@@ -193,9 +199,14 @@ public class Head extends AbstractHead implements Cloneable{
 		}
 	}
 	
-	public void addPartiallyActivatedContext(Percept pct,Context partialyactivatedContext) {
-		partialyActivatedContexts.get(pct).add(partialyactivatedContext);
-		////system.out.println(pct.getName() + " " + partialyActivatedContexts.get(pct).size());
+	public void addPartiallyActivatedContext(Percept nonValidPercept,Context validContextExecptOnTheNonValidPercept) {
+		partiallyActivatedContexts.get(nonValidPercept).add(validContextExecptOnTheNonValidPercept);
+		//////System.out.println(pct.getName() + " " + partialyActivatedContexts.get(pct).size());
+	} 
+	
+	public void addPartialRequestNeighborContext(Percept nonValidPercept,Context validContextNeighborExecptOnTheNonValidPercept) {
+		partialNeighborContexts.get(nonValidPercept).add(validContextNeighborExecptOnTheNonValidPercept);
+		//////System.out.println(pct.getName() + " " + partialyActivatedContexts.get(pct).size());
 	} 
 
 	/**
@@ -204,17 +215,15 @@ public class Head extends AbstractHead implements Cloneable{
 	 */
 	public void play() {
 
-		if(world.getScheduler().getTick() == 119) {
-			//system.out.println("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TICK 119");
-			for(Context ctxt : activatedContexts) {
-				//system.out.println(ctxt.getName());
-			}
-		}
+		
+
+		
+		
 		for(Percept pct : this.world.getScheduler().getPercepts()) {
 			currentSituation.put(pct, pct.getValue());
 		}
 		
-		//system.out.println("HEAD ACTIVATED CONTEXT :" + activatedContexts.size());
+		////System.out.println("HEAD ACTIVATED CONTEXT :" + activatedContexts.size());
 		nPropositionsReceived = activatedContexts.size();
 		newContextWasCreated = false;
 		setContextFromPropositionWasSelected(false);		
@@ -245,17 +254,19 @@ public class Head extends AbstractHead implements Cloneable{
 		updateStatisticalInformations(); ///regarder dans le d�tail, possible que ce pas trop utile
 		
 		
-		//displayPartiallyActivatedContexts();
+
 		
 		newContext = null;
 		
-		////system.out.println("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Error allowded :" + errorAllowed);
-		////system.out.println("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Inexact allowded :" + inexactAllowed);
+		//////System.out.println("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Error allowded :" + errorAllowed);
+		//////System.out.println("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Inexact allowded :" + inexactAllowed);
 	}
 	
 	
 	
 	private void playWithOracle() {
+		
+		//System.out.println("Activated neighbors " + activatedNeighborsContexts.size());
 			
 		if (activatedContexts.size() > 0) {
 			selectBestContext(); //using highest confidence 
@@ -284,9 +295,14 @@ public class Head extends AbstractHead implements Cloneable{
 		
 		
 		selfAnalysationOfContexts();
+		
+		world.getAmoeba().PAUSE("BEFORE HEAD NCS ");
 
 		NCSDetection_IncompetentHead();		/*If there isn't any proposition or only bad propositions, the head is incompetent. It needs help from a context.*/
 		NCSDetection_Concurrence(); 		/*If result is good, shrink redundant context (concurrence NCS)*/
+		
+		world.getAmoeba().PAUSE("BEFORE HEAD NCS CONTEXT CREATION");
+		
 		NCSDetection_Create_New_Context();	/*Finally, head agent check the need for a new context agent*/
 		
 		
@@ -304,7 +320,7 @@ public class Head extends AbstractHead implements Cloneable{
 			noBestContext = false;
 			prediction = bestContext.getActionProposal();
 		} else {
-			//system.out.println("NO BEST ...");
+			////System.out.println("NO BEST ...");
 			noBestContext = true;
 			ArrayList<Agent> allContexts = world.getScheduler().getContexts();
 			Context nearestContext = this.getNearestContext(allContexts);
@@ -380,17 +396,17 @@ public class Head extends AbstractHead implements Cloneable{
 		
 		Double endogenousSumTerm = 0.0;
 		Double endogenousNormalizationTerm = 0.0;
-		//system.out.println("NEIGHBORS : " + activatedNeighborsContexts.size());
+		////System.out.println("NEIGHBORS : " + activatedNeighborsContexts.size());
 		for(Context ctxt :activatedNeighborsContexts) {
 			endogenousSumTerm += ctxt.getInfluenceWithConfidence(currentSituation)*ctxt.getActionProposal();
 			endogenousNormalizationTerm += ctxt.getInfluenceWithConfidence(currentSituation);
 		}
 		endogenousPredictionNContexts = endogenousSumTerm/endogenousNormalizationTerm;
-		//system.out.println("ENDO PRED N CTXT : " + endogenousPredictionNContexts);
+		////System.out.println("ENDO PRED N CTXT : " + endogenousPredictionNContexts);
 		
 		// Endogenous prediction N contexts by influence //
 		
-		//system.out.println("�~~�~~�~~�~~�~~�~~�~~�~~�~~�~~�~~~ INFLUENCES" + currentSituation);
+		////System.out.println("�~~�~~�~~�~~�~~�~~�~~�~~�~~�~~�~~~ INFLUENCES" + currentSituation);
 		
 		maxConfidence = Double.NEGATIVE_INFINITY;
 		minConfidence = Double.POSITIVE_INFINITY;
@@ -406,10 +422,10 @@ public class Head extends AbstractHead implements Cloneable{
 			
 			if(ctxt.getInfluenceWithConfidence(currentSituation)> 0.5) {
 				contextsNeighborsByInfluence.add(ctxt);
-				//system.out.println(ctxt);
+				////System.out.println(ctxt);
 			}
 		}
-		//system.out.println("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" + minConfidence + " ; " + maxConfidence + ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
+		////System.out.println("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" + minConfidence + " ; " + maxConfidence + ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
 		
 		endogenousSumTerm = 0.0;
 		endogenousNormalizationTerm = 0.0;
@@ -475,14 +491,14 @@ public class Head extends AbstractHead implements Cloneable{
 		//Test if there are surrounding contexts
 		boolean testSurroudingContext = false;
 		
-		////system.out.println("SURROUNDING CONTEXTS ...");
+		//////System.out.println("SURROUNDING CONTEXTS ...");
 		for(Percept pct : this.world.getScheduler().getPercepts()) {
 			
 			computeNearestContextsByPercept(pct);			
 				 
 			}
 		
-		//displayPartiallyActivatedContexts();
+
 		//displayContexts();
 		
 		for(Percept pcpt : this.world.getScheduler().getPercepts()) {
@@ -498,7 +514,7 @@ public class Head extends AbstractHead implements Cloneable{
 			
 		}
 		
-		////system.out.println("TEST SURROUNDING CONTEXTS ..." + testSurroudingContext);
+		//////System.out.println("TEST SURROUNDING CONTEXTS ..." + testSurroudingContext);
 		return testSurroudingContext;
 	}
 	
@@ -511,7 +527,7 @@ public class Head extends AbstractHead implements Cloneable{
 		for(Context ctxt : list) {
 			//system.out.print(ctxt.getRanges().get(prct).getRange(range) + "  ");
 		}
-		//system.out.println(" ");
+		////System.out.println(" ");
 		
 	}
 	
@@ -529,8 +545,8 @@ public class Head extends AbstractHead implements Cloneable{
 		if(activatedContextInOtherPercepts.size()>0) {
 			
 				
-			////system.out.println("Partially activated on other percepts than " + pct.getName() + " : " + activatedContextInOtherPercepts.size());			
-			////system.out.println("Value " + pct.getValue());		 
+			//////System.out.println("Partially activated on other percepts than " + pct.getName() + " : " + activatedContextInOtherPercepts.size());			
+			//////System.out.println("Value " + pct.getValue());		 
 			
 			CustomComparator rangeStartComparator =  new CustomComparator(pct, "start");
 			Collections.sort(activatedContextInOtherPercepts, rangeStartComparator);
@@ -568,7 +584,7 @@ public class Head extends AbstractHead implements Cloneable{
 			}
 		}
 		else {
-			////system.out.println("=====================================================");
+			//////System.out.println("=====================================================");
 		}
 		
 			
@@ -580,52 +596,39 @@ public class Head extends AbstractHead implements Cloneable{
 		
 	
 	private ArrayList<Context> getAllActivatedContextsExeptForOnePercept(Percept onePercept){
-		ArrayList<Context> activatedContexts = new ArrayList<Context>();
-		
-		Percept otherPercept = getDifferentPercept(onePercept);
 		
-		if(partialyActivatedContexts.get(otherPercept)!=null) {
-			for(Context ctxt : partialyActivatedContexts.get(otherPercept)) {
-				if(this.world.getScheduler().getPercepts().size()>2) {
-					if(contextActivateInOtherPerceptsThan(ctxt, onePercept, otherPercept)) {
-						activatedContexts.add(ctxt);
-					}
-				}
-				else {
-					activatedContexts.add(ctxt);
-				}
-//				if(!world.getScheduler().getContexts().contains(ctxt)) {
-//					//system.out.println("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ " + ctxt.getName());
-//				}
-			}
-			
-		}
+		return partiallyActivatedContexts.get(onePercept);
+	}
+	
+	private ArrayList<Context> getAllActivatedNeighborContextsExeptForOnePercept(Percept onePercept){
 		
-		return activatedContexts;
+		return partialNeighborContexts.get(onePercept);
 	}
 	
+	
+	
 	public void displayPartiallyActivatedContexts() {
-		//system.out.println("PARTIALLY ACTIVATED CONTEXTS");
-		for(Percept pct : partialyActivatedContexts.keySet()) {
+		////System.out.println("PARTIALLY ACTIVATED CONTEXTS");
+		for(Percept pct : partiallyActivatedContexts.keySet()) {
 			//system.out.print(pct.getName() + " : ");
-			if(partialyActivatedContexts.get(pct).size()>0)
-			for(Context ctxt : partialyActivatedContexts.get(pct)) {
+			if(partiallyActivatedContexts.get(pct).size()>0)
+			for(Context ctxt : partiallyActivatedContexts.get(pct)) {
 				//system.out.print(ctxt.getName() + " ; ");
 			}
-			//system.out.println(" ");
+			////System.out.println(" ");
 		}
 	}
 	
 	public void displayContexts() {
-		//system.out.println("CONTEXTS");
+		////System.out.println("CONTEXTS");
 		for(Context ctxt : this.world.getScheduler().getContextsAsContext()) {
 			//system.out.print(ctxt.getName() + " ; ");
 		}
-		//system.out.println(" ");
+		////System.out.println(" ");
 	}
 	
 	private Percept getDifferentPercept(Percept p) {
-		for(Percept pct : partialyActivatedContexts.keySet()) {
+		for(Percept pct : partiallyActivatedContexts.keySet()) {
 			if(p != pct) {
 				return pct;
 			}
@@ -635,16 +638,16 @@ public class Head extends AbstractHead implements Cloneable{
 	
 	private boolean contextActivateInOtherPerceptsThan(Context ctxt, Percept p1, Percept p2) {
 		boolean test = true;
-		for(Percept prct : partialyActivatedContexts.keySet()) {
+		for(Percept prct : partiallyActivatedContexts.keySet()) {
 			if(prct != p1 && prct != p2) {
-				test = test & partialyActivatedContexts.get(prct).contains(ctxt);
+				test = test & partiallyActivatedContexts.get(prct).contains(ctxt);
 			}
 		}
 		return test;
 	}
 	
 	private void NCS_EndogenousCompetition() {
-		//system.out.println("NCS Comptetition " + world.getScheduler().getTick());
+		////System.out.println("NCS Comptetition " + world.getScheduler().getTick());
 		// Creation of twin contexts to give the endogenous prediction
 
 		
@@ -764,7 +767,7 @@ public class Head extends AbstractHead implements Cloneable{
 		double contextInfluenceL = closestContexts.getL().getInfluenceWithConfidence(currentSituation);
 		double contextInfluenceR = closestContexts.getR().getInfluenceWithConfidence(currentSituation);
 		
-		//system.out.println("--------------------------------------------------DIFFERENCE :" + compareClosestContextPairModels(closestContexts));
+		////System.out.println("--------------------------------------------------DIFFERENCE :" + compareClosestContextPairModels(closestContexts));
 		
 		if(compareClosestContextPairModels(closestContexts)<10) {
 			endogenousPredictionActivatedContextsSharedIncompetence = (contextInfluenceL*closestContexts.getL().getActionProposal() + contextInfluenceR*closestContexts.getR().getActionProposal()) / (contextInfluenceL + contextInfluenceR);
@@ -819,19 +822,29 @@ public class Head extends AbstractHead implements Cloneable{
 	private void NCSDetection_Create_New_Context() {
 		/*Finally, head agent check the need for a new context agent*/
 		
+		System.out.println("activatedNeighborsContexts");
+		for(Context ctxt : activatedNeighborsContexts) {
+			System.out.println(ctxt.getName());
+		}
+		
 		boolean newContextCreated = false;
 		ArrayList<Agent> allContexts = world.getScheduler().getContexts();
 		AbstractPair<Context, Double> nearestGoodContext = getNearestGoodContextWithDistance(allContexts);
 		if (nearestGoodContext.getB() > 0) {
-			//system.out.println(world.getScheduler().getTick() + "Create_New_Context");
+			
+		}
+		
+		System.out.println(">>>>>>> " + world.getScheduler().getTick() + " " + activatedContexts.size());
+		if(activatedContexts.size() == 0) {
+			System.out.println(world.getScheduler().getTick() + " Create_New_Context");
 			
 			Context context;
-			if(nearestGoodContext.getA() != null) {
-				context = createNewContext(nearestGoodContext.getA());
-			}else {
-				context = createNewContext();
-			}
-			//context = createNewContext();
+//			if(nearestGoodContext.getA() != null) {
+//				context = createNewContext(nearestGoodContext.getA());
+//			}else {
+//				context = createNewContext();
+//			}
+			context = createNewContext();
 			
 
 			bestContext = context;
@@ -850,7 +863,7 @@ public class Head extends AbstractHead implements Cloneable{
 		if (bestContext != null && criticity <= this.errorAllowed) {
 			for (int i = 0 ; i < activatedContexts.size() ; i++) {
 				if (activatedContexts.get(i) != bestContext && !activatedContexts.get(i).isDying() && this.getCriticity(activatedContexts.get(i)) <= this.errorAllowed) {
-			//		//system.out.println("Shrink context " + contexts.get(i).getName());
+			//		////System.out.println("Shrink context " + contexts.get(i).getName());
 					activatedContexts.get(i).solveNCS_Concurrence(this);
 				}
 			}
@@ -864,10 +877,10 @@ public class Head extends AbstractHead implements Cloneable{
 			
 			Context c = getNearestGoodContext(allContexts);
 			if(c!=null) {
-				//system.out.println("Nearest good context : " + c.getName());
+				////System.out.println("Nearest good context : " + c.getName());
 			}
 			else {
-				//system.out.println("Nearest good context : null");
+				////System.out.println("Nearest good context : null");
 			}
 			if (c!=null) c.solveNCS_IncompetentHead(this);;
 			bestContext = c;
@@ -885,10 +898,10 @@ public class Head extends AbstractHead implements Cloneable{
 	}
 	
 	private void selfAnalysationOfContexts() {
-		//system.out.println(world.getScheduler().getTick());
+		////System.out.println(world.getScheduler().getTick());
 		/*All context which proposed itself must analyze its proposition*/
 		for (int i = 0 ; i < activatedContexts.size() ; i++) {
-			//system.out.println(activatedContexts.get(i).getName());
+			////System.out.println(activatedContexts.get(i).getName());
 			activatedContexts.get(i).analyzeResults(this);
 		}
 	}
@@ -960,6 +973,8 @@ public class Head extends AbstractHead implements Cloneable{
 	}
 	
 	
+	
+	
 	/**
 	 * Gets the nearest context.
 	 *
@@ -1012,6 +1027,23 @@ public class Head extends AbstractHead implements Cloneable{
 		return d;
 	}
 	
+	private double getDistanceToContext (Context context) {
+		double totalDistance = 0.0;
+		for (Percept p : world.getAllPercept()) {
+			double distance = context.distance(p, p.getValue());
+			if(distance > 0) {
+				totalDistance += distance;
+			}
+
+		}
+		
+		
+		
+		return totalDistance;
+	}
+	
+	
+	
 
 	
 	
@@ -1038,7 +1070,7 @@ public class Head extends AbstractHead implements Cloneable{
 	 * @return the context
 	 */
 	private Context createNewContext() {
-	//	//system.out.println("Creation d'un nouveau contexte : " + contexts.size());
+	//	////System.out.println("Creation d'un nouveau contexte : " + contexts.size());
 		newContextWasCreated = true;
 //		if (contexts.size() != 0) {
 //			System.exit(0);
@@ -1058,7 +1090,7 @@ public class Head extends AbstractHead implements Cloneable{
 	}
 	
 	private Context createNewContext(Context bestNearestCtxt) {
-		//	//system.out.println("Creation d'un nouveau contexte : " + contexts.size());
+		//	////System.out.println("Creation d'un nouveau contexte : " + contexts.size());
 			newContextWasCreated = true;
 //			if (contexts.size() != 0) {
 //				System.exit(0);
@@ -1066,7 +1098,7 @@ public class Head extends AbstractHead implements Cloneable{
 			world.raiseNCS(NCS.CREATE_NEW_CONTEXT);
 			Context context;
 			if (firstContext) {
-				System.out.println(bestNearestCtxt.toStringFull());
+				//System.out.println(bestNearestCtxt.toStringFull());
 				context = new Context(world, this, bestNearestCtxt);
 				Config.print("new context agent", 3);
 			}
@@ -1171,7 +1203,7 @@ public class Head extends AbstractHead implements Cloneable{
 		
 		
 		
-		////system.out.println("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Average Prediction Criticity :" + averagePredictionCriticity);
+		//////System.out.println("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Average Prediction Criticity :" + averagePredictionCriticity);
 		
 		if (averagePredictionCriticity > errorAllowed) {
 			perfIndicator--;
@@ -1188,27 +1220,27 @@ public class Head extends AbstractHead implements Cloneable{
 		if (perfIndicator <= nConflictBeforeAugmentation * (-1)) {
 			perfIndicator = 0;
 			errorAllowed *= augmentationFactorError;
-			////system.out.println("����������������������  augmentationFactorError :" + augmentationFactorError);
+			//////System.out.println("����������������������  augmentationFactorError :" + augmentationFactorError);
 		}
 		
 		if (perfIndicator >= nSuccessBeforeDiminution) {
 			perfIndicator = 0;
 			errorAllowed *= diminutionFactorError;
-			////system.out.println("����������������������  diminutionFactorError :" + diminutionFactorError);
+			//////System.out.println("����������������������  diminutionFactorError :" + diminutionFactorError);
 			errorAllowed = Math.max(minErrorAllowed, errorAllowed);
 		}
 		
 		if (perfIndicatorInexact <= nConflictBeforeInexactAugmentation * (-1)) {
 			perfIndicatorInexact = 0;
 			inexactAllowed *= augmentationInexactError;
-			////system.out.println("����������������������  augmentationInexactError :" + augmentationInexactError);
+			//////System.out.println("����������������������  augmentationInexactError :" + augmentationInexactError);
 		}
 		
 		if (perfIndicatorInexact >= nSuccessBeforeInexactDiminution) {
 			perfIndicatorInexact = 0;
 			inexactAllowed *= diminutionInexactError;
 			inexactAllowed = Math.max(minInexactAllowed, inexactAllowed);
-			////system.out.println("����������������������  diminutionInexactError :" + diminutionInexactError);
+			//////System.out.println("����������������������  diminutionInexactError :" + diminutionInexactError);
 
 		}
 		
@@ -1832,7 +1864,11 @@ public class Head extends AbstractHead implements Cloneable{
 
 	
 	public ArrayList<Context> getPartiallyActivatedContexts(Percept pct) {
-		return partialyActivatedContexts.get(pct);
+		return partiallyActivatedContexts.get(pct);
+	}
+	
+	public ArrayList<Context> getPartiallyActivatedNeighborContexts(Percept pct) {
+		return partialNeighborContexts.get(pct);
 	}
 	
 	
@@ -1845,7 +1881,7 @@ public class Head extends AbstractHead implements Cloneable{
 		
 
 		for(Percept pct : requestSurroundings.keySet()) {
-			////system.out.println("REQUEST SURROUNDINGS " +  requestSurroundings.get(pct).getL().getName() +  " ; " + requestSurroundings.get(pct).getR().getName());
+			//////System.out.println("REQUEST SURROUNDINGS " +  requestSurroundings.get(pct).getL().getName() +  " ; " + requestSurroundings.get(pct).getR().getName());
 			if(requestSurroundings.get(pct).contains(ctxt)) {
 				return true;
 			}
@@ -1877,7 +1913,29 @@ public class Head extends AbstractHead implements Cloneable{
 	
 	
 	public void addRequestNeighbor(Context ctxt) {
-		activatedNeighborsContexts.add(ctxt);
+		if(!activatedNeighborsContexts.contains(ctxt)) {
+			System.out.println(world.getScheduler().getTick() + " " + ctxt.getName() + " " + "VALID NEIGHBOR");
+			activatedNeighborsContexts.add(ctxt);
+		}	
+	}
+	
+	public void addActivatedContext(Context ctxt) {
+		if(!activatedContexts.contains(ctxt)) {
+			activatedContexts.add(ctxt);
+		}	
+	}
+	
+	public void removeActivatedContext(Context ctxt) {
+		if(activatedContexts.contains(ctxt)) {
+			activatedContexts.remove(ctxt);
+		}	
+	}
+	
+	public void removeRequestNeighbor(Context ctxt) {
+		if(activatedNeighborsContexts.contains(ctxt)) {
+			System.out.println(world.getScheduler().getTick() + " " + ctxt.getName() + " " + "NOT VALID NEIGHBOR ANYMORE");
+			activatedNeighborsContexts.remove(ctxt);
+		}	
 	}
 	
 	public ArrayList<Context> getActivatedNeighborsContexts(){
@@ -1890,7 +1948,7 @@ public class Head extends AbstractHead implements Cloneable{
 	
 	public void displayActivatedNeighborsContexts() {
 		for(Context ctxt : activatedNeighborsContexts) {
-			//system.out.println(ctxt.getName());
+			////System.out.println(ctxt.getName());
 		}
 	}
 	
@@ -1908,30 +1966,78 @@ public class Head extends AbstractHead implements Cloneable{
 		activatedNeighborsContexts.clear();
 		contextsNeighborsByInfluence.clear();
 		for(Percept pct : this.world.getScheduler().getPercepts()) {
-			partialyActivatedContexts.get(pct).clear();
-			
+			partiallyActivatedContexts.get(pct).clear();
+			partialNeighborContexts.get(pct).clear();
 		}
 	}
 	
 	public Double getMaxRadiusForContextCreation(Percept pct) {
-		double maxRadius = Double.POSITIVE_INFINITY;
-		double currentRadius = 0;
-		for(Context ctxt:activatedNeighborsContexts) {
+		double maxRadius = pct.getRadiusContextForCreation();
+		double currentRadius;
+		
+			
+		//for(Context ctxt:partialNeighborContexts.get(pct)) {
+		for(Context ctxt:activatedNeighborsContexts) {			
+			
 			currentRadius = ctxt.getRanges().get(pct).distance(pct.getValue());
-			if(currentRadius<maxRadius) {
+			System.out.println(ctxt.getName() + " " + pct.getName() + " " + currentRadius + " " + maxRadius);
+			if(currentRadius<maxRadius && currentRadius>0 ) {
 				maxRadius = currentRadius;
 			}
 		}
 		
-		if(maxRadius==Double.POSITIVE_INFINITY) {
-			return null;
-		}else {
-			return maxRadius;
+		return maxRadius;
+		
+		
+	}
+	
+	public AbstractPair<Double,Double> getMaxRadiusesForContextCreation(Percept pct) {
+		//AbstractPair<Double,Double> maxRadiuses = new AbstractPair<Double,Double>(pct.getRadiusContextForCreation(),pct.getRadiusContextForCreation());
+		AbstractPair<Double,Double> maxRadiuses = new AbstractPair<Double,Double>(Math.abs(pct.getMin()- pct.getValue()),Math.abs(pct.getMax()-pct.getValue()));
+
+		System.out.println("MIN MAX "  + pct.getName() +" " + pct.getValue() + " < " + pct.getMin() + " , "  + pct.getMax() + " > / < " + Math.abs(pct.getMin()- pct.getValue()) + " , " + Math.abs(pct.getMax()-pct.getValue()) + " >");
+		
+		double currentStartRadius;
+		double currentEndRadius;
+		
+			
+		//for(Context ctxt:partialNeighborContexts.get(pct)) {
+		for(Context ctxt:activatedNeighborsContexts) {			
+			
+			if(ctxt.getRanges().get(pct).centerDistance(pct.getValue()) < 0) {
+				// End radius
+				currentEndRadius = ctxt.getRanges().get(pct).distance(pct.getValue());
+				//System.out.println(ctxt.getName() + " " + pct.getName() + " " + currentRadius + " " + maxRadius);
+				if(currentEndRadius < maxRadiuses.getB() && currentEndRadius > 0 ) {
+					maxRadiuses.setB(currentEndRadius); 
+				}
+			}
+			
+			if(ctxt.getRanges().get(pct).centerDistance(pct.getValue()) > 0) {
+				// Start radius
+				currentStartRadius = ctxt.getRanges().get(pct).distance(pct.getValue());
+				//System.out.println(ctxt.getName() + " " + pct.getName() + " " + currentRadius + " " + maxRadius);
+				if(currentStartRadius < maxRadiuses.getA() && currentStartRadius > 0 ) {
+					maxRadiuses.setA(currentStartRadius); 
+				}
+			}
+
+			
+			
 		}
 		
+		return maxRadiuses;
+		
 		
 	}
 	
+	
+	
+	
+	
+	
+
+	
 }
 
 
diff --git a/AMOEBA3/src/mas/agents/percept/ContextProjection.java b/AMOEBA3/src/mas/agents/percept/ContextProjection.java
index f02865c53b6d65757f375e592b76c12bb4d84bcd..a4e3f871003d0010d087655e62c82e888e4c0b38 100644
--- a/AMOEBA3/src/mas/agents/percept/ContextProjection.java
+++ b/AMOEBA3/src/mas/agents/percept/ContextProjection.java
@@ -69,7 +69,12 @@ public class ContextProjection implements Serializable{
 	}
 	
 	public boolean contains(Double value) {
-		return ((value > start)  && (value < end));
+		return Math.abs(value - getCenter()) < getRadius() ;
+	}
+	
+	public boolean contains(Double value, Double neighborhood) {
+		System.out.println(context.getName() +" "+ percept.getName() + " " + value + " " + (start - neighborhood) + " " + start + " " + end + " " + (end + neighborhood));
+		return Math.abs(value - getCenter()) < (getRadius() + neighborhood );
 	}
 	
 	public boolean inNeighborhoodOf(Double value) {
diff --git a/AMOEBA3/src/mas/agents/percept/Percept.java b/AMOEBA3/src/mas/agents/percept/Percept.java
index 228f86a39e704444385d9036c1e96d0f088b15cc..f63f6c4d053e65fefe0eded210e8729873d7733c 100644
--- a/AMOEBA3/src/mas/agents/percept/Percept.java
+++ b/AMOEBA3/src/mas/agents/percept/Percept.java
@@ -171,7 +171,7 @@ public class Percept extends SystemAgent implements Serializable,Cloneable {
 				
 		oldValue = value;
 		//value = sensor.getValue();
-		////system.out.println(this.name);
+		//////System.out.println(this.name);
 		value = this.getWorld().getScheduler().getPerceptionsOrAction(this.name);
 		ajustMinMax(); 
 		computeContextProjectionValidity();
@@ -187,11 +187,11 @@ public class Percept extends SystemAgent implements Serializable,Cloneable {
 	}	
 	
 	public void displayContextProjections() {
-		//system.out.println("CONTEXT PROJECTIONS " + this.getName());
+		////System.out.println("CONTEXT PROJECTIONS " + this.getName());
 		for(Context ctxt : contextProjections.keySet()) {
 			//system.out.print(ctxt.getName() + " ; ");
 		}
-		//system.out.println(" ");
+		////System.out.println(" ");
 	}
 	
 	public void computeContextProjectionValidity() {
@@ -201,22 +201,40 @@ public class Percept extends SystemAgent implements Serializable,Cloneable {
 		
 		for(ContextProjection contextProjection : contextProjections.values()) {
 			
+			
+			if(!contextProjection.contains(this.value)) {
+
+				contextProjection.getContext().addNonValidPercept(this);	
+				
+			}
+			
+			//if(!contextProjection.contains(this.value, getRadiusContextForCreation())) {
+			if(!contextProjection.contains(this.value, world.getNeighborhood(contextProjection.getContext(), this))) {
+				////System.out.println(contextProjection.getContext().getName() + " " + this.getName() + " non valid");
+				contextProjection.getContext().addNonValidNeighborPercept(this);
+				
+				System.out.println(world.getScheduler().getTick() + " " + contextProjection.getContext().getName() + " " + this.getName() + " " + "NON VALID" + " " + getRadiusContextForCreation());
+			}
+			
+			
+			
+			
+			
 			if(contextProjection.contains(this.value)) {
 
 				validContextProjection.add(contextProjection.getContext());
 				contextProjection.getContext().setPerceptValidity(this);
-				////system.out.println("Percept "+this.name+ " Context "+contextProjection.getContex().getName());
-				
-				if(this.world.getScheduler().getHeadAgent().getPartiallyActivatedContexts(this)!=null) {
-					if(!this.world.getScheduler().getHeadAgent().getPartiallyActivatedContexts(this).contains(contextProjection.getContext())) {
-						this.world.getScheduler().getHeadAgent().addPartiallyActivatedContext(this,contextProjection.getContext());
-					}
-				}
-				
-				
+				//////System.out.println("Percept "+this.name+ " Context "+contextProjection.getContex().getName());
 				
+								
 			}
 			
+			
+//			if(contextProjection.contains(this.value, 2 * Math.abs(this.getMinMaxDistance()) * world.contextCreationPercentage )) {
+//				
+//			}
+			
+			
 			if(contextProjection.inNeighborhoodOf(this.value)){
 				validNeigborhoodContextProjection.add(contextProjection.getContext());
 				contextProjection.getContext().setNeighborhoodPerceptValidity(this);
@@ -288,8 +306,9 @@ public class Percept extends SystemAgent implements Serializable,Cloneable {
 		/* In order to avoid big gap in min-max value in order to adapt with the system dynamic
 		 * It's also a warranty to avoid to flaw AVT with flawed value */
 		double dist = max - min;
-		min += 0.05*dist;
-		max -= 0.05*dist;
+		//TODO ?
+		//min += 0.05*dist;
+		//max -= 0.05*dist;
 	}
 	
 	/**
@@ -446,30 +465,30 @@ public class Percept extends SystemAgent implements Serializable,Cloneable {
 	 */
 	
 	public void displaySortedRanges() {
-		//system.out.println("########### SORTED RANGES DISPLAY " + this.getName() +" ###########");
-		//system.out.println("########### START ###########");
+		////System.out.println("########### SORTED RANGES DISPLAY " + this.getName() +" ###########");
+		////System.out.println("########### START ###########");
 		for(Context cntxt : this.sortedRanges.get("start")) {
-			//system.out.println(cntxt.getRanges().get(this).getStart());
+			////System.out.println(cntxt.getRanges().get(this).getStart());
 		}
 		
-		//system.out.println("########### END ###########");
+		////System.out.println("########### END ###########");
 		for(Context cntxt : this.sortedRanges.get("end")) {
-			//system.out.println(cntxt.getRanges().get(this).getEnd());
+			////System.out.println(cntxt.getRanges().get(this).getEnd());
 		}
 	}
 	
 	public void displaySortedRangesTreeSet() {
-		//system.out.println("########### SORTED RANGES DISPLAY TREE " + this.getName() +" ###########");
-		//system.out.println(sortedContextbyStartRanges.size()+ " " + sortedContextbyEndRanges.size());
-		//system.out.println("########### START ###########");
+		////System.out.println("########### SORTED RANGES DISPLAY TREE " + this.getName() +" ###########");
+		////System.out.println(sortedContextbyStartRanges.size()+ " " + sortedContextbyEndRanges.size());
+		////System.out.println("########### START ###########");
 		
 		for(Context ctxt: sortedContextbyStartRanges) {
-			//system.out.println(ctxt.getRanges().get(this).getStart());
+			////System.out.println(ctxt.getRanges().get(this).getStart());
 		}
 		
-		//system.out.println("########### END ###########");
+		////System.out.println("########### END ###########");
 		for(Context ctxt: sortedContextbyEndRanges) {
-			//system.out.println(ctxt.getRanges().get(this).getEnd());
+			////System.out.println(ctxt.getRanges().get(this).getEnd());
 		}
 	}
 	
@@ -553,7 +572,7 @@ public class Percept extends SystemAgent implements Serializable,Cloneable {
 	private void swapListElements(ArrayList<Context> list, int indexFirstElement) {
 		try {
 			list.add(indexFirstElement, list.get(indexFirstElement+1));
-			////system.out.println(list);
+			//////System.out.println(list);
 			list.remove(indexFirstElement+2);
 		} catch (OutOfRangeException e) {
 			// TODO: handle exception
@@ -579,8 +598,8 @@ public class Percept extends SystemAgent implements Serializable,Cloneable {
 		//displaySortedRanges();
 		//displaySortedRangesTreeSet();
 		
-		////system.out.println("----------------------AUTO PRINT");
-		////system.out.println(sortedEndRanges.size()+ " " + sortedStartRanges);
+		//////System.out.println("----------------------AUTO PRINT");
+		//////System.out.println(sortedEndRanges.size()+ " " + sortedStartRanges);
 	}
 	
 	private void insertContextInSortedRanges(Context context, String range) {
@@ -631,18 +650,18 @@ public class Percept extends SystemAgent implements Serializable,Cloneable {
 	
 	public void deleteContextProjection(Context context) {
 		contextProjections.remove(context);
-		//system.out.println("DELETION ------------------------------------------------------------------------------------------------------" + world.getScheduler().getTick());
-		//system.out.println(context.getName());
+		////System.out.println("DELETION ------------------------------------------------------------------------------------------------------" + world.getScheduler().getTick());
+		////System.out.println(context.getName());
 		displayContextProjections();
-		//system.out.println("----------------------------------------------------------------------------------------------------------------");
+		////System.out.println("----------------------------------------------------------------------------------------------------------------");
 	}
 	
 	
 	
 	public void updateContextProjectionStart(Context context) {
-		//system.out.println(context.getName());
-		//system.out.println(contextProjections.get(context));
-		//system.out.println(contextProjections.size() + " " + world.getScheduler().getContextsAsContext().size());
+		////System.out.println(context.getName());
+		////System.out.println(contextProjections.get(context));
+		////System.out.println(contextProjections.size() + " " + world.getScheduler().getContextsAsContext().size());
 		if(!context.isDying()) {
 			contextProjections.get(context).updateStart();
 		}
@@ -701,7 +720,7 @@ public class Percept extends SystemAgent implements Serializable,Cloneable {
 		double contextStart2 = getStartRangeProjection(context2);
 		double contextEnd1 = getEndRangeProjection(context1);
 		double contextEnd2 = getEndRangeProjection(context2);
-		////system.out.println(context1.getName() + "  " + contextStart1 + "  " + contextEnd1 + "  " + context2.getName() + "  " + contextStart2 + "  " + contextEnd2);
+		//////System.out.println(context1.getName() + "  " + contextStart1 + "  " + contextEnd1 + "  " + context2.getName() + "  " + contextStart2 + "  " + contextEnd2);
 		return ( (contextStart1< contextStart2 && contextStart2 <contextEnd1) || ((contextStart1< contextEnd2 && contextEnd2 <contextEnd1)) ) || ( (contextStart2< contextStart1 && contextStart1 <contextEnd2) || ((contextStart2< contextEnd1 && contextEnd1 <contextEnd2)) ) ;
 		
 	}
@@ -748,7 +767,7 @@ public class Percept extends SystemAgent implements Serializable,Cloneable {
 			overlapRanges.put("end", getEndRangeProjection(context2));
 		}
 		else {
-			////system.out.println("PROBLEM !!!!!!!!!!!!!!!!! " + context1.getName() + "  " + getStartRangeProjection(context1) + "  " + getEndRangeProjection(context1) + "  " + context2.getName()  + "  " + getStartRangeProjection(context2) + "  " + getEndRangeProjection(context2));
+			//////System.out.println("PROBLEM !!!!!!!!!!!!!!!!! " + context1.getName() + "  " + getStartRangeProjection(context1) + "  " + getEndRangeProjection(context1) + "  " + context2.getName()  + "  " + getStartRangeProjection(context2) + "  " + getEndRangeProjection(context2));
 			overlapRanges.put("start", -1.0);
 			overlapRanges.put("end", 1.0);
 			//return null;
@@ -779,4 +798,8 @@ public class Percept extends SystemAgent implements Serializable,Cloneable {
 	public Percept clone() throws CloneNotSupportedException{
 		return (Percept)super.clone();
 	}
+	
+	public double getRadiusContextForCreation() {
+		return getMinMaxDistance()*world.getContextCreationPercentage();
+	}
 }
diff --git a/AMOEBA3/src/mas/kernel/AMOEBA.java b/AMOEBA3/src/mas/kernel/AMOEBA.java
index 81595aadf3c28bd19090196e66b0ab809ee3447f..6caf1c133438096f57acd7020452ee2375c320d7 100644
--- a/AMOEBA3/src/mas/kernel/AMOEBA.java
+++ b/AMOEBA3/src/mas/kernel/AMOEBA.java
@@ -495,5 +495,28 @@ public class AMOEBA extends Thread {
 	public double getNumberOfContextAgents() {
 		return scheduler.getContexts().size();
 	}
+	
+	public void PAUSE(String message) {
+		System.out.println(message);
+		
+		if(!isRunning()) {
+			while(!getPlayOneStep()) {
+				scheduler.scheduledItemsAndView();
+
+				try        
+				{
+				    Thread.sleep(100);
+				} 
+				catch(InterruptedException ex) 
+				{
+				    Thread.currentThread().interrupt();
+				}
+				//System.out.println(getPlayOneStep());
+			}
+			setPlayOneStep(false);
+		}
+		
+	}
+
 
 }
\ No newline at end of file
diff --git a/AMOEBA3/src/mas/kernel/NCSMemory.java b/AMOEBA3/src/mas/kernel/NCSMemory.java
index 346ea1b8133339169a8ad6b91e328da432a0231d..ad46cabbc3dd8add5673e09bd02da23aa6068fbd 100644
--- a/AMOEBA3/src/mas/kernel/NCSMemory.java
+++ b/AMOEBA3/src/mas/kernel/NCSMemory.java
@@ -10,6 +10,7 @@ import mas.agents.percept.Percept;
 public class NCSMemory {
 
 	private ArrayList<Context> contexts = new ArrayList<Context>();
+	private ArrayList<Context> partiallyActivatedContexts = new ArrayList<Context>();
 	private ArrayList<Context> otherContexts = new ArrayList<Context>();
 	private ArrayList<Percept> percepts = new ArrayList<Percept>();;
 	private Head head;
@@ -36,8 +37,17 @@ public class NCSMemory {
 			for(Context ctxt : concernContexts) {
 				contexts.add(new Context(ctxt));
 			}
+			
+			for(Percept pct : world.getScheduler().getPercepts()) {
+				for(Context ctxt : world.getScheduler().getHeadAgent().getPartiallyActivatedContexts(pct)) {
+					partiallyActivatedContexts.add(new Context(ctxt));
+				}
+			}
+			
+			
+			
 			for(Context ctx : world.getScheduler().getContextsAsContext()) {
-				if(!concernContexts.contains(ctx)) {
+				if((!concernContexts.contains(ctx)) && (!partiallyActivatedContexts.contains(ctx))) {
 					otherContexts.add(new Context(ctx));
 				}
 			}
@@ -167,6 +177,10 @@ public class NCSMemory {
 		return otherContexts;
 	}
 	
+	public ArrayList<Context> getPartiallyActivatedContexts(){
+		return partiallyActivatedContexts;
+	}
+	
 	public ArrayList<Percept> getPercepts(){
 		return percepts;
 	}
diff --git a/AMOEBA3/src/mas/kernel/Scheduler.java b/AMOEBA3/src/mas/kernel/Scheduler.java
index 0b3aa6cd436d5eff9e3a93956bf1ad2583d2a3df..d5b5327dcb90e41a118589a4750612ee1d28e988 100644
--- a/AMOEBA3/src/mas/kernel/Scheduler.java
+++ b/AMOEBA3/src/mas/kernel/Scheduler.java
@@ -242,7 +242,7 @@ public class Scheduler implements Serializable{
 		}
 	}
 	
-	private void scheduledItemsAndView() {
+	public void scheduledItemsAndView() {
 		//Scheduled item
 		if (scheduled == null) scheduled = new ArrayList<ScheduledItem>();
 		
@@ -355,7 +355,9 @@ public class Scheduler implements Serializable{
 //		}
 		
 		
-
+		for(Context ctxt : getContextsAsContext()) {
+			ctxt.clearNonValidPerceptNeighbors();
+		}
 
 
 	}
diff --git a/AMOEBA3/src/mas/kernel/World.java b/AMOEBA3/src/mas/kernel/World.java
index 88f7f448662704d010ae84164933517bb35eb4a2..8400c2b859b73ec617767b861d95ef09720f67b6 100644
--- a/AMOEBA3/src/mas/kernel/World.java
+++ b/AMOEBA3/src/mas/kernel/World.java
@@ -89,10 +89,16 @@ public class World implements Serializable {
 	
 	public int tickThreshol = 10000;
 	
+	private double contextCreationPercentage = 0.2;
+	
 	public World() {
 		
 	}
 	
+	public double getContextCreationPercentage() {
+		return contextCreationPercentage;
+	}
+	
 	/**
 	 * Instantiates a new world.
 	 *
@@ -868,4 +874,9 @@ public class World implements Serializable {
 		return increment_up ;
 	}
 	
+	public double getNeighborhood(Context ctxt, Percept pct) {
+		return 2*ctxt.getRanges().get(pct).getRadius();
+		
+	}
+	
 }
diff --git a/AMOEBA3/src/visualization/view/system/twoDim/GrapheTwoDimPanelNCSMemories.java b/AMOEBA3/src/visualization/view/system/twoDim/GrapheTwoDimPanelNCSMemories.java
index c62941b5a5a356416e89defaca9174ce50ad98cc..f52d4a4a85553febd6bc99f45822e4a9b1c36892 100644
--- a/AMOEBA3/src/visualization/view/system/twoDim/GrapheTwoDimPanelNCSMemories.java
+++ b/AMOEBA3/src/visualization/view/system/twoDim/GrapheTwoDimPanelNCSMemories.java
@@ -386,7 +386,10 @@ public class GrapheTwoDimPanelNCSMemories extends JPanel implements ViewerListen
 		//System.out.println("NODES before : " + graph.getNodeSet().size() );
 		for(Context ctxt : memoryContexts) {
 			//System.out.println(ctxt.getName());
-			graph.removeNode(ctxt.getName());
+			if(graph.getNode(ctxt.getName())!=null) {
+				graph.removeNode(ctxt.getName());
+			}
+			
 		}
 		clearMemory();
 		//System.out.println("NODES after : " + graph.getNodeSet().size() );
@@ -394,154 +397,23 @@ public class GrapheTwoDimPanelNCSMemories extends JPanel implements ViewerListen
 		//setView(2);
 		
 		//System.out.println("Ctxt to draw : " + ncsMemory.getContexts().size() );
-		for (Context ctxt : ncsMemory.getContexts()) {
-
-			String name = ctxt.getName();
-			Node node;
-			memoryContexts.add(ctxt);
-			//System.out.println(name);
-			graph.addNode(name);
-			node = graph.getNode(name);
-			node.addAttribute("ui.class", ctxt.getClass().getSimpleName());
-			node.addAttribute("ui.label", ctxt.getName());
+		
+		
+		for (Context ctxt : ncsMemory.getOtherContexts()) {
 
-			node.addAttribute("EXIST", true);
-			if (ctxt.getRanges().size() > 0){
-				drawRectangle(node, ctxt);
-			}
-			
+			drawContexts(ctxt, 50);
 			
+		}
+		
+		for (Context ctxt : ncsMemory.getContexts()) {
 
-			Double r = 0.0;
-			Double g = 0.0;
-			Double b = 0.0;
-			double[] coefs = ctxt.getLocalModel().getCoef();
-			//System.out.println("COEFS : " + coefs.length);
-			if(coefs.length>0) {
-				if(coefs.length==1) {
-					//System.out.println(coefs[0]);	
-					b = normalizePositiveValues(255, 5, Math.abs(coefs[0]));
-					if(b.isNaN()) {
-						b = 0.0;
-					}
-				}
-				else if(coefs.length==2) {
-					//System.out.println(coefs[0] + " " + coefs[1]);
-					g =  normalizePositiveValues(255, 5, Math.abs(coefs[0]));
-					b =  normalizePositiveValues(255, 5, Math.abs(coefs[1]));
-					if(g.isNaN()) {
-						g = 0.0;
-					}
-					if(b.isNaN()) {
-						b = 0.0;
-					}
-				}
-				else if(coefs.length>=3) {
-					//System.out.println(coefs[0] + " " + coefs[1] + " " + coefs[2]);
-					r =  normalizePositiveValues(255, 5,  Math.abs(coefs[0]));
-					g =  normalizePositiveValues(255, 5,  Math.abs(coefs[1]));
-					b =  normalizePositiveValues(255, 5,  Math.abs(coefs[2]));
-					if(r.isNaN()) {
-						r = 0.0;
-					}
-					if(g.isNaN()) {
-						g = 0.0;
-					}
-					if(b.isNaN()) {
-						b = 0.0;
-					}
-				}
-				else {
-					r = 255.0;
-					g = 255.0;
-					b = 255.0;
-				}
-			}
-			else {
-				r = 255.0;
-				g = 255.0;
-				b = 255.0;
-			}
-			
-			node.addAttribute("ui.class","RGBAColor");
-			//System.out.println("COLORS : " + r + " " + g + " " + b);
-			
-			node.addAttribute("ui.style", "fill-color: rgba(" + r.intValue() + "," + g.intValue() + "," + b.intValue() + ",150);");
+			drawContexts(ctxt, 150);
 			
 		}
 		
-		for (Context ctxt : ncsMemory.getOtherContexts()) {
+		for (Context ctxt : ncsMemory.getPartiallyActivatedContexts()) {
 
-			String name = ctxt.getName();
-			Node node;
-			memoryContexts.add(ctxt);
-			//System.out.println(name);
-			graph.addNode(name);
-			node = graph.getNode(name);
-			node.addAttribute("ui.class", ctxt.getClass().getSimpleName());
-			node.addAttribute("ui.label", ctxt.getName());
-
-			node.addAttribute("EXIST", true);
-			if (ctxt.getRanges().size() > 0){
-				drawRectangle(node, ctxt);
-			}
-			
-			
-			Double r = 0.0;
-			Double g = 0.0;
-			Double b = 0.0;
-			double[] coefs = ctxt.getLocalModel().getCoef();
-			//System.out.println("COEFS : " + coefs.length);
-			if(coefs.length>0) {
-				if(coefs.length==1) {
-					//System.out.println(coefs[0]);	
-					b = normalizePositiveValues(255, 5, Math.abs(coefs[0]));
-					if(b.isNaN()) {
-						b = 0.0;
-					}
-				}
-				else if(coefs.length==2) {
-					//System.out.println(coefs[0] + " " + coefs[1]);
-					g =  normalizePositiveValues(255, 5, Math.abs(coefs[0]));
-					b =  normalizePositiveValues(255, 5, Math.abs(coefs[1]));
-					if(g.isNaN()) {
-						g = 0.0;
-					}
-					if(b.isNaN()) {
-						b = 0.0;
-					}
-				}
-				else if(coefs.length>=3) {
-					//System.out.println(coefs[0] + " " + coefs[1] + " " + coefs[2]);
-					r =  normalizePositiveValues(255, 5,  Math.abs(coefs[0]));
-					g =  normalizePositiveValues(255, 5,  Math.abs(coefs[1]));
-					b =  normalizePositiveValues(255, 5,  Math.abs(coefs[2]));
-					if(r.isNaN()) {
-						r = 0.0;
-					}
-					if(g.isNaN()) {
-						g = 0.0;
-					}
-					if(b.isNaN()) {
-						b = 0.0;
-					}
-				}
-				else {
-					r = 255.0;
-					g = 255.0;
-					b = 255.0;
-				}
-			}
-			else {
-				r = 255.0;
-				g = 255.0;
-				b = 255.0;
-			}
-			
-			node.addAttribute("ui.class","RGBAColor");
-			//System.out.println("COLORS : " + r + " " + g + " " + b);
-			
-			node.addAttribute("ui.style", "fill-color: rgba(" + r.intValue() + "," + g.intValue() + "," + b.intValue() + ",50);");
+			drawContexts(ctxt, 150);
 			
 		}
 	
@@ -566,6 +438,85 @@ public class GrapheTwoDimPanelNCSMemories extends JPanel implements ViewerListen
 		textarea.setText(ncsMemory.toStringDetailled());
 	}
 	
+	
+	private void drawContexts(Context ctxt, int transparence) {
+		
+		String name = ctxt.getName();
+		Node node;
+		memoryContexts.add(ctxt);
+		//System.out.println(name);
+		if(graph.getNode(name)==null) {
+			graph.addNode(name);
+		}
+		
+		node = graph.getNode(name);
+		node.addAttribute("ui.class", ctxt.getClass().getSimpleName());
+		node.addAttribute("ui.label", ctxt.getName());
+
+		node.addAttribute("EXIST", true);
+		if (ctxt.getRanges().size() > 0){
+			drawRectangle(node, ctxt);
+		}
+		
+		
+		Double r = 0.0;
+		Double g = 0.0;
+		Double b = 0.0;
+		double[] coefs = ctxt.getLocalModel().getCoef();
+		//System.out.println("COEFS : " + coefs.length);
+		if(coefs.length>0) {
+			if(coefs.length==1) {
+				//System.out.println(coefs[0]);	
+				b = normalizePositiveValues(255, 5, Math.abs(coefs[0]));
+				if(b.isNaN()) {
+					b = 0.0;
+				}
+			}
+			else if(coefs.length==2) {
+				//System.out.println(coefs[0] + " " + coefs[1]);
+				g =  normalizePositiveValues(255, 5, Math.abs(coefs[0]));
+				b =  normalizePositiveValues(255, 5, Math.abs(coefs[1]));
+				if(g.isNaN()) {
+					g = 0.0;
+				}
+				if(b.isNaN()) {
+					b = 0.0;
+				}
+			}
+			else if(coefs.length>=3) {
+				//System.out.println(coefs[0] + " " + coefs[1] + " " + coefs[2]);
+				r =  normalizePositiveValues(255, 5,  Math.abs(coefs[0]));
+				g =  normalizePositiveValues(255, 5,  Math.abs(coefs[1]));
+				b =  normalizePositiveValues(255, 5,  Math.abs(coefs[2]));
+				if(r.isNaN()) {
+					r = 0.0;
+				}
+				if(g.isNaN()) {
+					g = 0.0;
+				}
+				if(b.isNaN()) {
+					b = 0.0;
+				}
+			}
+			else {
+				r = 255.0;
+				g = 255.0;
+				b = 255.0;
+			}
+		}
+		else {
+			r = 255.0;
+			g = 255.0;
+			b = 255.0;
+		}
+		
+		node.addAttribute("ui.class","RGBAColor");
+		//System.out.println("COLORS : " + r + " " + g + " " + b);
+		
+		node.addAttribute("ui.style", "fill-color: rgba(" + r.intValue() + "," + g.intValue() + "," + b.intValue() + "," + transparence + ");");
+		
+	}
+	
 	public void addNCSmemomry(NCSMemory ncsMemory) {
 		NCSsituations.addItem(ncsMemory);
 		NCSsituations2.addItem(ncsMemory);
@@ -1325,11 +1276,17 @@ private void startPanelController() {
 		}
 		
 		
-		Node originNode;
-		originNode = graph.getNode("origin");
-		originNode.addAttribute("EXIST", true);
-		originNode.setAttribute("xyz", 0, 0, 0);
-		originNode.addAttribute("ui.style", "size: " + doubleFormat.format(2) + "gu, " + doubleFormat.format(2) +"gu;");
+		Node originNode1;
+		originNode1 = graph.getNode("origin1");
+		originNode1.addAttribute("EXIST", true);
+		originNode1.setAttribute("xyz", 0, 0, 0);
+		originNode1.addAttribute("ui.style", "size: " + doubleFormat.format(1) + "gu, " + doubleFormat.format(3) +"gu;");
+		
+		Node originNode2;
+		originNode2 = graph.getNode("origin2");
+		originNode2.addAttribute("EXIST", true);
+		originNode2.setAttribute("xyz", 0, 0, 0);
+		originNode2.addAttribute("ui.style", "size: " + doubleFormat.format(3) + "gu, " + doubleFormat.format(1) +"gu;");
 
 	}
 	
@@ -1744,28 +1701,29 @@ private void startPanelController() {
 		System.out.println("Context pushed : " + id);
 		
 		String info = "";
-		if (rememberState) {
-			Observation o = getObservationByTick(sliderValue);
-			if (o != null) {
-				Context c = o.getContextById(id);
-				if ( c != null ) {
-					info = "State :" + sliderValue + "\n";
-					info = info.concat(o.getContextById(id).toStringFull());
-					info = info.replace("Current", "\nCurrent");
-					info = info.replace("AVT", "\nAVT");
-				} else {
-					info = "No context";
-				}
-				
-			} 
-			
-		} else {
-			info = "State :" + currentTick + "\n";
-			info = info.concat(world.getAgents().get(id).toString());
-			info = info.replace("Current", "\nCurrent");
-			info = info.replace("AVT", "\nAVT");
-		}
+//		if (rememberState) {
+//			Observation o = getObservationByTick(sliderValue);
+//			if (o != null) {
+//				Context c = o.getContextById(id);
+//				if ( c != null ) {
+//					info = "State :" + sliderValue + "\n";
+//					info = info.concat(o.getContextById(id).toStringFull());
+//					info = info.replace("Current", "\nCurrent");
+//					info = info.replace("AVT", "\nAVT");
+//				} else {
+//					info = "No context";
+//				}
+//				
+//			} 
+//			
+//		} else {
+//			info = "State :" + currentTick + "\n";
+//			info = info.concat(world.getAgents().get(id).toString());
+//			info = info.replace("Current", "\nCurrent");
+//			info = info.replace("AVT", "\nAVT");
+//		}
 		
+		info += world.getScheduler().getContextByName(id).toStringFull();
 		textarea.setText(info);
 		
 	}
diff --git a/AMOEBA3/src/visualization/view/system/twoDim/GrapheTwoDimPanelStandard.java b/AMOEBA3/src/visualization/view/system/twoDim/GrapheTwoDimPanelStandard.java
index b22073450021ebc2b298128099287bcd633f064d..c4e51abc55cc8d2364e2f059a9c8812872d67380 100644
--- a/AMOEBA3/src/visualization/view/system/twoDim/GrapheTwoDimPanelStandard.java
+++ b/AMOEBA3/src/visualization/view/system/twoDim/GrapheTwoDimPanelStandard.java
@@ -12,6 +12,8 @@ import java.awt.Robot;
 import java.awt.dnd.Autoscroll;
 import java.awt.event.ActionEvent;
 import java.awt.event.InputEvent;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
 import java.awt.event.KeyEvent;
 import java.awt.event.MouseEvent;
 import java.awt.event.MouseListener;
@@ -48,6 +50,7 @@ import javax.swing.event.ChangeListener;
 import javax.swing.event.MouseInputListener;
 
 import mas.kernel.Config;
+import mas.kernel.NCSMemory;
 import mas.kernel.Scheduler;
 import mas.kernel.World;
 import visualization.log.LogMessageType;
@@ -182,6 +185,7 @@ public class GrapheTwoDimPanelStandard extends JPanel implements ViewerListener,
 	private JLabel labelSearchContext = new JLabel("Search Context :");
 	private JTextField contextID = new JTextField("?");
 	
+	private JComboBox<Context> Contexts;
 
 	
 	/** The mouse event. */
@@ -355,6 +359,34 @@ public class GrapheTwoDimPanelStandard extends JPanel implements ViewerListener,
 		xValue = new JLabel();
 		yValue = new JLabel();
 		
+		Contexts = new JComboBox<Context>();
+		Contexts.addItemListener(new ItemListener() {
+			
+			@Override
+			public void itemStateChanged(ItemEvent e) {
+				
+				
+				
+				recolorContexts();
+				
+				
+				if(Contexts.getSelectedItem()!=null) {
+					
+					Node node = graph.getNode(((Context) Contexts.getSelectedItem()).getName());
+					node.addAttribute("ui.style", "fill-color: rgba(0,255,0,150);");
+				}
+
+				
+				
+				
+			}
+		});
+		
+		
+		
+		toolBar.add(Contexts);
+		
+		
 		toolBar.add(labelSearchContext);
 		contextID.setSize(new Dimension(50,30));
 		toolBar.add(contextID);
@@ -1016,14 +1048,29 @@ private void startPanelController() {
 	}
 
 	private void setOrigin() {
-		Node originNode;
-		graph.addNode("origin");
-		originNode = graph.getNode("origin");
-		originNode.addAttribute("EXIST", true);
+
+		
+		Node originNode1;
+		
+		graph.addNode("origin1");
+		originNode1 = graph.getNode("origin1");
+		originNode1.addAttribute("EXIST", true);
+		originNode1.setAttribute("xyz", 0, 0, 0);
+		originNode1.addAttribute("ui.style", "size: " + doubleFormat.format(0.2) + "gu, " + doubleFormat.format(4) +"gu;");
+		originNode1.addAttribute("ui.class","RGBAColor");
+		
+		originNode1.addAttribute("ui.style", "fill-color: rgba(0,0,0,255);");
 		
-		originNode.setAttribute("xyz", 0, 0, 0);
+		Node originNode2;
 		
-		originNode.addAttribute("ui.style", "size: " + doubleFormat.format(0.5) + "gu, " + doubleFormat.format(0.5) +"gu;");
+		graph.addNode("origin2");
+		originNode2 = graph.getNode("origin2");
+		originNode2.addAttribute("EXIST", true);
+		originNode2.setAttribute("xyz", 0, 0, 0);
+		originNode2.addAttribute("ui.style", "size: " + doubleFormat.format(4) + "gu, " + doubleFormat.format(0.2) +"gu;");
+		originNode2.addAttribute("ui.class","RGBAColor");
+		
+		originNode2.addAttribute("ui.style", "fill-color: rgba(0,0,0,255);");
 	}
 	
 	/**
@@ -1163,59 +1210,99 @@ private void startPanelController() {
 			}		
 
 
-			for (String name : world.getAgents().keySet()) {
-				SystemAgent a = world.getAgents().get(name);
-				if (a instanceof Context) {
-					Context n = (Context)a;
-					Node node = graph.getNode(name);
+			
+			recolorContexts();
+			
+			
+			for(Context context : world.getScheduler().getContextsAsContext()) {
+				for(ContextOverlap contextOverlap : context.contextOverlaps) {
+					world.getScheduler().getView().getTabbedPanel().getPanelTwoDimStandard().drawOverlap(contextOverlap);
+				}
+				
+				for(ContextVoid contextVoid : context.contextVoids) {
+					world.getScheduler().getView().getTabbedPanel().getPanelTwoDimStandard().drawVoid(contextVoid);
+				}
+				
+			}
 
-					//node.addAttribute("ui.class","ContextColorDynamic");
-					//node.setAttribute("ui.color", (n.getActionProposal() - min) / (max - min) ); 
-//					node.setAttribute("ui.color", 0.0 ); 
-					
-					Double r = 0.0;
-					Double g = 0.0;
-					Double b = 0.0;
-					double[] coefs = n.getLocalModel().getCoef();
-					//System.out.println("COEFS : " + coefs.length);
-					if(coefs.length>0) {
-						if(coefs.length==1) {
-							//System.out.println(coefs[0]);	
-							b = normalizePositiveValues(255, 5, Math.abs(coefs[0]));
-							if(b.isNaN()) {
-								b = 0.0;
-							}
+		}
+		
+		
+		Node originNode1;
+		originNode1 = graph.getNode("origin1");
+		originNode1.addAttribute("EXIST", true);
+		originNode1.setAttribute("xyz", 0, 0, 0);
+		originNode1.addAttribute("ui.style", "size: " + doubleFormat.format(0.5) + "gu, " + doubleFormat.format(2) +"gu;");
+		originNode1.addAttribute("ui.class","RGBAColor");
+		
+		originNode1.addAttribute("ui.style", "fill-color: rgba(0,0,0,255);");
+		
+		Node originNode2;
+		originNode2 = graph.getNode("origin2");
+		originNode2.addAttribute("EXIST", true);
+		originNode2.setAttribute("xyz", 0, 0, 0);
+		originNode2.addAttribute("ui.style", "size: " + doubleFormat.format(2) + "gu, " + doubleFormat.format(0.5) +"gu;");
+		originNode2.addAttribute("ui.class","RGBAColor");
+		
+		originNode2.addAttribute("ui.style", "fill-color: rgba(0,0,0,255);");
+		
+		
+		Contexts.removeAllItems();
+		Contexts.addItem(null);
+		for(Context ctxt : world.getScheduler().getContextsAsContext()) {
+			Contexts.addItem(ctxt);
+		}
+
+	}
+	
+	public void recolorContexts() {
+		for (String name : world.getAgents().keySet()) {
+			SystemAgent a = world.getAgents().get(name);
+			if (a instanceof Context) {
+				Context n = (Context)a;
+				Node node = graph.getNode(name);
+
+				//node.addAttribute("ui.class","ContextColorDynamic");
+				//node.setAttribute("ui.color", (n.getActionProposal() - min) / (max - min) ); 
+//				node.setAttribute("ui.color", 0.0 ); 
+				
+				Double r = 0.0;
+				Double g = 0.0;
+				Double b = 0.0;
+				double[] coefs = n.getLocalModel().getCoef();
+				//System.out.println("COEFS : " + coefs.length);
+				if(coefs.length>0) {
+					if(coefs.length==1) {
+						//System.out.println(coefs[0]);	
+						b = normalizePositiveValues(255, 5, Math.abs(coefs[0]));
+						if(b.isNaN()) {
+							b = 0.0;
+						}
+					}
+					else if(coefs.length==2) {
+						//System.out.println(coefs[0] + " " + coefs[1]);
+						g =  normalizePositiveValues(255, 5, Math.abs(coefs[0]));
+						b =  normalizePositiveValues(255, 5, Math.abs(coefs[1]));
+						if(g.isNaN()) {
+							g = 0.0;
 						}
-						else if(coefs.length==2) {
-							//System.out.println(coefs[0] + " " + coefs[1]);
-							g =  normalizePositiveValues(255, 5, Math.abs(coefs[0]));
-							b =  normalizePositiveValues(255, 5, Math.abs(coefs[1]));
-							if(g.isNaN()) {
-								g = 0.0;
-							}
-							if(b.isNaN()) {
-								b = 0.0;
-							}
+						if(b.isNaN()) {
+							b = 0.0;
+						}
+					}
+					else if(coefs.length>=3) {
+						//System.out.println(coefs[0] + " " + coefs[1] + " " + coefs[2]);
+						r =  normalizePositiveValues(255, 5,  Math.abs(coefs[0]));
+						g =  normalizePositiveValues(255, 5,  Math.abs(coefs[1]));
+						b =  normalizePositiveValues(255, 5,  Math.abs(coefs[2]));
+						if(r.isNaN()) {
+							r = 0.0;
 						}
-						else if(coefs.length>=3) {
-							//System.out.println(coefs[0] + " " + coefs[1] + " " + coefs[2]);
-							r =  normalizePositiveValues(255, 5,  Math.abs(coefs[0]));
-							g =  normalizePositiveValues(255, 5,  Math.abs(coefs[1]));
-							b =  normalizePositiveValues(255, 5,  Math.abs(coefs[2]));
-							if(r.isNaN()) {
-								r = 0.0;
-							}
-							if(g.isNaN()) {
-								g = 0.0;
-							}
-							if(b.isNaN()) {
-								b = 0.0;
-							}
+						if(g.isNaN()) {
+							g = 0.0;
 						}
-						else {
-							r = 255.0;
-							g = 255.0;
-							b = 255.0;
+						if(b.isNaN()) {
+							b = 0.0;
 						}
 					}
 					else {
@@ -1223,45 +1310,49 @@ private void startPanelController() {
 						g = 255.0;
 						b = 255.0;
 					}
-					
-					node.addAttribute("ui.class","RGBAColor");
-					
-					node.addAttribute("ui.style", "fill-color: rgba(" + r.intValue() + "," + g.intValue() + "," + b.intValue() + ",100);");
-
-					
-					if(world.getScheduler().getHeadAgent().getActivatedContexts().contains(n)) {
-						node.addAttribute("ui.style", "fill-color: rgba(0,0,255,150);");
-					}
-					
-					
+				}
+				else {
+					r = 255.0;
+					g = 255.0;
+					b = 255.0;
 				}
 				
+				node.addAttribute("ui.class","RGBAColor");
 				
+				node.addAttribute("ui.style", "fill-color: rgba(" + r.intValue() + "," + g.intValue() + "," + b.intValue() + ",100);");
 
-			}
-			
-			
+				
+				
+				
+				
+				
+//				for(Percept pct : world.getScheduler().getPercepts()) {
+//					if(world.getScheduler().getHeadAgent().getPartiallyActivatedNeighborContexts(pct).contains(n)) {
+//						node.addAttribute("ui.style", "fill-color: rgba(0,255,255,150);");
+//					}
+//				}
 			
-			for(Context context : world.getScheduler().getContextsAsContext()) {
-				for(ContextOverlap contextOverlap : context.contextOverlaps) {
-					world.getScheduler().getView().getTabbedPanel().getPanelTwoDimStandard().drawOverlap(contextOverlap);
+//				for(Percept pct : world.getScheduler().getPercepts()) {
+//					if(world.getScheduler().getHeadAgent().getPartiallyActivatedContexts(pct).contains(n)) {
+//						node.addAttribute("ui.style", "fill-color: rgba(0,0,255,150);");
+//					}
+//				}
+//				
+				//System.out.println(world.getScheduler().getTick() + " Neighbor size "+ world.getScheduler().getHeadAgent().getActivatedNeighborsContexts().size());
+				if(world.getScheduler().getHeadAgent().getActivatedNeighborsContexts().contains(n)) {
+					node.addAttribute("ui.style", "fill-color: rgba(255,0,255,200);");
 				}
-				
-				for(ContextVoid contextVoid : context.contextVoids) {
-					world.getScheduler().getView().getTabbedPanel().getPanelTwoDimStandard().drawVoid(contextVoid);
+//				
+				if(world.getScheduler().getHeadAgent().getActivatedContexts().contains(n)) {
+					node.addAttribute("ui.style", "fill-color: rgba(255,0,0,200);");
 				}
+
 				
 			}
+			
+			
 
 		}
-		
-		
-		Node originNode;
-		originNode = graph.getNode("origin");
-		originNode.addAttribute("EXIST", true);
-		originNode.setAttribute("xyz", 0, 0, 0);
-		originNode.addAttribute("ui.style", "size: " + doubleFormat.format(2) + "gu, " + doubleFormat.format(2) +"gu;");
-
 	}