Commit 306239e5 authored by nilabha's avatar nilabha
Browse files

update changes to flatland3

parent 2afd7915
Pipeline #8158 failed with stage
in 3 minutes and 4 seconds
width: 25
height: 25
number_of_agents: 5
max_num_cities: 4
width: 30
height: 30
number_of_agents: 6
max_num_cities: 2
grid_mode: False
max_rails_between_cities: 2
max_rails_in_city: 3
......
......@@ -6,7 +6,7 @@ from flatland.envs.malfunction_generators import malfunction_from_params
# from flatland.envs.rail_env import RailEnv
from envs.flatland.utils.gym_env_wrappers import FlatlandRenderWrapper as RailEnv
from flatland.envs.rail_generators import sparse_rail_generator
from flatland.envs.schedule_generators import sparse_schedule_generator
from flatland.envs.line_generators import sparse_line_generator
MalfunctionParameters = NamedTuple('MalfunctionParameters', [('malfunction_rate', float), ('min_duration', int), ('max_duration', int)])
......@@ -34,12 +34,12 @@ def random_sparse_env_small(random_seed, max_width, max_height, observation_buil
stochastic_data = {'malfunction_rate': malfunction_rate, 'min_duration': malfunction_min_duration,
'max_duration': malfunction_max_duration}
schedule_generator = sparse_schedule_generator({1.: 0.25, 1. / 2.: 0.25, 1. / 3.: 0.25, 1. / 4.: 0.25})
line_generator = sparse_line_generator({1.: 0.25, 1. / 2.: 0.25, 1. / 3.: 0.25, 1. / 4.: 0.25})
while width <= max_width and height <= max_height:
try:
env = RailEnv(width=width, height=height, rail_generator=rail_generator,
schedule_generator=schedule_generator, number_of_agents=nr_trains,
line_generator=line_generator, number_of_agents=nr_trains,
malfunction_generator_and_process_data=malfunction_from_params(stochastic_data),
obs_builder_object=observation_builder, remove_agents_at_target=False)
......
......@@ -5,7 +5,7 @@ import numpy as np
from flatland.envs.malfunction_generators import no_malfunction_generator, malfunction_from_params, MalfunctionParameters
from flatland.envs.rail_env import RailEnv
from flatland.envs.rail_generators import sparse_rail_generator
from flatland.envs.schedule_generators import sparse_schedule_generator
from flatland.envs.line_generators import sparse_line_generator
from envs.flatland import get_generator_config
from envs.flatland.observations import make_obs
......@@ -71,7 +71,7 @@ class FlatlandSingle(gym.Env):
speed_ratio_map = {
float(k): float(v) for k, v in self._config['speed_ratio_map'].items()
}
schedule_generator = sparse_schedule_generator(speed_ratio_map)
line_generator = sparse_line_generator(speed_ratio_map)
env = None
try:
......@@ -79,7 +79,7 @@ class FlatlandSingle(gym.Env):
width=self._config['width'],
height=self._config['height'],
rail_generator=rail_generator,
schedule_generator=schedule_generator,
line_generator=line_generator,
number_of_agents=self._config['number_of_agents'],
malfunction_generator_and_process_data=malfunction_generator,
obs_builder_object=self._observation.builder(),
......
......@@ -8,7 +8,7 @@ from flatland.envs.malfunction_generators import malfunction_from_params, no_mal
from envs.flatland.utils.gym_env_wrappers import FlatlandRenderWrapper as RailEnv
from flatland.envs.rail_generators import sparse_rail_generator
from flatland.envs.schedule_generators import sparse_schedule_generator
from flatland.envs.line_generators import sparse_line_generator
from envs.flatland import get_generator_config
from envs.flatland.observations import make_obs
......@@ -76,7 +76,7 @@ class FlatlandSparse(FlatlandBase):
max_num_cities=self._config['max_num_cities'],
grid_mode=self._config['grid_mode'],
max_rails_between_cities=self._config['max_rails_between_cities'],
max_rails_in_city=self._config['max_rails_in_city']
max_rail_pairs_in_city=self._config['max_rails_in_city']
)
malfunction_generator = no_malfunction_generator()
......@@ -93,7 +93,7 @@ class FlatlandSparse(FlatlandBase):
speed_ratio_map = {
float(k): float(v) for k, v in self._config['speed_ratio_map'].items()
}
schedule_generator = sparse_schedule_generator(speed_ratio_map)
line_generator = sparse_line_generator(speed_ratio_map)
env = None
try:
......@@ -101,7 +101,7 @@ class FlatlandSparse(FlatlandBase):
width=self._config['width'],
height=self._config['height'],
rail_generator=rail_generator,
schedule_generator=schedule_generator,
line_generator=line_generator,
number_of_agents=self._config['number_of_agents'],
malfunction_generator_and_process_data=malfunction_generator,
obs_builder_object=self._observation.builder(),
......
......@@ -3,7 +3,7 @@ from flatland.envs.malfunction_generators import malfunction_from_params, Malfun
from flatland.envs.observations import GlobalObsForRailEnv
from flatland.envs.rail_env import RailEnv
from flatland.envs.rail_generators import sparse_rail_generator
from flatland.envs.schedule_generators import sparse_schedule_generator
from flatland.envs.line_generators import sparse_line_generator
from flatland.utils.rendertools import RenderTool
import random
......@@ -81,7 +81,7 @@ def create_test_env(fnParams, nTest, sDir):
seed=seed,
grid_mode=False,
max_rails_between_cities=max_rails_between_cities,
max_rails_in_city=max_rails_in_cities,
max_rail_pairs_in_city=max_rails_in_cities,
)
......@@ -110,7 +110,7 @@ def create_test_env(fnParams, nTest, sDir):
1. / 3.: 0.25,
1. / 4.: 0.25}
schedule_generator = sparse_schedule_generator(DEFAULT_SPEED_RATIO_MAP)
line_generator = sparse_line_generator(DEFAULT_SPEED_RATIO_MAP)
for iAttempt in range(5):
try:
......@@ -118,7 +118,7 @@ def create_test_env(fnParams, nTest, sDir):
width=width,
height=height,
rail_generator=rail_generator,
schedule_generator=schedule_generator,
line_generator=line_generator,
number_of_agents=nr_trains,
malfunction_generator_and_process_data=malfunction_from_params(stochastic_data),
obs_builder_object=observation_builder,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment