-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.cpp
126 lines (118 loc) · 2.79 KB
/
app.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#include <cbs.hpp>
#include <default_params.hpp>
#include <ecbs.hpp>
#include <hca.hpp>
#include <icbs.hpp>
#include <iostream>
#include <ir.hpp>
#include <pibt.hpp>
#include <pibt_complete.hpp>
#include <problem.hpp>
#include <push_and_swap.hpp>
#include <random>
#include <revisit_pp.hpp>
#include <vector>
#include <whca.hpp>
#include <winpibt.hpp>
std::unique_ptr<Solver> getSolver(const std::string solver_name, Problem *P);
int main()
{
std::string instance_file = "mapf_input.txt";
std::string output_file = "result.txt";
std::string solver_name = "PIBT";
// set problem
Problem P = Problem(instance_file);
// solve
auto solver = getSolver(solver_name, &P);
solver->solve();
if (solver->succeed() && !solver->getSolution().validate(&P))
{
std::cout << "error@app: invalid results" << std::endl;
return 0;
}
// output result
solver->printResult();
solver->makeLog(output_file);
std::cout << "save result as " << output_file << std::endl;
return 0;
}
std::unique_ptr<Solver> getSolver(const std::string solver_name, Problem *P)
{
std::unique_ptr<Solver> solver;
if (solver_name == "PIBT")
{
solver = std::make_unique<PIBT>(P);
}
else if (solver_name == "winPIBT")
{
solver = std::make_unique<winPIBT>(P);
}
else if (solver_name == "HCA")
{
solver = std::make_unique<HCA>(P);
}
else if (solver_name == "WHCA")
{
solver = std::make_unique<WHCA>(P);
}
else if (solver_name == "CBS")
{
solver = std::make_unique<CBS>(P);
}
else if (solver_name == "ICBS")
{
solver = std::make_unique<ICBS>(P);
}
else if (solver_name == "PIBT_COMPLETE")
{
solver = std::make_unique<PIBT_COMPLETE>(P);
}
else if (solver_name == "ECBS")
{
solver = std::make_unique<ECBS>(P);
}
else if (solver_name == "RevisitPP")
{
solver = std::make_unique<RevisitPP>(P);
}
else if (solver_name == "PushAndSwap")
{
solver = std::make_unique<PushAndSwap>(P);
}
else if (solver_name == "IR")
{
solver = std::make_unique<IR>(P);
}
else if (solver_name == "IR_SINGLE_PATHS")
{
solver = std::make_unique<IR_SINGLE_PATHS>(P);
}
else if (solver_name == "IR_FIX_AT_GOALS")
{
solver = std::make_unique<IR_FIX_AT_GOALS>(P);
}
else if (solver_name == "IR_FOCUS_GOALS")
{
solver = std::make_unique<IR_FOCUS_GOALS>(P);
}
else if (solver_name == "IR_MDD")
{
solver = std::make_unique<IR_MDD>(P);
}
else if (solver_name == "IR_BOTTLENECK")
{
solver = std::make_unique<IR_BOTTLENECK>(P);
}
else if (solver_name == "IR_HYBRID")
{
solver = std::make_unique<IR_HYBRID>(P);
}
else
{
std::cout << "Unknown solver name, " + solver_name + ", continue with PIBT"
<< std::endl;
solver = std::make_unique<PIBT>(P);
}
solver->setVerbose(true);
return solver;
}