16 double size_tol,
const Array<double,1>& init_step_size,
bool vrbs)
38 void print_state(
unsigned int iter, gsl_multimin_fminimizer *
s,
int status)
40 printf(
"Solver '%s'; iter = %3u; c(x) = %g; gsl status = %s\n",
41 gsl_multimin_fminimizer_name(s), iter,
42 gsl_multimin_fminimizer_minimum(s), gsl_strerror((
int)status) );
44 printf(
"Where x is\n" );
45 (void) gsl_vector_fprintf(stdout, gsl_multimin_fminimizer_x(s),
"%25.14lf");
47 printf(
"Average distance from the simplex center to its vertices = %25.10lf\n",
48 gsl_multimin_fminimizer_size(s) );
56 int max_cost_function_calls,
double size_tol,
57 const Array<double,1>& init_step_size,
60 Size_tol(size_tol), Initial_step_size(init_step_size)
62 if( (init_step_size.size() > 0) && (init_step_size.size() != p->expected_parameter_size())) {
64 e <<
"If initial-step-size provided, its size must be equal to the expected-parameter-size:\n" 65 <<
" Initial-step-size: " << init_step_size.size() <<
"\n" 66 <<
" Expected-parameter-size: " << p->expected_parameter_size() <<
"\n";
81 int gsl_status = GSL_FAILURE;
82 int gsl_status_s = GSL_CONTINUE;
84 gsl_multimin_fminimizer *
s = gsl_multimin_fminimizer_alloc(T, f.n);
86 blitz::Array<double, 1> X(
P->parameters());
88 gsl_vector *ss = gsl_vector_alloc(f.n);
89 bool ss_initialized =
false;
101 gsl_vector_set_all(ss, 1.0);
108 ss_initialized =
true;
114 if( s && ss_initialized )
115 if( !(gsl_status = gsl_multimin_fminimizer_set(s, &f,
GslVector(X).gsl(), ss)) ) {
133 gsl_status = gsl_multimin_fminimizer_iterate(s);
134 if( (gsl_status != GSL_SUCCESS) && (gsl_status != GSL_ENOPROG) ) {
139 gsl_status_s = gsl_multimin_test_size(gsl_multimin_fminimizer_size(s),
Size_tol);
140 if(gsl_status_s == GSL_SUCCESS) {
145 if(gsl_status == GSL_ENOPROG) {
151 }
while (gsl_status_s == GSL_CONTINUE &&
P->num_cost_evaluations() <
max_cost_f_calls);
162 if( ss ) gsl_vector_free(ss);
163 if( s ) gsl_multimin_fminimizer_name(s);
solve method called but an error was encountered
const Unit s("s", 1.0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0)
void record_cost_at_accepted_point(double cost)
Called to record the cost function value at an accepted point.
solve method called and a solution found
blitz::Array< double, 1 > Initial_step_size
solve method was called but stalled
virtual void solve()
The method that solves the optimization problem.
CostMinimizerGSL(const boost::shared_ptr< CostFunc > &p, int max_cost_function_calls, double size_tol=0.001, const blitz::Array< double, 1 > &init_step_size=blitz::Array< double, 1 >(), bool vrbs=false)
Initializes the minimizer.
This is the base of the exception hierarchy for Full Physics code.
The base class for all iterative cost minimizers that do not require derivatives of any order...
#define REGISTER_LUA_DERIVED_CLASS(X, Y)
gsl_multimin_function gsl_get_mdm(const FullPhysics::CostFunc *cost)
Apply value function to a blitz array.
virtual const gsl_multimin_fminimizer_type * get_gsl_multimin_fminimizer()
solve method called but did not converge to a solution
solve method not called yet
void record_accepted_point(const blitz::Array< double, 1 > &point)
Called to record an accepted point.
boost::shared_ptr< IterativeSolver > cost_minimizer_gsl_create(const boost::shared_ptr< CostFunc > &cost, int max_cost_function_calls, double size_tol, const Array< double, 1 > &init_step_size, bool vrbs)
Contains classes to abstract away details in various Spurr Radiative Transfer software.
#define REGISTER_LUA_END()
def(luabind::constructor< int >()) .def("rows"
The base class for all iterative optimizers.
boost::shared_ptr< CostFunc > P
This provides thin wrapper around the GNU Scientific Library gsl_vector.
void print_state(unsigned int iter, gsl_multimin_fminimizer *s, int status)