Class for traces in the optimization search space. More...
#include <cmtkSearchTrace.h>
Classes | |
struct | _TraceListEntry |
Public Member Functions | |
SearchTrace (const int _DOF) | |
Constructor. | |
~SearchTrace () | |
Destructor. | |
void | Add (const double value, const int dir=0, const R step=0) |
Add a location to the trace list. | |
int | Get (double &value, const int dir=0, const R step=0) const |
Get a previously visited location from the list. | |
void | Move (const int dir, const R step) |
Move current position in search space. | |
void | Clear () |
Clear list from memory. | |
Private Types | |
typedef struct cmtk::SearchTrace::_TraceListEntry | TraceListEntry |
Private Member Functions | |
int | IsHit (const TraceListEntry *entry, const int dir, const R step) const |
Compare an item from the track list to a given location. | |
Private Attributes | |
int | DOF |
Dimension of the search space. | |
TraceListEntry * | List |
Pointer to the first element of the list of visited locations. |
Class for traces in the optimization search space.
An object of this class runs a list of those locations in search space that have already been visited during the optimization. This may save evaluations of the target function when these locations are approached again later in the optimum search. The type of relative vectors is defined by a template argument R. For one step size only, the default setting of "short", even "signed char" may be enough. To keep track of multiresolution schemes, however, we shall need to use "float" or "double".
Definition at line 55 of file cmtkSearchTrace.h.
typedef struct cmtk::SearchTrace::_TraceListEntry cmtk::SearchTrace< R >::TraceListEntry [private] |
cmtk::SearchTrace< R >::SearchTrace | ( | const int | _DOF ) | [inline] |
Constructor.
Set dimension of search space and initialize trace list.
Definition at line 102 of file cmtkSearchTrace.h.
References NULL.
cmtk::SearchTrace< R >::~SearchTrace | ( | ) | [inline] |
Destructor.
Call Clear() to remove list from memory.
Definition at line 110 of file cmtkSearchTrace.h.
void cmtk::SearchTrace< R >::Add | ( | const double | value, |
const int | dir = 0 , |
||
const R | step = 0 |
||
) | [inline] |
Add a location to the trace list.
value | The value of the target function at the location to be added to the list. |
dir | Direction of the location to add with respect to the current position in search space. This is the index of the parameter we are modifying. |
step | Size of the step, ie. distance of the new location from the current position in search space. |
Definition at line 121 of file cmtkSearchTrace.h.
References cmtk::SearchTrace< R >::_TraceListEntry::FunctionValue, cmtk::SearchTrace< R >::_TraceListEntry::Next, and cmtk::SearchTrace< R >::_TraceListEntry::RelativePosition.
void cmtk::SearchTrace< R >::Clear | ( | ) | [inline] |
Clear list from memory.
All list entries as well as the location vectors stored in them are deleted and the list pointer is reset to NULL.
Definition at line 176 of file cmtkSearchTrace.h.
References cmtk::Memory::DeleteArray(), and cmtk::SearchTrace< R >::_TraceListEntry::Next.
int cmtk::SearchTrace< R >::Get | ( | double & | value, |
const int | dir = 0 , |
||
const R | step = 0 |
||
) | const [inline] |
Get a previously visited location from the list.
value | This reference is used to return the target function's value at the location that was asked for. This value is only valid, if the location was in the list. In case the function returns 0, value is undefined. |
dir | Direction in search space towards the location we ask for. |
step | Size of the step to make in the given direction. |
Definition at line 141 of file cmtkSearchTrace.h.
References cmtk::SearchTrace< R >::_TraceListEntry::FunctionValue, and cmtk::SearchTrace< R >::_TraceListEntry::Next.
Referenced by cmtk::BestNeighbourOptimizer::Optimize().
int cmtk::SearchTrace< R >::IsHit | ( | const TraceListEntry * | entry, |
const int | dir, | ||
const R | step | ||
) | const [inline, private] |
Compare an item from the track list to a given location.
As with every move in the search space, relative locations of the previously seen samples are updated, all components of the tested location must be zero except for the one giving the current search direction.
entry | The entry in the track list to be tested. |
dir | Direction, i.e. index of the parameter, in which we are moving. |
step | Size of the intended step. |
Definition at line 89 of file cmtkSearchTrace.h.
References cmtk::SearchTrace< R >::_TraceListEntry::RelativePosition.
void cmtk::SearchTrace< R >::Move | ( | const int | dir, |
const R | step | ||
) | [inline] |
Move current position in search space.
All entries in the table of visited positions are modified accordingly to keep their relative positions up-to-date.
dir | Parameter modified to do the move. |
step | Size of the update step in the direction defined by 'dir'. |
Definition at line 162 of file cmtkSearchTrace.h.
References cmtk::SearchTrace< R >::_TraceListEntry::Next, and cmtk::SearchTrace< R >::_TraceListEntry::RelativePosition.
Referenced by cmtk::BestNeighbourOptimizer::Optimize().
int cmtk::SearchTrace< R >::DOF [private] |
Dimension of the search space.
Definition at line 72 of file cmtkSearchTrace.h.
TraceListEntry* cmtk::SearchTrace< R >::List [private] |
Pointer to the first element of the list of visited locations.
Definition at line 76 of file cmtkSearchTrace.h.