ANIMA
4.0
|
Implements an ITK wrapper for the NLOPT library. More...
#include <animaNLOPTOptimizers.h>
Public Types | |
typedef itk::SmartPointer< const Self > | ConstPointer |
typedef anima::NLOPTParametersConstraintFunction | ConstraintsFunctionType |
typedef CostFunctionType::Pointer | CostFunctionPointer |
typedef itk::SingleValuedCostFunction | CostFunctionType |
typedef SingleValuedNonLinearOptimizer::ParametersType | ParametersType |
typedef itk::SmartPointer< Self > | Pointer |
typedef NLOPTOptimizers | Self |
typedef SingleValuedNonLinearOptimizer | Superclass |
Public Member Functions | |
void | AddEqualityConstraint (ConstraintsFunctionType *constraint) |
Adds a nonlinear equality constraint of the form \( h(x) = 0 \). The parameter tol is a tolerance that is used for the purpose of stopping criteria only: a point x is considered feasible for judging whether to stop the optimization if \( |h(x)| <= tol \). For equality constraints, a small positive tolerance is strongly advised in order to allow NLopt to converge even if the equality constraint is slightly nonzero. More... | |
void | AddInequalityConstraint (ConstraintsFunctionType *constraint) |
Adds a nonlinear inequality constraint of the form \( fc(x) <= 0 \). The parameter tol is a tolerance that is used for the purpose of stopping criteria only: a point x is considered feasible for judging whether to stop the optimization if \( fc(x) <= tol \). A tolerance of zero means that NLopt will try not to consider any x to be converged unless fc is strictly non-positive; generally, at least a small positive tolerance is advisable to reduce sensitivity to rounding errors. More... | |
void | ClearEqualityConstraints () |
Clears all equality constraints. More... | |
void | ClearInequalityConstraints () |
Clears all inequality constraints. More... | |
virtual ::itk::LightObject::Pointer | CreateAnother (void) const |
virtual const nlopt_algorithm & | GetAlgorithm () const |
virtual const MeasureType & | GetCurrentCost () const |
virtual const nlopt_result & | GetErrorCode () const |
std::string | GetErrorCodeDescription () const |
Gets the current error code description as a std::string. More... | |
virtual const double & | GetFTolAbs () const |
virtual const double & | GetFTolRel () const |
virtual const nlopt_algorithm & | GetLocalOptimizer () const |
virtual const ParametersType & | GetLowerBoundParameters () const |
virtual const int & | GetMaxEval () const |
virtual const bool & | GetMaximize () const |
virtual const double & | GetMaxTime () const |
virtual const char * | GetNameOfClass () const |
virtual const int & | GetPopulationSize () const |
virtual const double & | GetStopVal () const |
virtual const ParametersType & | GetUpperBoundParameters () const |
MeasureType | GetValue () const |
virtual const int & | GetVectorStorageSize () const |
virtual unsigned int | GetVerboseLevel () |
virtual const double & | GetXTolAbs () const |
virtual const double & | GetXTolRel () const |
bool | isSuccessful () const |
Return true if the optimization was successful (ie the last error code was positive or equal to NLOPT_ROUNDOFF_LIMITED or NLOPT_FORCED_STOP) More... | |
virtual void | SetAlgorithm (nlopt_algorithm _arg) |
virtual void | SetErrorCode (nlopt_result _arg) |
virtual void | SetFTolAbs (double _arg) |
virtual void | SetFTolRel (double _arg) |
virtual void | SetLocalOptimizer (nlopt_algorithm _arg) |
void | SetLowerBoundParameters (const ParametersType &p) |
Set the lower bound parameters (not used by all algorithms) More... | |
virtual void | SetMaxEval (int _arg) |
virtual void | SetMaximize (bool _arg) |
virtual void | SetMaxTime (double _arg) |
virtual void | SetPopulationSize (int _arg) |
void | SetStopVal (double stopval) |
void | SetUpperBoundParameters (const ParametersType &p) |
Set the upper bound parameters (not used by all algorithms) More... | |
virtual void | SetVectorStorageSize (int _arg) |
virtual void | SetVerboseLevel (unsigned int _arg) |
virtual void | SetXTolAbs (double _arg) |
virtual void | SetXTolRel (double _arg) |
void | StartOptimization () ITK_OVERRIDE |
Starts the optimization. More... | |
void | StopOptimization () |
Static Public Member Functions | |
static Pointer | New () |
Protected Member Functions | |
NLOPTOptimizers () | |
Default constructor. More... | |
NLOPTOptimizers (const NLOPTOptimizers &) | |
void | PrintSelf (std::ostream &os, itk::Indent indent) const ITK_OVERRIDE |
virtual void | SetCurrentCost (double _arg) |
virtual | ~NLOPTOptimizers () |
Destructor. More... | |
Static Protected Member Functions | |
static double | NloptFunctionWrapper (unsigned n, const double *x, double *grad, void *data) |
NloptFunctionWrapper is called by nlopt to evaluate the function f to minimize. NloptFunctionWrapper converts the nlopt parameters to the SingleValuedCostFunction parameters, and call the SingleValuedCostFunction to actually compute the value of f. More... | |
Implements an ITK wrapper for the NLOPT library.
Version 1.0.0
This code was graciously provided to us by the CRL at Boston.
Copyright (c) 2010-2011 Children's Hospital Boston.
Benoit Scherrer, CRL (Computational Radiology Laboratory), Harvard Medical School
The wrapper is very easy to use. Here is an example of how to minimimze a function with MyCostFunction being a regular itk::SingleValuedCostFunction
For more information about NLOPT and the available algorithms:
http://ab-initio.mit.edu/wiki/index.php/NLopt
This software is licensed by the copyright holder under the terms of the Open Software License version 3.0.
http://www.opensource.org/licenses/osl-3.0.php
This research was carried out in the Computational Radiology Laboratory of Children's Hospital, Boston and Harvard Medical School.
http://www.crl.med.harvard.edu
For more information contact: simon .war field @chi ldren s.ha rvard .edu
This research work was made possible by Grant Number R01 RR021885 (Principal Investigator: Simon K. Warfield, Ph.D.) to Children's Hospital, Boston from the National Center for Research Resources (NCRR), a component of the National Institutes of Health (NIH).
NLopt is a free/open-source library for nonlinear optimization, providing a common interface for a number of different free optimization routines available online as well as original implementations of various other algorithms. WEBSITE: http://ab-initio.mit.edu/wiki/index.php/NLopt \n AUTHOR: Steven G. Johnson This ITK wrapper was created by:\n Benoit Scherrer, CRL, Harvard Medical School. \n Copyright (c) 2010-2011 Children's Hospital Boston
Definition at line 94 of file animaNLOPTOptimizers.h.
typedef itk::SmartPointer<const Self> anima::NLOPTOptimizers::ConstPointer |
Standard ITK "ConstPointer" typedef.
Definition at line 102 of file animaNLOPTOptimizers.h.
Base constraints (for inequality and equality)
Definition at line 105 of file animaNLOPTOptimizers.h.
typedef CostFunctionType::Pointer anima::NLOPTOptimizers::CostFunctionPointer |
Definition at line 115 of file animaNLOPTOptimizers.h.
typedef itk::SingleValuedCostFunction anima::NLOPTOptimizers::CostFunctionType |
Type of the Cost Function
Definition at line 114 of file animaNLOPTOptimizers.h.
typedef SingleValuedNonLinearOptimizer::ParametersType anima::NLOPTOptimizers::ParametersType |
Parameter type
Definition at line 104 of file animaNLOPTOptimizers.h.
typedef itk::SmartPointer<Self> anima::NLOPTOptimizers::Pointer |
Standard ITK "Pointer" typedef.
Definition at line 101 of file animaNLOPTOptimizers.h.
Standard ITK "Self" typedef.
Definition at line 99 of file animaNLOPTOptimizers.h.
typedef SingleValuedNonLinearOptimizer anima::NLOPTOptimizers::Superclass |
Standard ITK "Superclass" typedef.
Definition at line 100 of file animaNLOPTOptimizers.h.
|
protected |
|
protected |
|
protectedvirtual |
void anima::NLOPTOptimizers::AddEqualityConstraint | ( | ConstraintsFunctionType * | constraint | ) |
Adds a nonlinear equality constraint of the form \( h(x) = 0 \). The parameter tol is a tolerance that is used for the purpose of stopping criteria only: a point x is considered feasible for judging whether to stop the optimization if \( |h(x)| <= tol \). For equality constraints, a small positive tolerance is strongly advised in order to allow NLopt to converge even if the equality constraint is slightly nonzero.
(For any algorithm listed as "derivative-free" below, the grad argument to fc or h will always be NULL and need never be computed.)
constraint | The constraint function containing all details |
Definition at line 381 of file animaNLOPTOptimizers.cxx.
void anima::NLOPTOptimizers::AddInequalityConstraint | ( | ConstraintsFunctionType * | constraint | ) |
Adds a nonlinear inequality constraint of the form \( fc(x) <= 0 \). The parameter tol is a tolerance that is used for the purpose of stopping criteria only: a point x is considered feasible for judging whether to stop the optimization if \( fc(x) <= tol \). A tolerance of zero means that NLopt will try not to consider any x to be converged unless fc is strictly non-positive; generally, at least a small positive tolerance is advisable to reduce sensitivity to rounding errors.
constraint | The constraint function containing all details |
Definition at line 346 of file animaNLOPTOptimizers.cxx.
void anima::NLOPTOptimizers::ClearEqualityConstraints | ( | ) |
Clears all equality constraints.
Definition at line 394 of file animaNLOPTOptimizers.cxx.
void anima::NLOPTOptimizers::ClearInequalityConstraints | ( | ) |
Clears all inequality constraints.
Definition at line 359 of file animaNLOPTOptimizers.cxx.
virtual::itk::LightObject::Pointer anima::NLOPTOptimizers::CreateAnother | ( | void | ) | const |
|
virtual |
|
virtual |
Returns the current value
|
virtual |
std::string anima::NLOPTOptimizers::GetErrorCodeDescription | ( | ) | const |
Gets the current error code description as a std::string.
Definition at line 295 of file animaNLOPTOptimizers.cxx.
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
Run-time type information (and related methods).
|
virtual |
|
virtual |
|
virtual |
|
inline |
Returns the current value
Definition at line 133 of file animaNLOPTOptimizers.h.
Referenced by NloptFunctionWrapper().
|
virtual |
|
virtual |
|
virtual |
|
virtual |
bool anima::NLOPTOptimizers::isSuccessful | ( | ) | const |
Return true if the optimization was successful (ie the last error code was positive or equal to NLOPT_ROUNDOFF_LIMITED or NLOPT_FORCED_STOP)
Definition at line 275 of file animaNLOPTOptimizers.cxx.
|
static |
Method for creation through the object factory.
Referenced by anima::MCMEstimatorImageFilter< InputPixelType, OutputPixelType >::CreateOptimizer().
|
staticprotected |
NloptFunctionWrapper is called by nlopt to evaluate the function f to minimize. NloptFunctionWrapper converts the nlopt parameters to the SingleValuedCostFunction parameters, and call the SingleValuedCostFunction to actually compute the value of f.
n | The. | |
x | The x coordinate. | |
[in,out] | grad | If non-null, the graduated. |
[in,out] | data | If non-null, the data. |
Definition at line 95 of file animaNLOPTOptimizers.cxx.
References GetValue().
|
protected |
Definition at line 436 of file animaNLOPTOptimizers.cxx.
|
virtual |
NLOPT Algorithm to use
|
protectedvirtual |
|
virtual |
Returns the last error code of NLOPT
|
virtual |
Stopping criteria: Set absolute tolerance on function value: stop when an optimization step (or an estimate of the optimum) changes the function value by less than tol. Criterion is disabled if tol is non-positive.
|
virtual |
Stopping criteria: Set relative tolerance on function value: stop when an optimization step (or an estimate of the optimum) changes the objective function value by less than tol multiplied by the absolute value of the function value. (If there is any chance that your optimum function value is close to zero, you might want to set an absolute tolerance with nlopt_set_ftol_abs as well.) Criterion is disabled if tol is non-positive.
|
virtual |
Set local optimizer for AUGLAG and MLSL algos
void anima::NLOPTOptimizers::SetLowerBoundParameters | ( | const ParametersType & | p | ) |
Set the lower bound parameters (not used by all algorithms)
p | The lower bound parameters. |
Definition at line 409 of file animaNLOPTOptimizers.cxx.
|
virtual |
Stopping criteria: Stop when the number of function evaluations exceeds maxeval. (This is not a strict maximum: the number of function evaluations may exceed maxeval slightly, depending upon the algorithm.) Criterion is disabled if maxeval is non-positive.
|
virtual |
Set if the Optimizer should Maximize the metric
|
virtual |
Stopping criteria: Stop when the optimization time (in seconds) exceeds maxtime. (This is not a strict maximum: the time may exceed maxtime slightly, depending upon the algorithm and on how slow your function evaluation is.) Criterion is disabled if maxtime is non-positive
|
virtual |
Stochastic population size: This is for random global optimization. It sets the number of random particles to propagate from.
|
inline |
Stopping criteria: Stop when an objective value of at least stopval is found: stop minimizing when an objective value <= stopval is found, or stop maximizing a value >= stopval is found. (Setting stopval to -HUGE_VAL for minimizing or +HUGE_VAL for maximizing disables this stopping criterion.)
Definition at line 161 of file animaNLOPTOptimizers.h.
void anima::NLOPTOptimizers::SetUpperBoundParameters | ( | const ParametersType & | p | ) |
Set the upper bound parameters (not used by all algorithms)
p | The upper bound parameters. |
Definition at line 426 of file animaNLOPTOptimizers.cxx.
|
virtual |
Vector storage size: number of gradients to "remember" from previous optimization steps: increasing it increases the memory requirements but speeds convergence.
|
virtual |
|
virtual |
Stopping criteria: Set the absolute tolerance on optimization parameters.
|
virtual |
Stopping criteria: Set relative tolerance on optimization parameters: stop when an optimization step (or an estimate of the optimum) changes every parameter by less than tol multiplied by the absolute value of the parameter. (If there is any chance that an optimal parameter is close to zero, you might want to set an absolute tolerance with nlopt_set_xtol_abs as well.) Criterion is disabled if tol is non-positive.
void anima::NLOPTOptimizers::StartOptimization | ( | ) |
Starts the optimization.
itk::ExceptionObject | Thrown when exception. |
Definition at line 134 of file animaNLOPTOptimizers.cxx.
|
inline |
Tells Nlopt to stop the optimization at the next iteration and to returns the best point found so far.
Definition at line 298 of file animaNLOPTOptimizers.h.