44template<
typename,
typename>
class OptiCase;
55template<
typename S,
typename C>
109 bool verboseOn=
true,
const std::string fname=
"",
110 const std::string logFileName=
"",
111 bool withUpperBound=
false, S upperBound=S(),
112 bool withLowerBound=
false, S lowerBound=S(),
113 bool vectorBounds=
false,
114 S controlEps=S(std::numeric_limits<double>::epsilon() ),
115 bool failOnMaxIter =
true,
116 std::vector<OptimizerLogType> gplotAnalysis = {});
212 bool _failOnMaxIter {true};
219 bool _withUpperBound;
220 bool _withLowerBound;
228 explicit OptimizationParameters(XMLreader *xml);
232OptimizationParameters<S>::OptimizationParameters(XMLreader *xml)
242 mutable OstreamManager clout;
245 OptimizationParameters<T> _optiParam;
247 std::shared_ptr<Controller<T>> _controller;
249 std::unique_ptr<OptiCase<T>> _optiCase;
256 std::vector<T> _derivativeObjective;
261 bool _controlsConverged {false};
266 OptiCase<T>* _optiCase;
273 virtual void optimizationStep() = 0;
275 void maxIterationReached();
278 virtual void optimize(OptiCase<T>* optiCase);
281 void evaluate(OptiCase<T>* optiCase)
283 optiCase->evaluateObjective(_control);
class for marking output with some text
Abstract base class for optimization tasks.
Interface for the use of various optimization algorithms.
const S & getObjective() const
void setControl(C &control)
void print(int it)
Prints information of the current optimization step it.
void setReferenceControl(C result)
set the reference value for the control vector (exact solution)
virtual void optimize(OptiCase< S, C > &optiCase)
std::vector< OptimizerLogType > _gplotAnalysis
For defining what kind of gnuplot analysis is wanted, if empty vector - no analysis,...
OptiCase< S, C > * getOptiCase()
bool _withUpperBound
Bounded versions.
int _maxIt
Maximal number of iteration.
S _eps
Optimizer stops if |_derivatives| < _eps.
const C & getDerivative() const
int _it
Current iteration no.
virtual void optimizationStep()=0
C _derivative
Vector of derivatives of the object functional with respect to the controlled variables.
int _dimCtrl
Number of controlled variables.
OptiCase< S, C > * _optiCase
Provides the Optimizer with methods to evaluate the value of an object functional and compute derivat...
void setOptiCase(OptiCase< S, C > *optiCase)
C _control
Vector of controlled variables (size _dimCtrl)
void maxIterationReached()
void setStartValue(S startValue)
void readControlFromFile(const std::string fname="control.dat")
Reads the latest control variables from file fname.
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={})
S _value
Value of the objective functional evaluated for controlled variables saved in _control.
bool _controlsConverged
For setting tolerance of controls.
void computeDerivatives(const C &control, C &derivatives)
bool _failOnMaxIter
Fail when max number of iteration reached.
void simulate(OptiCase< S, C > &optiCase)
C _referenceControl
control vector to compare with (for numerical evaluation)
void writeControlToFile(const std::string fname="control.dat")
Writes the current control variables linewise into file fname.
const C & getControl() const
void evaluateObjective(const C &control, S &result)
Wrapper functions that simplify the use of MPI.
void getGnuplotTagsFromString(std::string gplotAnalysisString, std::vector< OptimizerLogType > &gplotAnalysis)
the gplotAnalysisString is gained from the xml file and the function than separates and prepares it t...
Top level namespace for all of OpenLB.
Definition of singletons: global, publicly available information.
Input/Output in XML format – header file.