SHOGUN
4.1.0
|
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.
Public Member Functions | |
NLOPTMinimizer () | |
NLOPTMinimizer (FirstOrderCostFunction *fun) | |
virtual | ~NLOPTMinimizer () |
virtual float64_t | minimize () |
virtual bool | supports_batch_update () const |
virtual CMinimizerContext * | save_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_t > | m_target_variable |
float64_t | m_max_iterations |
float64_t | m_variable_tolerance |
float64_t | m_function_tolerance |
nlopt_algorithm | m_nlopt_algorithm |
FirstOrderCostFunction * | m_fun |
Penalty * | m_penalty_type |
float64_t | m_penalty_weight |
NLOPTMinimizer | ( | ) |
Default constructor
Definition at line 37 of file NLOPTMinimizer.cpp.
NLOPTMinimizer | ( | FirstOrderCostFunction * | fun | ) |
|
virtual |
Destructor
Definition at line 43 of file NLOPTMinimizer.cpp.
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
var | the variable used in regularization |
Definition at line 164 of file FirstOrderMinimizer.h.
|
protectedvirtual |
Definition at line 163 of file NLOPTMinimizer.cpp.
|
virtual |
Load the given context object to restores mutable variables Usually it is used in deserialization.
context | a context object |
Reimplemented from FirstOrderMinimizer.
Definition at line 85 of file NLOPTMinimizer.h.
|
virtual |
Do minimization and get the optimal value
Implements FirstOrderMinimizer.
Definition at line 65 of file NLOPTMinimizer.cpp.
|
virtual |
Return a context object which stores mutable variables Usually it is used in serialization.
Reimplemented from FirstOrderMinimizer.
Definition at line 78 of file NLOPTMinimizer.h.
|
virtualinherited |
Set cost function used in the minimizer
fun | the cost function |
Definition at line 92 of file FirstOrderMinimizer.h.
|
virtual |
Definition at line 133 of file NLOPTMinimizer.cpp.
|
virtualinherited |
Set the type of penalty For example, L2 penalty
penalty_type | the type of penalty. If NULL is given, regularization is not enabled. |
Definition at line 137 of file FirstOrderMinimizer.h.
|
virtualinherited |
Set the weight of penalty
penalty_weight | the weight of penalty, which is positive |
Definition at line 126 of file FirstOrderMinimizer.h.
|
virtual |
Does minimizer support batch update?
Implements FirstOrderMinimizer.
Definition at line 71 of file NLOPTMinimizer.h.
|
protectedvirtualinherited |
Update a context object to store mutable variables
context | a context object |
Reimplemented in FirstOrderStochasticMinimizer, SMDMinimizer, and SMIDASMinimizer.
Definition at line 147 of file FirstOrderMinimizer.h.
|
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}\)
gradient | unpenalized gradient wrt its target variable |
var | the target variable |
Definition at line 190 of file FirstOrderMinimizer.h.
|
protectedinherited |
Cost function
Definition at line 205 of file FirstOrderMinimizer.h.
|
protected |
absolute tolerance on function value
Definition at line 123 of file NLOPTMinimizer.h.
|
protected |
max number of iterations
Definition at line 117 of file NLOPTMinimizer.h.
|
protected |
algorithm provided by NLOPT for minimization
Definition at line 126 of file NLOPTMinimizer.h.
|
protectedinherited |
the type of penalty
Definition at line 208 of file FirstOrderMinimizer.h.
|
protectedinherited |
the weight of penalty
Definition at line 211 of file FirstOrderMinimizer.h.
Definition at line 111 of file NLOPTMinimizer.h.
|
protected |
absolute tolerance on optimization parameters
Definition at line 120 of file NLOPTMinimizer.h.