IMP::domino::DominoSampler supports an interactive mode whereby each step of the sampling process is called explicitly and all intermediate results are exposed. This usage mode can be used to help understand how domino behaves as well as to distribute a domino computation to multiple cores or multiple machines. For the latter, it is useful to use the IMP::domino::get_assignments() and IMP::domino::set_assignments() functions to save the states to a file.
10 from __future__
import print_function
23 for x
in range(0, 3)])
27 [(ps[i[0]], ps[i[1]])
for i
in [(0, 1), (1, 2)]])
28 print([(m.get_particle_name(p[0]), m.get_particle_name(p[1]))
29 for p
in lpc.get_contents()])
31 r.set_maximum_score(.1)
38 pst.set_particle_states(m.get_particle(p), space)
40 m.set_log_level(IMP.SILENT)
47 print(
"Unable to display graph using 'dot'")
51 ds.set_restraints([r])
52 ds.set_scoring_function([r])
54 ds.set_log_level(IMP.SILENT)
59 def get_assignments(vertex):
60 on = mt.get_out_neighbors(vertex)
63 ret = ds.get_vertex_assignments(vertex)
70 a0 = get_assignments(on[0])
71 a1 = get_assignments(on[1])
72 ret = ds.get_vertex_assignments(vertex, a0, a1)
73 print(mt.get_vertex_name(vertex), [str(r)
for r
in ret])
77 get_assignments(mt.get_vertices()[-1])
84 def schedule_job(vertex):
87 on = mt.get_out_neighbors(vertex)
90 max_child_time = max(schedule_job(n), max_child_time)
91 my_time = max_child_time + 1
92 while len(schedule) < my_time + 1:
95 schedule[my_time].append(vertex)
98 schedule_job(mt.get_vertices()[-1])
99 print(
"The merging can be scheduled as", schedule)