39template <
typename S,
typename C>
54 const C&
control, C& derivatives,
unsigned optiStep=0) = 0;
63template <
typename S,
typename C>
78 const C&
control,
unsigned optiStep=0)
override {
83 const C&
control, C& derivatives,
unsigned optiStep=0)
override {
88template <
typename S,
typename C>
90 std::function<
void (
const C&, C&)>)
93template <
typename S,
typename C>
95 std::function<
void (
const C&, C&)>,
96 std::function<
void (
void)>)
101template <
typename S,
typename C>
113 explicit OptiCaseDQ(std::function<S (
const C&,
unsigned)> function,
126 template <
typename F>
134 const C&
control,
unsigned optiStep=0)
override {
143template <
typename S,
typename C>
149 template <
typename F>
155 template <
typename F>
162 C& derivatives,
unsigned optiStep=0)
override
164 assert((
control.size() == derivatives.size()));
169 const S objective(this->_objective);
171 for (std::size_t it = 0; it <
control.size(); ++it)
176 derivatives[it] = (shiftedObjective - objective) / this->
_stepWidth;
182template <
typename S,
typename C>
183OptiCaseFDQ(std::function<S (
const C&)>, std::function<
void (
void)>)
186template <
typename S,
typename C>
187OptiCaseFDQ(std::function<S (
const C&)>, S, std::function<
void (
void)>)
190template <
typename S,
typename C>
191OptiCaseFDQ(std::function<S (
const C&,
unsigned)>, std::function<
void (
void)>)
194template <
typename S,
typename C>
195OptiCaseFDQ(std::function<S (
const C&,
unsigned)>, S, std::function<
void (
void)>)
198template <
typename S,
typename C>
202template <
typename S,
typename C>
206template <
typename S,
typename C>
210template <
typename S,
typename C>
215template <
typename S,
typename C>
221 template <
typename F>
227 template <
typename F>
234 C& derivatives,
unsigned optiStep=0)
override
236 assert((
control.size() == derivatives.size()));
238 for (std::size_t it = 0; it <
control.size(); ++it)
247 derivatives[it] = 0.5 * (shiftedObjective_plus - shiftedObjective_minus) / this->_stepWidth;
252template <
typename S,
typename C>
253OptiCaseCDQ(std::function<S (
const C&)>, std::function<
void (
void)>)
256template <
typename S,
typename C>
257OptiCaseCDQ(std::function<S (
const C&)>, S, std::function<
void (
void)>)
260template <
typename S,
typename C>
261OptiCaseCDQ(std::function<S (
const C&,
unsigned)>, std::function<
void (
void)>)
264template <
typename S,
typename C>
265OptiCaseCDQ(std::function<S (
const C&,
unsigned)>, S, std::function<
void (
void)>)
268template <
typename S,
typename C>
272template <
typename S,
typename C>
276template <
typename S,
typename C>
280template <
typename S,
typename C>
class for marking output with some text
Gradient is just passed as a function (and not computed by an own routine)
std::function< S(const C &) _function)
OptiCaseAnalytical(std::function< S(const C &)> function, std::function< void(const C &, C &)> derivative, std::function< void(void)> postEvaluation=[](){})
void computeDerivatives(const C &control, C &derivatives, unsigned optiStep=0) override
std::function< void(const C &, C &) _derivative)
S evaluateObjective(const C &control, unsigned optiStep=0) override
Gradient computation with central difference quotients.
void computeDerivatives(const C &control, C &derivatives, unsigned optiStep=0) override
OptiCaseCDQ(F function, S stepWidth, std::function< void(void)> postEvaluation=[](){})
OptiCaseCDQ(F function, std::function< void(void)> postEvaluation=[](){})
OptiCaseDQ(std::function< S(const C &)> function, std::function< void(void)> postEvaluation)
std::function< S(const C &, unsigned) _function)
std::function< S(const C &) _functionHelp)
S evaluateObjective(const C &control, unsigned optiStep=0) override
OptiCaseDQ(F function, S stepWidth, std::function< void(void)> postEvaluation)
OptiCaseDQ(std::function< S(const C &, unsigned)> function, std::function< void(void)> postEvaluation)
Gradient computation with forward difference quotients.
void computeDerivatives(const C &control, C &derivatives, unsigned optiStep=0) override
OptiCaseFDQ(F function, S stepWidth, std::function< void(void)> postEvaluation=[](){})
OptiCaseFDQ(F function, std::function< void(void)> postEvaluation=[](){})
Abstract base class for optimization tasks.
virtual S evaluateObjective(const C &control, unsigned optiStep=0)=0
std::function< void(void)> _postEvaluation
virtual void computeDerivatives(const C &control, C &derivatives, unsigned optiStep=0)=0
OptiCase(std::function< void(void)> postEvaluation)
OptiCaseCDQ(std::function< S(const C &)>, std::function< void(void)>) -> OptiCaseCDQ< S, C >
OptiCaseFDQ(std::function< S(const C &)>, std::function< void(void)>) -> OptiCaseFDQ< S, C >
OptiCaseAnalytical(std::function< S(const C &)>, std::function< void(const C &, C &)>) -> OptiCaseAnalytical< S, C >
Top level namespace for all of OpenLB.
Input/Output in XML format – header file.