Skip to content

Commit

Permalink
add IR test
Browse files Browse the repository at this point in the history
  • Loading branch information
Kei18 committed Jan 15, 2021
1 parent ede962c commit a1d8743
Show file tree
Hide file tree
Showing 15 changed files with 180 additions and 6 deletions.
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ add_test(test_paths ./tests/test_paths.cpp)
add_test(test_lib_solver ./tests/test_lib_solver.cpp)
add_test(test_problem ./tests/test_problem.cpp)
add_test(test_lib_ir ./tests/test_lib_ir.cpp)
# solvers
add_test(test_hca ./tests/test_hca.cpp)
add_test(test_whca ./tests/test_whca.cpp)
add_test(test_revisit_pp ./tests/test_revisit_pp.cpp)
add_test(test_pibt ./tests/test_pibt.cpp)
add_test(test_cbs ./tests/test_cbs.cpp)
add_test(test_icbs ./tests/test_icbs.cpp)
add_test(test_ecbs ./tests/test_ecbs.cpp)
add_test(test_pibt_complete ./tests/test_pibt_complete.cpp)
add_test(test_ir ./tests/test_ir.cpp)

add_executable(test ${TEST_ALL_SRC})
target_link_libraries(test lib-mapf gtest)
2 changes: 2 additions & 0 deletions mapf/include/problem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class Problem
int getMaxCompTime() { return max_comp_time; };
std::string getInstanceFileName() { return instance; };

bool isInitializedInstance() const { return instance_initialized; }

// used when making new instance file
void makeScenFile(const std::string& output_file);
};
2 changes: 1 addition & 1 deletion mapf/include/solver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class Solver

public:
Solver(Problem* _P);
virtual ~Solver(){};
virtual ~Solver();

// call start -> run -> end
void solve();
Expand Down
8 changes: 5 additions & 3 deletions mapf/src/lib_cbs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,11 @@ void LibCBS::MDD::copy(const MDD& other)
return _node->t == prev_node->t &&
_node->v == prev_node->v;
});
MDDNode* new_prev_node = *itr;
new_prev_node->next.push_back(new_node);
new_node->prev.push_back(new_prev_node);
if (itr != new_prev_nodes.end()) {
auto new_prev_node = *itr;
new_prev_node->next.push_back(new_node);
new_node->prev.push_back(new_prev_node);
}
}
}
body.push_back(new_nodes);
Expand Down
9 changes: 7 additions & 2 deletions mapf/src/solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ Solver::Solver(Problem* _P)
LibCBS::MDD::MT = MT;
}

Solver::~Solver()
{
if (P->isInitializedInstance()) LibCBS::MDD::PURE_MDD_TABLE.clear();
}

void Solver::solve()
{
start();
Expand Down Expand Up @@ -91,10 +96,10 @@ void Solver::printResult()
<< solver_name << ", comp_time(ms)=" << std::right << std::setw(8)
<< comp_time << ", soc=" << std::right << std::setw(6)
<< solution.getSOC() << " (LB=" << std::right << std::setw(6)
<< LB_soc << ")"
<< getLowerBoundSOC() << ")"
<< ", makespan=" << std::right << std::setw(4)
<< solution.getMakespan() << " (LB=" << std::right << std::setw(6)
<< LB_makespan << ")" << std::endl;
<< getLowerBoundMakespan() << ")" << std::endl;
}

void Solver::makeLog(const std::string& logfile)
Expand Down
36 changes: 36 additions & 0 deletions tests/instances/02.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
map_file=random-32-32-20.map
agents=30
seed=0
random_problem=0
max_timestep=100
max_comp_time=30000
5,1,11,7
12,28,31,23
9,28,11,22
5,20,15,26
16,4,7,18
28,15,6,12
25,8,18,5
20,8,30,7
5,11,18,28
28,7,10,15
28,20,14,12
4,18,23,30
9,31,17,23
30,14,0,27
22,2,13,4
9,12,7,0
31,9,29,25
22,16,1,16
17,6,24,22
25,19,8,14
3,12,6,14
21,28,17,17
3,16,4,30
24,24,11,1
12,18,26,0
16,10,9,9
15,0,0,2
2,23,7,28
3,22,30,3
4,11,0,9
14 changes: 14 additions & 0 deletions tests/test_cbs.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <cbs.hpp>

