#include <ObjectiveFunction.h>
Public Member Functions | |
virtual void | AddConstraintGradient (double *dx, double step=.0, bool *sgn_chg=nullptr) |
virtual void | DataFidelityGradient (double *dx, double step=.0, bool *sgn_chg=nullptr) |
virtual double | Evaluate (double *dx=NULL, double step=.0, bool *sgn_chg=NULL) |
virtual double | Get (int i) const =0 |
virtual void | Get (double *x) const =0 |
virtual void | Gradient (double *dx, double step=.0, bool *sgn_chg=nullptr)=0 |
virtual double | GradientNorm (const double *dx) const =0 |
virtual void | GradientStep (const double *dx, double &min, double &max) const |
virtual int | NumberOfDOFs () const =0 |
virtual void | Put (const double *x)=0 |
virtual double | Step (double *dx)=0 |
virtual void | Update (bool gradient=true) |
virtual bool | Upgrade () |
virtual double | Value ()=0 |
Evaluate objective function value. | |
virtual | ~ObjectiveFunction ()=0 |
Destructor. | |
Public Member Functions inherited from mirtk::Observable | |
void | AddObserver (Observer &) |
Add observer. | |
void | Broadcast (Event, const void *=NULL) |
Broadcast event to observers. | |
void | ClearObservers () |
Delete all observers. | |
void | DeleteObserver (Observer &) |
Delete observer. | |
void | NotifyObservers (Event, const void *=NULL) |
Notify all observers about given event if this object has changed. | |
int | NumberOfObservers () const |
Number of current observers. | |
virtual | ~Observable () |
Destructor. | |
Public Member Functions inherited from mirtk::Object | |
virtual const char * | NameOfClass () const =0 |
Get name of class, which this object is an instance of. | |
virtual ParameterList | Parameter () const |
Get parameter name/value pairs. | |
bool | Parameter (const ParameterList &) |
Set parameters from name/value pairs. | |
virtual bool | Set (const char *name, const char *value) |
virtual | ~Object () |
Destructor. | |
Protected Member Functions | |
mirtkAttributeMacro (double, StepLength) | |
Default step length used for gradient approximation. | |
Protected Member Functions inherited from mirtk::Observable | |
Observable () | |
Default constructor. | |
Observable (const Observable &) | |
Copy constructor. | |
Observable & | operator= (const Observable &) |
Assignment operator. | |
Protected Member Functions inherited from mirtk::Object | |
template<typename... Args> | |
void | Throw (ErrorType err, const char *func, Args... args) const |
Additional Inherited Members | |
Static Public Member Functions inherited from mirtk::Object | |
static const char * | NameOfType () |
Get name of this class type. | |
Static Protected Member Functions inherited from mirtk::Object | |
template<typename... Args> | |
static void | ThrowStatic (ErrorType err, const char *cls, const char *func, Args... args) |
Interface for objective function of an optimization problem.
An objective function can be minimized/maximized using a specialization of the irtkLocalOptimizer base class.
Definition at line 35 of file ObjectiveFunction.h.
|
inlinevirtual |
Add model constraint gradient of objective function w.r.t its DoFs
[in] | step | Step length for finite differences. |
[out] | dx | Gradient of objective function, e.g., either initialised to zero or the data fidelity gradient computed beforehand using DataFidelityGradient. |
[out] | sgn_chg | Whether function parameter value is allowed to change sign when stepping along the computed gradient. |
Reimplemented in mirtk::RegistrationEnergy.
Definition at line 226 of file ObjectiveFunction.h.
|
inlinevirtual |
Evaluate data fidelity gradient of objective function w.r.t its DoFs
[in] | step | Step length for finite differences. |
[out] | dx | Data fidelity gradient of objective function. |
[out] | sgn_chg | Whether function parameter value is allowed to change sign when stepping along the computed gradient. |
Reimplemented in mirtk::RegistrationEnergy.
Definition at line 219 of file ObjectiveFunction.h.
|
inlinevirtual |
Evaluate objective function
This function first updates the internal state of the function object if required due to a previous change of the function parameters and then evaluates the current function value. If dx
is not NULL
, the gradient of the objective function is computed as well.
[in] | step | Step length for finite differences. |
[out] | dx | Gradient of objective function. If NULL , only the function value is computed. |
[out] | sgn_chg | Whether function parameter value is allowed to change sign when stepping along the computed gradient. Ignord if dx is NULL . |
Reimplemented in mirtk::DeformableSurfaceModel, and mirtk::RegistrationEnergy.
Definition at line 232 of file ObjectiveFunction.h.
|
pure virtual |
Get function parameter value
[in] | i | Function parameter (DoF) index. |
Implemented in mirtk::DeformableSurfaceModel, mirtk::RegistrationEnergy, and mirtk::TransformationApproximationError.
|
pure virtual |
Get function parameter values
This function can be used to store a backup of the current funtion parameter values before an update such that these can be restored using the Put member function if the update did not result in the desired change of the overall objective function value.
[in] | x | Function parameter (DoF) values. |
Implemented in mirtk::DeformableSurfaceModel, mirtk::RegistrationEnergy, and mirtk::TransformationApproximationError.
|
pure virtual |
Evaluate gradient of objective function w.r.t its DoFs
When the data fidelity and/or gradient of model constraints need to be evaluated separately, use the following code instead:
[in] | step | Step length for finite differences. |
[out] | dx | Gradient of objective function. |
[out] | sgn_chg | Whether function parameter value is allowed to change sign when stepping along the computed gradient. |
Implemented in mirtk::DeformableSurfaceModel, mirtk::RegistrationEnergy, and mirtk::TransformationApproximationError.
|
pure virtual |
Compute norm of gradient of objective function
This norm is used to define a unit for the step length used by gradient descent methods. It is, for example, the maximum absolute value norm for linear transformations and the maximum control point displacement for FFDs. The computation of the norm may be done after conjugating the gradient vector obtained using the Gradient member function.
[in] | dx | Gradient of objective function. |
Implemented in mirtk::DeformableSurfaceModel, mirtk::RegistrationEnergy, and mirtk::TransformationApproximationError.
|
inlinevirtual |
Adjust step length range
[in] | dx | Gradient of objective function. |
[in,out] | min | Minimum step length. |
[in,out] | max | Maximum step length. |
Reimplemented in mirtk::DeformableSurfaceModel, and mirtk::RegistrationEnergy.
Definition at line 213 of file ObjectiveFunction.h.
|
pure virtual |
Get number of DoFs
Implemented in mirtk::DeformableSurfaceModel, mirtk::RegistrationEnergy, and mirtk::TransformationApproximationError.
|
pure virtual |
Set function parameter values
This is function can be used to set the parameters of the objective function to particular values. In particular, it can be used to restore the function parameters after a failed incremental update which did not result in the desired improvement.
[in] | x | Function parameter (DoF) values. |
Implemented in mirtk::DeformableSurfaceModel, mirtk::RegistrationEnergy, and mirtk::TransformationApproximationError.
|
pure virtual |
Add change (i.e., scaled gradient) to each parameter value
This function updates each DoF of the objective function given a vector of corresponding changes, i.e., the computed gradient of the objective function w.r.t. these parameters or a desired change computed otherwise.
[in,out] | dx | Change of each function parameter (DoF) as computed by the Gradient member function and scaled by a chosen step length. The change of a parameter may be modified by this function in order to satisfy the hard constraints (if any). |
Implemented in mirtk::DeformableSurfaceModel, mirtk::RegistrationEnergy, and mirtk::TransformationApproximationError.
|
inlinevirtual |
Update internal state after change of parameters
[in] | gradient | Update also internal state required for evaluation of gradient of objective function. |
Reimplemented in mirtk::DeformableSurfaceModel, mirtk::RegistrationEnergy, and mirtk::TransformationApproximationError.
Definition at line 202 of file ObjectiveFunction.h.
|
inlinevirtual |
Update objective function after convergence
This function may be called by the optimizer after the optimization of the current objective function has converged or the improvement is insignificant. It allows the objective function to modify itself considering the current estimate of the parameters (DoFs). For example, the fiducial registration error term of a registration energy function could update the point correspondences.
Reimplemented in mirtk::DeformableSurfaceModel, and mirtk::RegistrationEnergy.
Definition at line 207 of file ObjectiveFunction.h.