Skip to content

Commit

Permalink
added some tests to test contain_all_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexYFM committed Jun 23, 2024
1 parent 66d636c commit 350716b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 20 deletions.
4 changes: 2 additions & 2 deletions demo/fixed_points/helicopter.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,14 @@ def decisionLogic(ego: State, other: State):
scenario = Scenario(ScenarioConfig(init_seg_length=1, parallel=False))

scenario.add_agent(helicopter) ### need to add breakpoint around here to check decision_logic of agents
init_h = [[10 for _ in range(28)],[10 for _ in range(28)]]
init_h = [[10 for _ in range(28)],[11 for _ in range(28)]]
# # -----------------------------------------

scenario.set_init_single(
'Helicopter', init_h, (HelicopterMode.Normal,)
)

trace = scenario.verify(10, 0.01)
trace = scenario.verify(20, 0.01)

# is false, should be false
print(f'Fixed points exists? {fixed_points_fix(trace, 10, 0.01)}')
Expand Down
2 changes: 1 addition & 1 deletion demo/fixed_points/jet_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def decisionLogic(ego: State, other: State):
'JE', init_JE, (JEMode.Mode4,)
)

trace = scenario.verify(10, 0.01)
trace = scenario.verify(60, 0.01)

# pp_fix(reach_at_fix(trace, 0, 10))

Expand Down
43 changes: 26 additions & 17 deletions demo/fixed_points/traffic_signal_scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,25 +86,34 @@
# print("Is h1 contained within h1:", contained_single(h1, h1))
###

### unit testing contain_all_fix
r1_1 = {0: [[0, 0], [1,0]]}
r2_1 = {0: [[-1, 0], [0.5, 0], [0.5, 0], [2, 0]]}
r3_1 = {0: [[-1, 0], [0.499, 0], [0.501, 0], [2, 0]]}
r4_1 = {0: [[-1, 0], [0.5, 0], [0.5, 1], [2, 1]]}
print(f'Is r1 contained within r2: {contain_all_fix(r1_1, r2_1)}')
print(f'Is r1 contained within r3: {contain_all_fix(r1_1, r3_1)}')
print(f'Is r1 contained within r4: {contain_all_fix(r1_1, r4_1)}')

###
# ball_scenario = BallScenario().scenario
ball_scenario_branch = BallScenarioBranch().scenario

# # ball_scenario_branch_nt = BallScenarioBranchNT().scenario ### this scenario's verify doesn't really make any sense given its simulate -- figure out why
# # ## trying to verify with two agents in NT takes forever for some reason
# # trace = ball_scenario_branch_nt.verify(80, 0.1)
# # trace = ball_scenario_branch_nt.simulate(80, 0.1)

trace = ball_scenario_branch.verify(40, 0.1)
pp_fix(reach_at_fix(trace)) ### print out more elegantly, for example, line breaks and cut off array floats, test out more thoroughly
# pp_old(reach_at(trace, 39, 39.91)) ### needs to be slightly more than T-delta T due to small differences in real trace, could also fix in reach_at by rounding off the times dimension
pp_fix(reach_at_fix(trace, 0, 39.91))
# # print(fixed_points_sat(trace, 40, 0.01))
print(fixed_points_fix(trace, 40, 0.01))

fig = go.Figure()
fig = reachtube_tree(trace, None, fig, 1, 2, [1, 2], "fill", "trace")
fig.show()
# ball_scenario_branch = BallScenarioBranch().scenario

# # # ball_scenario_branch_nt = BallScenarioBranchNT().scenario ### this scenario's verify doesn't really make any sense given its simulate -- figure out why
# # # ## trying to verify with two agents in NT takes forever for some reason
# # # trace = ball_scenario_branch_nt.verify(80, 0.1)
# # # trace = ball_scenario_branch_nt.simulate(80, 0.1)

# trace = ball_scenario_branch.verify(40, 0.1)
# pp_fix(reach_at_fix(trace)) ### print out more elegantly, for example, line breaks and cut off array floats, test out more thoroughly
# # pp_old(reach_at(trace, 39, 39.91)) ### needs to be slightly more than T-delta T due to small differences in real trace, could also fix in reach_at by rounding off the times dimension
# pp_fix(reach_at_fix(trace, 0, 39.91))
# # # print(fixed_points_sat(trace, 40, 0.01))
# print(fixed_points_fix(trace, 40, 0.01))

# fig = go.Figure()
# fig = reachtube_tree(trace, None, fig, 1, 2, [1, 2], "fill", "trace")
# fig.show()
# print(f'Do there exist fixed points? {fixed_points(ball_scenario, "red-ball", t=80)}')
# print(f'Do there exist fixed points? {fixed_points_aa_branching(ball_scenario, t=80)}')
# print(f'Do there exist fixed points? {fixed_points_aa_branching(ball_scenario_branch, t=80)}')
Expand Down

0 comments on commit 350716b

Please sign in to comment.