Commit 35c8acd2 authored by VIGNET Pierre's avatar VIGNET Pierre
Browse files

[cmd] Fix 'no valid paths' error due to artefacts from the solver... another awesome project...

parent edac0b01
......@@ -128,6 +128,29 @@ def build_graph(solution, steps, transitions):
edges.append(trans)
continue
# Get valid paths to add all transitions to nodes linked via the condition
# Since there are useless steps, this function can raise an exception
# if there is no valid path. We test this here before going any further.
try:
temp_inihibtors_nodes = set(inhibitors_nodes)
valid_paths = parse_condition(
attributes['condition'],
all_nodes,
temp_inihibtors_nodes, # Modified in place
)
# In case of error, inhibitors_nodes can be wrongly modified...
inhibitors_nodes = temp_inihibtors_nodes
except AssertionError as e:
LOGGER.warning(
"No valid path for the event '%s' in the solution '%s'.\n"
"Most of the time it is just an artefact from the solver. "
"This event will NOT be added to the final graph.",
attributes["label"],
solution,
)
LOGGER.debug("Exception returned: %s", str(e))
continue
event = attributes['label'].split('[')[0]
# Add the transition as node
......@@ -166,11 +189,6 @@ def build_graph(solution, steps, transitions):
)
# Add all transitions to nodes linked via the condition
valid_paths = parse_condition(
attributes['condition'],
all_nodes,
inhibitors_nodes # Modified in place
)
for i, path in enumerate(valid_paths):
for node in path:
edges_in_cond.append(
......
......@@ -318,6 +318,7 @@ def parse_condition(condition, all_nodes, inhibitors_nodes):
:param condition: Condition string of a transition.
:param all_nodes: Nodes involved in transitions + frontier places.
:param inhibitors_nodes: Inactivated nodes in paths of conditions.
Modified by the function.
:type condition: <str>
:type inhibitors_nodes: <set>
:type all_nodes: <set>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment