Skip to content
Snippets Groups Projects
Commit feb3684c authored by adrian_egli's avatar adrian_egli
Browse files

Merge branch '45-bugfix' into 'master'

Resolve "Runtime error in training_navigation.py"

Closes #45

See merge request flatland/flatland!35
parents 42e55fbd 9921665c
No related branches found
No related tags found
No related merge requests found
......@@ -36,7 +36,7 @@ env = RailEnv(width=20,
"""
env = RailEnv(width=15,
height=15,
rail_generator=complex_rail_generator(nr_start_goal=2, nr_extra=30, min_dist=5, max_dist=99999, seed=0),
rail_generator=complex_rail_generator(nr_start_goal=6, nr_extra=30, min_dist=10, max_dist=99999, seed=0),
number_of_agents=3)
"""
......@@ -144,8 +144,8 @@ for trials in range(1, n_trials + 1):
# Run episode
for step in range(100):
if demo:
env_renderer.renderEnv(show=True, obsrender=True)
time.sleep(2)
env_renderer.renderEnv(show=True)
# print(step)
# Action
for a in range(env.get_num_agents()):
......@@ -193,29 +193,15 @@ for trials in range(1, n_trials + 1):
scores.append(np.mean(scores_window))
dones_list.append((np.mean(done_window)))
print(
'\rTraining {} Agents.\t' +
'Episode {}\t' +
'Average Score: {:.0f}\t' +
'Dones: {:.2f}%\t' +
'Epsilon: {:.2f} \t ' +
'Action Probabilities: \t ' +
'{}'.format(
print('\rTraining {} Agents.\t Episode {}\t Average Score: {:.0f}\tDones: {:.2f}%\tEpsilon: {:.2f} \t Action Probabilities: \t {}'.format(
env.get_num_agents(),
trials,
np.mean(scores_window),
100 * np.mean(done_window),
eps, action_prob / np.sum(action_prob)),
end=" ")
eps, action_prob / np.sum(action_prob)), end=" ")
if trials % 100 == 0:
print(
'\rTraining {} Agents.\t' +
'Episode {}\t' +
'Average Score: {:.0f}\t' +
'Dones: {:.2f}%\t' +
'Epsilon: {:.2f} \t ' +
'Action Probabilities: \t ' +
'{}'.format(
print('\rTraining {} Agents.\t Episode {}\t Average Score: {:.0f}\tDones: {:.2f}%\tEpsilon: {:.2f} \t Action Probabilities: \t {}'.format(
env.get_num_agents(),
trials,
np.mean(scores_window),
......
......@@ -683,6 +683,7 @@ class RenderTool(object):
self.gl.pause(0.00001)
return
def _draw_square(self, center, size, color, opacity=255, layer=0):
......
%% Cell type:markdown id: tags:
# Rail Editor v0.2
%% Cell type:code id: tags:
``` python
%load_ext autoreload
%autoreload 2
```
%% Cell type:code id: tags:
``` python
import numpy as np
from numpy import array
import ipywidgets
import IPython
from IPython.core.display import display, HTML
```
%% Cell type:code id: tags:
``` python
display(HTML("<style>.container { width:95% !important; }</style>"))
```
%% Output
%% Cell type:code id: tags:
``` python
from flatland.utils.editor import EditorMVC, EditorModel, View, Controller
```
%% Output
cpu
%% Cell type:code id: tags:
``` python
mvc = EditorMVC(sGL="PIL" ) # sGL="PIL")
```
%% Output
%% Cell type:markdown id: tags:
## Instructions
- Drag to draw (improved dead-ends)
- Shift-Drag to erase rails (erasing dead ends not yet automated - drag right across them)
- ctrl-click to add agent
- direction chosen randomly to fit rail
- ctrl-shift-click to add target for last agent
- target can be moved by repeating
- to Resize the env (cannot preserve work):
- select "Regen" tab, set regen size slider, click regenerate.
%% Cell type:code id: tags:
``` python
mvc.view.display()
```
%% Output
len: 190 <class 'bytes'> temp.pkl /home/jeremy/projects/aicrowd/rl-trains/notebooks
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
c:\users\u224870\appdata\local\programs\python\python36\lib\site-packages\flatland_rl-0.1.1-py3.6.egg\flatland\utils\editor.py in regenerate(self, event)
309 method = self.view.wRegenMethod.value
310 nAgents = self.view.wNAgents.value
--> 311 self.model.regenerate(method, nAgents)
312
313 def setRegenSize(self, event):
c:\users\u224870\appdata\local\programs\python\python36\lib\site-packages\flatland_rl-0.1.1-py3.6.egg\flatland\utils\editor.py in regenerate(self, method, nAgents)
582 self.fix_env()
583 self.set_env(self.env)
--> 584 self.player = Player(self.env)
585 self.view.new_env()
586 self.redraw()
c:\users\u224870\appdata\local\programs\python\python36\lib\site-packages\flatland_rl-0.1.1-py3.6.egg\examples\play_model.py in __init__(self, env)
30 # self.agent.qnetwork_local.load_state_dict(torch.load('../flatland/baselines/Nets/avoid_checkpoint9900.pth'))
31 self.agent.qnetwork_local.load_state_dict(torch.load(
---> 32 '../flatland/flatland/baselines/Nets/avoid_checkpoint15000.pth'))
33
34 self.iFrame = 0
c:\users\u224870\appdata\local\programs\python\python36\lib\site-packages\torch\serialization.py in load(f, map_location, pickle_module)
354 (sys.version_info[0] == 3 and isinstance(f, pathlib.Path)):
355 new_fd = True
--> 356 f = open(f, 'rb')
357 try:
358 return _load(f, map_location, pickle_module)
FileNotFoundError: [Errno 2] No such file or directory: '../flatland/flatland/baselines/Nets/avoid_checkpoint15000.pth'
%% Cell type:code id: tags:
``` python
mvc.view.wOutput.clear_output()
mvc.view.wOutput
```
%% Output
%% Cell type:code id: tags:
``` python
len(mvc.editor.env.agents), len(mvc.editor.env.agents_static)
```
%% Output
(0, 0)
......
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