Skip to content
Snippets Groups Projects
Commit a93d9429 authored by MasterScrat's avatar MasterScrat
Browse files

Merged from 323_unordered_cell_locking

parents a25eff95 d0f6c718
No related branches found
No related tags found
No related merge requests found
File added
...@@ -16,7 +16,8 @@ class MotionCheck(object): ...@@ -16,7 +16,8 @@ class MotionCheck(object):
def addAgent(self, iAg, rc1, rc2, xlabel=None): def addAgent(self, iAg, rc1, rc2, xlabel=None):
""" add an agent and its motion as row,col tuples of current and next position. """ add an agent and its motion as row,col tuples of current and next position.
The agent's current position is given an "agent" attribute recording the agent index. The agent's current position is given an "agent" attribute recording the agent index.
If an agent does not move this round then its cell is If an agent does not want to move this round (rc1 == rc2) then a self-loop edge is created.
xlabel is used for test cases to give a label (see graphviz)
""" """
# Agents which have not yet entered the env have position None. # Agents which have not yet entered the env have position None.
...@@ -181,14 +182,19 @@ class MotionCheck(object): ...@@ -181,14 +182,19 @@ class MotionCheck(object):
def render(omc:MotionCheck, horizontal=True): def render(omc:MotionCheck, horizontal=True):
oAG = nx.drawing.nx_agraph.to_agraph(omc.G) try:
oAG.layout("dot") oAG = nx.drawing.nx_agraph.to_agraph(omc.G)
sDot = oAG.to_string() oAG.layout("dot")
if horizontal: sDot = oAG.to_string()
sDot = sDot.replace('{', '{ rankdir="LR" ') if horizontal:
#return oAG.draw(format="png") sDot = sDot.replace('{', '{ rankdir="LR" ')
# This returns a graphviz object which implements __repr_svg #return oAG.draw(format="png")
return gv.Source(sDot) # This returns a graphviz object which implements __repr_svg
return gv.Source(sDot)
except ImportError as oError:
print("Flatland agent_chains ignoring ImportError - install pygraphviz to render graphs")
return None
class ChainTestEnv(object): class ChainTestEnv(object):
""" Just for testing agent chains """ Just for testing agent chains
......
...@@ -329,13 +329,17 @@ def schedule_from_file(filename, load_from_package=None) -> ScheduleGenerator: ...@@ -329,13 +329,17 @@ def schedule_from_file(filename, load_from_package=None) -> ScheduleGenerator:
# setup with loaded data # setup with loaded data
agents_position = [a.initial_position for a in agents] agents_position = [a.initial_position for a in agents]
agents_direction = [a.direction for a in agents]
# this logic is wrong - we should really load the initial_direction as the direction.
#agents_direction = [a.direction for a in agents]
agents_direction = [a.initial_direction for a in agents]
agents_target = [a.target for a in agents] agents_target = [a.target for a in agents]
agents_speed = [a.speed_data['speed'] for a in agents] agents_speed = [a.speed_data['speed'] for a in agents]
agents_malfunction = [a.malfunction_data['malfunction_rate'] for a in agents] #agents_malfunction = [a.malfunction_data['malfunction_rate'] for a in agents]
return Schedule(agent_positions=agents_position, agent_directions=agents_direction, return Schedule(agent_positions=agents_position, agent_directions=agents_direction,
agent_targets=agents_target, agent_speeds=agents_speed, agent_malfunction_rates=None, agent_targets=agents_target, agent_speeds=agents_speed,
agent_malfunction_rates=None,
max_episode_steps=max_episode_steps) max_episode_steps=max_episode_steps)
return generator return generator
source diff could not be displayed: it is too large. Options to address this: view the blob.
...@@ -21,5 +21,5 @@ attrs ...@@ -21,5 +21,5 @@ attrs
gym==0.14.0 gym==0.14.0
networkx networkx
ipycanvas ipycanvas
pygraphviz
graphviz graphviz
imageio
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