Uses genetic algorithms to perform an optimization run. More...
#include <MOptRun.h>
Public Member Functions | |
| MOptRun () | |
| virtual | ~MOptRun () |
| virtual void | run () |
| void | minimize (const mvec &start, const mtime &timeout, size_t population=100, size_t samples=1, double target=mnum::min()) |
| void | maximize (const mvec &start, const mtime &timeout, size_t population=100, size_t samples=1, double target=mnum::max()) |
Static Public Member Functions | |
| static void | finish (double metric) |
Uses genetic algorithms to perform an optimization run.
A flexible interface for performing an optimization run using a genetic algorithms approach. This class is extended to provide a run() method that performs an application-specific operation involving its input iteration parameters and judges the performance by computing a metric that is then passed to finish(). The goal of the optimization is to either maximize or minimize this metric. The optimization process runs several trials until either a target metric is achieved or maxTime has expired. Arguments are passed to each run through the standard MProgram arguments interface.
| Meta::MOptRun::MOptRun | ( | ) |
Constructor.
| virtual Meta::MOptRun::~MOptRun | ( | ) | [virtual] |
Destructor.
| static void Meta::MOptRun::finish | ( | double | metric | ) | [static] |
| void Meta::MOptRun::maximize | ( | const mvec & | start, | |
| const mtime & | timeout, | |||
| size_t | population = 100, |
|||
| size_t | samples = 1, |
|||
| double | target = mnum::max() | |||
| ) |
Similar to minimize(), start the optimization run where the goal is to maximize the metric.
| void Meta::MOptRun::minimize | ( | const mvec & | start, | |
| const mtime & | timeout, | |||
| size_t | population = 100, |
|||
| size_t | samples = 1, |
|||
| double | target = mnum::min() | |||
| ) |
Called once to start the optimization run where the goal is to minimize the metric.
| start | A vector containing a sequence of named mappings to the start parameters, e.g: [[x:2,y:[1,2.4,3]],[x:3,y:[5,6.3,7,3]]]. All values must be derived of numerical types and each must define a consistent structure. | |
| timeout | Stop the run if this timeout is reached. | |
| population | The parameter set population that the run uses -- not necessarily the size of the start vector. | |
| samples | Useful for stochastic runs, where multiple iterations are performed for the same input parameters with the metrics that finish() accepts averaged. | |
| target | Halt when this metric is achieved. |
| virtual void Meta::MOptRun::run | ( | ) | [virtual] |
Application-specific method that must be re-implemented to perform a run iteration.
1.6.1