IMP  2.1.1
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.
3 # Incremental scoring can be significantly faster than non-incremental
4 # scoring when using moves that only move a few particles at a time.
5 
6 import IMP.core
7 import IMP.container
8 import IMP.algebra
9 import IMP.display
10 m = IMP.kernel.Model()
12  IMP.algebra.Vector3D(30, 30, 30))
13 ps = []
14 for i in range(0, 20):
15  ps.append(IMP.kernel.Particle(m))
17  d.set_radius(10)
18  d.set_coordinates(IMP.algebra.get_random_vector_in(bb))
19  d.set_coordinates_are_optimized(True)
20 
25  IMP.core.HarmonicUpperBound(0, 1), bb),
26  psl)
27 mc = IMP.core.MonteCarlo(m)
28 isf = IMP.core.IncrementalScoringFunction(ps, [r, rb])
29 mc.set_incremental_scoring_function(isf)
30 
31 mvs = [IMP.core.BallMover([p], 5) for p in ps]
32 sm = IMP.core.SerialMover(mvs)
33 mc.add_mover(sm)
34 IMP.base.set_log_level(IMP.base.SILENT)
35 print "initial", isf.evaluate(False)
36 after = mc.optimize(10000)
37 print "final", after
38 name = IMP.base.create_temporary_file_name("incremental_mc", ".pym")
40 for p in ps:
42  w.add_geometry(g)
43 print "pymol", name
Applies a SingletonScore to each Singleton in a list.
A Monte Carlo optimizer.
Definition: MonteCarlo.h:47
See IMP.container for more information.
Upper bound harmonic function (non-zero when feature > mean)
void set_log_level(LogLevel l)
Set the current global log level.
std::string create_temporary_file_name(std::string prefix="imp_temp", std::string suffix="")
Modify a set of continuous variables by perturbing them within a ball.
Score particles based on how far outside a box they are.
Vector3D get_random_vector_in(const Cylinder3D &c)
Generate a random vector in a cylinder with uniform density.
static XYZR setup_particle(kernel::Model *m, ParticleIndex pi)
Definition: XYZR.h:48
Class to handle individual model particles.
See IMP.core for more information.
See IMP.algebra for more information.
Prevent a set of particles and rigid bodies from inter-penetrating.
Write a CGO file with the geometry.
Definition: PymolWriter.h:34
See IMP.display for more information.
Definition: BildWriter.h:20
Apply a list of movers one at a time.
Definition: SerialMover.h:23
Class for storing model, its restraints, constraints, and particles.
Display an IMP::core::XYZR particle as a ball.
Definition: XYZR.h:160