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
0107cbcb
Commit
0107cbcb
authored
5 years ago
by
Erik Nygren
Browse files
Options
Downloads
Patches
Plain Diff
introduce probability when sampling for start and target positions
parent
49abf9b2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
flatland/envs/rail_generators.py
+14
-3
14 additions, 3 deletions
flatland/envs/rail_generators.py
with
14 additions
and
3 deletions
flatland/envs/rail_generators.py
+
14
−
3
View file @
0107cbcb
...
...
@@ -815,7 +815,13 @@ def sparse_rail_generator(num_cities=5, node_radius=2,
return
train_stations
,
built_num_trainstations
def
_generate_start_target_pairs
(
num_agents
,
nb_nodes
,
train_stations
):
"""
Fill the trainstation positions with targets and goals
:param num_agents:
:param nb_nodes:
:param train_stations:
:return:
"""
# Generate start and target node directory for all agents.
# Assure that start and target are not in the same node
agent_start_targets_nodes
=
[]
...
...
@@ -831,8 +837,13 @@ def sparse_rail_generator(num_cities=5, node_radius=2,
for
agent_idx
in
range
(
num_agents
):
avail_start_nodes
=
[
idx
for
idx
,
val
in
enumerate
(
node_available_start
)
if
val
>
0
]
avail_target_nodes
=
[
idx
for
idx
,
val
in
enumerate
(
node_available_target
)
if
val
>
0
]
start_node
=
np
.
random
.
choice
(
avail_start_nodes
)
target_node
=
np
.
random
.
choice
(
avail_target_nodes
)
# Set probability to choose start and stop from trainstations
sum_start
=
sum
(
node_available_start
)
sum_target
=
sum
(
node_available_target
)
p_avail_start
=
[
float
(
i
)
/
sum_start
for
i
in
node_available_start
]
p_avail_target
=
[
float
(
i
)
/
sum_target
for
i
in
node_available_target
]
start_node
=
np
.
random
.
choice
(
avail_start_nodes
,
p
=
p_avail_start
)
target_node
=
np
.
random
.
choice
(
avail_target_nodes
,
p
=
p_avail_target
)
tries
=
0
found_agent_pair
=
True
while
target_node
==
start_node
:
...
...
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