SHOGUN  4.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
List of all members | Public Member Functions | Protected Member Functions | Protected Attributes
NLOPTMinimizer Class Reference

Detailed Description

The class wraps the external NLOPT library.

This minimizer supports bound constrainted minimization and unconstrainted minimization using the NLOPT library

Definition at line 47 of file NLOPTMinimizer.h.

Inheritance diagram for NLOPTMinimizer:
Inheritance graph
[legend]

Public Member Functions

 NLOPTMinimizer ()
 
 NLOPTMinimizer (FirstOrderCostFunction *fun)
 
virtual ~NLOPTMinimizer ()
 
virtual float64_t minimize ()
 
virtual bool supports_batch_update () const
 
virtual CMinimizerContextsave_to_context ()
 
virtual void load_from_context (CMinimizerContext *context)
 
virtual void set_nlopt_parameters (nlopt_algorithm algorithm=NLOPT_LD_LBFGS, float64_t max_iterations=1000, float64_t variable_tolerance=1e-6, float64_t function_tolerance=1e-6)
 
virtual void set_cost_function (FirstOrderCostFunction *fun)
 
virtual void set_penalty_weight (float64_t penalty_weight)
 
virtual void set_penalty_type (Penalty *penalty_type)
 

Protected Member Functions

virtual void init_minimization ()
 
virtual void update_context (CMinimizerContext *context)
 
virtual float64_t get_penalty (SGVector< float64_t > var)
 
virtual void update_gradient (SGVector< float64_t > gradient, SGVector< float64_t > var)
 

Protected Attributes

SGVector< float64_tm_target_variable
 
float64_t m_max_iterations
 
float64_t m_variable_tolerance
 
float64_t m_function_tolerance
 
nlopt_algorithm m_nlopt_algorithm
 
FirstOrderCostFunctionm_fun
 
Penaltym_penalty_type
 
float64_t m_penalty_weight
 

Constructor & Destructor Documentation

Default constructor

Definition at line 37 of file NLOPTMinimizer.cpp.

Constructor

Parameters
funcost function

Definition at line 47 of file NLOPTMinimizer.cpp.

~NLOPTMinimizer ( )
virtual

Destructor

Definition at line 43 of file NLOPTMinimizer.cpp.

Member Function Documentation

virtual float64_t get_penalty ( SGVector< float64_t var)
protectedvirtualinherited

Get the penalty given target variables For L2 penalty, the target variable is \(w\) and the value of penalty is \(\lambda \frac{w^t w}{2}\), where \(\lambda\) is the weight of penalty

Parameters
varthe variable used in regularization

Definition at line 164 of file FirstOrderMinimizer.h.

void init_minimization ( )
protectedvirtual

Definition at line 163 of file NLOPTMinimizer.cpp.

virtual void load_from_context ( CMinimizerContext context)
virtual

Load the given context object to restores mutable variables Usually it is used in deserialization.

Parameters
contexta context object

Reimplemented from FirstOrderMinimizer.

Definition at line 85 of file NLOPTMinimizer.h.

float64_t minimize ( )
virtual

Do minimization and get the optimal value

Returns
optimal value

Implements FirstOrderMinimizer.

Definition at line 65 of file NLOPTMinimizer.cpp.

virtual CMinimizerContext* save_to_context ( )
virtual

Return a context object which stores mutable variables Usually it is used in serialization.

Returns
a context object

Reimplemented from FirstOrderMinimizer.

Definition at line 78 of file NLOPTMinimizer.h.

virtual void set_cost_function ( FirstOrderCostFunction fun)
virtualinherited

Set cost function used in the minimizer

Parameters
funthe cost function

Definition at line 92 of file FirstOrderMinimizer.h.

void set_nlopt_parameters ( nlopt_algorithm  algorithm = NLOPT_LD_LBFGS,
float64_t  max_iterations = 1000,
float64_t  variable_tolerance = 1e-6,
float64_t  function_tolerance = 1e-6 
)
virtual

Definition at line 133 of file NLOPTMinimizer.cpp.

virtual void set_penalty_type ( Penalty penalty_type)
virtualinherited

Set the type of penalty For example, L2 penalty

Parameters
penalty_typethe type of penalty. If NULL is given, regularization is not enabled.

Definition at line 137 of file FirstOrderMinimizer.h.

virtual void set_penalty_weight ( float64_t  penalty_weight)
virtualinherited

Set the weight of penalty

Parameters
penalty_weightthe weight of penalty, which is positive

Definition at line 126 of file FirstOrderMinimizer.h.

virtual bool supports_batch_update ( ) const
virtual

Does minimizer support batch update?

Returns
whether minimizer supports batch update

Implements FirstOrderMinimizer.

Definition at line 71 of file NLOPTMinimizer.h.

virtual void update_context ( CMinimizerContext context)
protectedvirtualinherited

Update a context object to store mutable variables

Parameters
contexta context object

Reimplemented in FirstOrderStochasticMinimizer, SMDMinimizer, and SMIDASMinimizer.

Definition at line 147 of file FirstOrderMinimizer.h.

virtual void update_gradient ( SGVector< float64_t gradient,
SGVector< float64_t var 
)
protectedvirtualinherited

Add gradient of the penalty wrt target variables to unpenalized gradient For least sqaure with L2 penalty,

\[ L2f(w)=f(w) + L2(w) \]

where \( f(w)=\sum_i{(y_i-w^T x_i)^2}\) is the least sqaure cost function and \(L2(w)=\lambda \frac{w^t w}{2}\) is the L2 penalty

Target variables is \(w\) Unpenalized gradient is \(\frac{\partial f(w) }{\partial w}\) Gradient of the penalty wrt target variables is \(\frac{\partial L2(w) }{\partial w}\)

Parameters
gradientunpenalized gradient wrt its target variable
varthe target variable

Definition at line 190 of file FirstOrderMinimizer.h.

Member Data Documentation

FirstOrderCostFunction* m_fun
protectedinherited

Cost function

Definition at line 205 of file FirstOrderMinimizer.h.

float64_t m_function_tolerance
protected

absolute tolerance on function value

Definition at line 123 of file NLOPTMinimizer.h.

float64_t m_max_iterations
protected

max number of iterations

Definition at line 117 of file NLOPTMinimizer.h.

nlopt_algorithm m_nlopt_algorithm
protected

algorithm provided by NLOPT for minimization

Definition at line 126 of file NLOPTMinimizer.h.

Penalty* m_penalty_type
protectedinherited

the type of penalty

Definition at line 208 of file FirstOrderMinimizer.h.

float64_t m_penalty_weight
protectedinherited

the weight of penalty

Definition at line 211 of file FirstOrderMinimizer.h.

SGVector<float64_t> m_target_variable
protected

Definition at line 111 of file NLOPTMinimizer.h.

float64_t m_variable_tolerance
protected

absolute tolerance on optimization parameters

Definition at line 120 of file NLOPTMinimizer.h.


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

SHOGUN Machine Learning Toolbox - Documentation