text
stringlengths 1
93.6k
|
|---|
norm=checkpoint_args.norm,
|
)
|
# set the policy into eval mode
|
policy.eval()
|
# load the policy parameters
|
policy.load_state_dict(chkpnt['state_dict'])
|
policy = policy.to(device)
|
policy_name = 'TreeGatePolicy'
|
elif checkpoint_args.policy_type == 'NoTreePolicy':
|
policy = NoTreePolicy(
|
var_dim=state_dims['var_dim'],
|
node_dim=state_dims['node_dim'],
|
mip_dim=state_dims['mip_dim'],
|
hidden_size=checkpoint_args.hidden_size,
|
depth=checkpoint_args.depth,
|
dropout=checkpoint_args.dropout,
|
dim_reduce_factor=checkpoint_args.dim_reduce_factor,
|
infimum=checkpoint_args.infimum,
|
norm=checkpoint_args.norm,
|
)
|
# set the policy into eval mode
|
policy.eval()
|
# load the policy parameters
|
policy.load_state_dict(chkpnt['state_dict'])
|
policy = policy.to(device)
|
policy_name = 'NoTreePolicy'
|
else:
|
raise ValueError('A valid policy should be set.')
|
# main evaluation
|
eps = np.finfo(np.float32).eps.item()
|
with torch.no_grad():
|
exp_dict = env.run_episode(
|
instance=instance_file_path,
|
name=args.name.split('.')[0],
|
policy=policy,
|
policy_name=policy_name,
|
state_dims=state_dims,
|
scip_seed=args.seed,
|
cutoff_value=cutoff_dict[name],
|
scip_limits=limits,
|
scip_params=settings[args.setting],
|
verbose=args.verbose,
|
)
|
# dump the exp_dict
|
f = open(os.path.join(args.out_dir, '{}_{}_ILEval_info.pkl'.format(name, args.seed)), 'wb')
|
pickle.dump(exp_dict, f)
|
f.close()
|
# <FILESEP>
|
from htag import Tag,HTagException
|
from htag.render import HRenderer
|
import pytest
|
def test_statics_only_tagbase():
|
class AEFF(Tag):
|
statics="body {background:red}", b"alert(42);"
|
h=str(HRenderer(AEFF,"//js"))
|
assert "<style>body {background:red}</style>" in h
|
assert "<script>alert(42);</script>" in h
|
del AEFF
|
def test_built_immediatly():
|
################################################################
|
# test static discovering (in built immediatly)
|
################################################################
|
class O(Tag.div):
|
statics=Tag.style("/*S1*/")
|
assert "/*S1*/" in str(HRenderer( O, "//"))
|
################################################################
|
class OO1(Tag.div):
|
imports = O
|
def init(self):
|
self <= O() # "O" is a direct child
|
assert "/*S1*/" in str(HRenderer( OO1, "//"))
|
# ################################################################
|
class OO2(Tag.div):
|
imports = O
|
def init(self):
|
self <= Tag.div( O() ) # "O" is a non-direct child
|
assert "/*S1*/" in str(HRenderer( OO2, "//"))
|
################################################################
|
def test_build_lately():
|
################################################################
|
# test static discovering (in built lately)
|
################################################################
|
class O(Tag.div):
|
statics=Tag.style("/*S1*/")
|
assert "/*S1*/" in str(HRenderer( O, "//"))
|
################################################################
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.