Simplex scheme optimizer for likelihoods. More...

#include "optimizing/optimizer_simplex.h"

Collaboration diagram for optimizer_simplex:

Public Member Functions

 optimizer_simplex (int seed)
 Class constructor, accepts the integer seed for a random number generator as an argument.
 
std::vector< double > run_optimizer (likelihood &L, std::string optimizer_results_filename="Opt.dat", size_t number_of_instances=0, size_t number_of_restarts=2, size_t maximum_iterations=20000, double tolerance=1e-15)
 Function to run the optimizer, takes a likelihood object, vector of priors, name of an optimizer output file, and tuning parameters for the optimizer. More...
 
std::vector< double > run_optimizer (likelihood &L, std::vector< double > start_parameter_values, std::string optimizer_results_filename="Opt.dat", size_t number_of_instances=0, size_t number_of_restarts=2, size_t maximum_iterations=20000, double tolerance=1e-15)
 Function to run the optimizer, takes a likelihood object, vector of priors, name of an optimizer output file, and tuning parameters for the optimizer. More...
 
std::vector< double > run_optimizer (likelihood &L, std::vector< std::vector< double > > start_parameter_values, std::string optimizer_results_filename="Opt.dat", size_t number_of_restarts=2, size_t maximum_iterations=20000, double tolerance=1e-15)
 Function to run the optimizer, takes a likelihood object, vector of priors, name of an optimizer output file, and tuning parameters for the optimizer. More...
 
void set_cpu_distribution (int num_likelihood)
 Function to set the distribution of processors in different layers of parallelization. More...
 

Private Member Functions

std::vector< double > generate_start_point (likelihood &L)
 Function to generate a random starting point given the bounds on the prior. Assumes an arctan distribution if both bounds on the prior are infinity, an exponential distribution if the bound on one side is infinity, and a uniform distribution if both bounds are finite. More...
 
double get_optimal_point (std::vector< double > &pvec, double tolerance, size_t maximum_iterations)
 Function to ncapsulate the process of optimization. Returns the maximized likelihood and resets pvec to the optimal position. More...
 
void amoeba (double **p, double y[], double ftol, int Nmax)
 
double amotry (double **p, double y[], std::vector< double > &psum, int ihi, double fac)
 

Private Attributes

likelihood_Lptr
 
size_t _ndim
 
int _num_likelihood
 
Ran2RNG _rng
 

Detailed Description

Maximizes a given likelihood using the simplex method as described in Numerical Recipes in C (1992; Press, Teukoslky, Vetterling and Flannery). An attempt to generate a global maximum is made by starting many simplexes at random/specified locations.

Has some difficulty with very high-dimensional problems and accuracy. Occasional errant simplex trajectories are constructed, with simplex contraction near the boundary occuring genenerating false maxima. It is not clear that this method is sufficiently efficient for typical use, but does provide an independent check.

Todo:

Member Function Documentation

std::vector< double > generate_start_point ( likelihood L)
private
Parameters
LAn object of class likelihood.

Here is the call graph for this function:

Here is the caller graph for this function:

double get_optimal_point ( std::vector< double > &  pvec,
double  tolerance,
size_t  maximum_iterations 
)
private
Parameters
pvecvector of start parameter position, reset to the optimal point.
tolerancenumerical tolerance at which to terminate maximization.
maximum_iterationsnumber of iterations before quitting.

Here is the call graph for this function:

Here is the caller graph for this function:

std::vector< double > run_optimizer ( likelihood L,
std::string  optimizer_results_filename = "Opt.dat",
size_t  number_of_instances = 0,
size_t  number_of_restarts = 2,
size_t  maximum_iterations = 20000,
double  tolerance = 1e-15 
)
Parameters
LAn object of class likelihood.
optimizer_results_filenameName of file to which to write summary data. Default is Opt.dat.
number_of_instancesNumber of independent realizations of the optimizer to run. When set to 0 will run the maximum allowed by the number of processes being used. Default is 0.
number_of_restartsThe number of times to restart each optimizer realization from the best point. Default 2.
maximum_iterationsMaximum number of simplex steps to take. Default 20,000.
toleranceConvergence tolerance. Default 1e-15.

Here is the call graph for this function:

Here is the caller graph for this function:

std::vector< double > run_optimizer ( likelihood L,
std::vector< double >  start_parameter_values,
std::string  optimizer_results_filename = "Opt.dat",
size_t  number_of_instances = 0,
size_t  number_of_restarts = 2,
size_t  maximum_iterations = 20000,
double  tolerance = 1e-15 
)
Parameters
LAn object of class likelihood.
start_parameter_valuesA vector of a single start point that we want to initialize a simplex around.
optimizer_results_filenameName of file to which to write summary data. Default is Opt.dat.
number_of_instancesNumber of independent realizations of the optimizer to run. When set to 0 will run the maximum allowed by the number of processes being used. Default is 0.
number_of_restartsThe number of times to restart each optimizer realization from the best point. Default 2.
maximum_iterationsMaximum number of simplex steps to take. Default 20,000.
toleranceConvergence tolerance. Default 1e-15.

Here is the call graph for this function:

std::vector< double > run_optimizer ( likelihood L,
std::vector< std::vector< double > >  start_parameter_values,
std::string  optimizer_results_filename = "Opt.dat",
size_t  number_of_restarts = 2,
size_t  maximum_iterations = 20000,
double  tolerance = 1e-15 
)
Parameters
LAn object of class likelihood.
start_parameter_valuesA vector of start points at which to initialize every simplex around. Note that this sets the number of instances explicitly.
optimizer_results_filenameName of file to which to write summary data. Default is Opt.dat.
number_of_restartsThe number of times to restart each optimizer realization from the best point. Default 2.
maximum_iterationsMaximum number of simplex steps to take. Default 20,000.
toleranceConvergence tolerance. Default 1e-15.

Here is the call graph for this function:

void set_cpu_distribution ( int  num_likelihood)
Parameters
num_likelihoodnumber of threads allocated for each likelihood calculation.

The documentation for this class was generated from the following files: