11 #ifndef OOPS_ASSIMILATION_DUALMINIMIZER_H_ 12 #define OOPS_ASSIMILATION_DUALMINIMIZER_H_ 16 #include <boost/scoped_ptr.hpp> 18 #include "eckit/config/Configuration.h" 28 #include "oops/util/dot_product.h" 29 #include "oops/util/Logger.h" 52 const std::string
classname()
const override = 0;
57 const int &,
const double &,
Dual_ &,
const double &) = 0;
65 template<
typename MODEL>
67 int ninner = config.getInt(
"ninner");
68 double gnreduc = config.getDouble(
"gradient_norm_reduction");
70 bool runOnlineAdjTest =
false;
71 if (config.has(
"onlineDiagnostics")) {
72 const eckit::LocalConfiguration onlineDiag(config,
"onlineDiagnostics");
73 runOnlineAdjTest = onlineDiag.getBool(
"onlineAdjTest");
77 gradJb_.reset(
new CtrlInc_(J_.jb()));
79 gradJb_.reset(
new CtrlInc_(J_.jb().resolution(), *gradJb_));
83 Log::info() << classname() <<
": max iter = " << ninner
84 <<
", requested norm reduction = " << gnreduc << std::endl;
88 const HBHt_ HBHt(J_, runOnlineAdjTest);
95 for (
unsigned jj = 0; jj < J_.nterms(); ++jj) {
96 vv.
append(J_.jterm(jj).newDualVector());
102 for (
unsigned jj = 0; jj < J_.nterms(); ++jj) {
103 rr.
append(J_.jterm(jj).newGradientFG());
112 CtrlInc_ hdxfg(J_.jb().getFirstGuess());
118 J_.jb().addGradientFG(g0, *gradJb_);
120 double sigma = dot_product(J_.jb().getFirstGuess(), g0);
123 double reduc = this->solve(vv, vvp, rr, HBHt, Rinv, ninner, gnreduc, dy,
sigma);
125 Log::test() << classname() <<
": reduction in residual norm = " << reduc << std::endl;
136 Log::info() << classname() <<
": Estimated Final Jb = " 137 << 0.5 * dot_product(*dx, dh) << std::endl;
138 Log::info() << classname() <<
" output" << *dx << std::endl;
150 #endif // OOPS_ASSIMILATION_DUALMINIMIZER_H_
const std::string classname() const override=0
Container of dual space vectors for all terms of the cost function.
virtual double solve(Dual_ &, double &, Dual_ &, const HBHt_ &, const Rinv_ &, const int &, const double &, Dual_ &, const double &)=0
integer, parameter sigma
Flags to indicate where climatology pressure levels are pressure or sigma levels. ...
void multiply(CtrlInc_ &dx, DualVector< MODEL > &dy, const bool idModel=false) const
The namespace for the main oops code.
DualMinimizer(const CostFct_ &J)
CostFunction< MODEL > CostFct_
HBHtMatrix< MODEL > HBHt_
ControlIncrement< MODEL > CtrlInc_
void multiply(const DualVector< MODEL > &dy, ControlIncrement< MODEL > &dx, const bool idModel=false) const
RinvMatrix< MODEL > Rinv_
CtrlInc_ * doMinimize(const eckit::Configuration &) override
subroutine, public info(self)
Minimizer< MODEL > Minimizer_
void append(GeneralizedDepartures *)
A Minimizer knows how to minimize a cost function.
void multiply(const CtrlInc_ &x, CtrlInc_ &bx) const
boost::scoped_ptr< CtrlInc_ > gradJb_
DualVector< MODEL > Dual_