Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cs598mp-fall2021-proj
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
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
chsieh16
cs598mp-fall2021-proj
Commits
4bf0656f
Commit
4bf0656f
authored
2 years ago
by
chsieh16
Browse files
Options
Downloads
Patches
Plain Diff
Move spurious check to TeacherBase
parent
b7293ccb
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
gem_stanley_teacher.py
+0
-20
0 additions, 20 deletions
gem_stanley_teacher.py
teacher_base.py
+21
-0
21 additions, 0 deletions
teacher_base.py
with
21 additions
and
20 deletions
gem_stanley_teacher.py
+
0
−
20
View file @
4bf0656f
...
@@ -31,12 +31,6 @@ NEW_ATAN_K_CTE_V_LIM = np.arctan(NEW_K_CTE_V_LIM)
...
@@ -31,12 +31,6 @@ NEW_ATAN_K_CTE_V_LIM = np.arctan(NEW_K_CTE_V_LIM)
NEW_RAW_ANG_ERR_LIM
=
ANG_LIM
+
FORWARD_VEL
*
CYCLE_TIME
NEW_RAW_ANG_ERR_LIM
=
ANG_LIM
+
FORWARD_VEL
*
CYCLE_TIME
def
z3_float64_const_to_real
(
v
:
float
)
->
z3
.
RatNumRef
:
return
z3
.
simplify
(
z3
.
fpToReal
(
z3
.
FPVal
(
v
,
z3
.
Float64
()))
)
class
GEMStanleyDRealTeacher
(
DRealTeacherBase
):
class
GEMStanleyDRealTeacher
(
DRealTeacherBase
):
def
__init__
(
self
,
name
=
"
gem_stanley
"
,
norm_ord
=
2
,
delta
=
0.001
)
->
None
:
def
__init__
(
self
,
name
=
"
gem_stanley
"
,
norm_ord
=
2
,
delta
=
0.001
)
->
None
:
...
@@ -90,20 +84,6 @@ class GEMStanleyGurobiTeacher(GurobiTeacherBase):
...
@@ -90,20 +84,6 @@ class GEMStanleyGurobiTeacher(GurobiTeacherBase):
PERC_GT
=
np
.
array
([[
0.
,
-
1.
,
0.
],
PERC_GT
=
np
.
array
([[
0.
,
-
1.
,
0.
],
[
0.
,
0.
,
-
1.
]],
float
)
[
0.
,
0.
,
-
1.
]],
float
)
@staticmethod
def
is_spurious_example
(
state_dim
:
int
,
perc_dim
:
int
,
candidate
:
z3
.
BoolRef
,
cex
:
Tuple
[
float
,
...])
->
bool
:
state_subs_map
=
[(
z3
.
Real
(
f
"
x_
{
i
}
"
),
z3_float64_const_to_real
(
cex
[
i
]))
for
i
in
range
(
state_dim
)]
perc_subs_map
=
[(
z3
.
Real
(
f
"
z_
{
i
}
"
),
z3_float64_const_to_real
(
cex
[
i
+
state_dim
]))
for
i
in
range
(
perc_dim
)]
sub_map
=
state_subs_map
+
perc_subs_map
val
=
z3
.
simplify
(
z3
.
substitute
(
candidate
,
*
sub_map
))
assert
z3
.
is_bool
(
val
)
if
z3
.
is_false
(
val
):
return
True
elif
z3
.
is_true
(
val
):
return
False
else
:
raise
RuntimeError
(
f
"
Cannot validate negative example
{
cex
}
by substitution
"
)
def
__init__
(
self
,
name
=
"
gem_stanley
"
,
norm_ord
=
2
,
ultimate_bound
:
float
=
0.0
)
->
None
:
def
__init__
(
self
,
name
=
"
gem_stanley
"
,
norm_ord
=
2
,
ultimate_bound
:
float
=
0.0
)
->
None
:
assert
ultimate_bound
>=
0.0
assert
ultimate_bound
>=
0.0
self
.
_ultimate_bound
=
ultimate_bound
self
.
_ultimate_bound
=
ultimate_bound
...
...
This diff is collapsed.
Click to expand it.
teacher_base.py
+
21
−
0
View file @
4bf0656f
...
@@ -10,7 +10,28 @@ import z3
...
@@ -10,7 +10,28 @@ import z3
import
dreal
import
dreal
def
z3_float64_const_to_real
(
v
:
float
)
->
z3
.
RatNumRef
:
return
z3
.
simplify
(
z3
.
fpToReal
(
z3
.
FPVal
(
v
,
z3
.
Float64
()))
)
class
TeacherBase
(
abc
.
ABC
):
class
TeacherBase
(
abc
.
ABC
):
@staticmethod
def
is_spurious_example
(
state_dim
:
int
,
perc_dim
:
int
,
candidate
:
z3
.
BoolRef
,
cex
:
Tuple
[
float
,
...])
->
bool
:
state_subs_map
=
[(
z3
.
Real
(
f
"
x_
{
i
}
"
),
z3_float64_const_to_real
(
cex
[
i
]))
for
i
in
range
(
state_dim
)]
perc_subs_map
=
[(
z3
.
Real
(
f
"
z_
{
i
}
"
),
z3_float64_const_to_real
(
cex
[
i
+
state_dim
]))
for
i
in
range
(
perc_dim
)]
sub_map
=
state_subs_map
+
perc_subs_map
val
=
z3
.
simplify
(
z3
.
substitute
(
candidate
,
*
sub_map
))
assert
z3
.
is_bool
(
val
)
if
z3
.
is_false
(
val
):
return
True
elif
z3
.
is_true
(
val
):
return
False
else
:
raise
RuntimeError
(
f
"
Cannot validate negative example
{
cex
}
by substitution
"
)
def
__init__
(
self
)
->
None
:
def
__init__
(
self
)
->
None
:
pass
pass
...
...
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