This example optimizes a set of a balls to form 100 chains packed into a box. It illustrates using Monte Carlo (incremental) and conjugate gradients in conjunction in a non-trivial optimization.
36 for i
in range(0, ni):
37 for j
in range(0, nj):
40 for k
in range(0, np):
42 p.set_name(
"P" + str(i) +
" " + str(j) +
" " + str(k))
46 d.set_coordinates_are_optimized(
True)
48 movers[-1].set_was_used(
True)
52 d.set_coordinates(base)
54 d.set_coordinates_are_optimized(
True)
67 restraints.append(bbr)
82 isf.add_close_pair_score(sps, 0, aps, filters)
87 nbl.set_pair_filters(filters)
91 mc.set_incremental_scoring_function(isf)
94 mc.set_scoring_function(sf)
101 cg.set_scoring_function(sf)
104 print r.get_name(), r.evaluate(
False)
107 for i
in range(1, 11):
116 for j
in range(0, 5):
118 mc.set_kt(100.0 / (3 * j + 1))
119 print "mc", mc.optimize(ni * nj * np * (j + 1) * 100), cg.optimize(10)
122 print r.get_name(), r.evaluate(
False)