diff --git a/AMOEBAonAMAK/src/agents/context/Context.java b/AMOEBAonAMAK/src/agents/context/Context.java index 41d7af9ecdc65f0d8a1386e2126fa79c9ad424c9..aeb93fd4c076c7ae331d2a7f8de9f8d5053ab8f5 100644 --- a/AMOEBAonAMAK/src/agents/context/Context.java +++ b/AMOEBAonAMAK/src/agents/context/Context.java @@ -117,10 +117,16 @@ public class Context extends AmoebaAgent { //TODO use neihbors sizes to define radiuses for creation !!!!!!!!!!! Pair<Double, Double> radiuses = getAmas().getHeadAgent().getRadiusesForContextCreation(p); + + + if(getAmas().getHeadAgent().activatedNeighborsContexts.size()>0) { + double radiusCreation = getAmas().getHeadAgent().minNeighborhoodRadius; + //double radiusCreation = getAmas().getHeadAgent().meanNeighborhoodRaduises.get(p); + //double radiusCreation = getAmas().getHeadAgent().minMeanNeighborhoodRaduises; getAmas().getEnvironment() .trace(TRACE_LEVEL.INFORM, new ArrayList<String>(Arrays.asList("Range creation by mean", this.getName(), p.getName(), getAmas().getHeadAgent().meanNeighborhoodRaduises.get(p).toString()))); - r = new Range(this, p.getValue() - getAmas().getHeadAgent().minMeanNeighborhoodRaduises, p.getValue() + getAmas().getHeadAgent().minMeanNeighborhoodRaduises, 0, true, true, p, getAmas().getHeadAgent().minMeanNeighborhoodStartIncrements, getAmas().getHeadAgent().minMeanNeighborhoodEndIncrements); + r = new Range(this, p.getValue() - radiusCreation, p.getValue() + radiusCreation, 0, true, true, p, getAmas().getHeadAgent().minMeanNeighborhoodStartIncrements, getAmas().getHeadAgent().minMeanNeighborhoodEndIncrements); }else { r = new Range(this, p.getValue() - radiuses.getA(), p.getValue() + radiuses.getB(), 0, true, true, p); getAmas().getEnvironment() @@ -200,9 +206,12 @@ public class Context extends AmoebaAgent { if(getAmas().getHeadAgent().activatedNeighborsContexts.size()>0) { + double radiusCreation = getAmas().getHeadAgent().minNeighborhoodRadius; + //double radiusCreation = getAmas().getHeadAgent().meanNeighborhoodRaduises.get(p); + //double radiusCreation = getAmas().getHeadAgent().minMeanNeighborhoodRaduises; getAmas().getEnvironment() .trace(TRACE_LEVEL.INFORM, new ArrayList<String>(Arrays.asList("Range creation by mean", this.getName(), p.getName(), getAmas().getHeadAgent().meanNeighborhoodRaduises.get(p).toString()))); - r = new Range(this, p.getValue() - getAmas().getHeadAgent().minMeanNeighborhoodRaduises, p.getValue() + getAmas().getHeadAgent().minMeanNeighborhoodRaduises, 0, true, true, p, getAmas().getHeadAgent().minMeanNeighborhoodStartIncrements, getAmas().getHeadAgent().minMeanNeighborhoodEndIncrements); + r = new Range(this, p.getValue() - radiusCreation, p.getValue() + radiusCreation, 0, true, true, p, getAmas().getHeadAgent().minMeanNeighborhoodStartIncrements, getAmas().getHeadAgent().minMeanNeighborhoodEndIncrements); }else { r = new Range(this, p.getValue() - radiuses.getA(), p.getValue() + radiuses.getB(), 0, true, true, p); getAmas().getEnvironment() diff --git a/AMOEBAonAMAK/src/agents/head/Head.java b/AMOEBAonAMAK/src/agents/head/Head.java index 625e54154606cc659fe13c5b5be460b9c237c084..1a0c84121e30d7b5369124ee08921b720cb7ca42 100644 --- a/AMOEBAonAMAK/src/agents/head/Head.java +++ b/AMOEBAonAMAK/src/agents/head/Head.java @@ -51,6 +51,10 @@ public class Head extends AmoebaAgent { public Double minMeanNeighborhoodStartIncrements = null; public Double minMeanNeighborhoodEndIncrements = null; + public Double minNeighborhoodRadius = null; + public Double minNeighborhoodStartIncrement = null; + public Double minNeighborhoodEndIncrement = null; + Queue<EndogenousRequest> endogenousRequests = new PriorityQueue<EndogenousRequest>(new Comparator<EndogenousRequest>(){ public int compare(EndogenousRequest r1, EndogenousRequest r2) { @@ -98,6 +102,10 @@ public class Head extends AmoebaAgent { minMeanNeighborhoodStartIncrements = Double.POSITIVE_INFINITY; minMeanNeighborhoodEndIncrements = Double.POSITIVE_INFINITY; + minNeighborhoodRadius = Double.POSITIVE_INFINITY; + minNeighborhoodStartIncrement = Double.POSITIVE_INFINITY; + minNeighborhoodEndIncrement = Double.POSITIVE_INFINITY; + getAmas().data.currentCriticalityPrediction = 0; getAmas().data.currentCriticalityMapping = 0; getAmas().data.currentCriticalityConfidence = 0; @@ -124,6 +132,9 @@ public class Head extends AmoebaAgent { HashMap<Percept,Double> neighborhoodRangesSums = new HashMap<Percept,Double>(); HashMap<Percept,Double> neighborhoodStartIncrementSums = new HashMap<Percept,Double>(); HashMap<Percept,Double> neighborhoodEndIncrementSums = new HashMap<Percept,Double>(); + + + for (Percept pct : getAmas().getPercepts()) { neighborhoodRangesSums.put(pct, 0.0); neighborhoodStartIncrementSums.put(pct, 0.0); @@ -145,6 +156,22 @@ public class Head extends AmoebaAgent { Double oldRadiusSum = neighborhoodRangesSums.get(pct); Double oldStartIncrSum = neighborhoodStartIncrementSums.get(pct); Double oldEndIncrSum = neighborhoodEndIncrementSums.get(pct); + + if( ctxt.getRanges().get(pct).getRadius() < minNeighborhoodRadius) { + minNeighborhoodRadius = ctxt.getRanges().get(pct).getRadius(); + } + + if( ctxt.getRanges().get(pct).getStartIncrement() < minNeighborhoodStartIncrement) { + minNeighborhoodStartIncrement = ctxt.getRanges().get(pct).getStartIncrement(); + } + + if( ctxt.getRanges().get(pct).getEndIncrement() < minNeighborhoodEndIncrement) { + minNeighborhoodEndIncrement = ctxt.getRanges().get(pct).getEndIncrement(); + } + + + + neighborhoodRangesSums.put(pct, oldRadiusSum + ctxt.getRanges().get(pct).getRadius()); neighborhoodStartIncrementSums.put(pct, oldStartIncrSum + ctxt.getRanges().get(pct).getStartIncrement()); neighborhoodEndIncrementSums.put(pct, oldEndIncrSum + ctxt.getRanges().get(pct).getEndIncrement()); diff --git a/AMOEBAonAMAK/src/agents/percept/Percept.java b/AMOEBAonAMAK/src/agents/percept/Percept.java index 82493994ac8974392f24deeae46d5e527af5f651..eaa2e3173840ae973d0e0be823418e94b501d757 100644 --- a/AMOEBAonAMAK/src/agents/percept/Percept.java +++ b/AMOEBAonAMAK/src/agents/percept/Percept.java @@ -392,7 +392,7 @@ public class Percept extends AmoebaAgent { } public double getMappingErrorAllowedMin() { - return getMinMaxDistance() * getEnvironment().getMappingErrorAllowed() * 0.5; + return getMinMaxDistance() * getEnvironment().getMappingErrorAllowed() * 0.25; } public double getMappingErrorAllowedOverMapping() { diff --git a/AMOEBAonAMAK/src/experiments/nDimensionsLaunchers/F_N_Manager.java b/AMOEBAonAMAK/src/experiments/nDimensionsLaunchers/F_N_Manager.java index df46653e5a7c450b51481e3d00e350b44260d9b5..968cac30920cc02e6018c124babb7807e8c64cfd 100644 --- a/AMOEBAonAMAK/src/experiments/nDimensionsLaunchers/F_N_Manager.java +++ b/AMOEBAonAMAK/src/experiments/nDimensionsLaunchers/F_N_Manager.java @@ -302,7 +302,7 @@ public class F_N_Manager implements StudiedSystem{ //return (y*y + x*x < spaceSize*spaceSize ) ? 2*x + y : 5*x - 8*y; /* Square */ - //return (x1 > -spaceSize && x1 < spaceSize && x0 < spaceSize && x0 > -spaceSize) ? model1(x0,x1) : model2(x0,x1) ; + //return (xRequest[0] > -spaceSize && xRequest[0] < spaceSize && xRequest[1] < spaceSize && xRequest[1] > -spaceSize) ? model1(xRequest[0],xRequest[1]) : model2(xRequest[0],xRequest[1]) ; //return model1(); /* Triangle */