39template <
typename S,
typename C>
54 const C&
control, C& derivatives,
unsigned optiStep=0) = 0;
63template <
typename S,
typename C>
89 const C&
control,
unsigned optiStep=0)
override {
94 const C&
control, C& derivatives,
unsigned optiStep=0)
override {
99template <
typename S,
typename C>
101 std::function<
void (
const C&, C&)>)
104template <
typename S,
typename C>
106 std::function<
void (
const C&, C&)>,
107 std::function<
void (
void)>)
112template <
typename S,
typename C>
124 explicit OptiCaseDQ(std::function<S (
const C&,
unsigned)> function,
137 template <
typename F>
145 const C&
control,
unsigned optiStep=0)
override {
154template <
typename S,
typename C>
160 template <
typename F>
166 template <
typename F>
173 C& derivatives,
unsigned optiStep=0)
override
175 assert((
control.size() == derivatives.size()));
180 const S objective(this->_objective);
182 for (std::size_t it = 0; it <
control.size(); ++it)
187 derivatives[it] = (shiftedObjective - objective) / this->
_stepWidth;
193template <
typename S,
typename C>
194OptiCaseFDQ(std::function<S (
const C&)>, std::function<
void (
void)>)
197template <
typename S,
typename C>
198OptiCaseFDQ(std::function<S (
const C&)>, S, std::function<
void (
void)>)
201template <
typename S,
typename C>
202OptiCaseFDQ(std::function<S (
const C&,
unsigned)>, std::function<
void (
void)>)
205template <
typename S,
typename C>
206OptiCaseFDQ(std::function<S (
const C&,
unsigned)>, S, std::function<
void (
void)>)
209template <
typename S,
typename C>
213template <
typename S,
typename C>
217template <
typename S,
typename C>
221template <
typename S,
typename C>
226template <
typename S,
typename C>
232 template <
typename F>
238 template <
typename F>
245 C& derivatives,
unsigned optiStep=0)
override
247 assert((
control.size() == derivatives.size()));
249 for (std::size_t it = 0; it <
control.size(); ++it)
258 derivatives[it] = 0.5 * (shiftedObjective_plus - shiftedObjective_minus) / this->_stepWidth;
263template <
typename S,
typename C>
264OptiCaseCDQ(std::function<S (
const C&)>, std::function<
void (
void)>)
267template <
typename S,
typename C>
268OptiCaseCDQ(std::function<S (
const C&)>, S, std::function<
void (
void)>)
271template <
typename S,
typename C>
272OptiCaseCDQ(std::function<S (
const C&,
unsigned)>, std::function<
void (
void)>)
275template <
typename S,
typename C>
276OptiCaseCDQ(std::function<S (
const C&,
unsigned)>, S, std::function<
void (
void)>)
279template <
typename S,
typename C>
283template <
typename S,
typename C>
287template <
typename S,
typename C>
291template <
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)
void setDerivative(std::function< void(const C &, C &)> d)
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
void setObjective(std::function< S(const C &)> f)
S evaluateObjective(const C &control, unsigned optiStep=0) override
std::function< void(const C &, C &)> _derivative
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)
S evaluateObjective(const C &control, unsigned optiStep=0) override
std::function< S(const C &, unsigned)> _function
OptiCaseDQ(F function, S stepWidth, std::function< void(void)> postEvaluation)
OptiCaseDQ(std::function< S(const C &, unsigned)> function, std::function< void(void)> postEvaluation)
std::function< S(const C &)> _functionHelp
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
OptiCase(std::function< void(void)> postEvaluation)
virtual void computeDerivatives(const C &control, C &derivatives, unsigned optiStep=0)=0
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.
Stores populations of the primal problems for adjoint simulations.
Input/Output in XML format – header file.