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.
33 nmc = ni * nj * np * 100
50 for i
in range(0, ni):
51 for j
in range(0, nj):
54 for k
in range(0, np):
56 p.set_name(
"P" + str(i) +
" " + str(j) +
" " + str(k))
60 d.set_coordinates_are_optimized(
True)
62 movers[-1].set_was_used(
True)
66 d.set_coordinates(base)
68 d.set_coordinates_are_optimized(
True)
81 restraints.append(bbr)
96 isf.add_close_pair_score(sps, 0, aps, filters)
101 nbl.set_pair_filters(filters)
105 mc.set_incremental_scoring_function(isf)
108 mc.set_scoring_function(sf)
115 cg.set_scoring_function(sf)
118 print r.get_name(), r.evaluate(
False)
121 for i
in range(1, nouter):
130 for j
in range(0, ninner):
132 mc.set_kt(100.0 / (3 * j + 1))
133 print "mc", mc.optimize((j + 1) * nmc), cg.optimize(nmc)
136 print r.get_name(), r.evaluate(
False)