-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathmain.cpp
53 lines (48 loc) · 2.18 KB
/
main.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
#include "mission.h"
int main(int argc, char* argv[])
{
if(argc < 1) {
std::cout << "Error! Pathfinding task file is not specified!" << std::endl;
return 0;
}
Mission mission(argv[1]);
std::cout << argv[1] << std::endl;
std::cout << "Parsing the map from XML:" << std::endl;
if(!mission.getMap()) {
std::cout << "Incorrect map! Program halted!" << std::endl;
}
else {
std::cout << "Map OK!" << std::endl << "Parsing configurations (algorithm, log) from XML:" <<std::endl;
if(!mission.getConfig())
std::cout << "Incorrect configurations! Program halted!" <<std::endl;
else {
std::cout << "Configurations OK!" << std::endl << "Creating log channel:" <<std::endl;
if(!mission.createLog())
std::cout << "Log chanel has not been created! Program halted!" << std::endl;
else {
std::cout << "Log OK!" << std::endl << "Start searching" << std::endl;
// mission.createSearch();
mission.createAlgorithm();
int tasksCount = mission.getSingleExecution() ? 1 : mission.getTasksCount();
for (int i = 0; i < tasksCount; ++i) {
std::string agentsFile = mission.getAgentsFile() + "-" + std::to_string(i + mission.getFirstTask()) + ".xml";
if (!mission.getAgents(agentsFile.c_str()))
std::cout << "Agent set has not been created! Program halted!" << std::endl;
else if (mission.checkAgentsCorrectness(agentsFile)) {
std::cout << "Starting search for agents file " << agentsFile << std::endl;
mission.startSearch(agentsFile);
}
}
if (!mission.getSingleExecution()) {
if (mission.getSaveAggregatedResults()) {
mission.saveAggregatedResultsToLog();
} else {
mission.saveSeparateResultsToLog();
}
}
std::cout << "All searches are finished!" << std::endl;
}
}
}
return 0;
}