GridSearch Class Reference

Optimize by trying out a grid of configurations. More...

#include <GridSearch.h>

Inheritance diagram for GridSearch:
Optimizer

List of all members.

Public Member Functions

 GridSearch (int verbosity=0)
 Constructor.
 ~GridSearch ()
 Destructor.
void init (Model &model)
 There is no useful default initialization for this optimizer.
void init (int params, double min, double max, int nodes)
 uniform initialization for all parameters
void init (int params, const Array< double > &min, const Array< double > &max, const Array< int > &nodes)
 individual definition for every parameter
void init (int params, const Array< double > &values)
 uniform definition of the values to test for all parameters
void init (int params, const Array< int > &nodes, const Array< double > &values)
 individual definition for every parameter
double optimize (Model &model, ErrorFunction &errorfunction, const Array< double > &input, const Array< double > &target)
 Please note that for the grid search optimizer it does not make sense to call optimize more than once, as the solution does not improve iteratively.

Protected Attributes

Array< int > numberOfValues
 The array holds the number of grid values for every parameter axis.
Array< double > nodeValues
 The array columns contain the grid values for the corresponding parameter axis.
int verbosity
 verbosity level

Detailed Description

Optimize by trying out a grid of configurations.

The GridSearch class allows for the definition of a grid in parameter space. It does a simple one-step optimization over the grid by trying out every possible parameter combination. Please note that the computation effort grows exponentially with the number of parameters.
If you only want to try a subset of the grid, consider using the PointSearch class instead. A more sophisticated (less exhaustive) grid search variant is available with the NestedGridSearch class.

Definition at line 71 of file GridSearch.h.


Constructor & Destructor Documentation

GridSearch::GridSearch ( int  verbosity = 0  ) 

Constructor.

Parameters:
verbosity 0=none, 1=dots, 2=values

Definition at line 51 of file GridSearch.cpp.

GridSearch::~GridSearch (  ) 

Destructor.

Definition at line 56 of file GridSearch.cpp.


Member Function Documentation

void GridSearch::init ( int  params,
const Array< int > &  nodes,
const Array< double > &  values 
)

individual definition for every parameter

Parameters:
params number of model parameters to optimize
nodes total number of values for every parameter
values values used. The first dimension is the parameter, the second dimension is the node. Unused entries are ignored.

Definition at line 131 of file GridSearch.cpp.

References nodeValues, and numberOfValues.

void GridSearch::init ( int  params,
const Array< double > &  values 
)

uniform definition of the values to test for all parameters

Parameters:
params number of model parameters to optimize
values values used for every coordinate

Definition at line 115 of file GridSearch.cpp.

References i, nodeValues, and numberOfValues.

void GridSearch::init ( int  params,
const Array< double > &  min,
const Array< double > &  max,
const Array< int > &  nodes 
)

individual definition for every parameter

Parameters:
params number of model parameters to optimize
min smallest value for every parameter
max largest value for every parameter
nodes total number of values for every parameter

Definition at line 85 of file GridSearch.cpp.

References i, nodeValues, and numberOfValues.

void GridSearch::init ( int  params,
double  min,
double  max,
int  nodes 
)

uniform initialization for all parameters

Parameters:
params number of model parameters to optimize
min smallest parameter value
max largest parameter value
nodes total number of values in the interval

Definition at line 66 of file GridSearch.cpp.

References i, nodeValues, and numberOfValues.

void GridSearch::init ( Model model  )  [virtual]

There is no useful default initialization for this optimizer.

Thus, this member throws an exception.

Implements Optimizer.

Definition at line 61 of file GridSearch.cpp.

double GridSearch::optimize ( Model model,
ErrorFunction errorfunction,
const Array< double > &  input,
const Array< double > &  target 
) [virtual]

Please note that for the grid search optimizer it does not make sense to call optimize more than once, as the solution does not improve iteratively.

Implements Optimizer.

Definition at line 140 of file GridSearch.cpp.

References ErrorFunction::error(), Model::getParameter(), i, Model::isFeasible(), nodeValues, numberOfValues, Model::setParameter(), and verbosity.


Member Data Documentation

Array<double> GridSearch::nodeValues [protected]

The array columns contain the grid values for the corresponding parameter axis.

As all columns have the same size, some values may be meaningless.

Definition at line 124 of file GridSearch.h.

Referenced by init(), and optimize().

Array<int> GridSearch::numberOfValues [protected]

The array holds the number of grid values for every parameter axis.

Definition at line 120 of file GridSearch.h.

Referenced by init(), and optimize().

int GridSearch::verbosity [protected]

verbosity level

Definition at line 127 of file GridSearch.h.

Referenced by optimize().


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