Skip to content

Commit

Permalink
delete libIR
Browse files Browse the repository at this point in the history
  • Loading branch information
Kei18 committed Feb 14, 2021
1 parent b247a02 commit 1590a5e
Show file tree
Hide file tree
Showing 6 changed files with 257 additions and 376 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ add_test(test_plan ./tests/test_plan.cpp)
add_test(test_paths ./tests/test_paths.cpp)
add_test(test_solver ./tests/test_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)
Expand Down
80 changes: 43 additions & 37 deletions mapf/include/ir.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "ecbs.hpp"
#include "hca.hpp"
#include "icbs_refine.hpp"
#include "lib_ir.hpp"
#include "pibt.hpp"
#include "pibt_complete.hpp"
#include "push_and_swap.hpp"
Expand Down Expand Up @@ -46,8 +45,7 @@ class IR : public Solver
// for log
std::string output_file;
bool make_log_every_itr; // true -> create log for every iteration
std::vector<std::tuple<int, int, int>>
HIST; // elapsed timestep, soc, makespan
std::vector<std::tuple<int, int, int>> HIST; // elapsed timestep, soc, makespan

// early stop
int timeout_refinement;
Expand All @@ -63,11 +61,11 @@ class IR : public Solver
int sampling_num;

// default params
static const INIT_SOLVER_TYPE DEFAULT_INIT_SOLVER;
static const OPTIMAL_SOLVER_TYPE DEFAULT_REFINE_SOLVER;
static const int DEFAULT_MAX_ITERATION;
static const int DEFAULT_TIMEOUT_REFINEMENT;
static const int DEFAULT_SAMPLING_NUM;
static constexpr INIT_SOLVER_TYPE DEFAULT_INIT_SOLVER = IR::INIT_SOLVER_TYPE::PIBT_COMPLETE;
static constexpr OPTIMAL_SOLVER_TYPE DEFAULT_REFINE_SOLVER = IR::OPTIMAL_SOLVER_TYPE::ICBS;
static constexpr int DEFAULT_MAX_ITERATION = 100;
static constexpr int DEFAULT_TIMEOUT_REFINEMENT = 3000;
static constexpr int DEFAULT_SAMPLING_NUM = 10;

void run();
void updateSolution(const Plan& plan);
Expand All @@ -76,20 +74,28 @@ class IR : public Solver
std::tuple<bool, Plan> getOptimalPlan(Problem* _P, const Plan& current_plan,
const std::vector<int>& sample);
virtual void refinePlan();
void printProcessInfo();

// ============================
void updateByRandom();
// work as macro
void updatePlanFocusOneAgent(std::function<void(const int, Plan&, IR*)> fn);
// ----------------------------
// define refinement rules
static void updateBySinglePaths(const int i, Plan& plan, IR* solver);
static void updateByFixAtGoals(const int i, Plan& plan, IR* solver);
static void updateByFocusGoals(const int i, Plan& plan, IR* solver);
static void updateByBottleneck(const int i, Plan& plan, IR* solver);
static void updateByMDD(const int i, Plan& plan, IR* solver);
// ============================

void printProcessInfo();
void updateByRandom();
void updatePlanFocusOneAgent(std::function<void(const int, Plan&, IR*)> fn); // work as macro
static void updateBySinglePaths(const int i, Plan& plan, IR* const solver);
static void updateByFixAtGoals(const int i, Plan& plan, IR* const solver);
static void updateByFocusGoals(const int i, Plan& plan, IR* const solver);
static void updateByBottleneck(const int i, Plan& plan, IR* const solver);
static void updateByMDD(const int i, Plan& plan, IR* const solver);

// ----------------------------
// utilities for refinement rules
public:
static std::vector<int> identifyInteractingSetByMDD
(const int i, const Plan& plan, Solver* const solver,
bool whole_duration = false, const int time_limit = -1, std::mt19937* MT = nullptr);
static std::vector<int> identifyAgentsAtGoal
(const int i, const Plan& plan, const Node* g, const int dist);
static std::tuple<int, std::vector<int>> identifyBottleneckAgentsWithScore
(const int i, const Paths& original_paths, Solver* const solver, const int time_limit = -1);

public:
IR(Problem* _P);
Expand All @@ -116,10 +122,10 @@ class IR_SINGLE_PATHS : public IR
public:
static const std::string SOLVER_NAME;
private:
void refinePlan();
void refinePlan() { updatePlanFocusOneAgent(updateBySinglePaths); }
public:
IR_SINGLE_PATHS(Problem* _P);
static void printHelp();
IR_SINGLE_PATHS(Problem* _P) : IR(_P) { solver_name = SOLVER_NAME; }
static void printHelp() { printHelpWithoutOption(SOLVER_NAME); }
};

// ---------------------------------
Expand All @@ -130,10 +136,10 @@ class IR_FIX_AT_GOALS : public IR
public:
static const std::string SOLVER_NAME;
private:
void refinePlan();
void refinePlan() { updatePlanFocusOneAgent(updateByFixAtGoals); }
public:
IR_FIX_AT_GOALS(Problem* _P);
static void printHelp();
IR_FIX_AT_GOALS(Problem* _P) : IR(_P) { solver_name = SOLVER_NAME; }
static void printHelp() { printHelpWithoutOption(SOLVER_NAME); }
};

// ---------------------------------
Expand All @@ -144,10 +150,10 @@ class IR_FOCUS_GOALS : public IR
public:
static const std::string SOLVER_NAME;
private:
void refinePlan();
void refinePlan() { updatePlanFocusOneAgent(updateByFocusGoals); }
public:
IR_FOCUS_GOALS(Problem* _P);
static void printHelp();
IR_FOCUS_GOALS(Problem* _P) : IR(_P) { solver_name = SOLVER_NAME; }
static void printHelp() { printHelpWithoutOption(SOLVER_NAME); }
};

// ---------------------------------
Expand All @@ -158,10 +164,10 @@ class IR_MDD : public IR
public:
static const std::string SOLVER_NAME;
private:
void refinePlan();
void refinePlan() { updatePlanFocusOneAgent(updateByMDD); }
public:
IR_MDD(Problem* _P);
static void printHelp();
IR_MDD(Problem* _P) : IR(_P) { solver_name = SOLVER_NAME; }
static void printHelp() { printHelpWithoutOption(SOLVER_NAME); }
};

// ---------------------------------
Expand All @@ -172,10 +178,10 @@ class IR_BOTTLENECK : public IR
public:
static const std::string SOLVER_NAME;
protected:
void refinePlan();
void refinePlan() { updatePlanFocusOneAgent(updateByBottleneck); }
public:
IR_BOTTLENECK(Problem* _P);
static void printHelp();
IR_BOTTLENECK(Problem* _P) : IR(_P) { solver_name = SOLVER_NAME; }
static void printHelp() { printHelpWithoutOption(SOLVER_NAME); }
};

// ---------------------------------
Expand All @@ -188,6 +194,6 @@ class IR_HYBRID : public IR
private:
void refinePlan();
public:
IR_HYBRID(Problem* _P);
static void printHelp();
IR_HYBRID(Problem* _P) : IR(_P) { solver_name = SOLVER_NAME; }
static void printHelp() { printHelpWithoutOption(SOLVER_NAME); }
};
112 changes: 0 additions & 112 deletions mapf/include/lib_ir.hpp

This file was deleted.

Loading

0 comments on commit 1590a5e

Please sign in to comment.