proj home

Files   Classes   Functions   Hierarchy  

lineoptimizergold2< LNPATH, T > Class Template Reference

Minimize fn on a 1D path in N dimensional space. More...

#include <lineoptimizergold2.h>

Inheritance diagram for lineoptimizergold2< LNPATH, T >:
Collaboration diagram for lineoptimizergold2< LNPATH, T >:

List of all members.

Public Member Functions

 lineoptimizergold2 (LNPATH linepath_)
ostreamprint (ostream &os) const
 Printing the objects state.
void printstate () const
 Print out the four consecutive positions and their values.
void reset (T const t0, T const t1)
 Search interval initialized.
void resetInnerTwoPoints ()
 Do not re-evaluate the end points.
void operator++ ()
 One iteration of the line minimization algorithm.
bool const verify () const
 Make sure the ti[ai[]] are consecutive (monotonic).
T const minimumrealize ()
 Realize the minimum state by setting xi to the lowest state.

Public Attributes

LNPATH linepath
 This is a path in 1D though N dimensional space.
T ti [4]
 The t values on the line correspond to index positions.
T fti [4]
 The value of the function at the index position.
uint ai [4]
 Indexes to vectors.
T lengthgold
 Interval length*goldratio.

Static Public Attributes

static T goldratio
 The client could assign the golden ratio themselves if needed.


Detailed Description

template<typename LNPATH, typename T>
class lineoptimizergold2< LNPATH, T >

Minimize fn on a 1D path in N dimensional space.

A linear line minimization algorithm. The golden ratio is used to choose the next best interval point.

Usage
Construct the optimizer. Realize the initial position x0 and direction in memory.
Call reset(...) before executing the minimizer. This initializes the interval.

You can reuse the optimizer by writing to the direction and initial position and calling reset.

Example
  double d1[] = {0.0,1.0,1.0};
  double x0[] = {0.0,0.0,0.0};
  parab2 fn;
  typedef linepathd1<parab2&,double*,double*,double> lpth;
  lineoptimizergold2<lpth,double> 
    opt( lpth(3,fn,fn.xi,x0,d1) );

  opt.reset(0.0,5.0);
  for (uint i=0; i<10; ++i)
  {
    ++opt;
    opt.printstate();
  }

Definition at line 47 of file lineoptimizergold2.h.


Constructor & Destructor Documentation

template<typename LNPATH, typename T>
lineoptimizergold2< LNPATH, T >::lineoptimizergold2 ( LNPATH  linepath_  )  [inline]

Definition at line 70 of file lineoptimizergold2.h.

00070                                         :
00071     linepath(linepath_) {}


Member Function Documentation

template<typename LNPATH, typename T>
T const lineoptimizergold2< LNPATH, T >::minimumrealize (  ) 

Realize the minimum state by setting xi to the lowest state.

template<typename LNPATH, typename T>
void lineoptimizergold2< LNPATH, T >::operator++ (  ) 

One iteration of the line minimization algorithm.

Reimplemented in lineoptimizerparabola< LNPATH, T >.

template<typename LNPATH, typename T>
ostream& lineoptimizergold2< LNPATH, T >::print ( ostream os  )  const

Printing the objects state.

Referenced by lineoptimizergold2< LNPATH, T >::print().

template<typename LNPATH, typename T>
void lineoptimizergold2< LNPATH, T >::printstate (  )  const

Print out the four consecutive positions and their values.

template<typename LNPATH, typename T>
void lineoptimizergold2< LNPATH, T >::reset ( T const   t0,
T const   t1 
)

Search interval initialized.

template<typename LNPATH, typename T>
void lineoptimizergold2< LNPATH, T >::resetInnerTwoPoints (  ) 

Do not re-evaluate the end points.

Generally for derived classes.

template<typename LNPATH, typename T>
bool const lineoptimizergold2< LNPATH, T >::verify (  )  const

Make sure the ti[ai[]] are consecutive (monotonic).

Referenced by lineoptimizergold2< LNPATH, T >::operator++().


Member Data Documentation

template<typename LNPATH, typename T>
uint lineoptimizergold2< LNPATH, T >::ai[4]

template<typename LNPATH, typename T>
T lineoptimizergold2< LNPATH, T >::fti[4]

template<typename LNPATH, typename T>
T lineoptimizergold2< LNPATH, T >::goldratio [static]

template<typename LNPATH, typename T>
T lineoptimizergold2< LNPATH, T >::lengthgold

template<typename LNPATH, typename T>
LNPATH lineoptimizergold2< LNPATH, T >::linepath

template<typename LNPATH, typename T>
T lineoptimizergold2< LNPATH, T >::ti[4]


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

Generated on Fri Mar 4 00:50:04 2011 for Chelton Evans Source by  doxygen 1.5.8