IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
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-2022 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
14#include <gsl/gsl_multimin.h>
15
16IMPGSL_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 */
22class IMPGSLEXPORT GSLOptimizer : public AttributeOptimizer {
23 double stop_score_;
24 mutable double best_score_;
25 mutable FloatIndexes fis_;
26
27 public:
28 GSLOptimizer(Model *m);
29
30 virtual ~GSLOptimizer();
31
32#ifndef SWIG
34#endif
35
36 //! Stop the optimization if the score falls below this value
37 void set_stop_score(double d) { stop_score_ = d; }
38#if !defined(IMP_DOXYGEN) && !defined(SWIG)
39 gsl_vector *get_state() const;
40 void update_state(gsl_vector *x) const;
41 void write_state(const gsl_vector *x) const;
42
43 double evaluate(const gsl_vector *v);
44 double evaluate_derivative(const gsl_vector *v, gsl_vector *df);
45 unsigned int get_dimension() const {
46 IMP_USAGE_CHECK(!fis_.empty(), "not initialized properly");
47 return fis_.size();
48 }
49 double optimize(unsigned int n, const gsl_multimin_fdfminimizer_type *t,
50 double step, double param, double min_gradient);
51
52 double optimize(unsigned int n, const gsl_multimin_fminimizer_type *t,
53 double size, double max_size);
54#endif
55};
57
58IMPGSL_END_NAMESPACE
59
60#endif /* IMPGSL_GSL_OPTIMIZER_H */
Base class for optimizers that act on individual attributes.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
double optimize(unsigned int max_steps)
Optimize the model for up to max_steps iterations.
A base class for GSL-based optimizers.
void set_stop_score(double d)
Stop the optimization if the score falls below this value.
IMP::Vector< IMP::Pointer< GSLOptimizer > > GSLOptimizers
IMP::Vector< FloatIndex > FloatIndexes
Definition FloatIndex.h:53
#define IMP_OBJECTS(Name, PluralName)
Define the types for storing lists of object pointers.