ARTS  2.4.0(git:4fb77825)
oem_mpi.h
Go to the documentation of this file.
1 
8 #endif _ARTS_OEM_MPI_H_
9 
10 #include "invlib/algebra.h"
11 #include "invlib/algebra/precision_matrix.h"
12 #include "invlib/algebra/solvers.h"
13 #include "invlib/interfaces/arts_wrapper.h"
14 #include "invlib/map.h"
15 #include "invlib/mpi/log.h"
16 #include "invlib/mpi/mpi_matrix.h"
17 #include "invlib/mpi/mpi_vector.h"
18 #include "invlib/optimization.h"
19 #include "invlib/profiling/timer.h"
20 
21 namespace oem {
22 
24 using MPIMatrix = invlib::Matrix<invlib::MPIMatrix<invlib::Timer<ArtsMatrix>>>;
27  invlib::MPIMatrix<invlib::Timer<ArtsCovarianceMatrixWrapper>>>;
29 using MPIVector = invlib::Vector<invlib::MPIVector<invlib::Timer<ArtsVector>>>;
30 
37 template <typename ForwardModel>
38 using OEM_STANDARD_MPI = invlib::MAP<ForwardModel,
39  OEMMatrix,
42  OEMVector,
43  Formulation::STANDARD>;
44 
46 using LM_MPI = invlib::LevenbergMarquardt<Numeric, MPISparse, CG>;
47 
57 
58  public:
59  const unsigned int m, n;
60 
63  Index m_,
64  Index n_)
65  : ws_(ws),
68  m(static_cast<unsigned int>(m_)),
69  n(static_cast<unsigned int>(n_)) {}
70 
77  MPIMatrix Jacobian(const OEMVector &xi, OEMVector &yi) {
78  yi.resize(m);
81  // Create MPI vector from local results, use conversion to vector
82  // to broadcast local results.
83  MPIVector yi_mpi(yi);
84  yi = yi_mpi;
85 
87  return jacobian;
88  }
89 
98  OEMVector evaluate(const OEMVector &xi) {
99  Matrix dummy = local_jacobian_;
100  OEMVector yi;
101  yi.resize(m);
103  *ws_, yi, dummy, xi, 0, *inversion_iterate_agenda_);
104 
105  // Create MPI vector from local results, use conversion to vector
106  // to broadcast local results.
107  MPIVector yi_mpi = yi;
108  yi = yi_mpi;
109  return yi;
110  }
111 
112  private:
116  OEMMatrix local_jacobian_;
119 };
120 } // namespace oem
121 #endif // _ARTS_OEM_MPI_H_
Matrix
The Matrix class.
Definition: matpackI.h:1193
oem::AgendaWrapperMPI::inversion_iterate_agenda_
const Agenda * inversion_iterate_agenda_
Pointer to the inversion_iterate_agenda defining the foward model.
Definition: oem_mpi.h:118
oem::AgendaWrapperMPI::evaluate
OEMVector evaluate(const OEMVector &xi)
Evaluate forward model.
Definition: oem_mpi.h:98
oem::AgendaWrapperMPI::ws_
Workspace * ws_
Pointer to current workspace.
Definition: oem_mpi.h:114
oem::MPIMatrix
invlib::Matrix< invlib::MPIMatrix< invlib::Timer< ArtsMatrix > >> MPIMatrix
MPI-distributed matrix type based on ARTS built-in dense matrices.
Definition: oem_mpi.h:24
oem::AgendaWrapperMPI::m
const unsigned int m
Definition: oem_mpi.h:59
oem::AgendaWrapperMPI::AgendaWrapperMPI
AgendaWrapperMPI(Workspace *ws_, const Agenda *inversion_iterate_agenda, Index m_, Index n_)
Definition: oem_mpi.h:61
oem::Matrix
invlib::Matrix< ArtsMatrix > Matrix
invlib wrapper type for ARTS matrices.
Definition: oem.h:34
oem::MPICovarianceMatrix
invlib::Matrix< invlib::MPIMatrix< invlib::Timer< ArtsCovarianceMatrixWrapper > >> MPICovarianceMatrix
MPI-distributed covariance matrix type.
Definition: oem_mpi.h:27
ARTS::Var::inversion_iterate_agenda
Agenda inversion_iterate_agenda(Workspace &ws) noexcept
Definition: autoarts.h:3635
Agenda
The Agenda class.
Definition: agenda_class.h:44
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::LM_MPI
invlib::LevenbergMarquardt< Numeric, MPISparse, CG > LM_MPI
Distributed Levenberg-Marquardt optimization.
Definition: oem_mpi.h:46
oem::AgendaWrapperMPI::local_jacobian_
OEMMatrix local_jacobian_
Process-local part of the Jacobian.
Definition: oem_mpi.h:116
oem
Definition: oem.h:29
oem::AgendaWrapperMPI::Jacobian
MPIMatrix Jacobian(const OEMVector &xi, OEMVector &yi)
Compute Jacobian of forward model.
Definition: oem_mpi.h:77
Workspace
Workspace class.
Definition: workspace_ng.h:40
oem::AgendaWrapperMPI
Interface for distributed ARTS forward model.
Definition: oem_mpi.h:56
oem::OEM_STANDARD_MPI
invlib::MAP< ForwardModel, OEMMatrix, MPICovarianceMatrix, MPICovarianceMatrix, OEMVector, Formulation::STANDARD > OEM_STANDARD_MPI
Distributed OEM standard form.
Definition: oem_mpi.h:43
ARTS::Var::jacobian
Matrix jacobian(Workspace &ws) noexcept
Definition: autoarts.h:3892
Index
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
oem::MPIVector
invlib::Vector< invlib::MPIVector< invlib::Timer< ArtsVector > >> MPIVector
MPI-distributed vector type.
Definition: oem_mpi.h:29
oem::AgendaWrapperMPI::n
const unsigned int n
Definition: oem_mpi.h:59