DGtal  1.3.beta
AngleLinearMinimizer.h
1 
17 #pragma once
18 
35 #if defined(AngleLinearMinimizer_RECURSES)
36 #error Recursive header files inclusion detected in AngleLinearMinimizer.h
37 #else // defined(AngleLinearMinimizer_RECURSES)
38 
39 #define AngleLinearMinimizer_RECURSES
40 
41 #if !defined AngleLinearMinimizer_h
42 
43 #define AngleLinearMinimizer_h
44 
46 // Inclusions
47 #include <iostream>
48 #include <vector>
49 #include "DGtal/base/Common.h"
50 #include "DGtal/math/AngleComputer.h"
51 #include "DGtal/arithmetic/ModuloComputer.h"
53 
54 namespace DGtal
55 {
56 
58 // class AngleLinearMinimizer
68 {
69 
70 public:
74  struct ValueInfo
75  {
79  double value;
80 
84  double oldValue;
85 
89  double min;
90 
94  double max;
95 
99  double distToNext;
100 
101  };
102 
103 
104 
105  // ----------------------- Standard services ------------------------------
106 public:
107 
111  virtual ~AngleLinearMinimizer();
112 
117 
121  void reset();
122 
128  void init( unsigned int nbMax );
129 
130 
134  ValueInfo & rw( unsigned int i );
135 
136 
140  const ValueInfo & ro( unsigned int i ) const;
141 
145  unsigned int maxSize() const;
146 
150  unsigned int size() const;
151 
156  void setSize( unsigned int nb );
157 
164  void setIsCurveOpen( bool is_curve_open = false );
165 
166 
167 
168 
169  // ------------------------- Optimization services --------------------------
170 
171 public:
172 
178  double getEnergy( unsigned int i1, unsigned int i2 ) const;
179 
185  double getFormerEnergy( unsigned int i1, unsigned int i2 ) const;
186 
187 
191  std::vector<double> getGradient() const;
192 
193 
197  std::vector<double> getFormerGradient() const;
198 
208  double optimize();
209 
210 
223  double optimize( unsigned int i1, unsigned int i2 );
224 
225 
229  double sum() const;
230 
231 
232 
236  double max() const;
237 
238 
239 protected:
240 
250  virtual void oneStep( unsigned int i1, unsigned int i2 );
251 
252 
253 public:
262  virtual double lastDelta() const;
263 
264 
265 
266 
267 
268  // --------------- CDrawableWithBoard2D realization -------------------
269  public:
270 
274  std::string className() const;
275 
276  // ----------------------- Interface --------------------------------------
277 public:
278 
279 
284  void selfDisplay ( std::ostream & out ) const;
285 
290  bool isValid() const;
291 
292  // ------------------------- Protected Datas ------------------------------
293 
294 protected:
299 
304 
309  unsigned int mySize;
310 
311 private:
312 
316  unsigned int myMaxSize;
317 
318 
319  // ------------------------- Private Datas --------------------------------
320 private:
324  double mySum;
325 
329  double myMax;
330 
331  // ------------------------- Hidden services ------------------------------
332 
333 
334 
335 private:
349 
350 
351 
352  // ------------------------- Internals ------------------------------------
353 private:
354 
355 }; // end of class AngleLinearMinimizer
356 
357 
358 
359 
364  {
365  public:
370 
375 
376  protected:
377 
386  virtual void oneStep( unsigned int i1, unsigned int i2 );
387 
388 public:
397  virtual double lastDelta() const;
398 
399  // ----------------------- Interface --------------------------------------
400  public:
405  virtual void selfDisplay( std::ostream & aStream ) const;
406 
407  };
408 
409 
410 
415  {
416  private:
417 
421  double myStep;
422 
423  public:
427  AngleLinearMinimizerByGradientDescent( double step = 0.1 );
428 
433 
434  protected:
435 
444  virtual void oneStep( unsigned int i1, unsigned int i2 );
445 
446 public:
455  virtual double lastDelta() const;
456 
457  // ----------------------- Interface --------------------------------------
458  public:
463  virtual void selfDisplay( std::ostream & aStream ) const;
464 
465  };
466 
467 
473  {
474  private:
475 
479  double myStep;
480 
481  public:
486 
491 
492  protected:
493 
502  virtual void oneStep( unsigned int i1, unsigned int i2 );
503 
504 public:
513  virtual double lastDelta() const;
514 
515  // ----------------------- Interface --------------------------------------
516  public:
521  virtual void selfDisplay( std::ostream & aStream ) const;
522 
523  };
524 
525 
526 
527 
534 std::ostream&
535 operator<< ( std::ostream & out, const AngleLinearMinimizer & object );
536 
537 
538 } // namespace DGtal
539 
540 
542 // Includes inline functions.
543 #include "DGtal/math/AngleLinearMinimizer.ih"
544 
545 // //
547 
548 #endif // !defined AngleLinearMinimizer_h
549 
550 #undef AngleLinearMinimizer_RECURSES
551 #endif // else defined(AngleLinearMinimizer_RECURSES)
DGtal::AngleLinearMinimizer::mySum
double mySum
Definition: AngleLinearMinimizer.h:324
DGtal::AngleLinearMinimizerByRelaxation::oneStep
virtual void oneStep(unsigned int i1, unsigned int i2)
DGtal::AngleLinearMinimizer::ValueInfo::distToNext
double distToNext
Definition: AngleLinearMinimizer.h:99
DGtal::AngleLinearMinimizer::optimize
double optimize()
DGtal::AngleLinearMinimizer::myIsCurveOpen
bool myIsCurveOpen
Definition: AngleLinearMinimizer.h:298
DGtal::AngleLinearMinimizer::max
double max() const
DGtal::AngleLinearMinimizerByGradientDescent::myStep
double myStep
Definition: AngleLinearMinimizer.h:421
DGtal::AngleLinearMinimizerByAdaptiveStepGradientDescent::selfDisplay
virtual void selfDisplay(std::ostream &aStream) const
DGtal::AngleLinearMinimizer::lastDelta
virtual double lastDelta() const
DGtal::AngleLinearMinimizer::getGradient
std::vector< double > getGradient() const
DGtal::AngleLinearMinimizer::ValueInfo::max
double max
Definition: AngleLinearMinimizer.h:94
DGtal::AngleLinearMinimizer::ValueInfo::value
double value
Definition: AngleLinearMinimizer.h:79
DGtal::AngleLinearMinimizer::ValueInfo::min
double min
Definition: AngleLinearMinimizer.h:89
DGtal::AngleLinearMinimizer::mySize
unsigned int mySize
Definition: AngleLinearMinimizer.h:309
DGtal::AngleLinearMinimizerByGradientDescent::AngleLinearMinimizerByGradientDescent
AngleLinearMinimizerByGradientDescent(double step=0.1)
DGtal::AngleLinearMinimizer::selfDisplay
void selfDisplay(std::ostream &out) const
DGtal::AngleLinearMinimizer::reset
void reset()
DGtal::AngleLinearMinimizer::init
void init(unsigned int nbMax)
DGtal::AngleLinearMinimizer::setIsCurveOpen
void setIsCurveOpen(bool is_curve_open=false)
DGtal::AngleLinearMinimizerByGradientDescent::selfDisplay
virtual void selfDisplay(std::ostream &aStream) const
DGtal::AngleLinearMinimizerByAdaptiveStepGradientDescent::~AngleLinearMinimizerByAdaptiveStepGradientDescent
virtual ~AngleLinearMinimizerByAdaptiveStepGradientDescent()
DGtal::AngleLinearMinimizer::getEnergy
double getEnergy(unsigned int i1, unsigned int i2) const
DGtal::AngleLinearMinimizer::size
unsigned int size() const
DGtal::AngleLinearMinimizerByRelaxation::~AngleLinearMinimizerByRelaxation
virtual ~AngleLinearMinimizerByRelaxation()
DGtal::AngleLinearMinimizer::ro
const ValueInfo & ro(unsigned int i) const
DGtal::AngleLinearMinimizerByRelaxation::AngleLinearMinimizerByRelaxation
AngleLinearMinimizerByRelaxation()
DGtal::AngleLinearMinimizer::setSize
void setSize(unsigned int nb)
DGtal::AngleLinearMinimizer::rw
ValueInfo & rw(unsigned int i)
DGtal::operator<<
std::ostream & operator<<(std::ostream &out, const ATu0v1< TKSpace, TLinearAlgebra > &object)
DGtal::AngleLinearMinimizerByAdaptiveStepGradientDescent::myStep
double myStep
Definition: AngleLinearMinimizer.h:479
DGtal::AngleLinearMinimizerByGradientDescent
Definition: AngleLinearMinimizer.h:414
DGtal::AngleLinearMinimizerByGradientDescent::oneStep
virtual void oneStep(unsigned int i1, unsigned int i2)
DGtal::AngleLinearMinimizer::myValues
ValueInfo * myValues
Definition: AngleLinearMinimizer.h:303
DGtal::AngleLinearMinimizerByGradientDescent::~AngleLinearMinimizerByGradientDescent
virtual ~AngleLinearMinimizerByGradientDescent()
DGtal::AngleLinearMinimizer::myMax
double myMax
Definition: AngleLinearMinimizer.h:329
DGtal::AngleLinearMinimizerByAdaptiveStepGradientDescent
Definition: AngleLinearMinimizer.h:472
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::AngleLinearMinimizer::ValueInfo
Definition: AngleLinearMinimizer.h:74
DGtal::AngleLinearMinimizer::maxSize
unsigned int maxSize() const
DGtal::AngleLinearMinimizer::getFormerGradient
std::vector< double > getFormerGradient() const
DGtal::AngleLinearMinimizer::operator=
AngleLinearMinimizer & operator=(const AngleLinearMinimizer &other)
DGtal::AngleLinearMinimizerByAdaptiveStepGradientDescent::oneStep
virtual void oneStep(unsigned int i1, unsigned int i2)
DGtal::AngleLinearMinimizer
Aim: Used to minimize the angle variation between different angles while taking into accounts min and...
Definition: AngleLinearMinimizer.h:67
DGtal::AngleLinearMinimizer::getFormerEnergy
double getFormerEnergy(unsigned int i1, unsigned int i2) const
DGtal::AngleLinearMinimizer::oneStep
virtual void oneStep(unsigned int i1, unsigned int i2)
DGtal::AngleLinearMinimizerByAdaptiveStepGradientDescent::AngleLinearMinimizerByAdaptiveStepGradientDescent
AngleLinearMinimizerByAdaptiveStepGradientDescent(double step=0.1)
DGtal::AngleLinearMinimizerByRelaxation
Definition: AngleLinearMinimizer.h:363
DGtal::AngleLinearMinimizer::AngleLinearMinimizer
AngleLinearMinimizer()
DGtal::AngleLinearMinimizer::sum
double sum() const
DGtal::AngleLinearMinimizer::~AngleLinearMinimizer
virtual ~AngleLinearMinimizer()
DGtal::AngleLinearMinimizerByRelaxation::selfDisplay
virtual void selfDisplay(std::ostream &aStream) const
DGtal::AngleLinearMinimizerByRelaxation::lastDelta
virtual double lastDelta() const
DGtal::AngleLinearMinimizerByAdaptiveStepGradientDescent::lastDelta
virtual double lastDelta() const
DGtal::AngleLinearMinimizer::ValueInfo::oldValue
double oldValue
Definition: AngleLinearMinimizer.h:84
DGtal::AngleLinearMinimizer::className
std::string className() const
DGtal::AngleLinearMinimizer::isValid
bool isValid() const
DGtal::AngleLinearMinimizerByGradientDescent::lastDelta
virtual double lastDelta() const
DGtal::AngleLinearMinimizer::myMaxSize
unsigned int myMaxSize
Definition: AngleLinearMinimizer.h:316