#include "gtest/gtest.h"

TEST(CBS, solve)
{
Problem P = Problem("../tests/instances/02.txt");
std::unique_ptr<Solver> solver = std::make_unique<CBS>(&P);
solver->solve();

ASSERT_TRUE(solver->succeed());
ASSERT_TRUE(solver->getSolution().validate(&P));
ASSERT_EQ(solver->getSolution().getSOC(), 635);
}
13 changes: 13 additions & 0 deletions tests/test_ecbs.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <ecbs.hpp>

#include "gtest/gtest.h"

TEST(ECBS, solve)
{
Problem P = Problem("../tests/instances/02.txt");
std::unique_ptr<Solver> solver = std::make_unique<ECBS>(&P);
solver->solve();

ASSERT_TRUE(solver->succeed());
ASSERT_TRUE(solver->getSolution().validate(&P));
}
13 changes: 13 additions & 0 deletions tests/test_hca.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <hca.hpp>

#include "gtest/gtest.h"

TEST(HCA, solve)
{
Problem P = Problem("../tests/instances/02.txt");
std::unique_ptr<Solver> solver = std::make_unique<HCA>(&P);
solver->solve();

ASSERT_TRUE(solver->succeed());
ASSERT_TRUE(solver->getSolution().validate(&P));
}
14 changes: 14 additions & 0 deletions tests/test_icbs.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <icbs.hpp>

#include "gtest/gtest.h"

TEST(ICBS, solve)
{
Problem P = Problem("../tests/instances/02.txt");
std::unique_ptr<Solver> solver = std::make_unique<ICBS>(&P);
solver->solve();

ASSERT_TRUE(solver->succeed());
ASSERT_TRUE(solver->getSolution().validate(&P));
ASSERT_EQ(solver->getSolution().getSOC(), 635);
}
13 changes: 13 additions & 0 deletions tests/test_ir.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <ir.hpp>

#include "gtest/gtest.h"

TEST(IR, solve)
{
Problem P = Problem("../tests/instances/02.txt");
std::unique_ptr<Solver> solver = std::make_unique<IR>(&P);
solver->solve();

ASSERT_TRUE(solver->succeed());
ASSERT_TRUE(solver->getSolution().validate(&P));
}
13 changes: 13 additions & 0 deletions tests/test_pibt.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <pibt.hpp>

#include "gtest/gtest.h"

TEST(PIBT, solve)
{
Problem P = Problem("../tests/instances/02.txt");
std::unique_ptr<Solver> solver = std::make_unique<PIBT>(&P);
solver->solve();

ASSERT_TRUE(solver->succeed());
ASSERT_TRUE(solver->getSolution().validate(&P));
}
13 changes: 13 additions & 0 deletions tests/test_pibt_complete.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <pibt_complete.hpp>

#include "gtest/gtest.h"

TEST(PIBT_COMPLETE, solve)
{
Problem P = Problem("../tests/instances/02.txt");
std::unique_ptr<Solver> solver = std::make_unique<PIBT_COMPLETE>(&P);
solver->solve();

ASSERT_TRUE(solver->succeed());
ASSERT_TRUE(solver->getSolution().validate(&P));
}
13 changes: 13 additions & 0 deletions tests/test_revisit_pp.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <revisit_pp.hpp>

#include "gtest/gtest.h"

TEST(RevisitPP, solve)
{
Problem P = Problem("../tests/instances/02.txt");
std::unique_ptr<Solver> solver = std::make_unique<RevisitPP>(&P);
solver->solve();

ASSERT_TRUE(solver->succeed());
ASSERT_TRUE(solver->getSolution().validate(&P));
}
13 changes: 13 additions & 0 deletions tests/test_whca.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <whca.hpp>

#include "gtest/gtest.h"

TEST(WHCA, solve)
{
Problem P = Problem("../tests/instances/02.txt");
std::unique_ptr<Solver> solver = std::make_unique<WHCA>(&P);
solver->solve();

ASSERT_TRUE(solver->succeed());
ASSERT_TRUE(solver->getSolution().validate(&P));
}

0 comments on commit a1d8743

Please sign in to comment.