While we do not recomment doing serious work using optimizer states written it python, it is often useful when prototyping or testing code. Copy this example and modify as needed.
6 from __future__
import print_function
17 def __init__(self, rs):
18 IMP.OptimizerState.__init__(self, rs[0].get_model(),
19 "MyOptimizerState%1%")
24 print(r.get_name(), r.get_last_score())
30 r0 = IMP._ConstRestraint(m, [], 1)
31 r0.set_name(
"restraint 0")
33 r1 = IMP._ConstRestraint(m, [], 2)
34 r1.set_name(
"restraint 1")
37 sf = rs.create_scoring_function()
39 os = MyOptimizerState([r0, r1])
40 os.set_name(
"python optimizer state")
42 co = IMP._ConstOptimizer(m)
43 co.set_scoring_function(sf)
44 co.add_optimizer_state(os)
45 print(co.optimize(100))
48 co.remove_optimizer_state(os)