IMP  2.1.1
The Integrative Modeling Platform
QuasiNewton.h
Go to the documentation of this file.
1 /**
2  * \file IMP/gsl/QuasiNewton.h
3  * \brief A GSL-based Quasi-Newton optimizer
4  *
5  * Copyright 2007-2013 IMP Inventors. All rights reserved.
6  */
7 
8 #ifndef IMPGSL_QUASI_NEWTON_H
9 #define IMPGSL_QUASI_NEWTON_H
10 
11 #include <IMP/gsl/gsl_config.h>
12 
13 #include "GSLOptimizer.h"
14 
15 IMPGSL_BEGIN_NAMESPACE
16 
17 //! A quasi-Newton optimizer taken from GSL
18 /** \untested{QuasiNewton}
19  */
20 class IMPGSLEXPORT QuasiNewton : public GSLOptimizer {
21  double initial_step_, line_step_, min_gradient_;
22 
23  public:
25  /** \deprecated_at{2.1} Pass a model to the constructor. */
26  IMPGSL_DEPRECATED_FUNCTION_DECL(2.1)
27  QuasiNewton();
28 
29  // default 0.01
30  void set_initial_step(double length) {
31  IMP_USAGE_CHECK(length > 0 && length <= 4,
32  "The initial step is relative to the rescaled attributes"
33  << " and so should not be much larger than 1.");
34  initial_step_ = length;
35  }
36 
37  // default 0.01
38  void set_line_step(double d) {
39  IMP_USAGE_CHECK(d > 0 && d <= 4,
40  "The minimum size is relative to the rescaled attributes"
41  << " and so should not be much larger than 1 "
42  << "(and must be non-zero).");
43  line_step_ = d;
44  }
45 
46  // default 0.001
47  void set_minimum_gradient(double d) {
48  IMP_USAGE_CHECK(d > 0 && d <= 1, "The minimum gradient is relative.");
49  min_gradient_ = d;
50  }
51  virtual Float do_optimize(unsigned int max_steps) IMP_OVERRIDE;
53 };
54 
55 IMPGSL_END_NAMESPACE
56 
57 #endif /* IMPGSL_QUASI_NEWTON_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.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
A quasi-Newton optimizer taken from GSL.
Definition: QuasiNewton.h:20
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.