IMP  2.1.1
The Integrative Modeling Platform
GSLOptimizer.h
Go to the documentation of this file.
1 /**
2  * \file IMP/gsl/GSLOptimizer.h
3  * \brief A base class for GSL-based optimizers
4  *
5  * Copyright 2007-2013 IMP Inventors. All rights reserved.
6  */
7 
8 #ifndef IMPGSL_GSL_OPTIMIZER_H
9 #define IMPGSL_GSL_OPTIMIZER_H
10 
11 #include <IMP/gsl/gsl_config.h>
12 
13 #include <IMP/AttributeOptimizer.h>
14 #include <gsl/gsl_multimin.h>
15 
16 IMPGSL_BEGIN_NAMESPACE
17 
18 //! A base class for GSL-based optimizers
19 /** This class is a base class for the various GSL-based optimizers. It exposes
20  very little user functionality.
21  */
22 class IMPGSLEXPORT GSLOptimizer : public AttributeOptimizer {
23  double stop_score_;
24  mutable double best_score_;
25  mutable FloatIndexes fis_;
26 
27  public:
29  GSLOptimizer();
30 
31  virtual ~GSLOptimizer();
32 
33 #ifndef SWIG
34  using Optimizer::optimize;
35 #endif
36 
37  //! Stop the optimization if the score falls below this value
38  void set_stop_score(double d) { stop_score_ = d; }
39 #if !defined(IMP_DOXYGEN) && !defined(SWIG)
40  gsl_vector *get_state() const;
41  void update_state(gsl_vector *x) const;
42  void write_state(const gsl_vector *x) const;
43 
44  double evaluate(const gsl_vector *v);
45  double evaluate_derivative(const gsl_vector *v, gsl_vector *df);
46  unsigned int get_dimension() const {
47  IMP_USAGE_CHECK(!fis_.empty(), "not initialized properly");
48  return fis_.size();
49  }
50  double optimize(unsigned int n, const gsl_multimin_fdfminimizer_type *t,
51  double step, double param, double min_gradient);
52 
53  double optimize(unsigned int n, const gsl_multimin_fminimizer_type *t,
54  double size, double max_size);
55 #endif
56 };
58 
59 IMPGSL_END_NAMESPACE
60 
61 #endif /* IMPGSL_GSL_OPTIMIZER_H */
A base class for GSL-based optimizers.
Definition: GSLOptimizer.h:22
void set_stop_score(double d)
Stop the optimization if the score falls below this value.
Definition: GSLOptimizer.h:38
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
#define IMP_OBJECTS(Name, PluralName)
Define the types for storing sets of objects.
Import IMP/kernel/AttributeOptimizer.h in the namespace.
Class for storing model, its restraints, constraints, and particles.