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.
32 nmc = ni * nj * np * 100
49 for i
in range(0, ni):
50 for j
in range(0, nj):
53 for k
in range(0, np):
55 p.set_name(
"P" + str(i) +
" " + str(j) +
" " + str(k))
59 d.set_coordinates_are_optimized(
True)
61 movers[-1].set_was_used(
True)
65 d.set_coordinates(base)
67 d.set_coordinates_are_optimized(
True)
80 restraints.append(bbr)
95 isf.add_close_pair_score(sps, 0, aps, filters)
100 nbl.set_pair_filters(filters)
104 mc.set_incremental_scoring_function(isf)
107 mc.set_scoring_function(sf)
114 cg.set_scoring_function(sf)
117 print(r.get_name(), r.evaluate(
False))
120 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))