29#ifndef OPTIMIZER_STEEPEST_DECENT_H
30#define OPTIMIZER_STEEPEST_DECENT_H
52template<
typename S,
typename C>
61 int dimCtrl, S eps,
int maxIt, S lambda,
int maxStepAttempts,
62 std::string stepCondition,
bool verboseOn=
true,
const std::string fname=
"",
63 const std::string logFileName=
"",
bool withUpperBound=
false, S upperBound=S(),
64 bool withLowerBound=
false, S lowerBound=S(),
65 bool vectorBounds=
false, S controlEps=S(std::numeric_limits<double>::epsilon() ),
66 std::vector<OptimizerLogType> gplotAnalysis = {})
68 dimCtrl, eps, maxIt, lambda, maxStepAttempts, stepCondition, verboseOn, fname, logFileName,
69 withUpperBound, upperBound, withLowerBound, lowerBound, vectorBounds, controlEps, true,gplotAnalysis),
70 clout(std::cout,
"OptimizerSteepestDescent") {};
79 else for (
int iDim=0; iDim<this->
_dimCtrl; iDim++) {
84 for (
int iDim=0; iDim<this->
_dimCtrl; iDim++) {
92template<
typename S,
typename C = std::vector<S>>
105 int maxStepAttempts = 100;
106 std::string stepCondition =
"Armijo";
108 bool vectorBounds =
false;
110 std::string fname =
"control.dat";
111 std::string logFileName =
"log.txt";
113 bool withUpperBound =
false;
115 bool withLowerBound =
false;
118 std::vector<OptimizerLogType> gplotAnalysis = {};
119 std::string gplotAnalysisString =
"";
122 params.
readOrWarn<
int>(
"Optimization",
"MaxIter",
"", maxIt);
124 params.
readOrWarn<S>(
"Optimization",
"Tolerance",
"", eps);
125 params.
readOrWarn<S>(
"Optimization",
"ControlTolerance",
"", controlEps);
126 params.
readOrWarn<S>(
"Optimization",
"Lambda",
"", lambda);
127 params.
readOrWarn<
int>(
"Optimization",
"MaxStepAttempts",
"", maxStepAttempts);
128 params.
readOrWarn<std::string>(
"Optimization",
"StepCondition",
"", stepCondition);
130 params.
readOrWarn<
bool>(
"Optimization",
"Verbose",
"", verboseOn);
131 params.
readOrWarn<std::string>(
"Optimization",
"InputFileName",
"", fname);
132 params.
readOrWarn<std::string>(
"Optimization",
"LogFileName",
"", logFileName);
134 params.
readOrWarn<
bool>(
"Optimization",
"VectorBounds",
"", vectorBounds);
135 if ( params.
readOrWarn<S>(
"Optimization",
"UpperBound",
"", upperBound,
false,
false) ) {
136 withUpperBound =
true;
139 if ( params.
readOrWarn<S>(
"Optimization",
"LowerBound",
"", lowerBound,
false,
false) ) {
140 withLowerBound =
true;
144 params.
readOrWarn<std::string>(
"Optimization",
"VisualizationGnuplot",
"VisualizedParameters",
"", gplotAnalysisString,
false,
false);
150 verboseOn, fname, logFileName, withUpperBound, upperBound, withLowerBound, lowerBound,
151 vectorBounds, controlEps, gplotAnalysis);
class for marking output with some text
bool readOrWarn(std::string name_parameter_1, std::string name_parameter_2, std::string name_parameter_3, ParameterType &var, bool defaultAvailable=true, bool exitIfMissing=false, bool showWarning=true) const
This wrapper function reads the given parameter from the "type_parameter" and "name_parameter_1" or "...
Optimization algorithm: LineSearch.
C _direction
Search direction.
Optimization algorithm: SteepestDescent.
virtual void computeDirection()
OptimizerSteepestDescent(int dimCtrl, S eps, int maxIt, S lambda, int maxStepAttempts, std::string stepCondition, 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()), std::vector< OptimizerLogType > gplotAnalysis={})
C _derivative
Vector of derivatives of the object functional with respect to the controlled variables.
int _dimCtrl
Number of controlled variables.
C _control
Vector of controlled variables (size _dimCtrl)
void computeDerivatives(const C &control, C &derivatives)
OptimizerSteepestDescent< S, C > * createOptimizerSteepestDescent(XMLreader const ¶ms, std::size_t dimCtrl)
Creator Function for Steepest Decent.
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.
The description of line search optimization algorithm – header file.