IMP logo
IMP Reference Guide  2.17.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
3 # best scoring conformation.
4 #
5 
6 from __future__ import print_function
7 import IMP.example
8 import IMP.statistics
9 import sys
10 
11 IMP.setup_from_argv(sys.argv, "Basic optimization")
12 
13 (m, c) = IMP.example.create_model_and_particles()
17 # we don't want to see lots of log messages about restraint evaluation
18 m.set_log_level(IMP.WARNING)
19 
20 # the container (c) stores a list of particle indices
21 pis = c.get_contents()
22 
24 s.set_scoring_function(sf)
25 s.set_number_of_attempts(10)
26 # but we do want something to watch
27 s.set_log_level(IMP.TERSE)
28 s.set_number_of_monte_carlo_steps(10)
29 # find some configurations which move the particles far apart
30 configs = s.create_sample()
31 for i in range(0, configs.get_number_of_configurations()):
32  configs.load_configuration(i)
33  # print out the sphere containing the point set
34  # - Why? - Why not?
36  print(sphere)
37 
38 # cluster the solutions based on their coordinates
40 
41 # of course, this doesn't return anything of interest since the points are
42 # randomly distributed, but, again, why not?
43 clustering = IMP.statistics.create_lloyds_kmeans(e, 3, 1000)
44 for i in range(0, clustering.get_number_of_clusters()):
45  # load the configuration for a central point
46  configs.load_configuration(clustering.get_cluster_representative(i))
48  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)
Strings setup_from_argv(const Strings &argv, std::string description, std::string positional_description, int num_positional)
ParticlesTemp get_particles(Model *m, const ParticleIndexes &ps)
Get the particles from a list of indexes.
Create a scoring function on a list of restraints.
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.