-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBasicSystem.h
More file actions
95 lines (78 loc) · 2.74 KB
/
Copy pathBasicSystem.h
File metadata and controls
95 lines (78 loc) · 2.74 KB
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
#pragma once
#include "BasicGraph.h"
#include "States.h"
#include "PriorityGraph.h"
#include "PBS.h"
#include "WHCAStar.h"
#include "ECBS.h"
#include "LRAStar.h"
class BasicSystem
{
public:
virtual void add_online_constraints(std::list<std::tuple<int,int,int>>& cons) const {}
// params for MAPF algotithms
MAPFSolver& solver;
bool hold_endpoints;
bool useDummyPaths;
int time_limit;
int travel_time_window;
//string potential_function;
//double potential_threshold;
//double suboptimal_bound;
int screen;
bool log;
int num_of_drives;
int seed;
int simulation_window;
int planning_window;
int simulation_time;
// ★新增:让 OnlineSystem 在下一次 solve() 前塞临时约束(只用一轮)
std::list<std::tuple<int,int,int>> extra_constraints;
// params for drive model
bool consider_rotation;
int k_robust;
BasicSystem(const BasicGraph& G, MAPFSolver& solver);
~BasicSystem();
// TODO
/*bool load_config(std::string fname);
bool generate_random_MAPF_instance();
bool run();
void print_MAPF_instance() const;
void save_MAPF_instance(std::string fname) const;
bool read_MAPF_instance(std::string fname);*/
// I/O
std::string outfile;
void save_results();
double saving_time = 0; // time for saving results to files, in seconds
int num_of_tasks; // number of finished tasks
list<int> new_agents; // used for replanning a subgroup of agents
// used for MAPF instance
vector<State> starts;
vector< vector<pair<int, int> > > goal_locations;
// unordered_set<int> held_endpoints;
int timestep;
// record movements of drives
std::vector<Path> paths;
std::vector<std::list<std::pair<int, int> > > finished_tasks; // location + finish time
bool congested() const;
bool check_collisions(const vector<Path>& input_paths) const;
// update
void update_start_locations();
void update_travel_times(unordered_map<int, double>& travel_times);
void update_paths(const std::vector<Path*>& MAPF_paths, int max_timestep);
void update_paths(const std::vector<Path>& MAPF_paths, int max_timestep);
void update_initial_paths(vector<Path>& initial_paths) const;
void update_initial_constraints(list< tuple<int, int, int> >& initial_constraints) const;
void add_partial_priorities(const vector<Path>& initial_paths, PriorityGraph& initial_priorities) const;
list<tuple<int, int, int>> move(); // return finished tasks
void solve();
void initialize_solvers();
bool load_records();
bool load_locations();
protected:
bool solve_by_WHCA(vector<Path>& planned_paths,
const vector<State>& new_starts, const vector< vector<pair<int, int> > >& new_goal_locations);
bool LRA_called = false;
private:
const BasicGraph& G;
};