IMP  2.4.0
The Integrative Modeling Platform
basic_optimization.py
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 from __future__ import print_function
7 import IMP.example
8 import IMP.statistics
9 
10 (m, c) = IMP.example.create_model_and_particles()
13 m.add_restraint(r)
14 # we don't want to see lots of log messages about restraint evaluation
15 m.set_log_level(IMP.WARNING)
16 
17 # the container (c) stores a list of particles, which are alse XYZR particles
18 # we can construct a list of all the decorated particles
19 xyzrs = c.get_particles()
20 
22 s.set_number_of_attempts(10)
23 # but we do want something to watch
24 s.set_log_level(IMP.base.TERSE)
25 s.set_number_of_monte_carlo_steps(10)
26 # find some configurations which move the particles far apart
27 configs = s.create_sample()
28 for i in range(0, configs.get_number_of_configurations()):
29  configs.load_configuration(i)
30  # print out the sphere containing the point set
31  # - Why? - Why not?
32  sphere = IMP.core.get_enclosing_sphere(xyzrs)
33  print(sphere)
34 
35 # cluster the solutions based on their coordinates
37 
38 # of course, this doesn't return anything of interest since the points are
39 # randomly distributed, but, again, why not?
40 clustering = IMP.statistics.create_lloyds_kmeans(e, 3, 1000)
41 for i in range(0, clustering.get_number_of_clusters()):
42  # load the configuration for a central point
43  configs.load_configuration(clustering.get_cluster_representative(i))
44  sphere = IMP.core.get_enclosing_sphere(xyzrs)
45  print(sphere)
PartitionalClusteringWithCenter * create_lloyds_kmeans(Embedding *embedding, unsigned int k, unsigned int iterations)
Embed a configuration using the XYZ coordinates of a set of particles.
Definition: embeddings.h:28
Lower bound harmonic function (non-zero when feature < mean)
Return all close unordered pairs of particles taken from the SingletonContainer.
Code to compute statistical measures.
A simple sampler.
Definition: MCCGSampler.h:40
algebra::Sphere3D get_enclosing_sphere(const XYZs &v)
Get a sphere enclosing the set of XYZRs.
Example module.
Applies a PairScore to each Pair in a list.