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
15d3ad1b
Commit
15d3ad1b
authored
2 years ago
by
crides
Browse files
Options
Downloads
Patches
Plain Diff
veri: port fix
parent
14a04b7d
No related branches found
Branches containing commit
No related tags found
1 merge request
!9
Tutorial
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
verse/scenario/scenario.py
+33
-34
33 additions, 34 deletions
verse/scenario/scenario.py
with
33 additions
and
34 deletions
verse/scenario/scenario.py
+
33
−
34
View file @
15d3ad1b
...
...
@@ -503,42 +503,41 @@ class Scenario:
# _transitions = [trans.transition for seg in cache.values() for trans in seg.transitions]
_transitions
=
[(
aid
,
trans
)
for
aid
,
seg
in
cache
.
items
()
for
trans
in
seg
.
transitions
if
reach_trans_suit
(
trans
.
inits
,
node
.
init
)]
# pp(("cached trans", len(_transitions)))
if
len
(
_transitions
)
==
0
:
return
None
,
[]
min_trans_ind
=
min
([
t
.
transition
for
_
,
t
in
_transitions
])
# TODO: check for asserts
cached_trans
=
[(
aid
,
tran
.
mode
,
tran
.
dest
,
tran
.
reset
,
tran
.
reset_idx
,
tran
.
paths
)
for
aid
,
tran
in
dedup
(
_transitions
,
lambda
p
:
(
p
[
0
],
p
[
1
].
mode
,
p
[
1
].
dest
))
if
tran
.
transition
==
min_trans_ind
]
if
len
(
paths
)
==
0
:
# print(red("full cache"))
return
None
,
cached_trans
if
len
(
_transitions
)
>
0
:
min_trans_ind
=
min
([
t
.
transition
for
_
,
t
in
_transitions
])
# TODO: check for asserts
cached_trans
=
[(
aid
,
tran
.
mode
,
tran
.
dest
,
tran
.
reset
,
tran
.
reset_idx
,
tran
.
paths
)
for
aid
,
tran
in
dedup
(
_transitions
,
lambda
p
:
(
p
[
0
],
p
[
1
].
mode
,
p
[
1
].
dest
))
if
tran
.
transition
==
min_trans_ind
]
if
len
(
paths
)
==
0
:
# print(red("full cache"))
return
None
,
cached_trans
path_transitions
=
defaultdict
(
int
)
for
seg
in
cache
.
values
():
for
tran
in
seg
.
transitions
:
for
p
in
tran
.
paths
:
path_transitions
[
p
.
cond
]
=
max
(
path_transitions
[
p
.
cond
],
tran
.
transition
)
for
agent_id
,
segment
in
cache
.
items
():
agent
=
node
.
agent
[
agent_id
]
if
len
(
agent
.
controller
.
args
)
==
0
:
continue
state_dict
=
{
aid
:
(
node
.
trace
[
aid
][
0
],
node
.
mode
[
aid
],
node
.
static
[
aid
])
for
aid
in
node
.
agent
}
agent_paths
=
dedup
([
p
for
tran
in
segment
.
transitions
for
p
in
tran
.
paths
],
lambda
i
:
(
i
.
var
,
i
.
cond
,
i
.
val
))
for
path
in
agent_paths
:
cont_var_dict_template
,
discrete_variable_dict
,
length_dict
=
self
.
sensor
.
sense
(
self
,
agent
,
state_dict
,
self
.
map
)
reset
=
(
path
.
var
,
path
.
val_veri
)
guard_expression
=
GuardExpressionAst
([
path
.
cond_veri
])
cont_var_updater
=
guard_expression
.
parse_any_all_new
(
cont_var_dict_template
,
discrete_variable_dict
,
length_dict
)
self
.
apply_cont_var_updater
(
cont_var_dict_template
,
cont_var_updater
)
guard_can_satisfied
=
guard_expression
.
evaluate_guard_disc
(
agent
,
discrete_variable_dict
,
cont_var_dict_template
,
self
.
map
)
if
not
guard_can_satisfied
:
path_transitions
=
defaultdict
(
int
)
for
seg
in
cache
.
values
():
for
tran
in
seg
.
transitions
:
for
p
in
tran
.
paths
:
path_transitions
[
p
.
cond
]
=
max
(
path_transitions
[
p
.
cond
],
tran
.
transition
)
for
agent_id
,
segment
in
cache
.
items
():
agent
=
node
.
agent
[
agent_id
]
if
len
(
agent
.
controller
.
args
)
==
0
:
continue
cached_guards
[
agent_id
].
append
((
path
,
guard_expression
,
cont_var_updater
,
copy
.
deepcopy
(
discrete_variable_dict
),
reset
,
path_transitions
[
path
.
cond
]))
state_dict
=
{
aid
:
(
node
.
trace
[
aid
][
0
],
node
.
mode
[
aid
],
node
.
static
[
aid
])
for
aid
in
node
.
agent
}
agent_paths
=
dedup
([
p
for
tran
in
segment
.
transitions
for
p
in
tran
.
paths
],
lambda
i
:
(
i
.
var
,
i
.
cond
,
i
.
val
))
for
path
in
agent_paths
:
cont_var_dict_template
,
discrete_variable_dict
,
length_dict
=
self
.
sensor
.
sense
(
self
,
agent
,
state_dict
,
self
.
map
)
reset
=
(
path
.
var
,
path
.
val_veri
)
guard_expression
=
GuardExpressionAst
([
path
.
cond_veri
])
cont_var_updater
=
guard_expression
.
parse_any_all_new
(
cont_var_dict_template
,
discrete_variable_dict
,
length_dict
)
self
.
apply_cont_var_updater
(
cont_var_dict_template
,
cont_var_updater
)
guard_can_satisfied
=
guard_expression
.
evaluate_guard_disc
(
agent
,
discrete_variable_dict
,
cont_var_dict_template
,
self
.
map
)
if
not
guard_can_satisfied
:
continue
cached_guards
[
agent_id
].
append
((
path
,
guard_expression
,
cont_var_updater
,
copy
.
deepcopy
(
discrete_variable_dict
),
reset
,
path_transitions
[
path
.
cond
]))
# for aid, trace in node.trace.items():
# if len(trace) < 2:
...
...
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