Revision 34:5aec80e14f27

View differences:

src/main/java/tt/jointeuclid2ni/Solver.java
14 14
import tt.jointeuclid2ni.probleminstance.EarliestArrivalProblemXMLDeserializer;
15 15
import tt.jointeuclid2ni.solver.Algorithm;
16 16
import tt.jointeuclid2ni.solver.Algorithms;
17
import tt.jointeuclid2ni.solver.HeuristicType;
17 18
import tt.jointeuclid2ni.solver.Parameters;
18 19
import tt.jointeuclid2ni.solver.impl.AlgorithmIIHP;
19 20
import tt.jointeuclid2ni.solver.impl.AlgorithmKSFO;
......
57 58
        String maxtimeStr = Args.getArgumentValue(args, "-maxtime", true);
58 59
        String gridStepStr = Args.getArgumentValue(args, "-gridstep", true);
59 60
        String gridPatternStr = Args.getArgumentValue(args, "-grid", false);
61

  
62
        String heuristicStr = Args.getArgumentValue(args, "-heuristic", false, "PERFECT");
63
        params.heuristic = HeuristicType.valueOf(heuristicStr);
64

  
60 65
        params.showVis = Args.isArgumentSet(args, "-showvis");
61 66

  
62 67
        params.printSummary = Args.isArgumentSet(args, "-summary");
src/main/java/tt/jointeuclid2ni/solver/HeuristicType.java
1
package tt.jointeuclid2ni.solver;
2

  
3
public enum HeuristicType {
4
	L1,
5
	L2,
6
	PERFECT
7
}
src/main/java/tt/jointeuclid2ni/solver/Parameters.java
17 17
    public long runtimeDeadlineMs;
18 18
    public int waitMoveDuration;
19 19
    public int[][] gridPattern = LazyGrid.PATTERN_4_WAY;
20
    public HeuristicType heuristic;
20 21
}
src/main/java/tt/jointeuclid2ni/solver/impl/AbstractSFBasedAlgorithm.java
7 7
import tt.euclid2i.EvaluatedTrajectory;
8 8
import tt.euclid2i.Line;
9 9
import tt.euclid2i.Point;
10
import tt.euclidtime3i.L1Heuristic;
11
import tt.euclidtime3i.L2Heuristic;
10 12
import tt.euclidtime3i.PerfectBasedHeuristic;
11 13
import tt.euclidtime3i.discretization.softconstraints.LinearSeparationPenaltyFunction;
12 14
import tt.euclidtime3i.discretization.softconstraints.PairwiseConstraint;
......
14 16
import tt.jointtraj.separableflow.AStarTrajectoryOptimizer;
15 17
import tt.jointtraj.separableflow.TrajectoryOptimizer;
16 18
import tt.jointtraj.solver.SearchResult;
19
import tt.util.NotImplementedException;
17 20
import tt.util.Verbose;
18 21

  
19 22

  
......
45 48
        HeuristicToGoal<tt.euclidtime3i.Point>[] heuristics = new HeuristicToGoal[problem.nAgents()];
46 49

  
47 50
        for (int i = 0; i < problem.nAgents(); i++) {
48
            heuristics[i] = new PerfectBasedHeuristic(graph[i], problem.getTarget(i));
51
        	switch (params.heuristic) {
52
			case PERFECT:
53
				heuristics[i] = new PerfectBasedHeuristic(graph[i], problem.getTarget(i));
54
				break;
55

  
56
			case L1:
57
				heuristics[i] = new L1Heuristic(problem.getTarget(i));
58
				break;
59

  
60
			case L2:
61
				heuristics[i] = new L2Heuristic(problem.getTarget(i));
62
				break;
63

  
64
			default:
65
				throw new NotImplementedException();
66
			}
49 67
        }
50 68

  
51 69
        // Create trajectory optimizers
