DGtal  1.5.beta
DGtal::AngleLinearMinimizer Class Reference

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

#include <DGtal/math/AngleLinearMinimizer.h>

Inheritance 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

◆ ~AngleLinearMinimizer()

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

Destructor.

◆ AngleLinearMinimizer() [1/2]

DGtal::AngleLinearMinimizer::AngleLinearMinimizer ( )

Constructor.

◆ AngleLinearMinimizer() [2/2]

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

Copy constructor.

Parameters
otherthe object to clone. Forbidden by default.

Member Function Documentation

◆ className()

std::string DGtal::AngleLinearMinimizer::className ( ) const
Returns
the style name used for drawing this object.

◆ getEnergy()

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.

◆ getFormerEnergy()

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.

◆ getFormerGradient()

std::vector<double> DGtal::AngleLinearMinimizer::getFormerGradient ( ) const
Returns
the energy gradient computed at the former position.

◆ getGradient()

std::vector<double> DGtal::AngleLinearMinimizer::getGradient ( ) const
Returns
the energy gradient computed at the current position.

◆ init()

void DGtal::AngleLinearMinimizer::init ( unsigned int  nbMax)

(Re-)initializes the linear minimizer.

Parameters
nbMaxan upper bound for the number of values to optimize.

Referenced by testAngleLinearMinimizer().

◆ isValid()

bool DGtal::AngleLinearMinimizer::isValid ( ) const

Checks the validity/consistency of the object.

Returns
'true' if the object is valid, 'false' otherwise.

◆ lastDelta()

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.

◆ max()

double DGtal::AngleLinearMinimizer::max ( ) const

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

◆ maxSize()

unsigned int DGtal::AngleLinearMinimizer::maxSize ( ) const
Returns
the maximum number of values stored in the object.

◆ oneStep()

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.

◆ operator=()

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

Assignment.

Parameters
otherthe object to copy.
Returns
a reference on 'this'. Forbidden by default.

◆ optimize() [1/2]

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

Referenced by testAngleLinearMinimizer().

◆ optimize() [2/2]

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

◆ reset()

void DGtal::AngleLinearMinimizer::reset ( )

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

◆ ro()

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

Referenced by testAngleLinearMinimizer().

◆ rw()

ValueInfo& DGtal::AngleLinearMinimizer::rw ( unsigned int  i)
Returns
a reference on the information structure of the [i]th value.

Referenced by testAngleLinearMinimizer().

◆ selfDisplay()

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.

◆ setIsCurveOpen()

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.

Referenced by testAngleLinearMinimizer().

◆ setSize()

void DGtal::AngleLinearMinimizer::setSize ( unsigned int  nb)

Specifies the exact number of valid values.

Parameters
nbany number below 'maxSize()'.

◆ size()

unsigned int DGtal::AngleLinearMinimizer::size ( ) const
Returns
the number of values stored in the object.

◆ sum()

double DGtal::AngleLinearMinimizer::sum ( ) const

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

Field Documentation

◆ myIsCurveOpen

bool DGtal::AngleLinearMinimizer::myIsCurveOpen
protected

Indicates if the curve is open.

Definition at line 298 of file AngleLinearMinimizer.h.

◆ myMax

double DGtal::AngleLinearMinimizer::myMax
private

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

Definition at line 329 of file AngleLinearMinimizer.h.

◆ myMaxSize

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.

◆ mySize

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.

◆ mySum

double DGtal::AngleLinearMinimizer::mySum
private

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

Definition at line 324 of file AngleLinearMinimizer.h.

◆ myValues

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: