IMP logo
IMP Reference Guide  develop.63b38c487d,2024/12/22
The Integrative Modeling Platform
simplex.py
1 ## \example gsl/simplex.py
2 # The IMP::gsl::Simplex optimizer is a local optimizer that does not
3 # require derivatives.
4 
5 import IMP
6 import IMP.test
7 import IMP.core
8 import IMP.gsl
9 import IMP.algebra
10 import sys
11 
12 IMP.setup_from_argv(sys.argv, "simplex")
13 
14 m = IMP.Model()
15 
16 # create two particles to optimize
21 d0.set_coordinates_are_optimized(True)
22 d1.set_coordinates_are_optimized(True)
23 
24 # restrain their distance to be 1
25 dist = IMP.core.DistanceRestraint(m, IMP.core.Harmonic(1, 1), d0, d1)
26 
27 opt = IMP.gsl.Simplex(m)
28 opt.set_scoring_function([dist])
29 opt.set_minimum_size(.000001)
30 opt.set_initial_length(1)
31 
32 # probably more steps than are needed
33 e = opt.optimize(1000000)
34 print(IMP.core.get_distance(d0, d1))
Support for running tests of IMP functionality.
Strings setup_from_argv(const Strings &argv, std::string description, std::string positional_description, int num_positional)
Several general purpose optimizers from the GNU Scientific Library (GSL).
Distance restraint between two particles.
static XYZ setup_particle(Model *m, ParticleIndex pi)
Definition: XYZ.h:51
double get_distance(XYZR a, XYZR b)
Compute the sphere distance between a and b.
Definition: XYZR.h:89
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:86
A simplex optimizer taken from GSL.
Definition: Simplex.h:27
Basic functionality that is expected to be used by a wide variety of IMP users.
General purpose algebraic and geometric methods that are expected to be used by a wide variety of IMP...
VectorD< 3 > Vector3D
Definition: VectorD.h:408
Class to handle individual particles of a Model object.
Definition: Particle.h:43
Harmonic function (symmetric about the mean)
Definition: core/Harmonic.h:27