-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathrun_cbba_example_03.py
49 lines (39 loc) · 1.4 KB
/
run_cbba_example_03.py
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
#!/usr/bin/env python3
import time
import json
import matplotlib.pyplot as plt
import pathmagic
with pathmagic.context():
from CBBA import CBBA
from WorldInfo import WorldInfo
import HelperLibrary as HelperLibrary
if __name__ == "__main__":
# a json configuration file
config_file_name = "config_example_03.json"
# Read the configuration from the json file
json_file = open(config_file_name)
config_data = json.load(json_file)
# create a world, each list is [min, max] coordinates for x,y,z axis
WorldInfoTest = WorldInfo([-2.0, 2.5], [-1.5, 5.5], [0.0, 20.0])
# create a list of Agent(s) and Task(s)
num_agents = 5
num_tasks = 20
max_depth = num_tasks
AgentList, TaskList = HelperLibrary.create_agents_and_tasks_homogeneous(
num_agents, num_tasks, WorldInfoTest, config_data)
# create a CBBA solver
CBBA_solver = CBBA(config_data)
t_start = time.time()
# solve, no time window
path_list, _ = CBBA_solver.solve(AgentList, TaskList, WorldInfoTest, max_depth, time_window_flag=False)
t_end = time.time()
t_used = t_end - t_start
print("Time used [sec]: ", t_used)
# the output is CBBA_solver.path_list or path_list
print("bundle_list")
print(CBBA_solver.bundle_list)
print("path_list")
print(path_list)
# plot without time window
CBBA_solver.plot_assignment_without_timewindow()
plt.show()