Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
OUTDATED Verse-library
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AutonomyCourse_ECEIllinois
OUTDATED Verse-library
Commits
bd479c6d
Commit
bd479c6d
authored
2 years ago
by
li213
Browse files
Options
Downloads
Patches
Plain Diff
adding support for ast.UnaryOp
parent
333f3a96
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
example_two_car_lane_switch.py
+2
-2
2 additions, 2 deletions
example_two_car_lane_switch.py
ourtool/automaton/guard.py
+11
-0
11 additions, 0 deletions
ourtool/automaton/guard.py
with
13 additions
and
2 deletions
example_two_car_lane_switch.py
+
2
−
2
View file @
bd479c6d
...
...
@@ -69,7 +69,7 @@ if __name__ == "__main__":
scenario
.
set_init
(
[
[[
10
,
0
,
0
,
0.5
],[
10
,
0
,
0
,
0.5
]],
[[
0
,
-
0.2
,
0
,
1.0
],[
0
,
0.2
,
0
,
1.0
]],
[[
-
0.5
,
-
0.2
,
0
,
1.0
],[
0
.5
,
0.2
,
0
,
1.0
]],
],
[
(
VehicleMode
.
Normal
,
LaneMode
.
Lane1
),
...
...
@@ -81,7 +81,7 @@ if __name__ == "__main__":
traces
=
scenario
.
verify
(
40
)
fig
=
plt
.
figure
()
fig
=
plot_tree
(
traces
,
'
car1
'
,
1
,
[
2
],
'
b
'
,
fig
)
#
fig = plot_tree(traces, 'car1', 1, [2], 'b', fig)
fig
=
plot_tree
(
traces
,
'
car2
'
,
1
,
[
2
],
'
r
'
,
fig
)
plt
.
show
()
...
...
This diff is collapsed.
Click to expand it.
ourtool/automaton/guard.py
+
11
−
0
View file @
bd479c6d
...
...
@@ -220,6 +220,11 @@ class GuardExpressionAst:
expr
=
astunparse
.
unparse
(
node
)
expr
=
expr
.
strip
(
'
\n
'
)
return
expr
elif
isinstance
(
node
,
ast
.
UnaryOp
):
# If is UnaryOp,
value
=
self
.
_generate_z3_expression_node
(
node
.
operand
)
if
isinstance
(
node
.
op
,
ast
.
USub
):
return
-
value
else
:
# For other cases, we can return the expression directly
expr
=
astunparse
.
unparse
(
node
)
...
...
@@ -327,6 +332,12 @@ class GuardExpressionAst:
return
True
,
root
elif
isinstance
(
root
,
ast
.
Constant
):
return
root
.
value
,
root
elif
isinstance
(
root
,
ast
.
UnaryOp
):
if
isinstance
(
root
.
op
,
ast
.
USub
):
res
,
root
.
operand
=
self
.
_evaluate_guard_disc
(
root
.
operand
,
agent
,
disc_var_dict
,
lane_map
)
else
:
raise
ValueError
(
f
'
Node type
{
root
}
from
{
astunparse
.
unparse
(
root
)
}
is not supported
'
)
return
True
,
root
else
:
raise
ValueError
(
f
'
Node type
{
root
}
from
{
astunparse
.
unparse
(
root
)
}
is not supported
'
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment