Conjugate-gradient method for unconstrained optimization. More...
#include <shark/Algorithms/GradientDescent/CG.h>
Inheritance diagram for shark::CG:Public Member Functions | |
| std::string | name () const |
| returns the name of the object More... | |
| SHARK_EXPORT_SYMBOL void | read (InArchive &archive) |
| Read the component from the supplied archive. More... | |
| SHARK_EXPORT_SYMBOL void | write (OutArchive &archive) const |
| Write the component to the supplied archive. More... | |
Public Member Functions inherited from shark::AbstractLineSearchOptimizer | |
| SHARK_EXPORT_SYMBOL | AbstractLineSearchOptimizer () |
| SHARK_EXPORT_SYMBOL void | init (ObjectiveFunctionType &objectiveFunction, SearchPointType const &startingPoint) |
| initializes the optimizer using a predefined starting point More... | |
| SHARK_EXPORT_SYMBOL void | step (ObjectiveFunctionType const &objectiveFunction) |
| Carry out one step of the optimizer for the supplied objective function. More... | |
| LineSearch const & | lineSearch () const |
| LineSearch & | lineSearch () |
Public Member Functions inherited from shark::AbstractSingleObjectiveOptimizer< RealVector > | |
| virtual void | init (ObjectiveFunctionType &function) |
| virtual const SolutionType & | solution () const |
| returns the current solution of the optimizer More... | |
Public Member Functions inherited from shark::AbstractOptimizer< RealVector, double, SingleObjectiveResultSet< RealVector > > | |
| const Features & | features () const |
| virtual void | updateFeatures () |
| bool | requiresValue () const |
| bool | requiresFirstDerivative () const |
| bool | requiresSecondDerivative () const |
| bool | canSolveConstrained () const |
| bool | requiresClosestFeasible () const |
| virtual | ~AbstractOptimizer () |
| Empty virtual d'tor. More... | |
Public Member Functions inherited from shark::INameable | |
| virtual | ~INameable () |
Public Member Functions inherited from shark::ISerializable | |
| virtual | ~ISerializable () |
| Virtual d'tor. More... | |
| void | load (InArchive &archive, unsigned int version) |
| Versioned loading of components, calls read(...). More... | |
| void | save (OutArchive &archive, unsigned int version) const |
| Versioned storing of components, calls write(...). More... | |
| BOOST_SERIALIZATION_SPLIT_MEMBER () | |
Protected Member Functions | |
| SHARK_EXPORT_SYMBOL void | initModel () |
| Initializes the internal model. More... | |
| SHARK_EXPORT_SYMBOL void | computeSearchDirection () |
| Updates the Model and computes the next search direction. More... | |
Protected Member Functions inherited from shark::AbstractOptimizer< RealVector, double, SingleObjectiveResultSet< RealVector > > | |
| void | checkFeatures (ObjectiveFunctionType const &objectiveFunction) |
| Convenience function that checks whether the features of the supplied objective function match with the required features of the optimizer. More... | |
Protected Attributes | |
| unsigned | m_count |
Protected Attributes inherited from shark::AbstractLineSearchOptimizer | |
| LineSearch | m_linesearch |
| used line search method. More... | |
| std::size_t | m_dimension |
| number of parameters More... | |
| double | m_initialStepLength |
| Initial step length to begin with the line search. More... | |
| RealVector | m_derivative |
| gradient of m_best.point More... | |
| RealVector | m_searchDirection |
| search direction of next step More... | |
| RealVector | m_lastPoint |
| previous point More... | |
| RealVector | m_lastDerivative |
| gradient of the previous point More... | |
| double | m_lastValue |
| value of the previous point More... | |
Protected Attributes inherited from shark::AbstractSingleObjectiveOptimizer< RealVector > | |
| SolutionType | m_best |
| current solution of the optimizer More... | |
Protected Attributes inherited from shark::AbstractOptimizer< RealVector, double, SingleObjectiveResultSet< RealVector > > | |
| Features | m_features |
Additional Inherited Members | |
Public Types inherited from shark::AbstractSingleObjectiveOptimizer< RealVector > | |
| typedef base_type::SearchPointType | SearchPointType |
| typedef base_type::SolutionType | SolutionType |
| typedef base_type::ResultType | ResultType |
| typedef base_type::ObjectiveFunctionType | ObjectiveFunctionType |
Public Types inherited from shark::AbstractOptimizer< RealVector, double, SingleObjectiveResultSet< RealVector > > | |
| enum | Feature |
| Models features that the optimizer requires from the objective function. More... | |
| typedef RealVector | SearchPointType |
| typedef double | ResultType |
| typedef SingleObjectiveResultSet< RealVector > | SolutionType |
| typedef AbstractObjectiveFunction< RealVector, ResultType > | ObjectiveFunctionType |
| typedef TypedFlags< Feature > | Features |
| typedef TypedFeatureNotAvailableException< Feature > | FeatureNotAvailableException |
Conjugate-gradient method for unconstrained optimization.
The next CG search Direction p_{k+1} is computed using the current gradient g_k by \( p_{k+1} = \beta p_k - g_k \) where beta can be computed using different formulas well known is the Fletcher - Reeves method: \( \beta = ||g_k||2/ ||g_{k-1}||^2 \) we use \( \beta = ||g_k||^2 /<p_k,g_k-g_{k-1}> \) which is formula 5.49 in Nocedal, Wright - Numerical Optimization. This formula has better numerical properties than Fletcher-Reeves for non-quadratic functions while ensuring a descent direction.
We implement restarting to ensure quadratic convergence near the optimum as well as numerical stability
|
protectedvirtual |
Updates the Model and computes the next search direction.
After a step was performed, this method is called to compute the next search direction. This usually involves updating the internal model using the new and old step information. Afterwards m_searchDirection should contain the next search direction.
Implements shark::AbstractLineSearchOptimizer.
|
protectedvirtual |
Initializes the internal model.
Line Search Methods use a Model to search for the next search direction. The model is initialized during init()
Implements shark::AbstractLineSearchOptimizer.
|
inlinevirtual |
returns the name of the object
Reimplemented from shark::INameable.
Definition at line 63 of file CG.h.
References read(), SHARK_EXPORT_SYMBOL, and write().
|
virtual |
Read the component from the supplied archive.
| [in,out] | archive | The archive to read from. |
Reimplemented from shark::AbstractLineSearchOptimizer.
Referenced by name().
|
virtual |
Write the component to the supplied archive.
| [in,out] | archive | The archive to write to. |
Reimplemented from shark::AbstractLineSearchOptimizer.
Referenced by name().