BubbleProfiler  0.3.0
by Peter Athron, Csaba Balazs, Michael Bardsley, Andrew Fowlie, Dylan Harries & Graham White
Public Types | Public Member Functions | Static Private Member Functions | Private Attributes | List of all members
BubbleProfiler::NLopt_optimizer Class Reference

#include <nlopt_optimizer.hpp>

Public Types

enum  Extremum_type { Extremum_type::MIN, Extremum_type::MAX }
 
using Index = Eigen::VectorXd::Index
 
using Function = std::function< double(const Eigen::VectorXd &)>
 

Public Member Functions

 NLopt_optimizer (Index)
 
template<typename F >
 NLopt_optimizer (F &&, Index)
 
void set_algorithm (nlopt::algorithm a)
 
void set_extremum_type (Extremum_type e)
 
template<typename F >
void set_function (F &&f)
 
void set_lower_bounds (double lb)
 
void set_lower_bounds (Index i, double lb)
 
void set_lower_bounds (const Eigen::VectorXd &lb)
 
void set_upper_bounds (double ub)
 
void set_upper_bounds (Index i, double ub)
 
void set_upper_bounds (const Eigen::VectorXd &ub)
 
void set_xtol_rel (double xtol_rel_)
 
void set_ftol_rel (double ftol_rel_)
 
void set_max_time (double maxtime)
 
Eigen::VectorXd get_extremum_location () const
 
double get_extremum_value () const
 
nlopt::result optimize (const Eigen::VectorXd &guess)
 

Static Private Member Functions

static double nlopt_function (const std::vector< double > &, std::vector< double > &, void *)
 

Private Attributes

Index n_dims {}
 
nlopt::algorithm algorithm {nlopt::GN_DIRECT_L}
 
Extremum_type extremum_type {Extremum_type::MIN}
 
Eigen::VectorXd lower_bounds {}
 
Eigen::VectorXd upper_bounds {}
 
double maxtime {0.}
 
Eigen::VectorXd extremum {}
 
double extremum_value {0.}
 
Function function {nullptr}
 
double xtol_rel {2. * std::numeric_limits<double>::epsilon()}
 
double ftol_rel {2. * std::numeric_limits<double>::epsilon()}
 

Detailed Description

Lightweight wrapper class for the NLOpt numerical optimization library.

Definition at line 35 of file nlopt_optimizer.hpp.

Member Typedef Documentation

using BubbleProfiler::NLopt_optimizer::Function = std::function<double(const Eigen::VectorXd&)>

Definition at line 38 of file nlopt_optimizer.hpp.

using BubbleProfiler::NLopt_optimizer::Index = Eigen::VectorXd::Index

Definition at line 37 of file nlopt_optimizer.hpp.

Member Enumeration Documentation

Enumerator
MIN 
MAX 

Definition at line 40 of file nlopt_optimizer.hpp.

Constructor & Destructor Documentation

BubbleProfiler::NLopt_optimizer::NLopt_optimizer ( Index  n)
explicit

Definition at line 50 of file nlopt_optimizer.cpp.

template<typename F >
BubbleProfiler::NLopt_optimizer::NLopt_optimizer ( F &&  f,
Index  n 
)

Definition at line 97 of file nlopt_optimizer.hpp.

Member Function Documentation

Eigen::VectorXd BubbleProfiler::NLopt_optimizer::get_extremum_location ( ) const
inline
double BubbleProfiler::NLopt_optimizer::get_extremum_value ( ) const
inline

Definition at line 70 of file nlopt_optimizer.hpp.

References extremum_value, and optimize().

double BubbleProfiler::NLopt_optimizer::nlopt_function ( const std::vector< double > &  x,
std::vector< double > &  ,
void *  params 
)
staticprivate

Definition at line 165 of file nlopt_optimizer.cpp.

Referenced by optimize().

nlopt::result BubbleProfiler::NLopt_optimizer::optimize ( const Eigen::VectorXd &  guess)

Run the optimizer with configured parameters.

Parameters
guessVector in which result will be stored
Returns
NLOpt status code

Definition at line 122 of file nlopt_optimizer.cpp.

References algorithm, extremum, extremum_type, extremum_value, ftol_rel, lower_bounds, maxtime, MIN, n_dims, nlopt_function(), upper_bounds, and xtol_rel.

Referenced by BubbleProfiler::find_global_min(), BubbleProfiler::find_one_dimensional_barrier(), and get_extremum_value().

void BubbleProfiler::NLopt_optimizer::set_algorithm ( nlopt::algorithm  a)
inline

Definition at line 46 of file nlopt_optimizer.hpp.

References algorithm.

