DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Protected Member Functions
DGtal::AngleLinearMinimizerByRelaxation Class Reference

#include <AngleLinearMinimizer.h>

Inheritance diagram for DGtal::AngleLinearMinimizerByRelaxation:
Inheritance graph
[legend]
Collaboration diagram for DGtal::AngleLinearMinimizerByRelaxation:
Collaboration graph
[legend]

Public Member Functions

 AngleLinearMinimizerByRelaxation ()
virtual ~AngleLinearMinimizerByRelaxation ()
virtual double lastDelta () const
virtual void selfDisplay (std::ostream &aStream) const
- Public Member Functions inherited from DGtal::AngleLinearMinimizer
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
std::string className () const
bool isValid () const

Protected Member Functions

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

Additional Inherited Members

- Protected Attributes inherited from DGtal::AngleLinearMinimizer
bool myIsCurveOpen
ValueInfomyValues
unsigned int mySize

Detailed Description

Specializes LinearMinimizer to optimize with a relaxation method.

Definition at line 372 of file AngleLinearMinimizer.h.


Constructor & Destructor Documentation

DGtal::AngleLinearMinimizerByRelaxation::AngleLinearMinimizerByRelaxation ( )
inline

Default constructor. Does nothing.

Definition at line 72 of file AngleLinearMinimizer.ih.

{}
DGtal::AngleLinearMinimizerByRelaxation::~AngleLinearMinimizerByRelaxation ( )
inlinevirtual

Destructor. Does nothing.

Definition at line 80 of file AngleLinearMinimizer.ih.

{}

Member Function Documentation

double DGtal::AngleLinearMinimizerByRelaxation::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 from DGtal::AngleLinearMinimizer.

Definition at line 353 of file AngleLinearMinimizer.cpp.

{
return max();
}
void DGtal::AngleLinearMinimizerByRelaxation::oneStep ( unsigned int  i1,
unsigned int  i2 
)
protectedvirtual

The method which performs the optimization effectively. Use a relaxation technique. The optimization is performed on values [i1] included to [i2] excluded.

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 from DGtal::AngleLinearMinimizer.

Definition at line 305 of file AngleLinearMinimizer.cpp.

References DGtal::AngleComputer::cast(), DGtal::AngleComputer::deviation(), DGtal::AngleLinearMinimizer::ValueInfo::distToNext, DGtal::AngleComputer::less(), DGtal::AngleLinearMinimizer::ValueInfo::max, DGtal::AngleLinearMinimizer::ValueInfo::min, DGtal::ModuloComputer< TInteger >::next(), DGtal::AngleLinearMinimizer::ValueInfo::oldValue, DGtal::ModuloComputer< TInteger >::previous(), and DGtal::AngleLinearMinimizer::ValueInfo::value.

{
double mid;
unsigned int i = i1;
unsigned int iprev = mc.previous( i );
do
{
unsigned int inext = mc.next( i );
ValueInfo & vi = this->rw( i );
// vi.oldValue = vi.value;
if ( myIsCurveOpen && ( i == ( size() - 1 ) ) )
{ // free extremity to the front/right.
const ValueInfo & viprev = this->ro( iprev );
mid = viprev.value; // - viprev.delta;
}
else if ( myIsCurveOpen && ( i == 0 ) )
{ // free extremity to the back/left.
const ValueInfo & vinext = this->ro( inext );
mid = vinext.oldValue; // + vi.delta;
}
else
{ // standard case.
const ValueInfo & viprev = this->ro( iprev );
const ValueInfo & vinext = this->ro( inext );
double valp = viprev.value; // - viprev.delta;
double valn = vinext.value;
// old
double y = AngleComputer::deviation( valn, valp );
mid = ( viprev.distToNext * y )
/ ( vi.distToNext + viprev.distToNext );
mid = AngleComputer::cast( mid + valp );
}
if ( AngleComputer::less( mid, vi.min ) ) mid = vi.min;
if ( AngleComputer::less( vi.max, mid ) ) mid = vi.max;
vi.value = mid;
iprev = i;
i = inext;
}
while ( i != i2 );
}
void DGtal::AngleLinearMinimizerByRelaxation::selfDisplay ( std::ostream &  aStream) const
virtual

Writes/Displays the object on an output stream.

Parameters:
aStreamthe output stream where the object is written.

Reimplemented from DGtal::AngleLinearMinimizer.

Definition at line 485 of file AngleLinearMinimizer.cpp.

{
aStream << "[LinearMinimizer::relaxation]";
}

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