Revision 323:9f17f52c9c38

View differences:

src/main/java/tt/jointeuclid2ni/demo/EightAgentsPrioritizedPlanningDemo.java
17 17
import tt.euclid2i.vis.RegionsLayer.RegionsProvider;
18 18
import tt.euclidtime3i.Point;
19 19
import tt.euclidtime3i.Region;
20
import tt.euclidtime3i.discretization.ConstantSpeedTimeExtension;
20 21
import tt.euclidtime3i.discretization.Straight;
21 22
import tt.euclidtime3i.discretization.SynchronizedMovesTimeExtension;
23
import tt.euclidtime3i.region.MovingCircle;
22 24
import tt.euclidtime3i.vis.TimeParameter;
23 25
import tt.euclidtime3i.vis.TimeParameterProjectionTo2d;
24 26
import tt.jointeuclid2ni.probleminstance.EarliestArrivalProblem;
......
44 46
public class EightAgentsPrioritizedPlanningDemo implements Creator {
45 47

  
46 48
    private static final int MAXTIME = 10000;
47
    private static final int GRID_STEP = 50;
49
    private static final int GRID_STEP = 100;
50
    private static final int SPEED = 1;
51
    private static final int TIME_STEP = GRID_STEP * SPEED;
48 52
    TimeParameter time;
49 53

  
50 54
    @Override
......
63 67

  
64 68
        // create a random problem
65 69

  
66
        EarliestArrivalProblem problem = new SuperconflictProblem(4, 25);
70
        EarliestArrivalProblem problem = new SuperconflictProblem(8, 50);
67 71
        visualizeProblem(problem);
68 72

  
69 73
        // solve the problem
......
114 118
                motions,
115 119
                problem.getBodyRadiuses(),
116 120
                PrioritizedPlanningSolver.VARIABLE_TIMESTEP,
117
                10,
121
                TIME_STEP/4,
118 122
                MAXTIME);
119 123

  
120
        final SearchResult result = solver.solve(Long.MAX_VALUE);
124
        final SearchResult result = solver.solve(24*3600*1000 /* 1 day runtime limit*/);
121 125

  
122 126
        if (result.foundSolution()) {
123 127
            System.out.println("Found a solution: " + result.trajectories);
......
129 133
    }
130 134

  
131 135
    private DirectedGraph<Point, Straight> createMotionGraph(final tt.euclid2i.Point init,
132
                                                             final tt.euclid2i.Point goal, Rectangle bounds, Collection<tt.euclid2i.Region> obstacles, int maxTime) {
136
                                                             final tt.euclid2i.Point goal, 
137
                                                             Rectangle bounds, 
138
                                                             Collection<tt.euclid2i.Region> obstacles, 
139
                                                             int maxTime) {
133 140

  
134 141
        LazyGrid grid = new LazyGrid(init,
135 142
                obstacles,
......
151 158
        }, new tt.euclid2i.vis.ProjectionTo2d(), Color.GRAY, Color.GRAY, 1, 4));
152 159

  
153 160
        // create spatio-temporal graph
154
        DirectedGraph<Point, Straight> motions = new SynchronizedMovesTimeExtension(spatialGraph, maxTime, 100, new LinkedList<Region>());
161
        DirectedGraph<Point, Straight> motions 
162
        	= new ConstantSpeedTimeExtension(spatialGraph, MAXTIME, new float[]{SPEED}, new LinkedList<MovingCircle>(), TIME_STEP, TIME_STEP);
163
        
155 164
        return motions;
156 165
    }
157 166

  
src/main/java/tt/jointeuclid2ni/probleminstance/SuperconflictProblem.java
26 26
        for (int i=0; i < nAgents; i++) {
27 27
            double angle = i*ANGLE_BETWEEN_AIRPLANES;
28 28

  
29
            Point start = new Point((int) (CENTER.x + Math.cos(angle)*CIRCLE_RADIUS), (int) (CENTER.y + Math.sin(angle)*CIRCLE_RADIUS));
30
            Point target = new Point((int) (CENTER.x + Math.cos(angle+Math.PI)*CIRCLE_RADIUS), (int) (CENTER.y + Math.sin(angle+Math.PI)*CIRCLE_RADIUS));
29
            Point start = new Point(
30
            		(int) Math.round((CENTER.x + Math.cos(angle)*CIRCLE_RADIUS)),
31
            		(int) Math.round((CENTER.y + Math.sin(angle)*CIRCLE_RADIUS)));
32
            
33
            Point target = new Point(
34
            		(int) Math.round((CENTER.x + Math.cos(angle+Math.PI)*CIRCLE_RADIUS)), 
35
            		(int) Math.round((CENTER.y + Math.sin(angle+Math.PI)*CIRCLE_RADIUS)));
31 36

  
32 37
            starts[i] = start;
33 38
            targets[i] = target;
src/main/java/tt/jointtrajineuclidtime3i/solver/PrioritizedPlanningSolver.java
24 24
    public static Logger LOGGER = Logger.getLogger(PrioritizedPlanningSolver.class);
25 25
    private HeuristicToGoal<tt.euclidtime3i.Point>[] heuristics;
26 26
	private int samplingInterval;
27
	private int timeStep;
28

  
27
	private int timeStepOfResultingTrajectories;
29 28
	public static final int VARIABLE_TIMESTEP = (-1);
30 29
	
31 30
    public PrioritizedPlanningSolver(Point[] starts, Point[] targets,
32 31
                                     DirectedGraph<tt.euclidtime3i.Point, Straight>[] agentsMotions,
33
                                     int[] bodyRadiuses, int timeStep, int samplingInterval, int maxTime) {
32
                                     int[] bodyRadiuses, int timeStepOfResultingTrajectory, int samplingInterval, int maxTime) {
34 33
        super(starts, targets, agentsMotions, bodyRadiuses, maxTime);
35
        this.timeStep = timeStep;
34
        this.timeStepOfResultingTrajectories = timeStepOfResultingTrajectory;
36 35
        this.samplingInterval = samplingInterval;
37 36
    }
38 37

  
......
95 94
            GraphPath<tt.euclidtime3i.Point, Straight> path = astar.findPathDeadlineLimit(Integer.MAX_VALUE, stopAtMs);
96 95

  
97 96
            if (path != null) {
98
            	if (timeStep != VARIABLE_TIMESTEP) {
99
            		trajs[i] = new ConstantStepSegmentedTrajectory(path.getEdgeList(), timeStep, path.getWeight());
97
            	if (timeStepOfResultingTrajectories != VARIABLE_TIMESTEP) {
98
            		trajs[i] = new ConstantStepSegmentedTrajectory(path.getEdgeList(), timeStepOfResultingTrajectories, path.getWeight());
100 99
            	} else {
101 100
            		trajs[i] = new StraightSegmentTrajectory(path, maxTime);
102 101
            	}
103 102
            } else {
104
                //return new SearchResult(trajs, true);
105 103
            	return new SearchResult(null, true);
106 104
            }
107 105
        }

Also available in: Unified diff