DGtal  0.9.4beta
Data Structures | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes
DGtal::AngleLinearMinimizer Class Reference

#include <DGtal/math/AngleLinearMinimizer.h>

Inheritance diagram for DGtal::AngleLinearMinimizer:
[legend]
Collaboration diagram for DGtal::AngleLinearMinimizer:
[legend]

Data Structures

struct  ValueInfo
 

Public Member Functions

virtual ~AngleLinearMinimizer ()
 
 AngleLinearMinimizer ()
 
void reset ()
 
void init (unsigned int nbMax)
 
ValueInforw (unsigned int i)
 
const ValueInforo (unsigned int i) const
 
unsigned int maxSize () const
 
unsigned int size () const
 
void setSize (unsigned int nb)
 
void setIsCurveOpen (bool is_curve_open=false)
 
double getEnergy (unsigned int i1, unsigned int i2) const
 
double getFormerEnergy (unsigned int i1, unsigned int i2) const
 
std::vector< double > getGradient () const
 
std::vector< double > getFormerGradient () const
 
double optimize ()
 
double optimize (unsigned int i1, unsigned int i2)
 
double sum () const
 
double max () const
 
virtual double lastDelta () const
 
std::string className () const
 
void selfDisplay (std::ostream &out) const
 
bool isValid () const
 

Protected Member Functions

virtual void oneStep (unsigned int i1, unsigned int i2)
 

Protected Attributes

bool myIsCurveOpen
 
ValueInfomyValues
 
unsigned int mySize
 

Private Member Functions

 AngleLinearMinimizer (const AngleLinearMinimizer &other)
 
AngleLinearMinimizeroperator= (const AngleLinearMinimizer &other)
 

Private Attributes

unsigned int myMaxSize
 
double mySum
 
double myMax
 

Detailed Description

Aim: Used to minimize the angle variation between different angles while taking into accounts min and max constraints. Example (.

Description of class 'AngleLinearMinimizer'

See also
math/testAngleLinearMinimizer.cpp)
double delta= alm.optimize();
double aPrecision=0.00001;
while(delta >aPrecision){
delta= alm.optimize();
cerr << "sum of displacements " << delta << endl;
}

Definition at line 67 of file AngleLinearMinimizer.h.

Constructor & Destructor Documentation

virtual DGtal::AngleLinearMinimizer::~AngleLinearMinimizer ( )
virtual

Destructor.

DGtal::AngleLinearMinimizer::AngleLinearMinimizer ( )

Constructor.

DGtal::AngleLinearMinimizer::AngleLinearMinimizer ( const AngleLinearMinimizer other)
private

Copy constructor.

Parameters
otherthe object to clone. Forbidden by default.

Member Function Documentation

std::string DGtal::AngleLinearMinimizer::className ( ) const
Returns
the style name used for drawing this object.
double DGtal::AngleLinearMinimizer::getEnergy ( unsigned int  i1,
unsigned int  i2 
) const
Parameters
i1the first value to be optimized (between 0 and 'size()-1').
i2the value after the last to be optimized (between 0 and 'size()-1')
Returns
the current energy of the system.
double DGtal::AngleLinearMinimizer::getFormerEnergy ( unsigned int  i1,
unsigned int  i2 
) const
Parameters
i1the first value to be optimized (between 0 and 'size()-1').
i2the value after the last to be optimized (between 0 and 'size()-1')
Returns
the former energy of the system.
std::vector<double> DGtal::AngleLinearMinimizer::getFormerGradient ( ) const
Returns
the energy gradient computed at the former position.
std::vector<double> DGtal::AngleLinearMinimizer::getGradient ( ) const
Returns
the energy gradient computed at the current position.
void DGtal::AngleLinearMinimizer::init ( unsigned int  nbMax)

(Re-)initializes the linear minimizer.

Parameters
nbMaxan upper bound for the number of values to optimize.
bool DGtal::AngleLinearMinimizer::isValid ( ) const

Checks the validity/consistency of the object.

Returns
'true' if the object is valid, 'false' otherwise.
virtual double DGtal::AngleLinearMinimizer::lastDelta ( ) const
virtual

Should be used to stop the minimization process. The smaller is this value, the more the optimization is at an end. May have several meanings, like the infinite norm of the last displacement or the infinite norm of the projected gradient.

Returns
an upper bound on the norm of the last displacement.

Reimplemented in DGtal::AngleLinearMinimizerByAdaptiveStepGradientDescent, DGtal::AngleLinearMinimizerByGradientDescent, and DGtal::AngleLinearMinimizerByRelaxation.

