ARTS  2.4.0(git:4fb77825)
oem.h
Go to the documentation of this file.
1 
12 #ifndef _ARTS_OEM_H_
13 #define _ARTS_OEM_H_
14 
15 #include <type_traits>
16 
17 #include "invlib/algebra.h"
18 #include "invlib/algebra/precision_matrix.h"
19 #include "invlib/algebra/solvers.h"
20 #include "invlib/interfaces/arts_wrapper.h"
21 #include "invlib/map.h"
22 #include "invlib/optimization.h"
23 #include "invlib/profiling/timer.h"
24 
26 // Type Aliases
28 
29 namespace oem {
30 
32 using Vector = invlib::Vector<ArtsVector>;
34 using Matrix = invlib::Matrix<ArtsMatrix>;
36 using MatrixReference = invlib::Matrix<ArtsMatrixReference<::Matrix>>;
38 using CovarianceMatrix = invlib::Matrix<ArtsCovarianceMatrixWrapper>;
39 using Identity = invlib::MatrixIdentity<Matrix>;
40 
42 // OEM Formulations
44 
46 using invlib::Formulation;
47 
56 template <typename ForwardModel>
57 using OEM_STANDARD = invlib::MAP<ForwardModel,
58  Matrix,
61  Vector,
62  Formulation::STANDARD,
63  invlib::Rodgers531>;
64 
73 template <typename ForwardModel>
74 using OEM_NFORM = invlib::MAP<ForwardModel,
75  Matrix,
78  Vector,
79  Formulation::NFORM>;
80 
89 template <typename ForwardModel>
90 using OEM_MFORM = invlib::MAP<ForwardModel,
91  Matrix,
94  Vector,
95  Formulation::MFORM>;
96 
98 // Solvers
100 
111 template <typename TransformationMatrixType,
112  typename SolverType = invlib::Standard>
113 class NormalizingSolver : SolverType {
114  public:
115  template <typename... Params>
116  NormalizingSolver(const TransformationMatrixType &trans,
117  bool apply,
118  Params... params)
119  : SolverType(params...), apply_(apply), trans_(trans) {}
120 
131  template <typename MatrixType, typename VectorType>
132  auto solve(const MatrixType &A, const VectorType &v) ->
133  typename VectorType::ResultType {
134  typename VectorType::ResultType w;
135  if (apply_) {
136  typename VectorType::ResultType vv = trans_ * v;
137  auto &&ww = SolverType::solve(trans_ * A * trans_, vv);
138  w = trans_ * ww;
139  } else {
140  w = SolverType::solve(A, v);
141  VectorType u = v - A * w;
142  }
143  return w;
144  }
145 
146  private:
148  const bool apply_ = false;
150  const TransformationMatrixType &trans_;
151 };
152 
159 
167 
169 using GN = invlib::GaussNewton<Numeric, Std>;
171 using GN_CG = invlib::GaussNewton<Numeric, CG>;
173 using LM = invlib::LevenbergMarquardt<Numeric, CovarianceMatrix, Std>;
175 using LM_CG = invlib::LevenbergMarquardt<Numeric, CovarianceMatrix, CG>;
176 
178 // Custom Log Class
180 
187 template <typename T>
189 
195 template <typename RealType, typename DampingMatrix, typename Solver>
197  invlib::LevenbergMarquardt<RealType, DampingMatrix, Solver>> {
199  static constexpr auto name = "Levenberg-Marquardt";
200 
202  static std::string header() {
203  std::string out = "Gamma Factor";
204  return out;
205  }
206 
208  static std::string log(
209  const invlib::LevenbergMarquardt<RealType, DampingMatrix, Solver> &g,
210  Vector &gamma_history_,
211  size_t i) {
212  std::string lambda = std::to_string(g.get_lambda());
213  std::string out(15 - std::min<size_t>(lambda.size(), 15), ' ');
214  out += lambda;
215  gamma_history_[i] = g.get_lambda();
216  return out;
217  }
218 };
219 
221 template <typename RealType, typename Solver>
222 struct OptimizerLog<invlib::GaussNewton<RealType, Solver>> {
224  static constexpr auto name = "Gauss-Newton";
225 
227  static std::string header() { return ""; }
228 
229  static std::string log(const invlib::GaussNewton<RealType, Solver> &,
230  Vector &,
231  size_t) {
232  return "";
233  }
234 };
235 
243 template <invlib::LogType type>
244 class ArtsLog {
245  public:
253  ArtsLog(unsigned int v, ::Vector &g, bool l = false)
254  : verbosity_(v), gamma_history_(g), linear_(l), finalized_(false) {}
255 
258  if ((verbosity_ >= 1) && (!finalized_)) {
259  std::cout << invlib::separator() << std::endl << std::endl;
260  std::cout << "Error during OEM computation." << std::endl;
261  std::cout << std::endl;
262  std::cout << invlib::center("----") << std::endl;
263  std::cout << std::endl;
264  }
265  }
266 
272  template <typename... Params>
273  void init(Params &... params) {
274  if (verbosity_ >= 1) {
275  std::tuple<Params &...> tuple(params...);
276 
277  auto &y = std::get<4>(tuple);
278  scaling_factor_ = 1.0 / static_cast<Numeric>(y.nelem());
279  std::cout << std::endl;
280  std::cout << invlib::center("MAP Computation") << std::endl;
281 
282  // Print formulation.
283  int formulation = static_cast<int>(std::get<6>(tuple));
284  switch (formulation) {
285  case 0:
286  std::cout << "Formulation: Standard" << std::endl;
287  break;
288  case 1:
289  std::cout << "Formulation: N-Form" << std::endl;
290  break;
291 
292  case 2:
293  std::cout << "Formulation: M-Form" << std::endl;
294  break;
295  }
296 
297  // Print optimization method.
298  using OptimizationType = typename std::decay<
299  typename std::tuple_element<5, decltype(tuple)>::type>::type;
300  std::cout << "Method: "
301  << invlib::OptimizerLog<OptimizationType>::name;
302  std::cout << std::endl;
303 
304  std::cout << std::endl;
305  std::cout << std::setw(5) << "Step" << std::setw(15) << "Total Cost";
306  std::cout << std::setw(15) << "x-Cost" << std::setw(15) << "y-Cost";
307  std::cout << std::setw(15) << "Conv. Crit.";
308  std::cout << std::setw(15) << OptimizerLog<OptimizationType>::header();
309  std::cout << std::endl << invlib::separator() << std::endl;
310  }
311  }
312 
318  template <typename... Params>
319  void step(const Params &... params) {
320  if (verbosity_ >= 1) {
321  std::tuple<const Params &...> tuple(params...);
322  using OptimizationType = typename std::decay<
323  typename std::tuple_element<5, decltype(tuple)>::type>::type;
324 
325  auto step_number = std::get<0>(tuple);
326  std::cout << std::setw(5) << step_number;
327  if (step_number == 0) {
328  start_cost_ = std::get<1>(tuple);
329  }
330  std::cout << std::setw(15) << scaling_factor_ * std::get<1>(tuple);
331  std::cout << std::setw(15) << scaling_factor_ * std::get<2>(tuple);
332  std::cout << std::setw(15) << scaling_factor_ * std::get<3>(tuple);
333 
334  if (std::isnan(std::get<4>(tuple))) {
335  std::cout << std::setw(15) << " ";
336  } else {
337  std::cout << std::setw(15) << std::get<4>(tuple);
338  }
339  std::cout << OptimizerLog<OptimizationType>::log(
340  std::get<5>(tuple), gamma_history_, std::get<0>(tuple));
341  std::cout << std::endl;
342  }
343  }
344 
350  template <typename... Params>
351  void finalize(const Params &... params) {
352  if (verbosity_ >= 1) {
353  std::cout << invlib::separator() << std::endl;
354 
355  std::tuple<const Params &...> tuple(params...);
356  std::cout << std::endl;
357 
358  std::cout << "Total number of steps: ";
359  std::cout << std::get<1>(tuple) << std::endl;
360  std::cout << "Final scaled cost function value: ";
361  std::cout << std::get<2>(tuple) * scaling_factor_ << std::endl;
362 
363  bool converged = std::get<0>(tuple);
364  if (converged) {
365  std::cout << "OEM computation converged." << std::endl;
366  } else if (linear_) {
367  std::cout << "Linear OEM computation finished." << std::endl;
368  } else {
369  std::cout << "OEM computation DID NOT converge!" << std::endl;
370  }
371  }
372 
373  finalized_ = true;
374  }
375 
377  template <typename... Params>
378  void time(const Params &... params) {
379  if (verbosity_ >= 1) {
380  std::tuple<const Params &...> tuple(params...);
381  std::cout << std::endl;
382  std::cout << "Elapsed Time for Retrieval: ";
383  std::cout << std::get<0>(tuple) << std::endl;
384  std::cout << "Time in inversion_iterate Agenda (No Jacobian): ";
385  std::cout << std::get<1>(tuple) << std::endl;
386  std::cout << "Time in inversion_iterate Agenda (With Jacobian): ";
387  std::cout << std::get<2>(tuple) << std::endl;
388 
389  std::cout << std::endl;
390  std::cout << invlib::center("----") << std::endl;
391  std::cout << std::endl;
392  }
393  }
394 
395  private:
405  bool linear_ = false;
407  bool finalized_ = false;
408 };
409 
411 // Exception Handling
413 
424 template <typename E>
425 std::vector<std::string> handle_nested_exception(const E &e, int level = 0) {
426  const std::exception *re;
427  std::vector<std::string> errors{};
428 
429  re = dynamic_cast<const std::exception *>(&e);
430  if (re) {
431  std::string s{};
432 
433  // If invlib level, extend error description.
434  if (level == 0) {
435  s = "Run-time error in oem computation: ";
436  }
437 
438  s += re->what();
439  errors.push_back(s);
440  }
441 
442  try {
443  std::rethrow_if_nested(e);
444  } catch (const std::exception &ne) {
445  std::vector<std::string> sv(handle_nested_exception(ne, level + 1));
446  errors.insert(errors.end(), sv.begin(), sv.end());
447  } catch (...) {
448  }
449  return errors;
450 }
451 
453 // Forward model interface
455 
463  public:
465  const unsigned int m = 0;
467  const unsigned int n = 0;
468 
484  unsigned int measurement_space_dimension,
485  unsigned int state_space_dimension,
486  ::Matrix &arts_jacobian,
487  ::Vector &arts_y,
489  : m(measurement_space_dimension),
490  n(state_space_dimension),
493  jacobian_(arts_jacobian),
494  reuse_jacobian_((arts_jacobian.nrows() != 0) &&
495  (arts_jacobian.ncols() != 0) && (arts_y.nelem() != 0)),
496  ws_(ws),
497  yi_(arts_y) {}
498 
503  ArtsVector get_measurement_vector() { return yi_; }
504 
505  AgendaWrapper(const AgendaWrapper &) = delete;
509 
522  if (!reuse_jacobian_) {
524  *ws_, yi_, jacobian_, xi, 1, 0, *inversion_iterate_agenda_);
525  yi = yi_;
526  iteration_counter_ += 1;
527  } else {
528  reuse_jacobian_ = false;
529  yi = yi_;
530  }
531  return jacobian_;
532  }
533 
543  Vector evaluate(const Vector &xi) {
544  if (!reuse_jacobian_) {
545  Matrix dummy;
547  yi_,
548  dummy,
549  xi,
550  0,
553  } else {
554  reuse_jacobian_ = false;
555  }
556  return yi_;
557  }
558 
559  private:
562  unsigned int iteration_counter_;
571 };
572 } // namespace oem
573 
574 
583  const Index& iq,
584  const Numeric& limit_low,
585  const Numeric& limit_high) {
586  // Sizes
587  const Index nq = x.nbooks();
588 
589  if (iq < -1) throw runtime_error("Argument *iq* must be >= -1.");
590  if (iq >= nq) {
591  ostringstream os;
592  os << "Argument *iq* is too high.\n"
593  << "You have selected index: " << iq << "\n"
594  << "but the number of quantities is only: " << nq << "\n"
595  << "(Note that zero-based indexing is used)\n";
596  throw runtime_error(os.str());
597  }
598 
599  Index ifirst = 0, ilast = nq - 1;
600  if (iq > -1) {
601  ifirst = iq;
602  ilast = iq;
603  }
604 
605  if (!std::isinf(limit_low)) {
606  for (Index i = ifirst; i <= ilast; i++) {
607  for (Index p = 0; p < x.npages(); p++) {
608  for (Index r = 0; r < x.nrows(); r++) {
609  for (Index c = 0; c < x.ncols(); c++) {
610  if (x(i, p, r, c) < limit_low) x(i, p, r, c) = limit_low;
611  }
612  }
613  }
614  }
615  }
616 
617  if (!std::isinf(limit_high)) {
618  for (Index i = ifirst; i <= ilast; i++) {
619  for (Index p = 0; p < x.npages(); p++) {
620  for (Index r = 0; r < x.nrows(); r++) {
621  for (Index c = 0; c < x.ncols(); c++) {
622  if (x(i, p, r, c) > limit_high) x(i, p, r, c) = limit_high;
623  }
624  }
625  }
626  }
627  }
628 }
629 
631 // OEM error checking
633 
667  Vector& x,
668  Vector& yf,
669  Matrix& jacobian,
671  const Vector& xa,
673  const Vector& y,
676  const String& method,
677  const Vector& x_norm,
678  const Index& max_iter,
679  const Numeric& stop_dx,
680  const Vector& lm_ga_settings,
681  const Index& clear_matrices,
682  const Index& display_progress) {
683  const Index nq = jacobian_quantities.nelem();
684  const Index n = xa.nelem();
685  const Index m = y.nelem();
686 
687  if ((x.nelem() != n) && (x.nelem() != 0))
688  throw runtime_error(
689  "The length of *x* must be either the same as *xa* or 0.");
690  if (covmat_sx.ncols() != covmat_sx.nrows())
691  throw runtime_error("*covmat_sx* must be a square matrix.");
692  if (covmat_sx.ncols() != n)
693  throw runtime_error("Inconsistency in size between *x* and *covmat_sx*.");
694  if ((yf.nelem() != m) && (yf.nelem() != 0))
695  throw runtime_error(
696  "The length of *yf* must be either the same as *y* or 0.");
697  if (covmat_se.ncols() != covmat_se.nrows())
698  throw runtime_error("*covmat_se* must be a square matrix.");
699  if (covmat_se.ncols() != m)
700  throw runtime_error("Inconsistency in size between *y* and *covmat_se*.");
701  if ((jacobian.nrows() != m) && (!jacobian.empty()))
702  throw runtime_error(
703  "The number of rows of the jacobian must be either the number of elements in *y* or 0.");
704  if ((jacobian.ncols() != n) && (!jacobian.empty()))
705  throw runtime_error(
706  "The number of cols of the jacobian must be either the number of elements in *xa* or 0.");
707 
708  ArrayOfArrayOfIndex jacobian_indices;
709  bool any_affine;
710  jac_ranges_indices(jacobian_indices, any_affine, jacobian_quantities);
711  if (jacobian_indices.nelem() != nq)
712  throw runtime_error(
713  "Different number of elements in *jacobian_quantities* "
714  "and *jacobian_indices*.");
715  if (nq && jacobian_indices[nq - 1][1] + 1 != n)
716  throw runtime_error(
717  "Size of *covmat_sx* do not agree with Jacobian "
718  "information (*jacobian_indices*).");
719 
720  // Check GINs
721  if (!(method == "li" || method == "gn" || method == "li_m" ||
722  method == "gn_m" || method == "ml" || method == "lm" ||
723  method == "li_cg" || method == "gn_cg" || method == "li_cg_m" ||
724  method == "gn_cg_m" || method == "lm_cg" || method == "ml_cg")) {
725  throw runtime_error(
726  "Valid options for *method* are \"nl\", \"gn\" and "
727  "\"ml\" or \"lm\".");
728  }
729 
730  if (!(x_norm.nelem() == 0 || x_norm.nelem() == n)) {
731  throw runtime_error(
732  "The vector *x_norm* must have length 0 or match "
733  "*covmat_sx*.");
734  }
735 
736  if (x_norm.nelem() > 0 && min(x_norm) <= 0) {
737  throw runtime_error("All values in *x_norm* must be > 0.");
738  }
739 
740  if (max_iter <= 0) {
741  throw runtime_error("The argument *max_iter* must be > 0.");
742  }
743 
744  if (stop_dx <= 0) {
745  throw runtime_error("The argument *stop_dx* must be > 0.");
746  }
747 
748  if ((method == "ml") || (method == "lm") || (method == "lm_cg") ||
749  (method == "ml_cg")) {
750  if (lm_ga_settings.nelem() != 6) {
751  throw runtime_error(
752  "When using \"ml\", *lm_ga_setings* must be a "
753  "vector of length 6.");
754  }
755  if (min(lm_ga_settings) < 0) {
756  throw runtime_error(
757  "The vector *lm_ga_setings* can not contain any "
758  "negative value.");
759  }
760  }
761 
762  if (clear_matrices < 0 || clear_matrices > 1)
763  throw runtime_error("Valid options for *clear_matrices* are 0 and 1.");
764  if (display_progress < 0 || display_progress > 1)
765  throw runtime_error("Valid options for *display_progress* are 0 and 1.");
766 
767  // If necessary compute yf and jacobian.
768  if (x.nelem() == 0) {
769  x = xa;
771  ws, yf, jacobian, xa, 1, 0, inversion_iterate_agenda);
772  }
773  if ((yf.nelem() == 0) || (jacobian.empty())) {
775  ws, yf, jacobian, x, 1, 0, inversion_iterate_agenda);
776  }
777 }
778 
779 #endif // _ARTS_OEM_H_
Matrix
The Matrix class.
Definition: matpackI.h:1193
oem::ArtsLog::scaling_factor_
Numeric scaling_factor_
Scaling factor for the cost.
Definition: oem.h:401
oem::AgendaWrapper::get_measurement_vector
ArtsVector get_measurement_vector()
Return most recently simulated measurement vector.
Definition: oem.h:503
oem::NormalizingSolver::trans_
const TransformationMatrixType & trans_
The transformation matrix.
Definition: oem.h:150
oem::AgendaWrapper::AgendaWrapper
AgendaWrapper(AgendaWrapper &&)=delete
oem::AgendaWrapper::reuse_jacobian_
bool reuse_jacobian_
Flag whether to reuse Jacobian from previous calculation.
Definition: oem.h:566
ARTS::Var::jacobian_quantities
ArrayOfRetrievalQuantity jacobian_quantities(Workspace &ws) noexcept
Definition: autoarts.h:3924
w
Complex w(Complex z) noexcept
The Faddeeva function.
Definition: linefunctions.cc:42
oem::ArtsLog::step
void step(const Params &... params)
Print step to command line.
Definition: oem.h:319
oem::ArtsLog::gamma_history_
Vector gamma_history_
Reference to ARTS vector holding the LM gamma history.
Definition: oem.h:399
oem::ArtsLog::finalize
void finalize(const Params &... params)
Finalize log output.
Definition: oem.h:351
oem::AgendaWrapper
Interface to ARTS inversion_iterate_agenda.
Definition: oem.h:462
oem::Matrix
invlib::Matrix< ArtsMatrix > Matrix
invlib wrapper type for ARTS matrices.
Definition: oem.h:34
oem::AgendaWrapper::ws_
Workspace * ws_
Pointer to current ARTS workspace.
Definition: oem.h:568
oem::NormalizingSolver::solve
auto solve(const MatrixType &A, const VectorType &v) -> typename VectorType::ResultType
Solve linear system.
Definition: oem.h:132
ARTS::Var::xa
Vector xa(Workspace &ws) noexcept
Definition: autoarts.h:7359
CovarianceMatrix
Definition: covariance_matrix.h:226
ARTS::Var::y
Vector y(Workspace &ws) noexcept
Definition: autoarts.h:7401
oem::OEM_NFORM
invlib::MAP< ForwardModel, Matrix, CovarianceMatrix, CovarianceMatrix, Vector, Formulation::NFORM > OEM_NFORM
OEM n form.
Definition: oem.h:79
oem::ArtsLog::ArtsLog
ArtsLog(unsigned int v, ::Vector &g, bool l=false)
Create log.
Definition: oem.h:253
OEM_checks
void OEM_checks(Workspace &ws, Vector &x, Vector &yf, Matrix &jacobian, const Agenda &inversion_iterate_agenda, const Vector &xa, const CovarianceMatrix &covmat_sx, const Vector &y, const CovarianceMatrix &covmat_se, const ArrayOfRetrievalQuantity &jacobian_quantities, const String &method, const Vector &x_norm, const Index &max_iter, const Numeric &stop_dx, const Vector &lm_ga_settings, const Index &clear_matrices, const Index &display_progress)
Error checking for OEM method.
Definition: oem.h:666
oem::CovarianceMatrix
invlib::Matrix< ArtsCovarianceMatrixWrapper > CovarianceMatrix
invlib wrapper type for ARTS the ARTS covariance class.
Definition: oem.h:38
ARTS::Var::inversion_iterate_agenda
Agenda inversion_iterate_agenda(Workspace &ws) noexcept
Definition: autoarts.h:3635
Tensor4
The Tensor4 class.
Definition: matpackIV.h:421
Agenda
The Agenda class.
Definition: agenda_class.h:44
oem::AgendaWrapper::iteration_counter_
unsigned int iteration_counter_
Definition: oem.h:562
Array
This can be used to make arrays out of anything.
Definition: array.h:108
oem::GN
invlib::GaussNewton< Numeric, Std > GN
OEM Gauss-Newton optimization using normed ARTS QR solver.
Definition: oem.h:169
Absorption::nelem
Index nelem(const Lines &l)
Number of lines.
Definition: absorptionlines.h:1820
oem::ArtsLog::linear_
bool linear_
Flag indicating whether forward model is linear.
Definition: oem.h:405
oem::GN_CG
invlib::GaussNewton< Numeric, CG > GN_CG
Gauss-Newton (GN) optimization using normed CG solver.
Definition: oem.h:171
min
#define min(a, b)
Definition: legacy_continua.cc:20628
inversion_iterate_agendaExecute
void inversion_iterate_agendaExecute(Workspace &ws, Vector &yf, Matrix &jacobian, const Vector &x, const Index jacobian_do, const Index inversion_iteration_counter, const Agenda &input_agenda)
Definition: auto_md.cc:23951
oem::OptimizerLog< invlib::GaussNewton< RealType, Solver > >::log
static std::string log(const invlib::GaussNewton< RealType, Solver > &, Vector &, size_t)
Definition: oem.h:229
oem::AgendaWrapper::Jacobian
MatrixReference Jacobian(const Vector &xi, Vector &yi)
Evaluate forward model and compute Jacobian.
Definition: oem.h:521
oem::ArtsLog::init
void init(Params &... params)
Initialize log output.
Definition: oem.h:273
my_basic_string< char >
oem::AgendaWrapper::yi_
Vector yi_
Cached simulation result.
Definition: oem.h:570
oem::ArtsLog
OEM log output.
Definition: oem.h:244
oem::OEM_MFORM
invlib::MAP< ForwardModel, Matrix, CovarianceMatrix, CovarianceMatrix, Vector, Formulation::MFORM > OEM_MFORM
OEM m form.
Definition: oem.h:95
ConstVectorView::nelem
Index nelem() const
Returns the number of elements.
Definition: matpackI.cc:51
oem::AgendaWrapper::AgendaWrapper
AgendaWrapper(const AgendaWrapper &)=delete
Numeric
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
oem::handle_nested_exception
std::vector< std::string > handle_nested_exception(const E &e, int level=0)
Handle exception encountered within invlib.
Definition: oem.h:425
ARTS::Var::yf
Vector yf(Workspace &ws) noexcept
Definition: autoarts.h:7658
ARTS::Var::covmat_sx
CovarianceMatrix covmat_sx(Workspace &ws) noexcept
Definition: autoarts.h:2945
ARTS::Var::covmat_se
CovarianceMatrix covmat_se(Workspace &ws) noexcept
Definition: autoarts.h:2879
MatrixType
Eigen::Matrix< Numeric, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > MatrixType
Definition: matpackI.h:109
oem::OptimizerLog< invlib::GaussNewton< RealType, Solver > >::header
static std::string header()
Name to append to header line.
Definition: oem.h:227
oem::AgendaWrapper::m
const unsigned int m
Dimension of the measurement space.
Definition: oem.h:465
Tensor4Clip
void Tensor4Clip(Tensor4 &x, const Index &iq, const Numeric &limit_low, const Numeric &limit_high)
Clip Tensor4.
Definition: oem.h:582
oem::Identity
invlib::MatrixIdentity< Matrix > Identity
Definition: oem.h:39
ARTS::Var::nrows
Index nrows(Workspace &ws) noexcept
Definition: autoarts.h:4682
oem::AgendaWrapper::jacobian_
MatrixReference jacobian_
Reference to the jacobian WSV.
Definition: oem.h:564
oem::AgendaWrapper::AgendaWrapper
AgendaWrapper(Workspace *ws, unsigned int measurement_space_dimension, unsigned int state_space_dimension, ::Matrix &arts_jacobian, ::Vector &arts_y, const Agenda *inversion_iterate_agenda)
Create inversion_iterate_agendaExecute wrapper.
Definition: oem.h:483
oem::Vector
invlib::Vector< ArtsVector > Vector
invlib wrapper type for ARTS vectors.
Definition: oem.h:32
oem::AgendaWrapper::inversion_iterate_agenda_
const Agenda * inversion_iterate_agenda_
Pointer to the inversion_iterate_agenda of the workspace.
Definition: oem.h:561
oem
Definition: oem.h:29
oem::OptimizerLog< invlib::LevenbergMarquardt< RealType, DampingMatrix, Solver > >::header
static std::string header()
Name to append to header line.
Definition: oem.h:202
oem::AgendaWrapper::evaluate
Vector evaluate(const Vector &xi)
Evaluate the ARTS forward model.
Definition: oem.h:543
oem::ArtsLog::finalized_
bool finalized_
Flag indicating whether output has been finalized.
Definition: oem.h:407
oem::MatrixReference
invlib::Matrix< ArtsMatrixReference<::Matrix > > MatrixReference
invlib wrapper type for ARTS matrices to be passed by reference.
Definition: oem.h:36
oem::ArtsLog::start_cost_
Numeric start_cost_
Start cost (not computed by invlib)
Definition: oem.h:403
Workspace
Workspace class.
Definition: workspace_ng.h:40
oem::OEM_STANDARD
invlib::MAP< ForwardModel, Matrix, CovarianceMatrix, CovarianceMatrix, Vector, Formulation::STANDARD, invlib::Rodgers531 > OEM_STANDARD
OEM standard form.
Definition: oem.h:63
oem::OptimizerLog
Log customization for different optimization methods.
Definition: oem.h:188
oem::LM_CG
invlib::LevenbergMarquardt< Numeric, CovarianceMatrix, CG > LM_CG
Levenberg-Marquardt (LM) optimization using normed CG solver.
Definition: oem.h:175
oem::NormalizingSolver
Normalizing solver.
Definition: oem.h:113
oem::AgendaWrapper::operator=
AgendaWrapper & operator=(AgendaWrapper &&)=delete
oem::NormalizingSolver::apply_
const bool apply_
Whether or not to apply the transformation.
Definition: oem.h:148
ARTS::Var::jacobian
Matrix jacobian(Workspace &ws) noexcept
Definition: autoarts.h:3892
ARTS::Var::x
Vector x(Workspace &ws) noexcept
Definition: autoarts.h:7346
Index
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
ARTS::Var::ncols
Index ncols(Workspace &ws) noexcept
Definition: autoarts.h:4546
oem::NormalizingSolver::NormalizingSolver
NormalizingSolver(const TransformationMatrixType &trans, bool apply, Params... params)
Definition: oem.h:116
oem::LM
invlib::LevenbergMarquardt< Numeric, CovarianceMatrix, Std > LM
Levenberg-Marquardt (LM) optimization using normed ARTS QR solver.
Definition: oem.h:173
oem::AgendaWrapper::operator=
AgendaWrapper & operator=(const AgendaWrapper &)=delete
Vector
The Vector class.
Definition: matpackI.h:860
jac_ranges_indices
void jac_ranges_indices(ArrayOfArrayOfIndex &jis, bool &any_affine, const ArrayOfRetrievalQuantity &jqs, const bool &before_affine)
Determines the index range inside x and the Jacobian for each retrieval quantity.
Definition: jacobian.cc:58
Array::nelem
Index nelem() const
Number of elements.
Definition: array.h:195
oem::AgendaWrapper::n
const unsigned int n
Dimension of the state space.
Definition: oem.h:467
oem::ArtsLog::time
void time(const Params &... params)
Print timing information to command line.
Definition: oem.h:378
oem::OptimizerLog< invlib::LevenbergMarquardt< RealType, DampingMatrix, Solver > >::log
static std::string log(const invlib::LevenbergMarquardt< RealType, DampingMatrix, Solver > &g, Vector &gamma_history_, size_t i)
Returns the string to append to the log of a single step.
Definition: oem.h:208
oem::ArtsLog::verbosity_
int verbosity_
Verbosity level of logger.
Definition: oem.h:397
oem::ArtsLog::~ArtsLog
~ArtsLog()
Finalizes log output if necessary.
Definition: oem.h:257
solve
void solve(VectorView w, const CovarianceMatrix &A, ConstVectorView v)
Definition: covariance_matrix.cc:594