IMP
2.0.1
The Integrative Modeling Platform
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
gsl/simplex.py
The
IMP::gsl::Simplex
optimizer is a local optimizer that does not require derivatives.
1
## \example gsl/simplex.py
2
## The IMP::gsl::Simplex optimizer is a local optimizer that does not require derivatives.
3
4
import
IMP,
IMP.test
5
import
IMP.core
6
import
IMP.gsl
7
import
IMP.algebra
8
9
10
m=
IMP.Model
()
11
12
# create two particles to optimize
13
d0=
IMP.core.XYZ.setup_particle
(
IMP.Particle
(m),
IMP.algebra.Vector3D
(0,0,0))
14
d1=
IMP.core.XYZ.setup_particle
(
IMP.Particle
(m),
IMP.algebra.Vector3D
(3,4,5))
15
d0.set_coordinates_are_optimized(
True
)
16
d1.set_coordinates_are_optimized(
True
)
17
18
# restrain their distance to be 1
19
dist=
IMP.core.DistanceRestraint
(
IMP.core.Harmonic
(1, 1), d0, d1)
20
m.add_restraint(dist)
21
22
opt =
IMP.gsl.Simplex
(m)
23
opt.set_minimum_size(.000001)
24
opt.set_initial_length(1)
25
26
# probably more steps than are needed
27
e = opt.optimize(1000000)
28
print
IMP.core.get_distance
(d0, d1)