Optimize six particles on a 2D unit grid. In order to remove translation degrees of freedom, the 0th particle is pinned at the origin by allowing it only a single conformation. To remove flips, the first particle is restrained to have a positive x coordinate.
7 from __future__
import print_function
19 def create_scoring(m, ps):
20 pairs = [[0, 1], [0, 2], [1, 3], [2, 3], [3, 4], [4, 5], [1, 5]]
26 [(ps[p[0]], ps[p[1]])
for p
in pairs],
29 pr.set_maximum_score(.01)
36 dr.set_maximum_score(.01)
40 def create_representation(m):
44 p = m.add_particle(
"P%d" % i)
50 def create_discrete_states(m, ps):
57 vs = vs + [-v
for v
in vs]
58 print(len(vs),
"states for each particle")
63 pst.set_particle_states(m.get_particle(p), states)
67 def create_sampler(m, r, pst):
85 states.set_log_level(IMP.SILENT)
86 s.set_assignments_table(states)
87 s.set_subset_filter_tables(filters)
95 m.set_log_level(IMP.SILENT)
97 print(
"creating representation")
98 ps = create_representation(m)
99 print(
"creating discrete states")
100 pst = create_discrete_states(m, ps)
101 print(
"creating score function")
102 rs = create_scoring(m, ps)
103 print(
"creating sampler")
104 s = create_sampler(m, rs, pst)
111 cs = s.create_sample()
113 print(
"found ", cs.get_number_of_configurations(),
"solutions")
115 for i
in range(cs.get_number_of_configurations()):
116 cs.load_configuration(i)
117 print(
"solution number:", i,
" is:", sf.evaluate(
False))