-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
120 lines (110 loc) · 3.27 KB
/
main.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
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
'''
Main Module
-----------
This module initiates the system. Here the agents are instantiated and the
simulation data are passed to the agents.
@author: @italocampos
'''
from tralhoto.agent import Bus, Station, Semaphore
from tralhoto import config
from pade.misc.utility import start_loop
import data
# Creating the road vector
road = [[[], None] for _ in range(205)]
agents = list()
# Creating the Station agents
for i, station in enumerate(data.stations):
agents.append(Station(
aid = 'station-%d' % i,
group = station['group'],
location = int(station['location'] * 10) + 6,
road = road,
side = station['side'],
name = station['name'],
proximity_factor = 5
))
# Creating the Semaphore agents
for i, semaphore in enumerate(data.semaphores):
agents.append(Semaphore(
aid = 'semaphore-%d' % i,
group = semaphore['group'],
location = int(semaphore['location'] * 10) + 6,
road = road,
perimeter = semaphore['perimeter'],
proximity_factor = 2,
))
# Creating the Bus agents
agents.extend([
Bus(aid = 'bus-0',
road = road,
name = 'TB0 Maracacuera São Brás',
velocity = config.BUS_VELOCITY[0],
n_simulations = 5,
start_time = config.SECOND * 60 * 5, # Starts at simulation minute 5
),
Bus(aid = 'bus-1',
road = road,
name = 'TB1 Maracacuera São Brás',
velocity = config.BUS_VELOCITY[1],
n_simulations = 5,
start_time = config.SECOND * 60 * 15, # Starts at simulation minute 15
),
Bus(aid = 'bus-2',
road = road,
name = 'TB2 Maracacuera São Brás',
velocity = config.BUS_VELOCITY[2],
n_simulations = 5,
start_time = config.SECOND * 60 * 25,
),
Bus(aid = 'bus-3',
road = road,
name = 'TB3 Maracacuera São Brás',
velocity = config.BUS_VELOCITY[3],
n_simulations = 5,
start_time = config.SECOND * 60 * 35,
),
Bus(aid = 'bus-4',
road = road,
name = 'TB4 Maracacuera São Brás',
velocity = config.BUS_VELOCITY[4],
n_simulations = 5,
start_time = config.SECOND * 60 * 45,
),
Bus(aid = 'bus-5',
road = road,
name = 'TB5 Maracacuera São Brás',
velocity = config.BUS_VELOCITY[0],
n_simulations = 5,
start_time = config.SECOND * 60 * 55,
),
Bus(aid = 'bus-6',
road = road,
name = 'TB6 Maracacuera São Brás',
velocity = config.BUS_VELOCITY[1],
n_simulations = 5,
start_time = config.SECOND * 60 * 65,
),
Bus(aid = 'bus-7',
road = road,
name = 'TB7 Maracacuera São Brás',
velocity = config.BUS_VELOCITY[2],
n_simulations = 5,
start_time = config.SECOND * 60 * 75,
),
Bus(aid = 'bus-8',
road = road,
name = 'TB8 Maracacuera São Brás',
velocity = config.BUS_VELOCITY[3],
n_simulations = 5,
start_time = config.SECOND * 60 * 85,
),
Bus(aid = 'bus-9',
road = road,
name = 'TB9 Maracacuera São Brás',
velocity = config.BUS_VELOCITY[4],
n_simulations = 5,
start_time = config.SECOND * 60 * 95,
),
])
if __name__ == '__main__':
start_loop(agents)