Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Flatland
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
yoogottamk
Flatland
Commits
7abf576f
Commit
7abf576f
authored
5 years ago
by
Erik Nygren
Browse files
Options
Downloads
Patches
Plain Diff
Introducing malfunction_generators
This resolves issue #273 updated examples
parent
f41d0f14
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/flatland_2_0_example.py
+2
-1
2 additions, 1 deletion
examples/flatland_2_0_example.py
examples/introduction_flatland_2_1.py
+2
-1
2 additions, 1 deletion
examples/introduction_flatland_2_1.py
with
4 additions
and
2 deletions
examples/flatland_2_0_example.py
+
2
−
1
View file @
7abf576f
...
...
@@ -2,6 +2,7 @@ import time
import
numpy
as
np
from
flatland.envs.malfunction_generators
import
malfunction_from_params
from
flatland.envs.observations
import
TreeObsForRailEnv
,
GlobalObsForRailEnv
from
flatland.envs.predictions
import
ShortestPathPredictorForRailEnv
from
flatland.envs.rail_env
import
RailEnv
...
...
@@ -38,7 +39,7 @@ env = RailEnv(width=100, height=100, rail_generator=sparse_rail_generator(max_nu
max_rails_in_city
=
8
,
),
schedule_generator
=
sparse_schedule_generator
(
speed_ration_map
),
number_of_agents
=
100
,
obs_builder_object
=
GlobalObsForRailEnv
(),
malfunction_generator
=
stochastic_data
,
obs_builder_object
=
GlobalObsForRailEnv
(),
malfunction_generator
=
malfunction_from_params
(
stochastic_data
)
,
remove_agents_at_target
=
True
)
# RailEnv.DEPOT_POSITION = lambda agent, agent_handle : (agent_handle % env.height,0)
...
...
This diff is collapsed.
Click to expand it.
examples/introduction_flatland_2_1.py
+
2
−
1
View file @
7abf576f
...
...
@@ -3,6 +3,7 @@ import numpy as np
# In Flatland you can use custom observation builders and predicitors
# Observation builders generate the observation needed by the controller
# Preditctors can be used to do short time prediction which can help in avoiding conflicts in the network
from
flatland.envs.malfunction_generators
import
malfunction_from_params
from
flatland.envs.observations
import
GlobalObsForRailEnv
# First of all we import the Flatland rail environment
from
flatland.envs.rail_env
import
RailEnv
...
...
@@ -73,7 +74,7 @@ observation_builder = GlobalObsForRailEnv()
# Construct the enviornment with the given observation, generataors, predictors, and stochastic data
env
=
RailEnv
(
width
=
width
,
height
=
height
,
rail_generator
=
rail_generator
,
schedule_generator
=
schedule_generator
,
number_of_agents
=
nr_trains
,
obs_builder_object
=
observation_builder
,
malfunction_generator
=
stochastic_data
,
number_of_agents
=
nr_trains
,
obs_builder_object
=
observation_builder
,
malfunction_generator
=
malfunction_from_params
(
stochastic_data
)
,
remove_agents_at_target
=
True
)
env
.
reset
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment