IMP  2.1.1
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-2013 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:
33  /** \deprecated_at{2.1} Pass a model to the constructor. */
34  IMPGSL_DEPRECATED_FUNCTION_DECL(2.1)
35  Simplex();
36 
37  /** \name Parameters
38 
39  The parameters are:
40 
41  - minumum_size: the optimization stops when the size of the
42  simplex falls below this. The size is defined as the average
43  distance from the centroid to the simplex vertices. (Default 0.1)
44 
45  - initial_length: the length of the initial sizes of the
46  simplex. Make sure that this covers the optimal solution, given
47  the starting configuration. (Default 1)
48 
49  \note Both quantities are relative to rescaled attribues and so should be
50  numbers between 0 and 1.
51  @{
52  */
53 
54  void set_initial_length(double length) {
55  IMP_USAGE_CHECK(length > 0 && length <= 4,
56  "The initial length is relative to the rescaled attributes"
57  << " and so should not be much larger than 1.");
58  max_length_ = length;
59  }
60 
61  void set_minimum_size(double d) {
62  IMP_USAGE_CHECK(d > 0 && d <= 4,
63  "The minimum size is relative to the rescaled attributes"
64  << " and so should not be much larger than 1 "
65  << "(and must be non-zero).");
66  min_length_ = d;
67  }
68  /** @} */
69  virtual Float do_optimize(unsigned int max_steps) IMP_OVERRIDE;
71 };
72 
73 IMPGSL_END_NAMESPACE
74 
75 #endif /* IMPGSL_SIMPLEX_H */
A base class for GSL-based optimizers.
Definition: GSLOptimizer.h:22
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
A simplex optimizer taken from GSL.
Definition: Simplex.h:27
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
double Float
Basic floating-point value (could be float, double...)
Definition: base/types.h:20
A base class for GSL-based optimizers.
Class for storing model, its restraints, constraints, and particles.