IMP logo
IMP Reference Guide  2.12.0
The Integrative Modeling Platform
Simplex.h
Go to the documentation of this file.
1 /**
2  * \file IMP/gsl/Simplex.h
3  * \brief The simplex algorithm from GSL.
4  *
5  * Copyright 2007-2019 IMP Inventors. All rights reserved.
6  */
7 
8 #ifndef IMPGSL_SIMPLEX_H
9 #define IMPGSL_SIMPLEX_H
10 
11 #include <IMP/gsl/gsl_config.h>
12 
13 #include "GSLOptimizer.h"
14 
15 IMPGSL_BEGIN_NAMESPACE
16 
17 //! A simplex optimizer taken from GSL
18 /** Simplex works by modifying a simplex in the space of the optimized
19  attributes. The algorithm may not behave well when using score
20  states, such as those involved in rigid bodies, which
21  significantly change the values of the attributes. Then, again, it
22  may work just fine. But be aware that it is not understood.
23 
24  The main advantage of Simplex is that it is a local optimizer that
25  does not require derivatives.
26  */
27 class IMPGSLEXPORT Simplex : public GSLOptimizer {
28  double min_length_;
29  double max_length_;
30 
31  public:
32  Simplex(Model *m);
33 
34  /** \name Parameters
35 
36  The parameters are:
37 
38  - minimum_size: the optimization stops when the size of the
39  simplex falls below this. The size is defined as the average
40  distance from the centroid to the simplex vertices. (Default 0.1)
41 
42  - initial_length: the length of the initial sizes of the
43  simplex. Make sure that this covers the optimal solution, given
44  the starting configuration. (Default 1)
45 
46  \note Both quantities are relative to rescaled attributes and so should be
47  numbers between 0 and 1.
48  @{
49  */
50 
51  void set_initial_length(double length) {
52  IMP_USAGE_CHECK(length > 0 && length <= 4,
53  "The initial length is relative to the rescaled attributes"
54  << " and so should not be much larger than 1.");
55  max_length_ = length;
56  }
57 
58  void set_minimum_size(double d) {
59  IMP_USAGE_CHECK(d > 0 && d <= 4,
60  "The minimum size is relative to the rescaled attributes"
61  << " and so should not be much larger than 1 "
62  << "(and must be non-zero).");
63  min_length_ = d;
64  }
65  /** @} */
66  virtual Float do_optimize(unsigned int max_steps) IMP_OVERRIDE;
68 };
69 
70 IMPGSL_END_NAMESPACE
71 
72 #endif /* IMPGSL_SIMPLEX_H */
A base class for GSL-based optimizers.
Definition: GSLOptimizer.h:22
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:72
A simplex optimizer taken from GSL.
Definition: Simplex.h:27
virtual double do_optimize(unsigned int ns)=0
override this function to do actual optimization
double Float
Basic floating-point value (could be float, double...)
Definition: types.h:20
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
Definition: check_macros.h:168
A base class for GSL-based optimizers.
#define IMP_OVERRIDE
Cause a compile error if this method does not override a parent method.