gsl_multidim_fdfminimizer.h

Go to the documentation of this file.
00001 
00002 
00003 //
00015 
00016 //  This multidimensional function minimizer class has been adapted from the gslwrap project.
00017 //  It is a C++ wrapper for the GNU Scientific Library
00018 //  Copyright (C) 2001 Ramin Nakisa
00019 
00020 //  This program is free software; you can redistribute it and/or modify
00021 //  it under the terms of the GNU General Public License as published by
00022 //  the Free Software Foundation; either version 2 of the License, or
00023 //  (at your option) any later version.
00024 
00025 //  This program is distributed in the hope that it will be useful,
00026 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00027 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00028 //  GNU General Public License for more details.
00029 
00030 //  You should have received a copy of the GNU General Public License
00031 //  along with this program; if not, write to the Free Software
00032 //  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00033 
00034 
00035 #ifndef _GSL_MULTIDIM_FDFMIN_H
00036 #define _GSL_MULTIDIM_FDFMIN_H
00037 
00038 #include <gsl/gsl_errno.h>
00039 #include <gsl/gsl_multimin.h>
00040 #include "gsl_vector_double.h"
00041 
00042 typedef unsigned int uint;
00043 
00045 //
00046 class multimin_fdf
00047 {
00048    public:
00049 
00051 //
00053 //
00054 
00055    virtual double operator()(const vector& x);
00056 
00058 //
00060 //
00061 
00062    virtual void derivative(const vector& x, vector& g);
00063 
00065 //
00067 //
00068 
00069    virtual double fval_and_derivative(const vector&x, vector& g );
00070 
00071 
00072    
00073    void set_params(const vector &vpass);
00074 
00076 //
00079 //
00080 
00081    static double f(const gsl_vector* x, void *p);
00082 
00084 //
00088 //
00089 
00090    static void df(const gsl_vector* x, void *p, gsl_vector* g);
00091 
00093 //
00098 //
00099 
00100    static void fdf(const gsl_vector* x, void *p, double* f, gsl_vector* g);
00101 };
00102 
00104 //
00105 
00106 class multimin_fdfminimizer 
00107 {
00108  public:
00109 
00111 //
00118 //
00119  
00120         multimin_fdfminimizer(uint _dim,
00121     const gsl_multimin_fdfminimizer_type* type=gsl_multimin_fdfminimizer_vector_bfgs);
00122 
00124 //
00126 //
00127         
00128         ~multimin_fdfminimizer();
00129 
00131 //
00139 //
00140 
00141         int set(multimin_fdf& function, const vector& initial_x, double step_size, double tol);
00142 
00144 //
00145         
00146         int iterate();
00147 
00149 //
00150 
00151         int restart();
00152 
00154 //
00155 
00156         double minimum(); 
00157 
00159 //
00160 
00161         vector x_value();  
00162 
00164 //      
00165 
00166         vector gradient();  
00167 
00169 //
00171 //
00172 
00173         void SetMaxIterations(int n);
00174 
00176 //
00177         
00178         int GetNIterations();
00179 
00181 //
00183 //
00184         
00185         bool is_converged();
00186         
00187  private:
00188  
00190 // 
00191         void assert_set();      
00192 
00194 //
00195 
00196         uint dim;
00197         
00199 //
00200 
00201         bool isSet;
00202 
00204 //
00205 
00206         bool isConverged;
00207         
00209 //
00210 
00211         int nIterations;
00212 
00214 //
00215 
00216         int maxIterations;
00217 
00219 //
00220 
00221         gsl_multimin_fdfminimizer* s;
00222 
00224 //
00225 
00226         gsl_multimin_function_fdf f;
00227 
00228 };
00229 
00230 #endif // GSL_MULTIDIM_FDFMIN_H
All Classes Files Functions Variables Typedefs Friends Defines