double DGtal::AngleLinearMinimizer::max ( ) const

Max of all the absolute displacements of the last optimisation step.

unsigned int DGtal::AngleLinearMinimizer::maxSize ( ) const
Returns
the maximum number of values stored in the object.
virtual void DGtal::AngleLinearMinimizer::oneStep ( unsigned int  i1,
unsigned int  i2 
)
protectedvirtual

The method which performs the optimization effectively. The user may override it. The optimization is performed on values [i1] included to [i2] excluded. Afterwards, the field ValueInfo::value should contain the new value.

Parameters
i1the first value to be optimized (between 0 and 'size()-1').
i2the value after the last to be optimized (between 0 and 'size()-1').

Reimplemented in DGtal::AngleLinearMinimizerByAdaptiveStepGradientDescent, DGtal::AngleLinearMinimizerByGradientDescent, and DGtal::AngleLinearMinimizerByRelaxation.

AngleLinearMinimizer& DGtal::AngleLinearMinimizer::operator= ( const AngleLinearMinimizer other)
private

Assignment.

Parameters
otherthe object to copy.
Returns
a reference on 'this'. Forbidden by default.
double DGtal::AngleLinearMinimizer::optimize ( )

Move each value on the straight line joining its neighboring values while maintaining the value between its bounds. The optimization is performed on all values. After preparing datas, calls oneStep, which may be overriden.

Returns
the sum of the displacements.
See also
oneStep
double DGtal::AngleLinearMinimizer::optimize ( unsigned int  i1,
unsigned int  i2 
)

Move each value on the straight line joining its neighboring values while maintaining the value between its bounds. The optimization is performed on values [i1] included to [i2] excluded. After preparing datas, calls oneStep, which may be overriden. Then, computes max and sum of displacements.

Parameters
i1the first value to be optimized (between 0 and 'size()-1').
i2the value after the last to be optimized (between 0 and 'size()-1').
Returns
the sum of the displacements.
See also
oneStep
void DGtal::AngleLinearMinimizer::reset ( )

Reset all. The object is as if it has just been created.

const ValueInfo& DGtal::AngleLinearMinimizer::ro ( unsigned int  i) const
Returns
a const reference on the information structure of the [i]th value.
ValueInfo& DGtal::AngleLinearMinimizer::rw ( unsigned int  i)
Returns
a reference on the information structure of the [i]th value.
void DGtal::AngleLinearMinimizer::selfDisplay ( std::ostream &  out) const

Writes/Displays the object on an output stream.

Parameters
outthe output stream where the object is written.
void DGtal::AngleLinearMinimizer::setIsCurveOpen ( bool  is_curve_open = false)

Specifies if the curve is open or not.

Parameters
is_curve_openwhen 'true' the curve is open and the last value does not depend on the first one, otherwise the curve is closed and the last value is linked to the first one.
void DGtal::AngleLinearMinimizer::setSize ( unsigned int  nb)

Specifies the exact number of valid values.

Parameters
nbany number below 'maxSize()'.
unsigned int DGtal::AngleLinearMinimizer::size ( ) const
Returns
the number of values stored in the object.
double DGtal::AngleLinearMinimizer::sum ( ) const

Sum of all the absolute displacements of the last optimisation step.

Field Documentation

bool DGtal::AngleLinearMinimizer::myIsCurveOpen
protected

Indicates if the curve is open.

Definition at line 298 of file AngleLinearMinimizer.h.

double DGtal::AngleLinearMinimizer::myMax
private

Max of all the absolute displacements of the last optimisation step.

Definition at line 329 of file AngleLinearMinimizer.h.

unsigned int DGtal::AngleLinearMinimizer::myMaxSize
private

The size of the array myValues, ie the maximal number of valid values.

Definition at line 316 of file AngleLinearMinimizer.h.

unsigned int DGtal::AngleLinearMinimizer::mySize
protected

The meaningful size of the array [myValues], ie the number of valid entries.

Definition at line 309 of file AngleLinearMinimizer.h.

double DGtal::AngleLinearMinimizer::mySum
private

Sum of all the absolute displacements of the last optimisation step.

Definition at line 324 of file AngleLinearMinimizer.h.

ValueInfo* DGtal::AngleLinearMinimizer::myValues
protected

The dynamically allocated array of values and the associated constraints.

Definition at line 303 of file AngleLinearMinimizer.h.


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