Skip to content

Commit

Permalink
add sanity check for identical start states
Browse files Browse the repository at this point in the history
This needs to be on the example-level, because the generic (E)CBS
implementation actually has no notion of time and conflicts as well as
constraints are abstract, templated types (only known by the low-level
search).
  • Loading branch information
whoenig committed Dec 6, 2021
1 parent e17e5bd commit 6fea197
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
10 changes: 10 additions & 0 deletions example/cbs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,16 @@ int main(int argc, char* argv[]) {
goals.emplace_back(Location(goal[0].as<int>(), goal[1].as<int>()));
}

// sanity check: no identical start states
std::unordered_set<State> startStatesSet;
for (const auto& s : startStates) {
if (startStatesSet.find(s) != startStatesSet.end()) {
std::cout << "Identical start states detected -> no solution!" << std::endl;
return 0;
}
startStatesSet.insert(s);
}

Environment mapf(dimx, dimy, obstacles, goals, disappearAtGoal);
CBS<State, Action, int, Conflict, Constraints, Environment> cbs(mapf);
std::vector<PlanResult<State, Action, int> > solution;
Expand Down
10 changes: 10 additions & 0 deletions example/cbs_ta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,16 @@ int main(int argc, char* argv[]) {
}
}

// sanity check: no identical start states
std::unordered_set<State> startStatesSet;
for (const auto& s : startStates) {
if (startStatesSet.find(s) != startStatesSet.end()) {
std::cout << "Identical start states detected -> no solution!" << std::endl;
return 0;
}
startStatesSet.insert(s);
}

Environment mapf(dimx, dimy, obstacles, startStates, goals,
maxTaskAssignments);
CBSTA<State, Action, int, Conflict, Constraints, Location, Environment>
Expand Down
10 changes: 10 additions & 0 deletions example/ecbs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,16 @@ int main(int argc, char* argv[]) {
goals.emplace_back(Location(goal[0].as<int>(), goal[1].as<int>()));
}

// sanity check: no identical start states
std::unordered_set<State> startStatesSet;
for (const auto& s : startStates) {
if (startStatesSet.find(s) != startStatesSet.end()) {
std::cout << "Identical start states detected -> no solution!" << std::endl;
return 0;
}
startStatesSet.insert(s);
}

Environment mapf(dimx, dimy, obstacles, goals, disappearAtGoal);
ECBS<State, Action, int, Conflict, Constraints, Environment> ecbs(mapf, w);
std::vector<PlanResult<State, Action, int> > solution;
Expand Down
10 changes: 10 additions & 0 deletions example/ecbs_ta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,16 @@ int main(int argc, char* argv[]) {
}
}

// sanity check: no identical start states
std::unordered_set<State> startStatesSet;
for (const auto& s : startStates) {
if (startStatesSet.find(s) != startStatesSet.end()) {
std::cout << "Identical start states detected -> no solution!" << std::endl;
return 0;
}
startStatesSet.insert(s);
}

Environment mapf(dimx, dimy, obstacles, startStates, goals,
maxTaskAssignments);
ECBSTA<State, Action, int, Conflict, Constraints, Location,
Expand Down

0 comments on commit 6fea197

Please sign in to comment.