Levenberg_marquardt.hpp
Go to the documentation of this file.
1 #ifndef MANGO_LEVENBERG_MARQUARDT_H
2 #define MANGO_LEVENBERG_MARQUARDT_H
3 
4 #include <fstream>
5 #include "Package_mango.hpp"
7 
8 #ifdef MANGO_EIGEN_AVAILABLE
9 #include <Eigen/Dense>
10 #endif
11 
12 namespace mango {
14  public:
15 #ifdef MANGO_EIGEN_AVAILABLE
16  Least_squares_solver* solver;
17 
18  // Define shorthand variable names:
19  int N_parameters;
20  int N_terms;
21  int verbose;
22  int N_line_search;
23  bool proc0_world;
24  MPI_Comm comm_group_leaders;
25 
26  // Convert some C arrays to Eigen vectors (no copying of memory is performed):
27  Eigen::Map<Eigen::VectorXd> state_vector;
28  Eigen::Map<Eigen::VectorXd> targets;
29  Eigen::Map<Eigen::VectorXd> sigmas;
30 
31  Eigen::VectorXd state_vector_tentative;
32  Eigen::VectorXd residuals;
33  Eigen::VectorXd shifted_residuals;
34  Eigen::MatrixXd Jacobian;
35  Eigen::VectorXd residuals_extended;
36  Eigen::MatrixXd Jacobian_extended;
37  Eigen::VectorXd delta_x;
38  Eigen::MatrixXd lambda_scan_residuals;
39  Eigen::MatrixXd lambda_scan_state_vectors;
40  Eigen::VectorXd lambdas;
41  Eigen::VectorXd lambda_scan_objective_functions;
42  Eigen::VectorXd delta_x_direct;
43  Eigen::MatrixXd alpha;
44  Eigen::MatrixXd alpha_prime;
45  Eigen::VectorXd beta;
46 
47  double central_lambda;
48  double lambda_reduction_on_success;
49  int max_line_search_iterations;
50  int max_outer_iterations;
51  int data, j, j_line_search, failed_int, j_lambda_grid;
52  double lambda, objective_function, tentative_objective_function, min_objective_function;
53  int min_objective_function_index;
54  double difference;
55  bool failed;
56  bool keep_going_outer;
57  bool line_search_succeeded;
58  double lambda_increase_factor;
59  double* normalized_lambda_grid;
60  std::ofstream lambda_file;
61  int outer_iteration;
62  bool check_least_squares_solution;
63  bool save_lambda_history;
64 
65  void evaluate_on_lambda_grid();
66  void process_lambda_grid_results();
67  void line_search();
68 
69  static double compute_lambda_increase_factor(const int);
70  static void compute_lambda_grid(const int, const double, double*);
71 
72 #endif
74  void solve();
75 
76  };
77 
78 }
79 
80 #endif
mango::Levenberg_marquardt::Levenberg_marquardt
Levenberg_marquardt(Least_squares_solver *)
Definition: Levenberg_marquardt.cpp:14
Least_squares_solver.hpp
mango::Least_squares_solver
Definition: Least_squares_solver.hpp:28
mango::Levenberg_marquardt::solve
void solve()
Definition: Levenberg_marquardt.cpp:18
mango::Levenberg_marquardt
Definition: Levenberg_marquardt.hpp:13
mango::LeastSquaresAlgorithm
Definition: Package_mango.hpp:48
Package_mango.hpp
mango
This C++ namespace contains everything related to MANGO.
Definition: Imfil.hpp:7