src/main/java/tt/jointeuclid2ni/solver/impl/AlgorithmODCN.java
9 9
import tt.euclid2i.EvaluatedTrajectory;
10 10
import tt.euclid2i.Line;
11 11
import tt.euclid2i.Point;
12
import tt.euclidtime3i.L1Heuristic;
12 13
import tt.jointeuclid2ni.operatordecomposition.ODEdge;
13 14
import tt.jointeuclid2ni.operatordecomposition.ODNode;
14 15
import tt.jointeuclid2ni.operatordecomposition.ODUtils;
......
17 18
import tt.jointeuclid2ni.operatordecomposition.utils.ODHeuristic;
18 19
import tt.jointeuclid2ni.probleminstance.EarliestArrivalProblem;
19 20
import tt.jointtraj.solver.SearchResult;
21
import tt.util.NotImplementedException;
20 22

  
21 23
public class AlgorithmODCN extends AbstractAlgorithm {
22 24

  
......
29 31

  
30 32
        Graph<Point, Line>[] graph = createGraphs(problem);
31 33
        ODWrapper odWrapper = new ODWrapper(graph, params.gridStep, true);
32
        ODHeuristic odHeuristic = new ODHeuristic(graph, problem.getTargets(), new HeuristicProvider<Point, Line>() {
33
            @Override
34
            public HeuristicToGoal<Point> getHeuristicToGoal(Graph<Point, Line> graph, Point goal) {
35
                return new PerfectHeuristic<Point, Line>(graph, goal);
36
            }
37
        });
38 34
        ODGoal goal = new ODGoal(problem.getTargets());
39 35
        ODNode start = ODNode.start(problem.getStarts(), goal, problem.getBodyRadiuses(), params.gridStep);
40 36

  
37
        ODHeuristic odHeuristic = new ODHeuristic(graph, problem.getTargets(), new HeuristicProvider<Point, Line>() {
38
        	@Override
39
        	public HeuristicToGoal<Point> getHeuristicToGoal(Graph<Point, Line> graph, Point goal) {
40
        		switch (params.heuristic) {
41
        		case PERFECT:
42
        			return new PerfectHeuristic<Point, Line>(graph, goal);
43
        		case L1:
44
        			return new tt.euclid2i.discretization.L1Heuristic(goal);
45
        		case L2:
46
        			return new tt.euclid2i.discretization.L1Heuristic(goal);
47
        		default:
48
        			throw new RuntimeException();
49
        		}
50
        	}
51
        });
52

  
41 53
        AStarShortestPathSimple<ODNode, ODEdge> astar
42 54
                = new AStarShortestPathSimple<ODNode, ODEdge>(odWrapper, odHeuristic, start, goal);
43 55

  
src/main/java/tt/jointeuclid2ni/solver/impl/AlgorithmPP.java
4 4
import org.jgrapht.DirectedGraph;
5 5
import org.jgrapht.util.HeuristicToGoal;
6 6
import tt.euclid2i.Line;
7
import tt.euclidtime3i.L1Heuristic;
8
import tt.euclidtime3i.L2Heuristic;
7 9
import tt.euclidtime3i.PerfectBasedHeuristic;
8 10
import tt.euclidtime3i.Point;
9 11
import tt.euclidtime3i.discretization.Straight;
12
import tt.jointeuclid2ni.solver.HeuristicType;
10 13
import tt.jointtraj.solver.SearchResult;
11 14
import tt.jointtrajineuclidtime3i.solver.PrioritizedPlanningSolver;
15
import tt.util.NotImplementedException;
12 16

  
13 17
public class AlgorithmPP extends AbstractAlgorithm {
14 18

  
......
33 37
        HeuristicToGoal<Point>[] heuristics = new HeuristicToGoal[problem.nAgents()];
34 38

  
35 39
        for (int i = 0; i < problem.nAgents(); i++) {
36
            heuristics[i] = new PerfectBasedHeuristic(spatial[i], problem.getTarget(i));
40
        	switch (params.heuristic) {
41
			case PERFECT:
42
				heuristics[i] = new PerfectBasedHeuristic(spatial[i], problem.getTarget(i));
43
				break;
44

  
45
			case L1:
46
				heuristics[i] = new L1Heuristic(problem.getTarget(i));
47
				break;
48

  
49
			case L2:
50
				heuristics[i] = new L2Heuristic(problem.getTarget(i));
51
				break;
52

  
53
			default:
54
				throw new NotImplementedException();
55
			}
37 56
        }
38 57

  
39 58
        solver.setHeuristics(heuristics);
src/main/resources/eclipse/Solver.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 KSFO -problemfile src/main/resources/problems/99.xml -timeout 5000 -maxtime 3500 -gridstep 50 -showvis -summary -grid 4 -k 1"/>
11
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-method PP -problemfile src/test/resources/problems/stopatgoaltest2.xml -timeout 500000 -maxtime 3500 -gridstep 25 -showvis -summary -grid 4 -k 1"/>
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/test/java/tt/jointeuclid2ni/SolverTest.java
52 52
    }
53 53

  
54 54
    @Test
55
    public void testPPOnCrossconflictL1() throws FileNotFoundException {
56
        testSolver("-method PP -problemfile src/test/resources/problems/cross_conflict.xml -timeout 2000 -maxtime 2500 -gridstep 50 -summary -grid 8 -heuristic L1",
57
                "^1570.00;[0-9]*;[0-9]*;\n");
58
    }
59

  
60
    @Test
55 61
    public void testKSFO1OnCrossconflict() throws FileNotFoundException {
56 62
        testSolver("-method KSFO -k 1 -problemfile src/test/resources/problems/cross_conflict.xml -timeout 2000 -maxtime 2500 -gridstep 50 -summary -grid 8",
57 63
                "^1541.00;[0-9]*;[0-9]*;\n");
58 64
    }
59 65

  
60 66
    @Test
67
    public void testKSFO1OnCrossconflictL1() throws FileNotFoundException {
68
        testSolver("-method KSFO -k 1 -problemfile src/test/resources/problems/cross_conflict.xml -timeout 2000 -maxtime 2500 -gridstep 50 -summary -grid 8 -heuristic L1",
69
                "^1570.00;[0-9]*;[0-9]*;\n");
70
    }
71

  
72
    @Test
61 73
    public void testODOnSymobst() throws FileNotFoundException {
62 74
        testSolver("-method ODCN -problemfile src/test/resources/problems/symmetric_obstacles.xml -timeout 5000 -maxtime 2500 -gridstep 100 -summary -grid 4",
63 75
                "^3200.00;[0-9]*;[0-9]*;\n");

Also available in: Unified diff