home
about
news
download
doc
source
systems
tests
bugs
contact
IMP Reference Guide
2.7.0
The Integrative Modeling Platform
IMP Manual
Reference Guide
Modules
Classes
Examples
version 2.7.0
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
import
sys
11
12
IMP.setup_from_argv
(sys.argv,
"simplex"
)
13
14
m =
IMP.Model
()
15
16
# create two particles to optimize
17
d0 =
IMP.core.XYZ.setup_particle
(
18
IMP.Particle
(m),
IMP.algebra.Vector3D
(0, 0, 0))
19
d1 =
IMP.core.XYZ.setup_particle
(
20
IMP.Particle
(m),
IMP.algebra.Vector3D
(3, 4, 5))
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))