Revision 101:61e316eca8f5

View differences:

misc/eclipse/Solver (test).launch
8 8
</listAttribute>
9 9
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.m2e.launchconfig.classpathProvider"/>
10 10
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="tt.jointeuclid2ni.Solver"/>
11
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-method KDPMD -k  10 -problemfile src/main/resources/problems/superconflict4.xml -maxtime 2500 -gridstep 40 -grid 16 -summary -showvis"/>
11
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-method PP -problemfile src/main/resources/problems/symmetric_obstacles.xml -maxtime 3500 -gridstep 25 -grid 8 -summary -showvis"/>
12 12
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="deconflictiontools"/>
13 13
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/>
14 14
</launchConfiguration>
src/main/java/tt/jointeuclid2ni/Solver.java
1 1
package tt.jointeuclid2ni;
2 2

  
3
import java.io.File;
4
import java.io.FileInputStream;
5
import java.io.FileNotFoundException;
6

  
3 7
import tt.euclid2i.discretization.LazyGrid;
4 8
import tt.jointeuclid2ni.probleminstance.EarliestArrivalProblem;
5 9
import tt.jointeuclid2ni.probleminstance.EarliestArrivalProblemSimpleMissionDeserializer;
......
10 14
import tt.jointeuclid2ni.solver.Parameters;
11 15
import tt.util.Args;
12 16

  
13
import java.io.File;
14
import java.io.FileInputStream;
15
import java.io.FileNotFoundException;
16

  
17 17

  
18 18
public class Solver {
19 19

  
......
72 72
            timeoutMs = Integer.parseInt(timeoutStr);
73 73
        }
74 74

  
75
        params.maxSpeed = 0;
75
        params.maxSpeed = 1;
76 76
        for (int i = 0; i < problem.getMaxSpeeds().length; i++) {
77 77
            if (problem.getMaxSpeed(i) > params.maxSpeed) {
78 78
                params.maxSpeed = problem.getMaxSpeed(i);
src/main/java/tt/jointeuclid2ni/probleminstance/EarliestArrivalProblemXMLDeserializer.java
197 197

  
198 198
    private Polygon parseObstacle(Element obstacle) {
199 199
        try {
200

  
201
            boolean forceFilledInside = false;
202
            if (obstacle.hasAttribute("filledinside")) {
203
                forceFilledInside = true;
204
            }
205

  
200 206
            NodeList pointElements = obstacle.getElementsByTagName(EarliestArrivalProblemXMLConstants.POINT);
201 207
            List<Point> points = new ArrayList<Point>();
202 208

  
......
204 210
                Node pointElement = pointElements.item(i);
205 211
                points.add(parsePoint((Element) pointElement));
206 212
            }
207
            return new Polygon(points.toArray(new Point[points.size()]));
213

  
214
            Point[] pointsArray = points.toArray(new Point[points.size()]);
215

  
216
            if (forceFilledInside) {
217
                if (!Polygon.isClockwise(pointsArray)) {
218
                    ArrayUtils.reverse(pointsArray);
219
                }
220
            }
221

  
222
            return new Polygon(pointsArray);
208 223
        } catch (Exception ex) {
209 224
            throw new RuntimeException("Error while parsing" + formatOutput(obstacle));
210 225
        }
211

  
212 226
    }
213 227

  
214 228
    private Point parsePoint(Element pointElement) {
src/main/java/tt/jointeuclid2ni/solver/impl/AbstractAlgorithm.java
1 1
package tt.jointeuclid2ni.solver.impl;
2 2

  
3
import cz.agents.alite.vis.VisManager;
4
import cz.agents.alite.vis.layer.common.ColorLayer;
5
import cz.agents.alite.vis.layer.common.VisInfoLayer;
6
import cz.agents.alite.vis.layer.toggle.KeyToggleLayer;
3
import static tt.jointtraj.util.Util.getSumCost;
4

  
5
import java.awt.Color;
6
import java.util.Collection;
7
import java.util.Collections;
8
import java.util.LinkedList;
9

  
10
import javax.vecmath.Point2d;
11

  
7 12
import org.jgrapht.DirectedGraph;
8 13
import org.jgrapht.Graph;
9
import tt.euclid2i.*;
14

  
15
import tt.euclid2i.EvaluatedTrajectory;
16
import tt.euclid2i.Line;
10 17
import tt.euclid2i.Point;
18
import tt.euclid2i.Region;
19
import tt.euclid2i.Trajectory;
11 20
import tt.euclid2i.discretization.AdditionalPointsExtension;
12 21
import tt.euclid2i.discretization.LazyGrid;
13 22
import tt.euclid2i.region.Rectangle;
14 23
import tt.euclid2i.util.Util;
15 24
import tt.euclid2i.vis.RegionsLayer;
25
import tt.euclid2i.vis.RegionsLayer.RegionsProvider;
16 26
import tt.euclidtime3i.discretization.ConstantSpeedTimeExtension;
17 27
import tt.euclidtime3i.discretization.FreeOnTargetWaitExtension;
18 28
import tt.euclidtime3i.discretization.Straight;
......
23 33
import tt.jointtraj.solver.SearchResult;
24 34
import tt.util.AgentColors;
25 35
import tt.util.Counters;
26
import tt.vis.*;
27

  
28
import javax.vecmath.Point2d;
29
import java.awt.*;
30
import java.util.Collection;
31
import java.util.Collections;
32
import java.util.LinkedList;
33

  
34
import static tt.jointtraj.util.Util.getSumCost;
36
import tt.vis.FastAgentsLayer;
37
import tt.vis.FastTrajectoriesLayer;
38
import tt.vis.GraphLayer;
39
import tt.vis.LabeledCircleLayer;
40
import tt.vis.ParameterControlLayer;
41
import tt.vis.TimeParameterHolder;
42
import cz.agents.alite.vis.VisManager;
43
import cz.agents.alite.vis.layer.common.ColorLayer;
44
import cz.agents.alite.vis.layer.common.VisInfoLayer;
45
import cz.agents.alite.vis.layer.toggle.KeyToggleLayer;
35 46

  
36 47

  
37 48
public abstract class AbstractAlgorithm implements Algorithm {
......
71 82

  
72 83
    protected DirectedGraph<tt.euclid2i.Point, Line> createAndShowGridForIthAgent(int i) {
73 84

  
74
        Collection<Region> inflatedObstacles = Util.inflateRegions(problem.getObstacles(), problem.getBodyRadius(i));
85
        final Collection<Region> inflatedObstacles = Util.inflateRegions(problem.getObstacles(), problem.getBodyRadius(i));
75 86

  
76 87
        final DirectedGraph<tt.euclid2i.Point, Line> grid = new LazyGrid(
77 88
                problem.getStart(i),
......
98 109
                    }
99 110
                }, new tt.euclid2i.vis.ProjectionTo2d(), Color.GRAY, Color.GRAY, 1, 4)
100 111
        );
112

  
113
        toggleLayer.addSubLayer(RegionsLayer.create(new RegionsProvider() {
114

  
115
            @Override
116
            public Collection<? extends Region> getRegions() {
117
                return inflatedObstacles;
118
            }
119
        }, Color.YELLOW));
120

  
121

  
101 122
        VisManager.registerLayer(toggleLayer);
102 123
        // create spatio-temporal graph
103 124

  
......
143 164
                        return list;
144 165
                    }
