Skip to content
Snippets Groups Projects
Commit 71dba61d authored by BrunoDatoMeneses's avatar BrunoDatoMeneses
Browse files

ENH: context creation filling void

parent b34926e3
Branches
No related tags found
No related merge requests found
Showing
with 1240 additions and 520 deletions
......@@ -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);
}
}
......
......@@ -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;
}
}
This diff is collapsed.
......@@ -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);
......
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();
}
}
This diff is collapsed.
......@@ -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) {
......
......@@ -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();
}
}
......@@ -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
......@@ -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;
}
......
......@@ -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();
}
}
......
......@@ -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();
}
}
......@@ -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);
}
......
......@@ -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;");
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment