IMP  2.3.1
The Integrative Modeling Platform
kernel/basic_optimization.py

This illustrates a basic main loop for optimization and searching for the best scoring conformation.

1 ## \example kernel/basic_optimization.py
2 # This illustrates a basic main loop for optimization and searching for the best
3 # scoring conformation.
4 #
5 
6 import IMP.example
7 import IMP.statistics
8 
9 (m, c) = IMP.example.create_model_and_particles()
12 m.add_restraint(r)
13 # we don't want to see lots of log messages about restraint evaluation
14 m.set_log_level(IMP.WARNING)
15 
16 # the container (c) stores a list of particles, which are alse XYZR particles
17 # we can construct a list of all the decorated particles
18 xyzrs = c.get_particles()
19 
21 s.set_number_of_attempts(10)
22 # but we do want something to watch
23 s.set_log_level(IMP.base.TERSE)
24 s.set_number_of_monte_carlo_steps(10)
25 # find some configurations which move the particles far apart
26 configs = s.create_sample()
27 for i in range(0, configs.get_number_of_configurations()):
28  configs.load_configuration(i)
29  # print out the sphere containing the point set
30  # - Why? - Why not?
31  sphere = IMP.core.get_enclosing_sphere(xyzrs)
32  print sphere
33 
34 # cluster the solutions based on their coordinates
36 
37 # of course, this doesn't return anything of interest since the points are
38 # randomly distributed, but, again, why not?
39 clustering = IMP.statistics.create_lloyds_kmeans(e, 3, 1000)
40 for i in range(0, clustering.get_number_of_clusters()):
41  # load the configuration for a central point
42  configs.load_configuration(clustering.get_cluster_representative(i))
43  sphere = IMP.core.get_enclosing_sphere(xyzrs)
44  print sphere