00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef MINIMIZE_LBFGS_H
00010 #define MINIMIZE_LBFGS_H
00011
00012 #include <minimize/DifferentiableEnergyInterface.hpp>
00013 #include <minimize/MinimizerInterface.hpp>
00014
00015 #include <external/liblbfgs/lbfgs.h>
00016
00017 namespace imaging
00018 {
00019
00025 class Lbfgs : public MinimizerInterface
00026 {
00027 DifferentiableEnergyInterface & _energy;
00028 lbfgs_parameter_t _lbfgs_parameters;
00029 size_t _n_steps;
00030 bool _terminated;
00031
00032 static lbfgsfloatval_t evaluate(void *instance,
00033 const lbfgsfloatval_t *x,
00034 lbfgsfloatval_t *g,
00035 const int n,
00036 const lbfgsfloatval_t step);
00037
00038 static int progress(void *instance,
00039 const lbfgsfloatval_t *x,
00040 const lbfgsfloatval_t *g,
00041 const lbfgsfloatval_t fx,
00042 const lbfgsfloatval_t xnorm,
00043 const lbfgsfloatval_t gnorm,
00044 const lbfgsfloatval_t step,
00045 int n,
00046 int k,
00047 int ls);
00048
00049 public:
00057 Lbfgs(DifferentiableEnergyInterface & energy,
00058 float_t epsilon = 1.0e-5,
00059 float_t line_search_f_tolerance = 1.0e-4,
00060 float_t line_search_g_tolerance = 0.9,
00061 size_t n_correction_steps = 6,
00062 size_t n_max_line_search_steps = 20);
00063
00064 bool minimize(size_t n_max_steps, size_t & n_steps);
00065 };
00066
00067 }
00068
00069 #endif