Skip to content
Snippets Groups Projects
Commit 81ae9c09 authored by Erik Nygren's avatar Erik Nygren :bullettrain_front:
Browse files

backward compatible with version 2.1.8:

Reintroduced some malfunction parameters but are not used.
parent c85e08ee
No related branches found
No related tags found
No related merge requests found
......@@ -39,7 +39,7 @@ class EnvAgentStatic(object):
# number of time the agent had to stop, since the last time it broke down
malfunction_data = attrib(
default=Factory(
lambda: dict({'malfunction': 0, 'nr_malfunctions': 0,
lambda: dict({'malfunction': 0, 'malfunction_rate': 0, 'next_malfunction': 0, 'nr_malfunctions': 0,
'moving_before_malfunction': False, 'fixed': True})))
status = attrib(default=RailAgentStatus.READY_TO_DEPART, type=RailAgentStatus)
......@@ -62,8 +62,10 @@ class EnvAgentStatic(object):
malfunction_datas = []
for i in range(len(schedule.agent_positions)):
malfunction_datas.append({'malfunction': 0,
'malfunction_rate': schedule.agent_malfunction_rates[
i] if schedule.agent_malfunction_rates is not None else 0.,
'next_malfunction': 0,
'nr_malfunctions': 0,
'moving_before_malfunction': False,
'fixed': True})
return list(starmap(EnvAgentStatic, zip(schedule.agent_positions,
......
......@@ -79,7 +79,7 @@ def complex_schedule_generator(speed_ratio_map: Mapping[float, float] = None, se
speeds = [1.0] * len(agents_position)
return Schedule(agent_positions=agents_position, agent_directions=agents_direction,
agent_targets=agents_target, agent_speeds=speeds)
agent_targets=agents_target, agent_speeds=speeds,agent_malfunction_rates=None)
return generator
......@@ -165,7 +165,7 @@ def sparse_schedule_generator(speed_ratio_map: Mapping[float, float] = None, see
speeds = [1.0] * len(agents_position)
return Schedule(agent_positions=agents_position, agent_directions=agents_direction,
agent_targets=agents_target, agent_speeds=speeds)
agent_targets=agents_target, agent_speeds=speeds,agent_malfunction_rates=None)
return generator
......@@ -263,7 +263,7 @@ def random_schedule_generator(speed_ratio_map: Optional[Mapping[float, float]] =
agents_speed = speed_initialization_helper(num_agents, speed_ratio_map, seed=_runtime_seed)
return Schedule(agent_positions=agents_position, agent_directions=agents_direction,
agent_targets=agents_target, agent_speeds=agents_speed)
agent_targets=agents_target, agent_speeds=speeds,agent_malfunction_rates=None)
return generator
......@@ -307,6 +307,6 @@ def schedule_from_file(filename, load_from_package=None) -> ScheduleGenerator:
else:
agents_speed = None
return Schedule(agent_positions=agents_position, agent_directions=agents_direction,
agent_targets=agents_target, agent_speeds=agents_speed)
agent_targets=agents_target, agent_speeds=speeds,agent_malfunction_rates=None)
return generator
......@@ -6,4 +6,5 @@ from flatland.core.grid.grid_utils import IntVector2DArray
Schedule = NamedTuple('Schedule', [('agent_positions', IntVector2DArray),
('agent_directions', List[Grid4TransitionsEnum]),
('agent_targets', IntVector2DArray),
('agent_speeds', List[float])])
('agent_speeds', List[float]),
('agent_malfunction_rates', List[int])])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment