Skip to content
Snippets Groups Projects
Commit d6ce98e6 authored by Daniel Zhuang's avatar Daniel Zhuang
Browse files

initial commit with tree depth limit in simulate simple

parent 969e9345
No related branches found
No related tags found
1 merge request!15Daniel branch
...@@ -18,6 +18,7 @@ class AnalysisTreeNode: ...@@ -18,6 +18,7 @@ class AnalysisTreeNode:
static = {}, static = {},
uncertain_param = {}, uncertain_param = {},
agent={}, agent={},
height =0,
assert_hits={}, assert_hits={},
child=[], child=[],
start_time = 0, start_time = 0,
...@@ -29,6 +30,7 @@ class AnalysisTreeNode: ...@@ -29,6 +30,7 @@ class AnalysisTreeNode:
self.init: Dict[str, List[float]] = init self.init: Dict[str, List[float]] = init
self.mode: Dict[str, List[str]] = mode self.mode: Dict[str, List[str]] = mode
self.agent: Dict = agent self.agent: Dict = agent
self.height: int = height
self.child: List[AnalysisTreeNode] = child self.child: List[AnalysisTreeNode] = child
self.start_time: float = round(start_time, ndigits) self.start_time: float = round(start_time, ndigits)
self.assert_hits = assert_hits self.assert_hits = assert_hits
......
...@@ -15,7 +15,8 @@ pp = functools.partial(pprint.pprint, compact=True, width=130) ...@@ -15,7 +15,8 @@ pp = functools.partial(pprint.pprint, compact=True, width=130)
from verse.analysis.analysis_tree import AnalysisTreeNode, AnalysisTree from verse.analysis.analysis_tree import AnalysisTreeNode, AnalysisTree
PathDiffs = List[Tuple[BaseAgent, ModePath]] PathDiffs = List[Tuple[BaseAgent, ModePath]]
#store in different file???
MAX_DEPTH = 3
def red(s): def red(s):
return "\x1b[31m" + s + "\x1b[0m" #]] return "\x1b[31m" + s + "\x1b[0m" #]]
...@@ -219,6 +220,7 @@ class Simulator: ...@@ -219,6 +220,7 @@ class Simulator:
static={}, static={},
uncertain_param={}, uncertain_param={},
agent={}, agent={},
height =0,
child=[], child=[],
start_time=0, start_time=0,
) )
...@@ -313,6 +315,10 @@ class Simulator: ...@@ -313,6 +315,10 @@ class Simulator:
next_node_init[agent_idx] = truncated_trace[agent_idx][0][1:] next_node_init[agent_idx] = truncated_trace[agent_idx][0][1:]
all_transition_paths.append(transition_paths) all_transition_paths.append(transition_paths)
if(node.height+1 > MAX_DEPTH ):
print("max depth reached")
continue
tmp = AnalysisTreeNode( tmp = AnalysisTreeNode(
trace=next_node_trace, trace=next_node_trace,
init=next_node_init, init=next_node_init,
...@@ -320,6 +326,7 @@ class Simulator: ...@@ -320,6 +326,7 @@ class Simulator:
static=next_node_static, static=next_node_static,
uncertain_param=next_node_uncertain_param, uncertain_param=next_node_uncertain_param,
agent=next_node_agent, agent=next_node_agent,
height=node.height+1,
child=[], child=[],
start_time=next_node_start_time, start_time=next_node_start_time,
type='simtrace' type='simtrace'
......
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