IMP  2.0.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/Optimizer.h>
14 #include <IMP/optimizer_macros.h>
15 #include <gsl/gsl_multimin.h>
16 
17 IMPGSL_BEGIN_NAMESPACE
18 
19 //! A base class for GSL-based optimizers
20 /** This class is a base class for the various GSL-based optimizers. It exposes
21  very little user functionality.
22  */
23 class IMPGSLEXPORT GSLOptimizer: public Optimizer
24 {
25  double stop_score_;
26  mutable double best_score_;
27  mutable FloatIndexes fis_;
28 public:
29  GSLOptimizer(Model *m);
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) {
39  stop_score_=d;
40  }
41 #if !defined(IMP_DOXYGEN) && !defined(SWIG)
42  gsl_vector* get_state() const;
43  void update_state(gsl_vector *x) const;
44  void write_state(const gsl_vector *x) const;
45 
46  double evaluate(const gsl_vector *v);
47  double evaluate_derivative(const gsl_vector *v, gsl_vector *df);
48  unsigned int get_dimension() const {
49  IMP_USAGE_CHECK(!fis_.empty(), "not initialized properly");
50  return fis_.size();
51  }
52  double optimize(unsigned int n, const gsl_multimin_fdfminimizer_type*t,
53  double step, double param, double min_gradient);
54 
55  double optimize(unsigned int n, const gsl_multimin_fminimizer_type*t,
56  double size, double max_size);
57 #endif
58 };
60 
61 
62 IMPGSL_END_NAMESPACE
63 
64 #endif /* IMPGSL_GSL_OPTIMIZER_H */