flatland-association / flatland-rl

The Flatland Framework is a multi-purpose environment to tackle problems around resilient resource allocation under uncertainty. It is designed to be a flexible and method agnostic to solve a wide range of problems in the field of operations research and reinforcement learning.
https://www.flatland-association.org/
MIT License
24 stars 8 forks source link

Bug - env.reset(regenerate_rail=False, regenerate_schedule=True) #24

Open aiAdrian opened 1 year ago

aiAdrian commented 1 year ago

Objectives

Errors in sparse_rail_generator and regenerate_schedule cause a "None - Pointer error" agents_hints => None

def _create_flatland_env(
            obs_builder_object: ObservationBuilder,
            max_rails_between_cities=2,
            max_rails_in_city=4,
            malfunction_rate=1 / 1000,
            n_cities=5,
            number_of_agents=10,
            grid_width=30,
            grid_height=40,
            grid_mode=True,
            random_seed=25041978) -> RailEnv:
        return RailEnv(
            width=grid_width,
            height=grid_height,
            rail_generator=sparse_rail_generator(
                max_num_cities=n_cities,
                grid_mode=grid_mode,
                max_rails_between_cities=max_rails_between_cities,
                max_rail_pairs_in_city=max_rails_in_city,
                seed=None,
            ),
            malfunction_generator=ParamMalfunctionGen(
                MalfunctionParameters(
                    malfunction_rate=malfunction_rate, min_duration=10, max_duration=50
                )
            ),
            random_seed=random_seed,
            number_of_agents=number_of_agents,
            obs_builder_object=obs_builder_object
        )
print('-ok-')
state, info = env.raw_env.reset(regenerate_rail=True, regenerate_schedule=True)
print('-ok-')
state, info = env.raw_env.reset(regenerate_rail=True, regenerate_schedule=False)
print('-ok-')
state, info = env.raw_env.reset(regenerate_rail=False, regenerate_schedule=False)
print('-error- !!')
state, info = env.raw_env.reset(regenerate_rail=False, regenerate_schedule=True)

Todos

Minimal testing requirements