OpenLB 1.7
|
Interface for the use of various optimization algorithms. More...
#include <optimizer.h>
Public Member Functions | |
Optimizer (int dimCtrl, S eps, int maxIt, bool verboseOn=true, const std::string fname="", const std::string logFileName="", bool withUpperBound=false, S upperBound=S(), bool withLowerBound=false, S lowerBound=S(), bool vectorBounds=false, S controlEps=S(std::numeric_limits< double >::epsilon()), bool failOnMaxIter=true, std::vector< OptimizerLogType > gplotAnalysis={}) | |
virtual | ~Optimizer () |
virtual void | optimizationStep ()=0 |
void | maxIterationReached () |
virtual void | optimize () |
virtual void | optimize (OptiCase< S, C > &optiCase) |
void | simulate () |
void | simulate (OptiCase< S, C > &optiCase) |
void | evaluateObjective (const C &control, S &result) |
void | computeDerivatives (const C &control, C &derivatives) |
void | print (int it) |
Prints information of the current optimization step it. | |
void | setControl (C &control) |
const C & | getControl () const |
const C & | getDerivative () const |
const S & | getObjective () const |
int | getIteration () const |
void | writeControlToFile (const std::string fname="control.dat") |
Writes the current control variables linewise into file fname. | |
void | readControlFromFile (const std::string fname="control.dat") |
Reads the latest control variables from file fname. | |
void | setStartValue (S startValue) |
OptiCase< S, C > * | getOptiCase () |
void | setOptiCase (OptiCase< S, C > *optiCase) |
void | setGnuplotData () |
void | setReferenceControl (C result) |
set the reference value for the control vector (exact solution) | |
Public Attributes | |
Gnuplot< S > | gplot |
std::vector< OptimizerLogType > | _gplotAnalysis |
For defining what kind of gnuplot analysis is wanted, if empty vector - no analysis, value, control and derivative are the possible options. | |
Protected Attributes | |
int | _dimCtrl |
Number of controlled variables. | |
C | _control |
Vector of controlled variables (size _dimCtrl) | |
S | _value |
Value of the objective functional evaluated for controlled variables saved in _control. | |
C | _derivative |
Vector of derivatives of the object functional with respect to the controlled variables. | |
int | _it |
Current iteration no. | |
int | _maxIt |
Maximal number of iteration. | |
bool | _failOnMaxIter |
Fail when max number of iteration reached. | |
S | _eps |
Optimizer stops if |_derivatives| < _eps. | |
bool | _verboseOn |
Verbose. | |
bool | _withUpperBound |
Bounded versions. | |
bool | _withLowerBound |
bool | _vectorBounds |
C | _boundedControl |
C | _upperBound |
C | _lowerBound |
bool | _controlsConverged |
For setting tolerance of controls. | |
S | _controlEps |
OptiCase< S, C > * | _optiCase |
Provides the Optimizer with methods to evaluate the value of an object functional and compute derivatives. | |
C | _referenceControl |
control vector to compare with (for numerical evaluation) | |
Interface for the use of various optimization algorithms.
This class is intended to be derived from. S is the underlying arithmetic data type C is the container type that is used to store the vectors (e.g. std::vector<S>) C is expected to allow construction via ContainerCreator class
Definition at line 56 of file optimizer.h.
olb::opti::Optimizer< S, C >::Optimizer | ( | int | dimCtrl, |
S | eps, | ||
int | maxIt, | ||
bool | verboseOn = true, | ||
const std::string | fname = "", | ||
const std::string | logFileName = "", | ||
bool | withUpperBound = false, | ||
S | upperBound = S(), | ||
bool | withLowerBound = false, | ||
S | lowerBound = S(), | ||
bool | vectorBounds = false, | ||
S | controlEps = S(std::numeric_limits<double>::epsilon() ), | ||
bool | failOnMaxIter = true, | ||
std::vector< OptimizerLogType > | gplotAnalysis = {} ) |
Definition at line 41 of file optimizer.hh.
References olb::opti::Optimizer< S, C >::_boundedControl, olb::opti::Optimizer< S, C >::_control, olb::opti::Optimizer< S, C >::_controlsConverged, olb::opti::Optimizer< S, C >::_derivative, olb::opti::Optimizer< S, C >::_dimCtrl, olb::opti::Optimizer< S, C >::_lowerBound, olb::opti::Optimizer< S, C >::_upperBound, olb::opti::Optimizer< S, C >::_vectorBounds, olb::opti::Optimizer< S, C >::_withLowerBound, olb::opti::Optimizer< S, C >::_withUpperBound, and olb::opti::Optimizer< S, C >::readControlFromFile().
|
inlinevirtual |
Definition at line 118 of file optimizer.h.
|
inline |
Definition at line 144 of file optimizer.h.
References olb::opti::Optimizer< S, C >::_it, olb::opti::Optimizer< S, C >::_optiCase, and olb::opti::control.
|
inline |
Definition at line 140 of file optimizer.h.
References olb::opti::Optimizer< S, C >::_it, olb::opti::Optimizer< S, C >::_optiCase, and olb::opti::control.
|
inline |
Definition at line 156 of file optimizer.h.
References olb::opti::Optimizer< S, C >::_control.
|
inline |
Definition at line 160 of file optimizer.h.
References olb::opti::Optimizer< S, C >::_derivative.
|
inline |
Definition at line 168 of file optimizer.h.
References olb::opti::Optimizer< S, C >::_it.
|
inline |
Definition at line 164 of file optimizer.h.
References olb::opti::Optimizer< S, C >::_value.
|
inline |
void olb::opti::Optimizer< S, C >::maxIterationReached | ( | ) |
Definition at line 83 of file optimizer.hh.
|
pure virtual |
Implemented in olb::opti::OptimizerLineSearch< S, C >.
|
virtual |
Definition at line 96 of file optimizer.hh.
References olb::util::euklidN2().
|
inlinevirtual |
Definition at line 126 of file optimizer.h.
References olb::opti::Optimizer< S, C >::_optiCase, and olb::opti::Optimizer< S, C >::optimize().
void olb::opti::Optimizer< S, C >::print | ( | int | it | ) |
Prints information of the current optimization step it.
Definition at line 131 of file optimizer.hh.
References olb::util::euklidN().
void olb::opti::Optimizer< S, C >::readControlFromFile | ( | const std::string | fname = "control.dat" | ) |
Reads the latest control variables from file fname.
Definition at line 155 of file optimizer.hh.
|
inline |
Definition at line 152 of file optimizer.h.
References olb::opti::Optimizer< S, C >::_control, and olb::opti::control.
void olb::opti::Optimizer< S, C >::setGnuplotData | ( | ) |
Definition at line 198 of file optimizer.hh.
References olb::opti::control, olb::opti::derivative, olb::opti::error, olb::util::euklidDistance(), olb::util::euklidN(), olb::opti::norm_derivative, and olb::opti::value.
|
inline |
Definition at line 182 of file optimizer.h.
References olb::opti::Optimizer< S, C >::_optiCase.
|
inline |
set the reference value for the control vector (exact solution)
Definition at line 187 of file optimizer.h.
References olb::opti::Optimizer< S, C >::_referenceControl.
void olb::opti::Optimizer< S, C >::setStartValue | ( | S | startValue | ) |
Definition at line 191 of file optimizer.hh.
|
inline |
Definition at line 131 of file optimizer.h.
References olb::opti::Optimizer< S, C >::_control, olb::opti::Optimizer< S, C >::_value, and olb::opti::Optimizer< S, C >::evaluateObjective().
|
inline |
Definition at line 135 of file optimizer.h.
References olb::opti::Optimizer< S, C >::_optiCase, and olb::opti::Optimizer< S, C >::simulate().
void olb::opti::Optimizer< S, C >::writeControlToFile | ( | const std::string | fname = "control.dat" | ) |
Writes the current control variables linewise into file fname.
Definition at line 141 of file optimizer.hh.
References olb::singleton::directories(), and olb::singleton::mpi().
|
protected |
Definition at line 87 of file optimizer.h.
|
protected |
Vector of controlled variables (size _dimCtrl)
Definition at line 65 of file optimizer.h.
|
protected |
Definition at line 93 of file optimizer.h.
|
protected |
For setting tolerance of controls.
Definition at line 92 of file optimizer.h.
|
protected |
Vector of derivatives of the object functional with respect to the controlled variables.
Definition at line 71 of file optimizer.h.
|
protected |
Number of controlled variables.
Definition at line 63 of file optimizer.h.
|
protected |
Optimizer stops if |_derivatives| < _eps.
Definition at line 79 of file optimizer.h.
|
protected |
Fail when max number of iteration reached.
Definition at line 77 of file optimizer.h.
std::vector<OptimizerLogType> olb::opti::Optimizer< S, C >::_gplotAnalysis |
For defining what kind of gnuplot analysis is wanted, if empty vector - no analysis, value, control and derivative are the possible options.
Definition at line 106 of file optimizer.h.
|
protected |
Current iteration no.
Definition at line 73 of file optimizer.h.
|
protected |
Definition at line 89 of file optimizer.h.
|
protected |
Maximal number of iteration.
Definition at line 75 of file optimizer.h.
|
protected |
Provides the Optimizer with methods to evaluate the value of an object functional and compute derivatives.
Definition at line 97 of file optimizer.h.
|
protected |
control vector to compare with (for numerical evaluation)
Definition at line 100 of file optimizer.h.
|
protected |
Definition at line 88 of file optimizer.h.
|
protected |
Value of the objective functional evaluated for controlled variables saved in _control.
Definition at line 68 of file optimizer.h.
|
protected |
Definition at line 86 of file optimizer.h.
|
protected |
Verbose.
Definition at line 81 of file optimizer.h.
|
protected |
Definition at line 85 of file optimizer.h.
|
protected |
Bounded versions.
Definition at line 84 of file optimizer.h.
Gnuplot<S> olb::opti::Optimizer< S, C >::gplot |
Definition at line 103 of file optimizer.h.