proj home

Files   Classes   Functions   Hierarchy  

patternsearch< EXP > Class Template Reference

Pattern search algorithm by Hooke and Jeeves 1961. More...

#include <patternsearch.h>

Collaboration diagram for patternsearch< EXP >:

List of all members.

Public Types

typedef typeop< EXP >::Tbare::Ttype T
typedef typeop< EXP >
::Tbare::XItype 
XI

Public Member Functions

 patternsearch (EXP exp_, T hstep_=1)
 The pattern move is configured with an exploratory mover and variable step length.
void reset ()
 Reset from the current position and keep the state.
void reset (T const *x0)
 New position and new state.
void operator++ ()
 One exploratory move then pattern moves.
bool const operator! () const

Public Attributes

EXP exp
 The exploratory mover.
T hstep
 Pattern move is X[n+1]=X[n]+hstep*(x[n]-x[n-1]).
cirbuffarr< Txi0
 The previous state.
vec< XI, Txivec
 The current state as a vec for arithmetic operations.


Detailed Description

template<typename EXP>
class patternsearch< EXP >

Pattern search algorithm by Hooke and Jeeves 1961.

I modified the algorithm for a variable step length. This showed improvement when I used the Fibonacci golden ratio as the step length.

Pattern move : X[n+1] = X[n] + hstep*(X[n]-X[n-1])

Definition at line 21 of file patternsearch.h.


Member Typedef Documentation

template<typename EXP>
typedef typeop<EXP>::Tbare::Ttype patternsearch< EXP >::T

Definition at line 25 of file patternsearch.h.

template<typename EXP>
typedef typeop<EXP>::Tbare::XItype patternsearch< EXP >::XI

Definition at line 26 of file patternsearch.h.


Constructor & Destructor Documentation

template<typename EXP >
patternsearch< EXP >::patternsearch ( EXP  exp_,
T  hstep_ = 1 
) [inline]

The pattern move is configured with an exploratory mover and variable step length.

Definition at line 94 of file patternsearch.h.

00095   : exp(exp_), hstep(hstep_), xi0(3,exp.N), xivec(exp.xi,exp.N)
00096 {
00097 }


Member Function Documentation

template<typename EXP>
bool const patternsearch< EXP >::operator! (  )  const [inline]

Definition at line 54 of file patternsearch.h.

References patternsearch< EXP >::exp.

00055     { return exp.valid; }

template<typename EXP >
void patternsearch< EXP >::operator++ (  )  [inline]

One exploratory move then pattern moves.

Definition at line 76 of file patternsearch.h.

References patternsearch< EXP >::exp, patternsearch< EXP >::hstep, patternsearch< EXP >::xi0, and patternsearch< EXP >::xivec.

00077 {
00078   for (bool loop=true; loop;)
00079   {
00080     xi0.push(exp.xi);
00081     xivec -= xi0[1];
00082     xivec *= hstep;
00083     xivec += xi0[0];
00084   
00085     exp.movelocal();
00086 
00087     loop = exp.evaluate();
00088   }
00089   xi0.copyto(exp.xi);
00090 }

template<typename EXP>
void patternsearch< EXP >::reset ( T const *  x0  )  [inline]

New position and new state.

ie a full reset.

Definition at line 47 of file patternsearch.h.

References patternsearch< EXP >::exp, and patternsearch< EXP >::reset().

Referenced by patternsearch< EXP >::reset().

00048     { exp.reset(x0); reset(); }

template<typename EXP >
void patternsearch< EXP >::reset (  )  [inline]

Reset from the current position and keep the state.

Definition at line 67 of file patternsearch.h.

References patternsearch< EXP >::exp, and patternsearch< EXP >::xi0.

Referenced by minimizecomparetest01(), minimizecomparetest02(), test08(), and test11().

00068 { 
00069   exp.reset(); 
00070   xi0.push(exp.xi); 
00071   exp.move(); 
00072   xi0.push(exp.xi); 
00073 }


Member Data Documentation

template<typename EXP>
EXP patternsearch< EXP >::exp

template<typename EXP>
T patternsearch< EXP >::hstep

Pattern move is X[n+1]=X[n]+hstep*(x[n]-x[n-1]).

Definition at line 32 of file patternsearch.h.

Referenced by patternsearch< EXP >::operator++().

template<typename EXP>
cirbuffarr< T > patternsearch< EXP >::xi0

The previous state.

Definition at line 38 of file patternsearch.h.

Referenced by patternsearch< EXP >::operator++(), and patternsearch< EXP >::reset().

template<typename EXP>
vec< XI, T > patternsearch< EXP >::xivec

The current state as a vec for arithmetic operations.

Definition at line 41 of file patternsearch.h.

Referenced by patternsearch< EXP >::operator++().


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

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