void BubbleProfiler::NLopt_optimizer::set_extremum_type ( Extremum_type  e)
inline
void BubbleProfiler::NLopt_optimizer::set_ftol_rel ( double  ftol_rel_)

Definition at line 62 of file nlopt_optimizer.cpp.

References ftol_rel.

Referenced by BubbleProfiler::find_one_dimensional_barrier(), and set_function().

template<typename F >
void BubbleProfiler::NLopt_optimizer::set_function ( F &&  f)
inline
void BubbleProfiler::NLopt_optimizer::set_lower_bounds ( double  lb)
void BubbleProfiler::NLopt_optimizer::set_lower_bounds ( Index  i,
double  lb 
)

Definition at line 72 of file nlopt_optimizer.cpp.

References lower_bounds, and n_dims.

void BubbleProfiler::NLopt_optimizer::set_lower_bounds ( const Eigen::VectorXd &  lb)

Definition at line 81 of file nlopt_optimizer.cpp.

References lower_bounds.

void BubbleProfiler::NLopt_optimizer::set_max_time ( double  maxtime)

Set a timeout for the optimizer. Failure to converge before timeout is considered an error, and an exception will be thrown. If this parameter is set to zero (the default value), no timeout is applied.

Parameters
maxtimemaximum runtime (seconds)

Definition at line 113 of file nlopt_optimizer.cpp.

References maxtime.

Referenced by BubbleProfiler::find_global_min(), BubbleProfiler::find_one_dimensional_barrier(), and set_function().

void BubbleProfiler::NLopt_optimizer::set_upper_bounds ( double  ub)
void BubbleProfiler::NLopt_optimizer::set_upper_bounds ( Index  i,
double  ub 
)

Definition at line 95 of file nlopt_optimizer.cpp.

References n_dims, and upper_bounds.

void BubbleProfiler::NLopt_optimizer::set_upper_bounds ( const Eigen::VectorXd &  ub)

Definition at line 104 of file nlopt_optimizer.cpp.

References upper_bounds.

void BubbleProfiler::NLopt_optimizer::set_xtol_rel ( double  xtol_rel_)

Definition at line 57 of file nlopt_optimizer.cpp.

References xtol_rel.

Referenced by BubbleProfiler::find_one_dimensional_barrier(), and set_function().

Member Data Documentation

nlopt::algorithm BubbleProfiler::NLopt_optimizer::algorithm {nlopt::GN_DIRECT_L}
private

Definition at line 81 of file nlopt_optimizer.hpp.

Referenced by optimize(), and set_algorithm().

Eigen::VectorXd BubbleProfiler::NLopt_optimizer::extremum {}
private

Definition at line 86 of file nlopt_optimizer.hpp.

Referenced by get_extremum_location(), and optimize().

Extremum_type BubbleProfiler::NLopt_optimizer::extremum_type {Extremum_type::MIN}
private

Definition at line 82 of file nlopt_optimizer.hpp.

Referenced by optimize(), and set_extremum_type().

double BubbleProfiler::NLopt_optimizer::extremum_value {0.}
private

Definition at line 87 of file nlopt_optimizer.hpp.

Referenced by get_extremum_value(), and optimize().

double BubbleProfiler::NLopt_optimizer::ftol_rel {2. * std::numeric_limits<double>::epsilon()}
private

Definition at line 90 of file nlopt_optimizer.hpp.

Referenced by optimize(), and set_ftol_rel().

Function BubbleProfiler::NLopt_optimizer::function {nullptr}
private

Definition at line 88 of file nlopt_optimizer.hpp.

Eigen::VectorXd BubbleProfiler::NLopt_optimizer::lower_bounds {}
private

Definition at line 83 of file nlopt_optimizer.hpp.

Referenced by optimize(), and set_lower_bounds().

double BubbleProfiler::NLopt_optimizer::maxtime {0.}
private

Definition at line 85 of file nlopt_optimizer.hpp.

Referenced by optimize(), set_function(), and set_max_time().

Index BubbleProfiler::NLopt_optimizer::n_dims {}
private

Definition at line 80 of file nlopt_optimizer.hpp.

Referenced by optimize(), set_lower_bounds(), and set_upper_bounds().

Eigen::VectorXd BubbleProfiler::NLopt_optimizer::upper_bounds {}
private

Definition at line 84 of file nlopt_optimizer.hpp.

Referenced by optimize(), and set_upper_bounds().

double BubbleProfiler::NLopt_optimizer::xtol_rel {2. * std::numeric_limits<double>::epsilon()}
private

Definition at line 89 of file nlopt_optimizer.hpp.

Referenced by optimize(), and set_xtol_rel().


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