IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
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
5import IMP
6import IMP.test
7import IMP.core
8import IMP.gsl
9import IMP.algebra
10import sys
11
12IMP.setup_from_argv(sys.argv, "simplex")
13
14m = IMP.Model()
15
16# create two particles to optimize
21d0.set_coordinates_are_optimized(True)
22d1.set_coordinates_are_optimized(True)
23
24# restrain their distance to be 1
25dist = IMP.core.DistanceRestraint(m, IMP.core.Harmonic(1, 1), d0, d1)
26
27opt = IMP.gsl.Simplex(m)
28opt.set_scoring_function([dist])
29opt.set_minimum_size(.000001)
30opt.set_initial_length(1)
31
32# probably more steps than are needed
33e = opt.optimize(1000000)
34print(IMP.core.get_distance(d0, d1))
Class for storing model, its restraints, constraints, and particles.
Definition Model.h:111
Class to handle individual particles of a Model object.
Definition Particle.h:45
Distance restraint between two particles.
Harmonic function (symmetric about the mean)
static XYZ setup_particle(Model *m, ParticleIndex pi)
Definition XYZ.h:51
A simplex optimizer taken from GSL.
Definition Simplex.h:27
General purpose algebraic and geometric methods that are expected to be used by a wide variety of IMP...
VectorD< 3 > Vector3D
Definition VectorD.h:407
Basic functionality that is expected to be used by a wide variety of IMP users.
double get_distance(const Surface &s, const XYZR &d)
Get distance from sphere to surface.
Definition Surface.h:153
Several general purpose optimizers from the GNU Scientific Library (GSL).
Support for running tests of IMP functionality.
void setup_from_argv(int argc, char **argv, std::string description)
Parse the command line flags and return the positional arguments.