IMP  2.0.0
The Integrative Modeling Platform
incremental_mc.py
1 ## \example core/incremental_mc.py
2 ## This example shows how to do incremental scoring with Monte Carlo. Incremental scoring can be significantly faster than non-incremental scoring when using moves that only move a few particles at a time.
3 
4 import IMP.core
5 import IMP.container
6 import IMP.algebra
7 import IMP.display
8 m= IMP.Model()
10  IMP.algebra.Vector3D(30, 30, 30))
11 ps=[]
12 for i in range(0,20):
13  ps.append(IMP.Particle(m))
15  d.set_radius(10)
16  d.set_coordinates(IMP.algebra.get_random_vector_in(bb))
17  d.set_coordinates_are_optimized(True)
18 
22  psl)
25 mc.set_incremental_scoring_function(isf)
26 
27 mvs=[IMP.core.BallMover([p], 5) for p in ps]
28 sm= IMP.core.SerialMover(mvs)
29 mc.add_mover(sm)
30 IMP.base.set_log_level(IMP.base.SILENT)
31 print "initial",isf.evaluate(False)
32 after=mc.optimize(10000)
33 print "final", after
34 name=IMP.base.create_temporary_file_name("incremental_mc", ".pym")
36 for p in ps:
38  w.add_geometry(g)
39 print "pymol", name