diff --git a/AMOEBA3/project b/AMOEBA3/.oldproject similarity index 100% rename from AMOEBA3/project rename to AMOEBA3/.oldproject diff --git a/AMOEBA3/Ressources/BadContext.xml b/AMOEBA3/Ressources/BadContext.xml new file mode 100644 index 0000000000000000000000000000000000000000..1282720b9e9d3dd30cf8d4019ceb3972fe8b25ee --- /dev/null +++ b/AMOEBA3/Ressources/BadContext.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> +<BlackBox> + + <Inputs> + </Inputs> + + <Outputs> + <Output Name="x" DefaultValue="0"></Output> + <Output Name="y" DefaultValue="0"></Output> + <Output Name="test" DefaultValue="0"></Output> + </Outputs> + + + + + <Functions> + </Functions> + +</BlackBox> \ No newline at end of file diff --git a/AMOEBA3/Ressources/BadContext_solver.xml b/AMOEBA3/Ressources/BadContext_solver.xml new file mode 100644 index 0000000000000000000000000000000000000000..75a2966a9bed78da3045403d414031cc9a1d33ca --- /dev/null +++ b/AMOEBA3/Ressources/BadContext_solver.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<System> + + <!-- General config options --> + <Configuration> + <Learning allowed = "true" creationOfNewContext = "true" loadPresetContext = "false"></Learning> + </Configuration> + + + <StartingAgents> + + <Sensor Name="px" Source="x"></Sensor> + <Sensor Name="py" Source="y"></Sensor> + + <Controller Name="Controller" Oracle="test"></Controller> + + + + </StartingAgents> + + +</System> diff --git a/AMOEBA3/Ressources/parallelCoordinates.html b/AMOEBA3/Ressources/parallelCoordinates.html new file mode 100644 index 0000000000000000000000000000000000000000..db50a73d133663b9a954b647ed760c308649bf36 --- /dev/null +++ b/AMOEBA3/Ressources/parallelCoordinates.html @@ -0,0 +1,128 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<style> + +svg { + font: 10px sans-serif; +} + +.background path { + fill: none; + stroke: #ccc; + stroke-opacity: .4; + shape-rendering: crispEdges; +} + +.foreground path { + fill: none; + stroke: steelblue; + stroke-opacity: .7; +} + +.brush .extent { + fill-opacity: .3; + stroke: #fff; + shape-rendering: crispEdges; +} + +.axis line, .axis path { + fill: none; + stroke: #000; + shape-rendering: crispEdges; +} + +.axis text { + text-shadow: 0 1px 0 #fff; +} + +</style> +<body> +<script src="http://mbostock.github.com/d3/d3.js?2.7.1"></script> +<script src="http://mbostock.github.com/d3/d3.csv.js?2.7.1"></script> +<script> + +var m = [30, 10, 10, 10], + w = 960 - m[1] - m[3], + h = 500 - m[0] - m[2]; + +var x = d3.scale.ordinal().rangePoints([0, w], .5), + y = {}; + +var line = d3.svg.line(), + axis = d3.svg.axis().orient("left"), + background, + foreground; + +var svg = d3.select("body").append("svg") + .attr("width", w + m[1] + m[3]) + .attr("height", h + m[0] + m[2]) + .append("g") + .attr("transform", "translate(" + m[3] + "," + m[0] + ")"); + +d3.csv("contexts.csv", function(cities) { + + // Extract the list of dimensions and create a scale for each. + x.domain(dimensions = d3.keys(cities[0]).filter(function(d) { + return d != "City" && (y[d] = d3.scale.linear() + .domain(d3.extent(cities, function(p) { return +p[d]; })) + .range([h, 0])); + })); + + // Add grey background lines for context. + background = svg.append("g") + .attr("class", "background") + .selectAll("path") + .data(cities) + .enter().append("path") + .attr("d", path); + + // Add blue foreground lines for focus. + foreground = svg.append("g") + .attr("class", "foreground") + .selectAll("path") + .data(cities) + .enter().append("path") + .attr("d", path); + + // Add a group element for each dimension. + var g = svg.selectAll(".dimension") + .data(dimensions) + .enter().append("g") + .attr("class", "dimension") + .attr("transform", function(d) { return "translate(" + x(d) + ")"; }); + + // Add an axis and title. + g.append("g") + .attr("class", "axis") + .each(function(d) { d3.select(this).call(axis.scale(y[d])); }) + .append("text") + .attr("text-anchor", "middle") + .attr("y", -9) + .text(String); + + // Add and store a brush for each axis. + g.append("g") + .attr("class", "brush") + .each(function(d) { d3.select(this).call(y[d].brush = d3.svg.brush().y(y[d]).on("brush", brush)); }) + .selectAll("rect") + .attr("x", -8) + .attr("width", 16); +}); + +// Returns the path for a given data point. +function path(d) { + return line(dimensions.map(function(p) { return [x(p), y[p](d[p])]; })); +} + +// Handles a brush event, toggling the display of foreground lines. +function brush() { + var actives = dimensions.filter(function(p) { return !y[p].brush.empty(); }), + extents = actives.map(function(p) { return y[p].brush.extent(); }); + foreground.style("display", function(d) { + return actives.every(function(p, i) { + return extents[i][0] <= d[p] && d[p] <= extents[i][1]; + }) ? null : "none"; + }); +} + +</script> diff --git a/AMOEBA3/Ressources/styleBlackBox.css b/AMOEBA3/Ressources/styleBlackBox.css new file mode 100644 index 0000000000000000000000000000000000000000..7351e2e63be49991c62a39e95f9b61a0176c90f5 --- /dev/null +++ b/AMOEBA3/Ressources/styleBlackBox.css @@ -0,0 +1,26 @@ +graph { + fill-color: white; +} +node { size-mode: fit; shape: rounded-box; padding: 3px, 2px; } + +node.Input { + fill-color: green; +} + +node.Output { + fill-color: orange; +} + +node.Function { + fill-color: grey; +} + + +edge { + arrow-shape: arrow; + arrow-size: 6px, 4px; +} + +node:clicked { + fill-color: blue; +} \ No newline at end of file diff --git a/AMOEBA3/pom.xml b/AMOEBA3/pom.xml index 34413bce6566f795d875fef9579cbf1503a1756d..b4887d634432d0f90d05461d821d9a5f53437427 100644 --- a/AMOEBA3/pom.xml +++ b/AMOEBA3/pom.xml @@ -7,88 +7,85 @@ <dependencies> - <!-- /home/arcady/unisync/irit/AMOEBA2/AMOEBA/forms-1.3.0.jar --> + <dependency> <groupId>com.jgoodies</groupId> <artifactId>jgoodies-forms</artifactId> <version>1.9.0</version> </dependency> - <!-- /home/arcady/unisync/irit/AMOEBA2/AMOEBA/forms-1.3.0-src.zip --> - <!-- /home/arcady/unisync/irit/AMOEBA2/AMOEBA/java-json.jar --> - <!-- /home/arcady/unisync/irit/AMOEBA2/AMOEBA/jdom-2.0.5.jar --> + <dependency> <groupId>org.jdom</groupId> <artifactId>jdom2</artifactId> <version>2.0.5</version> </dependency> - <!-- /home/arcady/unisync/irit/AMOEBA2/AMOEBA/log4j-1.2.17.jar --> + <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.17</version> </dependency> - <!-- /home/arcady/unisync/irit/AMOEBA2/AMOEBA/mqtt-client-1.7-uber.jar --> + <dependency> <groupId>org.fusesource.mqtt-client</groupId> <artifactId>mqtt-client-java1.4-uber</artifactId> <version>1.7</version> </dependency> - <!-- /home/arcady/unisync/irit/AMOEBA2/AMOEBA/slf4j-api-1.7.22.jar --> + <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.7.22</version> </dependency> - <!-- /home/arcady/unisync/irit/AMOEBA2/AMOEBA/slf4j-log4j12-1.7.22.jar --> + <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.7.22</version> </dependency> - <!-- /home/arcady/git/AMOEBA2/AMOEBA/src/asm-all-3.3.jar --> + <dependency> <groupId>asm</groupId> <artifactId>asm-all</artifactId> <version>3.3</version> </dependency> - <!-- /home/arcady/git/AMOEBA2/AMOEBA/src/guava-18.0.jar --> + <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>18.0</version> </dependency> - <!-- /home/arcady/git/AMOEBA2/AMOEBA/src/jdom.jar --> - <!-- /home/arcady/git/AMOEBA2/AMOEBA/src/junit-4.8.2.jar --> + <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.8.2</version> </dependency> - <!--/home/arcady/git/AMOEBA2/AMOEBA/src/jfreechart/jfreechart-1.0.19.jar --> + <dependency> <groupId>org.jfree</groupId> <artifactId>jfreechart</artifactId> <version>1.0.19</version> </dependency> - <!-- /home/arcady/git/AMOEBA2/AMOEBA/src/jfreechart/jcommon-1.0.23.jar --> + <dependency> <groupId>org.jfree</groupId> <artifactId>jcommon</artifactId> <version>1.0.23</version> </dependency> - <!-- /home/arcady/git/AMOEBA2/AMOEBA/src/gs-algo-1.3 --> + <dependency> <groupId>org.graphstream</groupId> <artifactId>gs-algo</artifactId> <version>1.3</version> </dependency> - <!-- /home/arcady/git/AMOEBA2/AMOEBA/src/gs-ui-1.3 --> + <dependency> <groupId>org.graphstream</groupId> <artifactId>gs-ui</artifactId> <version>1.3</version> </dependency> - <!-- /home/arcady/git/AMOEBA2/AMOEBA/src/Apache-Commons/commons-math3-3.5/commons-math3-3.5.jar --> + <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-math3</artifactId> @@ -101,7 +98,7 @@ <version>2.10.3</version> </dependency> - <!-- /home/arcady/git/AMOEBA2/AMOEBA/MarioAI --> + <dependency> <groupId>AIToolKit</groupId> @@ -139,7 +136,7 @@ - <build> + <!-- <build> <sourceDirectory>src</sourceDirectory> @@ -162,5 +159,5 @@ </configuration> </plugin> </plugins> - </build> + </build> --> </project> \ No newline at end of file diff --git a/AMOEBA3/src/MAS/agents/ContextProjection.java b/AMOEBA3/src/MAS/agents/ContextProjection.java index 6d6d3fbe0c33f25b9af867eebb6342885ef6e3aa..f2f2e24dc680345373443420a7eed778e07e0e76 100644 --- a/AMOEBA3/src/MAS/agents/ContextProjection.java +++ b/AMOEBA3/src/MAS/agents/ContextProjection.java @@ -54,4 +54,6 @@ public class ContextProjection implements Serializable{ public Context getContex() { return this.context; } + + } diff --git a/AMOEBA3/src/MAS/agents/Percept.java b/AMOEBA3/src/MAS/agents/Percept.java index ce1b5dbb3d848a7dca6b5fd65827d337cd876e6d..a74c3f98bdde4067eec20af7ddb33cbde1570f76 100644 --- a/AMOEBA3/src/MAS/agents/Percept.java +++ b/AMOEBA3/src/MAS/agents/Percept.java @@ -26,7 +26,11 @@ public class Percept extends SystemAgent implements Serializable { protected ArrayList<Agent> activatedContext = new ArrayList<Agent>(); public HashMap<Context, ContextProjection> contextProjections = new HashMap<Context, ContextProjection>(); - public ArrayList<Context> validContexteProjection = new ArrayList<Context>(); + public ArrayList<Context> validContextProjection = new ArrayList<Context>(); + public HashMap<String, PerceptOverlap> perceptOverlaps = new HashMap<String, PerceptOverlap>(); + public HashMap<String, ArrayList<Context>> sortedRanges = new HashMap<String, ArrayList<Context>>(); + //public ArrayList<Context> sortedStartRanges = new ArrayList<Context>(); + //public ArrayList<Context> sortedEndRanges = new ArrayList<Context>(); private double min = Double.MAX_VALUE; private double max = Double.MIN_VALUE; @@ -104,8 +108,13 @@ public class Percept extends SystemAgent implements Serializable { this.max = p.max; this.isEnum = p.isEnum; - contextProjections = new HashMap<Context, ContextProjection>(); - validContexteProjection = new ArrayList<Context>(); + this.contextProjections = new HashMap<Context, ContextProjection>(); + this.validContextProjection = new ArrayList<Context>(); + this.perceptOverlaps = new HashMap<String, PerceptOverlap>(); + + this.sortedRanges.put("start", new ArrayList<Context>()); + this.sortedRanges.put("end", new ArrayList<Context>()); + } @@ -124,17 +133,18 @@ public class Percept extends SystemAgent implements Serializable { } public void computeContextProjectionValidity() { - validContexteProjection = new ArrayList<Context>(); + validContextProjection = new ArrayList<Context>(); for(ContextProjection contextProjection : contextProjections.values()) { if(contextProjection.contains(this.value)) { - validContexteProjection.add(contextProjection.getContex()); + validContextProjection.add(contextProjection.getContex()); System.out.println("Percept "+this.name+ " Context "+contextProjection.getContex().getName()); } } - for(Context context : validContexteProjection) { + for(Context context : validContextProjection) { context.setPerceptValidity(this); } + } @@ -323,13 +333,162 @@ public class Percept extends SystemAgent implements Serializable { contextProjections.put(context, newContextProjection); } + public void addContextSortedRanges(Context context) { + + if(sortedRanges.isEmpty()) { + sortedRanges.put("start", new ArrayList<Context>()); + sortedRanges.put("end", new ArrayList<Context>()); + } + if(sortedRanges.get("start").size()==0) { + sortedRanges.get("start").add(context); + } + else { + insertContextInSortedRanges(context, "start"); + } + + if(sortedRanges.get("end").size()==0) { + sortedRanges.get("end").add(context); + } + else { + insertContextInSortedRanges(context, "end"); + } + + } + + private void insertContextInSortedRanges(Context context, String range) { + + int i = 0; + boolean inserted = false; + while(i<sortedRanges.get(range).size() && !inserted) { + if(getRangeProjection(context, range) < getRangeProjection(sortedRanges.get(range).get(i), range)) { + sortedRanges.get(range).add(i, context); + inserted = true; + } + i+=1; + } + if(i==sortedRanges.get(range).size() && !inserted) { + sortedRanges.get(range).add(context); + } + + } + public void deleteContextProjection(Context context) { contextProjections.remove(context); } + public void deleteContextRanges(Context context) { + sortedRanges.get("start").remove(context); + sortedRanges.get("end").remove(context); + } + public void updateContextProjection(Context context) { contextProjections.get(context).update(); } + + public void overlapNotification() { + for(PerceptOverlap perceptOverlap : perceptOverlaps.values()) { + ArrayList<Context> contexts = perceptOverlap.getContexts(); + contexts.get(0).setPerceptOverlap(this, contexts.get(1)); + contexts.get(1).setPerceptOverlap(this, contexts.get(0)); + } + } + public void overlapsDetection() { + + ArrayList<Context> computedContexts = new ArrayList<Context>(); + for(Context selectedContext : contextProjections.keySet()) { + + for(Context testedContext : contextProjections.keySet()) { + + if((testedContext != selectedContext) && (!computedContexts.contains(testedContext))){ + if(overlapBetweenContexts(selectedContext, testedContext)) { + + String overlapName = selectedContext.getName() + testedContext.getName(); + HashMap<String, Double> overlapRanges = getOverlapRangesBetweenContexts(selectedContext, testedContext); + + PerceptOverlap overlap = new PerceptOverlap(selectedContext, testedContext, overlapRanges.get("start"), overlapRanges.get("end"), overlapName); + perceptOverlaps.put(overlapName, overlap); + } + } + } + + computedContexts.add(selectedContext); + } + } + public boolean overlapBetweenContexts(Context context1, Context context2) { + + double contextStart1 = getStartRangeProjection(context1); + double contextStart2 = getStartRangeProjection(context2); + double contextEnd1 = getEndRangeProjection(context1); + double contextEnd2 = getEndRangeProjection(context2); + + return ( (contextStart1< contextStart2 && contextStart2 <contextEnd1) || ((contextStart1< contextEnd2 && contextEnd2 <contextEnd1)) ) ; + + } + + public double getRangeProjection(Context context, String range) { + if(range.equals("start")) { + return context.getRanges().get(this).getStart(); + } + else if(range.equals("end")) { + return context.getRanges().get(this).getEnd(); + } + else { + return 0; + } + + } + + public double getEndRangeProjection(Context context) { + return context.getRanges().get(this).getEnd(); + } + + public double getStartRangeProjection(Context context) { + return context.getRanges().get(this).getStart(); + } + + public HashMap<String, Double> getOverlapRangesBetweenContexts(Context context1, Context context2) { + + HashMap<String, Double> overlapRanges = new HashMap<String, Double>(); + + if( contextIncludedIn(context1, context2) ) { + overlapRanges.put("start", getStartRangeProjection(context1)); + overlapRanges.put("end", getEndRangeProjection(context1)); + } + else if(contextIncludedIn(context2, context1) ) { + overlapRanges.put("start", getStartRangeProjection(context2)); + overlapRanges.put("end", getEndRangeProjection(context2)); + } + else if(contextOrder(context1, context2)) { + overlapRanges.put("start", getStartRangeProjection(context2)); + overlapRanges.put("end", getEndRangeProjection(context1)); + } + else if(contextOrder(context2, context1)) { + overlapRanges.put("start", getStartRangeProjection(context1)); + overlapRanges.put("end", getEndRangeProjection(context2)); + } + + + return overlapRanges; + } + + public boolean contextIncludedIn(Context includedContext, Context includingContext) { + + double includedContextStart = getStartRangeProjection(includedContext); + double includingContextStart = getStartRangeProjection(includingContext); + double includedContextEnd = getEndRangeProjection(includedContext); + double includingContextEnd = getEndRangeProjection(includingContext); + + return ( (includingContextStart< includedContextStart && includedContextStart <includingContextEnd) && ((includingContextStart< includedContextEnd && includedContextEnd <includingContextEnd)) ); + } + + public boolean contextOrder(Context context1, Context context2) { + + double contextStart1 = getStartRangeProjection(context1); + double contextStart2 = getStartRangeProjection(context2); + double contextEnd1 = getEndRangeProjection(context1); + + return (contextStart1< contextStart2 && contextStart2 <contextEnd1) ; + } } diff --git a/AMOEBA3/src/MAS/agents/PerceptOverlap.java b/AMOEBA3/src/MAS/agents/PerceptOverlap.java new file mode 100644 index 0000000000000000000000000000000000000000..5f634b2fcbc8cc74814b7d6511962268866c7d61 --- /dev/null +++ b/AMOEBA3/src/MAS/agents/PerceptOverlap.java @@ -0,0 +1,30 @@ +package MAS.agents; + +import java.util.ArrayList; + +import MAS.agents.context.Context; + +public class PerceptOverlap { + + private double start; + private double end; + private Context context1; + private Context context2; + private String name; + + + public PerceptOverlap(Context context1, Context context2, double start, double end, String name) { + this.start = start; + this.end = end; + this.context1 = context1; + this.context2 = context2; + this.name = name; + } + + public ArrayList<Context> getContexts(){ + ArrayList<Context> contexts = new ArrayList<Context>(); + contexts.add(context1); + contexts.add(context2); + return contexts; + } +} diff --git a/AMOEBA3/src/MAS/agents/context/Context.java b/AMOEBA3/src/MAS/agents/context/Context.java index 52123a4f29d73196dc4ea8e7592a0a75b8767743..28286bbe8fc9c2163f045b07ba9979da09b13fd1 100644 --- a/AMOEBA3/src/MAS/agents/context/Context.java +++ b/AMOEBA3/src/MAS/agents/context/Context.java @@ -53,7 +53,9 @@ public class Context extends AbstractContext implements Serializable{ private boolean valid = false; private boolean firstTimePeriod = true; - private HashMap<Percept, Boolean> perceptValidities = new HashMap<Percept, Boolean>(); + private HashMap<Percept, Boolean> perceptValidities = new HashMap<Percept, Boolean>(); + public HashMap<Context, HashMap<Percept, Boolean>> contextOverlapsByPercept = new HashMap<Context, HashMap<Percept, Boolean>>(); + public HashMap<Context,String> neigbours = new HashMap<Context,String>(); /** @@ -95,6 +97,7 @@ public class Context extends AbstractContext implements Serializable{ firstPoint.addDimension(v, v.getValue()); v.addContextProjection(this); + v.addContextSortedRanges(this); } localModel = this.world.buildLocalModel(this); firstPoint.setProposition(this.controller.getOracleValue()); @@ -108,6 +111,10 @@ public class Context extends AbstractContext implements Serializable{ for(Percept percept : var) { perceptValidities.put(percept, false); } + + contextOverlapsByPercept = new HashMap<Context, HashMap<Percept, Boolean>>(); + + neigbours = new HashMap<Context,String>(); } /** @@ -834,6 +841,20 @@ private Percept getPerceptWithLesserImpactOnVolume(ArrayList<Percept> containing perceptValidities.put(percept, true); } + public void setPerceptOverlap(Percept percept, Context context) { + if(!contextOverlapsByPercept.keySet().contains(context)) { + contextOverlapsByPercept.put(context, new HashMap<Percept,Boolean>()); + + for(Percept p : ranges.keySet()) { + contextOverlapsByPercept.get(context).put(p, false); + } + } + + contextOverlapsByPercept.get(context).put(percept, true); + } + + + public Boolean computeValidityByPercepts() { Boolean test = true; for(Percept percept : perceptValidities.keySet()) { @@ -842,5 +863,22 @@ private Percept getPerceptWithLesserImpactOnVolume(ArrayList<Percept> containing } return test; } + + public Boolean computeOverlapsByPercepts() { + Boolean test = true; + + for(Context context : contextOverlapsByPercept.keySet()) { + test = true; + for(Percept percept : ranges.keySet()) { + test = test && contextOverlapsByPercept.get(context).get(percept); + } + if(test) { + neigbours.put(context, "Overlap"); + } + } + + + return test; + } } diff --git a/AMOEBA3/src/MAS/kernel/Config.java b/AMOEBA3/src/MAS/kernel/Config.java index cc264a3bfdde3d91fbcfe34c30febed04a96facc..0cc170d465e018c04d43cb50baa519193dae0671 100644 --- a/AMOEBA3/src/MAS/kernel/Config.java +++ b/AMOEBA3/src/MAS/kernel/Config.java @@ -41,7 +41,7 @@ public class Config implements Serializable { public static ImageIcon getIcon (String name) { if (!icons.containsKey(name)) { try { - icons.put(name, new ImageIcon(ImageIO.read(Config.class.getResourceAsStream("/src/VISUALIZATION/icons/" + name)))); + icons.put(name, new ImageIcon(ImageIO.read(Config.class.getResourceAsStream("/VISUALIZATION/icons/" + name)))); } catch (IOException e) { e.printStackTrace(); } diff --git a/AMOEBA3/src/MAS/kernel/Scheduler.java b/AMOEBA3/src/MAS/kernel/Scheduler.java index d44779542c2a4e0f167c808d382ed0daec267a13..b0b2bbbc3e7e918ce3e3d3bfc25d6f21559982ad 100644 --- a/AMOEBA3/src/MAS/kernel/Scheduler.java +++ b/AMOEBA3/src/MAS/kernel/Scheduler.java @@ -573,7 +573,7 @@ public class Scheduler implements Serializable{ * * @return the variables */ - public ArrayList<Percept> getVariables() { + public ArrayList<Percept> getPercepts() { return percepts; } diff --git a/AMOEBA3/src/MAS/kernel/World.java b/AMOEBA3/src/MAS/kernel/World.java index 7d3f30dac55507f9b1883717b3970bed839b282c..e3921bf865896570c3e92b895d77fa93d0f540a7 100644 --- a/AMOEBA3/src/MAS/kernel/World.java +++ b/AMOEBA3/src/MAS/kernel/World.java @@ -733,7 +733,7 @@ public class World implements Serializable { * @return the all percept */ public ArrayList<Percept> getAllPercept() { - return scheduler.getVariables(); + return scheduler.getPercepts(); } /** diff --git a/AMOEBA3/src/VISUALIZATION/view/blackbox/GrapheBlackBoxPanel.java b/AMOEBA3/src/VISUALIZATION/view/blackbox/GrapheBlackBoxPanel.java index fee6c4627cdccea25d42fa045ee280010aa3921f..d2aaceb7932d4dbe296a696acd0a29a322c3a314 100644 --- a/AMOEBA3/src/VISUALIZATION/view/blackbox/GrapheBlackBoxPanel.java +++ b/AMOEBA3/src/VISUALIZATION/view/blackbox/GrapheBlackBoxPanel.java @@ -182,7 +182,7 @@ public class GrapheBlackBoxPanel extends JPanel implements MouseInputListener, V for (String name : blackBox.getBlackBoxAgents().keySet()) { BlackBoxAgent bba = blackBox.getBlackBoxAgents().get(name); //graph.addAttribute("ui.stylesheet", "url('file:"+System.getProperty("user.dir")+"/bin/styles/styleBlackBox.css')"); - graph.addAttribute("ui.stylesheet", "url('" + this.getClass().getClassLoader().getResource("src/VISUALIZATION/styles/styleBlackBox.css") + "')"); + graph.addAttribute("ui.stylesheet", "url('" + this.getClass().getClassLoader().getResource("styleBlackBox.css") + "')"); /* graph.addAttribute("ui.stylesheet", "node { stroke-mode: plain;" + "fill-color: red;" diff --git a/AMOEBA3/src/VISUALIZATION/view/multiAMOEBA/PanelGraphAMOEBA.java b/AMOEBA3/src/VISUALIZATION/view/multiAMOEBA/PanelGraphAMOEBA.java index 716f62db5ac8aff540049427c418c9efd053448f..1074aa4a19458e4ceec490e9ae54f5538331594a 100644 --- a/AMOEBA3/src/VISUALIZATION/view/multiAMOEBA/PanelGraphAMOEBA.java +++ b/AMOEBA3/src/VISUALIZATION/view/multiAMOEBA/PanelGraphAMOEBA.java @@ -73,7 +73,7 @@ public class PanelGraphAMOEBA extends JPanel implements ViewerListener, MouseInp graph.addNode("jkuyg"); graph.addNode("rdrdufg"); //graph.addAttribute("ui.stylesheet", "url('file:"+System.getProperty("user.dir")+"/bin/styles/styleAMOEBA.css')"); - graph.addAttribute("ui.stylesheet", "url('" + this.getClass().getClassLoader().getResource("src/styles/styleAMOEBA.css") + "')"); + graph.addAttribute("ui.stylesheet", "url('" + this.getClass().getClassLoader().getResource("/styles/styleAMOEBA.css") + "')"); } diff --git a/AMOEBA3/src/VISUALIZATION/view/system/GrapheSystemPanel.java b/AMOEBA3/src/VISUALIZATION/view/system/GrapheSystemPanel.java index e80c57154a582123868cab7b4b6f39375aa2cbb6..b680886a37646e8140edf21107e24e8e07952954 100644 --- a/AMOEBA3/src/VISUALIZATION/view/system/GrapheSystemPanel.java +++ b/AMOEBA3/src/VISUALIZATION/view/system/GrapheSystemPanel.java @@ -173,7 +173,7 @@ public class GrapheSystemPanel extends JPanel implements ViewerListener, MouseIn public void setStandardStyle() { graph.removeAttribute("ui.stylesheet"); //graph.addAttribute("ui.stylesheet", "url('file:"+System.getProperty("user.dir")+"/bin/styles/styleSystem.css')"); - graph.addAttribute("ui.stylesheet", "url('" + this.getClass().getClassLoader().getResource("src/styles/styleSystem.css") + "')"); + graph.addAttribute("ui.stylesheet", "url('" + this.getClass().getClassLoader().getResource("/styles/styleSystem.css") + "')"); //"url('file:"+System.getProperty("user.dir")+"/bin/styles/styleSystemSoft.css')" } @@ -183,7 +183,7 @@ public class GrapheSystemPanel extends JPanel implements ViewerListener, MouseIn public void setDarkStyle() { graph.removeAttribute("ui.stylesheet"); //graph.addAttribute("ui.stylesheet", "url('file:"+System.getProperty("user.dir")+"/bin/styles/styleSystemDark.css')"); - graph.addAttribute("ui.stylesheet", "url('" + this.getClass().getClassLoader().getResource("src/styles/styleSystemDark.css") + "')"); + graph.addAttribute("ui.stylesheet", "url('" + this.getClass().getClassLoader().getResource("/styles/styleSystemDark.css") + "')"); } /** @@ -192,7 +192,7 @@ public class GrapheSystemPanel extends JPanel implements ViewerListener, MouseIn public void setSoftStyle() { graph.removeAttribute("ui.stylesheet"); //graph.addAttribute("ui.stylesheet", "url('file:"+System.getProperty("user.dir")+"/bin/styles/styleSystemSoft.css')"); - graph.addAttribute("ui.stylesheet", "url('" + this.getClass().getClassLoader().getResource("src/styles/styleSystemSoft.css") + "')"); + graph.addAttribute("ui.stylesheet", "url('" + this.getClass().getClassLoader().getResource("/styles/styleSystemSoft.css") + "')"); } /** diff --git a/AMOEBA3/src/VISUALIZATION/view/system/nDim/PanelParallelCoordinates.java b/AMOEBA3/src/VISUALIZATION/view/system/nDim/PanelParallelCoordinates.java index fc7697ebb9dc47ff0c574afc43cb90a979b2d05e..2646caffb3b4b6e3582c682bff2e65f85dc08d13 100644 --- a/AMOEBA3/src/VISUALIZATION/view/system/nDim/PanelParallelCoordinates.java +++ b/AMOEBA3/src/VISUALIZATION/view/system/nDim/PanelParallelCoordinates.java @@ -73,7 +73,7 @@ public class PanelParallelCoordinates extends JFXPanel{ webEngine = browser.getEngine(); //webEngine.load("file://" + System.getProperty( "user.dir") + "/bin/view/system/nDim/parallelCoordinates.html"); - InputStream input = getClass().getClassLoader().getResourceAsStream("src/VISUALIZATION/view/system/nDim/parallelCoordinates.html"); + InputStream input = getClass().getClassLoader().getResourceAsStream("parallelCoordinates.html"); File file = new File(System.getProperty( "user.dir") + "/tmp/parallelCoordinates.html"); diff --git a/AMOEBA3/src/VISUALIZATION/view/system/twoDim/GrapheTwoDimPanelStandard.java b/AMOEBA3/src/VISUALIZATION/view/system/twoDim/GrapheTwoDimPanelStandard.java index b3a061bec56503d4275fc452cf41906623e39458..7d4f15c6ad7c72202ab60fd4e0caa8ea172fec8e 100644 --- a/AMOEBA3/src/VISUALIZATION/view/system/twoDim/GrapheTwoDimPanelStandard.java +++ b/AMOEBA3/src/VISUALIZATION/view/system/twoDim/GrapheTwoDimPanelStandard.java @@ -701,7 +701,7 @@ private void startPanelController() { public void setStandardStyle() { graph.removeAttribute("ui.stylesheet"); //graph.addAttribute("ui.stylesheet", "url('file:"+System.getProperty("user.dir")+"/bin/styles/styleSystemScalable.css')"); - graph.addAttribute("ui.stylesheet", "url('" + this.getClass().getClassLoader().getResource("src/VISUALIZATION/styles/styleSystemScalable.css") + "')"); + graph.addAttribute("ui.stylesheet", "url('" + this.getClass().getClassLoader().getResource("VISUALIZATION/styles/styleSystemScalable.css") + "')"); } /** @@ -710,7 +710,7 @@ private void startPanelController() { public void setDarkStyle() { graph.removeAttribute("ui.stylesheet"); //graph.addAttribute("ui.stylesheet", "url('file:"+System.getProperty("user.dir")+"/bin/styles/styleSystemDark.css')"); - graph.addAttribute("ui.stylesheet", "url('" + this.getClass().getClassLoader().getResource("src/VISUALIZATION/styles/styleSystemDark.css") + "')"); + graph.addAttribute("ui.stylesheet", "url('" + this.getClass().getClassLoader().getResource("VISUALIZATION/styles/styleSystemDark.css") + "')"); } /** @@ -719,7 +719,7 @@ private void startPanelController() { public void setSoftStyle() { graph.removeAttribute("ui.stylesheet"); //graph.addAttribute("ui.stylesheet", "url('file:"+System.getProperty("user.dir")+"/bin/styles/styleSystemSoft.css')"); - graph.addAttribute("ui.stylesheet", "url('" + this.getClass().getClassLoader().getResource("src/VISUALIZATION/styles/styleSystemSoft.css") + "')"); + graph.addAttribute("ui.stylesheet", "url('" + this.getClass().getClassLoader().getResource("VISUALIZATION/styles/styleSystemSoft.css") + "')"); } diff --git a/AMOEBA3/src/experiments/badContext/AMOEBA_UI.java b/AMOEBA3/src/experiments/badContext/AMOEBA_UI.java index a9b08209eb639ff4bcf95e7f39cd866226b057d4..1b33fb9032f40d3a208872b5731c0e6e6b1aea7c 100644 --- a/AMOEBA3/src/experiments/badContext/AMOEBA_UI.java +++ b/AMOEBA3/src/experiments/badContext/AMOEBA_UI.java @@ -21,12 +21,12 @@ public class AMOEBA_UI { public AMOEBA_UI(boolean viewer, String percepts){ if(percepts.contentEquals("position")){ - amoeba = AMOEBAFactory.createAMOEBA(viewer, "src/experiments/droneControl/DroneControl.xml", - "src/experiments/droneControl/DroneControl_solver.xml"); + amoeba = AMOEBAFactory.createAMOEBA(viewer, "experiments/droneControl/DroneControl.xml", + "experiments/droneControl/DroneControl_solver.xml"); } else if (percepts.contentEquals("speed")){ - amoeba = AMOEBAFactory.createAMOEBA(viewer, "src/experiments/droneControl/DroneControlVariations.xml", - "src/experiments/droneControl/DroneControlVariations_solver.xml"); + amoeba = AMOEBAFactory.createAMOEBA(viewer, "experiments/droneControl/DroneControlVariations.xml", + "experiments/droneControl/DroneControlVariations_solver.xml"); } } @@ -113,4 +113,38 @@ public class AMOEBA_UI { return message; } + + public static void launchOverlapDetection(AMOEBA usedAmoeba) { + for(Percept percept : getAllPercepts(usedAmoeba)) { + percept.overlapsDetection(); + percept.overlapNotification(); + System.out.println("********************************** PERCEPT **********************************"); + System.out.println(percept.getName()+" overlaps "+percept.perceptOverlaps.size()); + System.out.println("************************ START ************************"); + for(Context cntxt : percept.sortedRanges.get("start")) { + System.out.println(cntxt.getRanges().get(percept).getStart()); + } + + System.out.println("************************ END ************************"); + for(Context cntxt : percept.sortedRanges.get("end")) { + System.out.println(cntxt.getRanges().get(percept).getEnd()); + } + + } + + for(Context context : getContextsAsContexts(usedAmoeba)) { + + context.computeOverlapsByPercepts(); + System.out.println("********************************** CONTEXT **********************************"); + System.out.println(context.getName()+" neighbours : "+context.neigbours.size()); + + for(Context c: context.neigbours.keySet()){ + + System.out.println(c.getName()+ " --> " + context.neigbours.get(c)); + + } + + } + + } } diff --git a/AMOEBA3/src/experiments/badContext/BadContextLauncherEasy.java b/AMOEBA3/src/experiments/badContext/BadContextLauncherEasy.java index dd9f4d060993ecf599610f65ef12a7d0b46074ea..eca80e2d321d6208560509f81713c5eedbf68d43 100644 --- a/AMOEBA3/src/experiments/badContext/BadContextLauncherEasy.java +++ b/AMOEBA3/src/experiments/badContext/BadContextLauncherEasy.java @@ -31,7 +31,8 @@ public class BadContextLauncherEasy implements Serializable { public static void launch(boolean viewer) { /*Here we create AMOEBA.*/ - AMOEBA amoeba = AMOEBAFactory.createAMOEBA(viewer, "src/experiments/badContext/BadContext.xml","src/experiments/badContext/BadContext_solver.xml"); +// AMOEBA amoeba = AMOEBAFactory.createAMOEBA(viewer, "/experiments/badContext/BadContext.xml","/experiments/badContext/BadContext_solver.xml"); + AMOEBA amoeba = AMOEBAFactory.createAMOEBA(viewer, "BadContext.xml","BadContext_solver.xml"); /* These method calls allow to setup AMOEBA*/ amoeba.setLocalModel(TypeLocalModel.MILLER_REGRESSION); @@ -46,7 +47,7 @@ public class BadContextLauncherEasy implements Serializable { bcm.setWorld(amoeba.getScheduler().getWorld()); ArrayList<Percept> percepts = new ArrayList<Percept>(); - for (int i = 0 ; i < 100 ; i++) { + for (int i = 0 ; i < 10 ; i++) { /* This is the studied system part. Feel free to use any data source.*/ bcm.playOneStep(0); @@ -65,7 +66,7 @@ public class BadContextLauncherEasy implements Serializable { System.out.println(" - - - - "); try { - Thread.sleep(100); + Thread.sleep(1000); } catch(InterruptedException ex) { @@ -80,6 +81,8 @@ public class BadContextLauncherEasy implements Serializable { System.out.println("Test request : " + amoeba.request(data)); }*/ + AMOEBA_UI.launchOverlapDetection(amoeba); + ArrayList<Percept> P = AMOEBA_UI.getAllPercepts(amoeba); ArrayList<Agent> A = AMOEBA_UI.getContexts(amoeba); ArrayList<Context> C = AMOEBA_UI.getContextsAsContexts(amoeba); diff --git a/AMOEBA3/src/experiments/droneControl/AMOEBA_UI.java b/AMOEBA3/src/experiments/droneControl/AMOEBA_UI.java index b3c2038f4d54c10db3242ce66460335ffb8b87fe..57924bdd4cc4930184b46dc6adf0d61641fb9374 100644 --- a/AMOEBA3/src/experiments/droneControl/AMOEBA_UI.java +++ b/AMOEBA3/src/experiments/droneControl/AMOEBA_UI.java @@ -20,12 +20,12 @@ public class AMOEBA_UI { public AMOEBA_UI(boolean viewer, String percepts){ if(percepts.contentEquals("position")){ - amoeba = AMOEBAFactory.createAMOEBA(viewer, "src/experiments/droneControl/DroneControl.xml", - "src/experiments/droneControl/DroneControl_solver.xml"); + amoeba = AMOEBAFactory.createAMOEBA(viewer, "/experiments/droneControl/DroneControl.xml", + "/experiments/droneControl/DroneControl_solver.xml"); } else if (percepts.contentEquals("speed")){ - amoeba = AMOEBAFactory.createAMOEBA(viewer, "src/experiments/droneControl/DroneControlVariations.xml", - "src/experiments/droneControl/DroneControlVariations_solver.xml"); + amoeba = AMOEBAFactory.createAMOEBA(viewer, "/experiments/droneControl/DroneControlVariations.xml", + "/experiments/droneControl/DroneControlVariations_solver.xml"); } } diff --git a/AMOEBA3/src/experiments/droneControl/Chat_ClientServeur.java b/AMOEBA3/src/experiments/droneControl/Chat_ClientServeur.java index 12c8ec04aa855406f6f1c5ee2c3598687a2978e9..af0f56cd31d777fff3a4750936a8895a4e86022d 100644 --- a/AMOEBA3/src/experiments/droneControl/Chat_ClientServeur.java +++ b/AMOEBA3/src/experiments/droneControl/Chat_ClientServeur.java @@ -41,17 +41,17 @@ public class Chat_ClientServeur implements Runnable { private int counter = 0; private String message = ""; - public AMOEBA amoebaX = AMOEBAFactory.createAMOEBA(viewer, "src/experiments/droneControl/DroneControl.xml", - "src/experiments/droneControl/DroneControl_solver.xml"); - public AMOEBA amoebaY = AMOEBAFactory.createAMOEBA(viewer, "src/experiments/droneControl/DroneControl.xml", - "src/experiments/droneControl/DroneControl_solver.xml"); - public AMOEBA amoebaZ = AMOEBAFactory.createAMOEBA(viewer, "src/experiments/droneControl/DroneControl.xml", - "src/experiments/droneControl/DroneControl_solver.xml"); + public AMOEBA amoebaX = AMOEBAFactory.createAMOEBA(viewer, "/experiments/droneControl/DroneControl.xml", + "/experiments/droneControl/DroneControl_solver.xml"); + public AMOEBA amoebaY = AMOEBAFactory.createAMOEBA(viewer, "/experiments/droneControl/DroneControl.xml", + "/experiments/droneControl/DroneControl_solver.xml"); + public AMOEBA amoebaZ = AMOEBAFactory.createAMOEBA(viewer, "/experiments/droneControl/DroneControl.xml", + "/experiments/droneControl/DroneControl_solver.xml"); - public AMOEBA amoebaVX = AMOEBAFactory.createAMOEBA(viewer, "src/experiments/droneControl/DroneControlVariations.xml", - "src/experiments/droneControl/DroneControlVariations_solver.xml"); - public AMOEBA amoebaVZ = AMOEBAFactory.createAMOEBA(viewer, "src/experiments/droneControl/DroneControlVariations.xml", - "src/experiments/droneControl/DroneControlVariations_solver.xml"); + public AMOEBA amoebaVX = AMOEBAFactory.createAMOEBA(viewer, "/experiments/droneControl/DroneControlVariations.xml", + "/experiments/droneControl/DroneControlVariations_solver.xml"); + public AMOEBA amoebaVZ = AMOEBAFactory.createAMOEBA(viewer, "/experiments/droneControl/DroneControlVariations.xml", + "/experiments/droneControl/DroneControlVariations_solver.xml"); public ControlModel controlModelVc = new ControlModel("Vc",0.5f);