145 166

  
146
                }, Color.BLACK, Color.WHITE));
167
                }, Color.LIGHT_GRAY, Color.WHITE));
147 168

  
148 169
        VisManager.registerLayer(RegionsLayer.create(
149 170
                new RegionsLayer.RegionsProvider() {
......
155 176
                        return list;
156 177
                    }
157 178

  
158
                }, Color.BLACK, new Color(240, 240, 240)));
179
                }, Color.GRAY));
159 180

  
160 181
        VisManager.registerLayer(RegionsLayer.create(
161 182
                new RegionsLayer.RegionsProvider() {
......
165 186
                        return problem.getObstacles();
166 187
                    }
167 188

  
168
                }, Color.GRAY, Color.GRAY));
189
                }, Color.BLACK));
169 190

  
170 191
        VisManager.registerLayer(LabeledCircleLayer.create(new LabeledCircleLayer.LabeledCircleProvider<tt.euclid2i.Point>() {
171 192

  
src/main/resources/problems/single_obstacle.xml
1
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
<multiagentproblem>
3
<environment>
4
<obstacles>
5
<obstacle>
6
<point id="0">
7
<x>250</x>
8
<y>250</y>
9
</point>
10
<point id="1">
11
<x>750</x>
12
<y>250</y>
13
</point>
14
<point id="2">
15
<x>750</x>
16
<y>750</y>
17
</point>
18
<point id="3">
19
<x>250</x>
20
<y>750</y>
21
</point>
22
</obstacle>
23
</obstacles>
24
<bounds>
25
<point>
26
<x>0</x>
27
<y>0</y>
28
</point>
29
<point>
30
<x>1000</x>
31
<y>1000</y>
32
</point>
33
</bounds>
34
</environment>
35
<agents>
36
<agent>
37
<start>
38
<point>
39
<x>100</x>
40
<y>100</y>
41
</point>
42
</start>
43
<target>
44
<point>
45
<x>900</x>
46
<y>900</y>
47
</point>
48
</target>
49
<radius>60</radius>
50
</agent>
51
</agents>
52
</multiagentproblem>

Also available in: Unified diff