IMP
2.2.1
The Integrative Modeling Platform
IMP Mainpage
All IMP Modules
Related Pages
Modules
Namespaces
Classes
Files
Examples
Indexes
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
3
# require derivatives.
4
5
import
IMP
6
import
IMP.test
7
import
IMP.core
8
import
IMP.gsl
9
import
IMP.algebra
10
11
12
m =
IMP.kernel.Model
()
13
14
# create two particles to optimize
15
d0 =
IMP.core.XYZ.setup_particle
(
16
IMP.kernel.Particle
(m),
IMP.algebra.Vector3D
(0, 0, 0))
17
d1 =
IMP.core.XYZ.setup_particle
(
18
IMP.kernel.Particle
(m),
IMP.algebra.Vector3D
(3, 4, 5))
19
d0.set_coordinates_are_optimized(
True
)
20
d1.set_coordinates_are_optimized(
True
)
21
22
# restrain their distance to be 1
23
dist =
IMP.core.DistanceRestraint
(
IMP.core.Harmonic
(1, 1), d0, d1)
24
m.add_restraint(dist)
25
26
opt =
IMP.gsl.Simplex
(m)
27
opt.set_minimum_size(.000001)
28
opt.set_initial_length(1)
29
30
# probably more steps than are needed
31
e = opt.optimize(1000000)
32
print
IMP.core.get_distance
(d0, d1)