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

ENH: subgroups of sorted contexts by percept overlaps

parent 8432286b
No related branches found
No related tags found
1 merge request!1Merge Master
...@@ -143,6 +143,24 @@ public class AMOEBA_UI { ...@@ -143,6 +143,24 @@ public class AMOEBA_UI {
System.out.println(c.getName()+ " ---> " + context.neigbours.get(c)); System.out.println(c.getName()+ " ---> " + context.neigbours.get(c));
} }
System.out.println("************************** SORTED NEIGHBOURS **************************");
for(Percept percept : getAllPercepts(usedAmoeba)) {
System.out.println("**************************" + percept.getName() + "**************************");
HashMap<String, ArrayList<Context>> neighbourscontextSortedContexts = context.getNearestNeighbour(percept, "start");
System.out.println("************************** START **************************");
for(Context cntxt : neighbourscontextSortedContexts.get("start")) {
System.out.println(cntxt.getName() + "--->" + cntxt.getRanges().get(percept).getStart());
}
System.out.println("************************** END **************************");
for(Context cntxt : neighbourscontextSortedContexts.get("end")) {
System.out.println(cntxt.getName() + "--->" + cntxt.getRanges().get(percept).getEnd());
}
}
} }
......
...@@ -896,11 +896,12 @@ private Percept getPerceptWithLesserImpactOnVolume(ArrayList<Percept> containing ...@@ -896,11 +896,12 @@ private Percept getPerceptWithLesserImpactOnVolume(ArrayList<Percept> containing
return test; return test;
} }
public Context getNearestNeighbour(Percept percept, Range range) { public HashMap<String , ArrayList<Context>> getNearestNeighbour(Percept percept, String rangeSide) {
Context nearestNeighbour; Context nearestNeighbour;
ArrayList<Percept> otherPercetps = new ArrayList<Percept>();; ArrayList<Percept> otherPercetps = new ArrayList<Percept>();;
ArrayList<Context> contextOverlapedInOtherPercepts = new ArrayList<Context>(); ArrayList<Context> contextOverlapedInOtherPercepts = new ArrayList<Context>();
boolean contextOverlapedInOtherPerceptsTest = true;
for(Percept p : ranges.keySet()) { for(Percept p : ranges.keySet()) {
if(p != percept) { if(p != percept) {
...@@ -908,17 +909,23 @@ private Percept getPerceptWithLesserImpactOnVolume(ArrayList<Percept> containing ...@@ -908,17 +909,23 @@ private Percept getPerceptWithLesserImpactOnVolume(ArrayList<Percept> containing
} }
} }
for(Context ctxt : contextOverlapsByPercept.keySet()) { for(Context ctxt : contextOverlapsByPercept.keySet()) {
contextOverlapedInOtherPerceptsTest = true;
for(Percept otherPctpt: otherPercetps) { for(Percept otherPctpt: otherPercetps) {
if(contextOverlapsByPercept.get(ctxt).get(otherPctpt)) { contextOverlapedInOtherPerceptsTest = contextOverlapedInOtherPerceptsTest && contextOverlapsByPercept.get(ctxt).get(otherPctpt);
contextOverlapedInOtherPercepts.add(ctxt); }
} if(contextOverlapedInOtherPerceptsTest) {
contextOverlapedInOtherPercepts.add(ctxt);
} }
} }
HashMap<String , ArrayList<Context>> sortedRangesSubGroup = new HashMap<String , ArrayList<Context>>();
sortedRangesSubGroup.put("start", percept.getSortedRangesSubGroup(contextOverlapedInOtherPercepts, "start"));
sortedRangesSubGroup.put("end", percept.getSortedRangesSubGroup(contextOverlapedInOtherPercepts, "end"));
return nearestNeighbour; return sortedRangesSubGroup;
} }
} }
...@@ -337,6 +337,18 @@ public class Percept extends SystemAgent implements Serializable { ...@@ -337,6 +337,18 @@ public class Percept extends SystemAgent implements Serializable {
return sortedRanges; return sortedRanges;
} }
public ArrayList<Context> getSortedRangesSubGroup(ArrayList<Context> subGroupOfContexts, String rangeString){
ArrayList<Context> sortedRangesSubGroup = new ArrayList<Context>();
for(Context ctxt : sortedRanges.get(rangeString)) {
if(subGroupOfContexts.contains(ctxt)) {
sortedRangesSubGroup.add(ctxt);
}
}
return sortedRangesSubGroup;
}
/* /*
* Sorted Ranges methods * Sorted Ranges methods
*/ */
...@@ -385,6 +397,8 @@ public class Percept extends SystemAgent implements Serializable { ...@@ -385,6 +397,8 @@ public class Percept extends SystemAgent implements Serializable {
sortedRanges.get("end").remove(context); sortedRanges.get("end").remove(context);
} }
/* /*
* Context projection methods * Context projection methods
*/ */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment