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
1359c0cd
Commit
1359c0cd
authored
3 years ago
by
chsieh16
Browse files
Options
Downloads
Patches
Plain Diff
Add code to validate candidate DNF with teacher
parent
8d310c51
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dtree_teacher_gem_stanley.py
+20
-1
20 additions, 1 deletion
dtree_teacher_gem_stanley.py
with
20 additions
and
1 deletion
dtree_teacher_gem_stanley.py
+
20
−
1
View file @
1359c0cd
import
pickle
import
gurobipy
as
gp
import
numpy
as
np
from
gem_stanley_teacher
import
GEMStanleyTeacher
...
...
@@ -28,6 +31,9 @@ class DTreeTeacherGEMStanley(GEMStanleyTeacher):
cons
=
m
.
addMConstr
(
coeff_mat
,
z_diff
,
'
<
'
,
cut_vec
)
self
.
_prev_candidate_constr
.
append
(
cons
)
# L2-norm objective
m
.
setObjective
(
z_diff
@
z_diff
,
gp
.
GRB
.
MINIMIZE
)
def
test_dtree_gem_stanley_teacher
():
a_mat
=
np
.
array
([[
0.
,
-
1.
,
0.
],
...
...
@@ -47,5 +53,18 @@ def test_dtree_gem_stanley_teacher():
teacher
.
dump_model
()
def
test_verified_candidate
():
with
open
(
"
winnerDnf.pickle
"
,
"
rb
"
)
as
dnf_pkl
:
winner_dnf
=
pickle
.
load
(
dnf_pkl
)
print
(
winner_dnf
)
teacher
=
DTreeTeacherGEMStanley
()
teacher
.
set_old_state_bound
(
lb
=
[
0.0
,
-
1.0
,
0.2
],
ub
=
[
30.0
,
-
0.9
,
0.22
])
for
cand
in
winner_dnf
:
print
(
teacher
.
check
(
cand
))
print
(
teacher
.
reason_unknown
())
if
__name__
==
"
__main__
"
:
test_dtree_gem_stanley_teacher
()
# test_dtree_gem_stanley_teacher()
test_verified_candidate
()
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