OpenLB 1.7
Loading...
Searching...
No Matches
Public Member Functions | List of all members
olb::opti::OptimizerSteepestDescent< S, C > Class Template Reference

Optimization algorithm: SteepestDescent. More...

#include <optimizerSteepestDecent.h>

+ Inheritance diagram for olb::opti::OptimizerSteepestDescent< S, C >:
+ Collaboration diagram for olb::opti::OptimizerSteepestDescent< S, C >:

Public Member Functions

 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={})
 
virtual void computeDirection ()
 
- Public Member Functions inherited from olb::opti::OptimizerLineSearch< S, C >
 OptimizerLineSearch (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()), bool failOnMaxIter=true, std::vector< OptimizerLogType > gplotAnalysis={})
 Construction of an OptimizerLineSearch.
 
virtual ~OptimizerLineSearch ()
 
void checkBound ()
 
void boundControl ()
 
bool smallerValue (const S &tempValue)
 
bool noCondition (const S &tempValue)
 
bool armijoWolfeConditions (const S &tempValue)
 
void quadraticInterpolationStep (const S &tempValue)
 
void backtrackingLineSearch (S &tempValue, S lambda, bool(OptimizerLineSearch::*condition)(const S &))
 
virtual void optimizationStep ()
 Optimization step: line search.
 
- Public Member Functions inherited from 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={})
 
virtual ~Optimizer ()
 
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)
 

Additional Inherited Members

- Public Attributes inherited from olb::opti::Optimizer< S, C >
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 inherited from olb::opti::OptimizerLineSearch< S, C >
_lambda
 Lambda start value.
 
_direction
 Search direction.
 
bool _lowerBoundFlag
 
bool _upperBoundFlag
 
int _maxStepAttempts
 Maximal number of step attempts for conditioned line search.
 
_nextDerivative
 
bool _nextDerivFlag
 
std::string _stepCondition
 
bool(OptimizerLineSearch::* _stepConditionFunction )(const S &)
 
void(OptimizerLineSearch::* _stepLengthFunction )(const S &)
 
- Protected Attributes inherited from olb::opti::Optimizer< S, C >
int _dimCtrl
 Number of controlled variables.
 
_control
 Vector of controlled variables (size _dimCtrl)
 
_value
 Value of the objective functional evaluated for controlled variables saved in _control.
 
_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.
 
_eps
 Optimizer stops if |_derivatives| < _eps.
 
bool _verboseOn
 Verbose.
 
bool _withUpperBound
 Bounded versions.
 
bool _withLowerBound
 
bool _vectorBounds
 
_boundedControl
 
_upperBound
 
_lowerBound
 
bool _controlsConverged
 For setting tolerance of controls.
 
_controlEps
 
OptiCase< S, C > * _optiCase
 Provides the Optimizer with methods to evaluate the value of an object functional and compute derivatives.
 
_referenceControl
 control vector to compare with (for numerical evaluation)
 

Detailed Description

template<typename S, typename C>
class olb::opti::OptimizerSteepestDescent< S, C >

Optimization algorithm: SteepestDescent.

OptimizerSteepestDescent optimizes an optimization problem which is given in OptiCase. OptiCase provides therefore methods to evaluate an object functional and compute derivatives. SteepestDescent searches along the direction of the derivative to find a lower value of the evaluated object functional.

This class is not intended to be derived from.

Definition at line 53 of file optimizerSteepestDecent.h.

Constructor & Destructor Documentation

◆ OptimizerSteepestDescent()

template<typename S , typename C >
olb::opti::OptimizerSteepestDescent< S, C >::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 = {} )
inline

Definition at line 60 of file optimizerSteepestDecent.h.

66 {})
68 dimCtrl, eps, maxIt, lambda, maxStepAttempts, stepCondition, verboseOn, fname, logFileName,
69 withUpperBound, upperBound, withLowerBound, lowerBound, vectorBounds, controlEps, true,gplotAnalysis),
70 clout(std::cout,"OptimizerSteepestDescent") {};
OptimizerLineSearch(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()), bool failOnMaxIter=true, std::vector< OptimizerLogType > gplotAnalysis={})
Construction of an OptimizerLineSearch.

Member Function Documentation

◆ computeDirection()

template<typename S , typename C >
virtual void olb::opti::OptimizerSteepestDescent< S, C >::computeDirection ( )
inlinevirtual

Implements olb::opti::OptimizerLineSearch< S, C >.

Definition at line 72 of file optimizerSteepestDecent.h.

73 {
74 // Update _derivative
75 // computeDerivative only if not already done by wolfeCondition()
76 if (!this->_nextDerivFlag) {
77 this->computeDerivatives(this->_control, this->_derivative);
78 }
79 else for (int iDim=0; iDim<this->_dimCtrl; iDim++) {
80 this->_derivative[iDim] = this->_nextDerivative[iDim];
81 }
82
83 // S normDerivative = util::euklidN(this->_derivative.data(), this->_dimCtrl);
84 for (int iDim=0; iDim<this->_dimCtrl; iDim++) {
85 this->_direction[iDim] = this->_derivative[iDim] ; // /normDerivative;
86 }
87 };
C _derivative
Vector of derivatives of the object functional with respect to the controlled variables.
Definition optimizer.h:71
int _dimCtrl
Number of controlled variables.
Definition optimizer.h:63
C _control
Vector of controlled variables (size _dimCtrl)
Definition optimizer.h:65
void computeDerivatives(const C &control, C &derivatives)
Definition optimizer.h:144

References olb::opti::Optimizer< S, C >::_control, olb::opti::Optimizer< S, C >::_derivative, olb::opti::Optimizer< S, C >::_dimCtrl, olb::opti::OptimizerLineSearch< S, C >::_direction, olb::opti::OptimizerLineSearch< S, C >::_nextDerivative, olb::opti::OptimizerLineSearch< S, C >::_nextDerivFlag, and olb::opti::Optimizer< S, C >::computeDerivatives().

+ Here is the call graph for this function:

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