/usr/include/mia-2.2/gsl++/multimin.hh is in libmia-2.2-dev 2.2.2-1+b1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | /* -*- mia-c++ -*-
*
* This file is part of MIA - a toolbox for medical image analysis
* Copyright (c) Leipzig, Madrid 1999-2014 Gert Wollny
*
* MIA is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MIA; if not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef GSLPP_MULTIMIN_HH
#define GSLPP_MULTIMIN_HH
#include <memory>
#include <gsl++/vector.hh>
#include <gsl/gsl_multimin.h>
#include <gsl++/gsldefines.hh>
namespace gsl {
/**
This class wraps the gradient based optimizers of the GSL
*/
class EXPORT_GSL CFDFMinimizer {
public:
/**
This is the base class for all optimization problems that provide
gradient information for optimization.
*/
class Problem {
public:
/**
Initialize the optimization problem with the given number of parameters
*/
Problem(size_t n_params);
/**
Callback to evaluate the value of the optimization criterion
To derive a CFDFMinimizer::Problem, the do_f methods has to be implemented accordingly.
\remark actually this function should be private and only visible CFDFMinimizer
*/
static double f(const gsl_vector * x, void * params);
/**
Callback to evaluate the gradient of the optimization criterion
To derive a CFDFMinimizer::Problem, the do_df methods has to be implemented accordingly.
\remark actually this function should be private and only visible CFDFMinimizer
*/
static void df(const gsl_vector * x, void * params, gsl_vector * g);
/**
Callback to evaluate the gradient and the value of the optimization criterion
To derive a CFDFMinimizer::Problem, the do_fdf methods has to be implemented accordingly.
\remark actually this function should be private and only visible to CFDFMinimizer
*/
static void fdf(const gsl_vector * x, void * params, double * f, gsl_vector * g);
operator gsl_multimin_function_fdf*();
size_t size() const;
private:
virtual double do_f(const DoubleVector& x) = 0;
virtual void do_df(const DoubleVector& x, DoubleVector& g) = 0;
virtual double do_fdf(const DoubleVector& x, DoubleVector& g) = 0;
gsl_multimin_function_fdf m_func;
};
typedef std::shared_ptr<Problem> PProblem;
/**
Construtor of the optimizer.
\param p problem to be optimized
\param ot optimizer type used
*/
CFDFMinimizer(PProblem p, const gsl_multimin_fdfminimizer_type *ot);
~CFDFMinimizer();
/**
Set the gradient tolerance stopping criterion. (See GSL documentation.)
*/
void set_g_tol(double tol);
/**
Set the epsilon stopping criterion. (See GSL documentation.)
*/
void set_stop_eps(double tol);
/**
Run the optimization
\param[in,out] x at entry contains the start point of the optimization at exit the optimized value
\returns returns a status whether the optimization succeeded or why it stopped
*/
int run(DoubleVector& x);
private:
struct CFDFMinimizerImpl *impl;
};
/**
This class wraps the gradient free optimizers of the GSL
*/
class EXPORT_GSL CFMinimizer {
public:
/**
This is the base class for all optimization problems that don't provide
gradient information for optimization.
*/
class Problem {
public:
/**
Initialize the optimization problem with the given number of parameters
*/
Problem(size_t n_params);
/**
Callback to evaluate the value of the optimization criterion
To derive a CFMinimizer::Problem, the do_f methods has to be implemented accordingly.
\remark actually this function should be private and only visible CFMinimizer
*/
static double f(const gsl_vector * x, void * params);
operator gsl_multimin_function*();
size_t size() const;
private:
virtual double do_f(const DoubleVector& x) = 0;
gsl_multimin_function m_func;
};
typedef std::shared_ptr<Problem> PProblem;
/**
Construtor of the optimizer.
\param p problem to be optimized
\param ot optimizer type used
*/
CFMinimizer(PProblem p, const gsl_multimin_fminimizer_type *ot);
~CFMinimizer();
/**
Run the optimization
\param[in,out] x at entry contains the start point of the optimization at exit the optimized value
\returns returns a status whether the optimization succeeded or why it stopped
*/
int run(DoubleVector& x);
private:
struct CFMinimizerImpl *impl;
};
}
#endif
|