Least_squares_solver.hpp
Go to the documentation of this file.
1 // Copyright 2019, University of Maryland and the MANGO development team.
2 //
3 // This file is part of MANGO.
4 //
5 // MANGO is free software: you can redistribute it and/or modify it
6 // under the terms of the GNU Lesser General Public License as
7 // published by the Free Software Foundation, either version 3 of the
8 // License, or (at your option) any later version.
9 //
10 // MANGO is distributed in the hope that it will be useful, but
11 // WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with MANGO. If not, see
17 // <https://www.gnu.org/licenses/>.
18 
19 #ifndef MANGO_LEAST_SQUARES_SOLVER_H
20 #define MANGO_LEAST_SQUARES_SOLVER_H
21 
22 #include "mango.hpp"
23 #include "Solver.hpp"
24 
25 namespace mango {
26 
27  // This class contains ugly implementation details that are specific to least-squares minimization.
28  class Least_squares_solver : public Solver {
29 
30  protected:
31  Least_squares_solver(); // This version of the constructor, with no arguments, is used only for unit testing. Protected so Catch2 can subclass it.
32 
33  // Overrides the routines in Solver:
34  void group_leaders_loop();
35 
36  // Many of the solver variables and method are public because this information must be used by the concrete Package.
37  public:
38  int N_terms;
39  double* targets;
40  double* sigmas;
43  double* residuals;
47 
50 
51  // Overrides of routines in Solver:
52  double optimize(MPI_Partition*);
53  void finite_difference_gradient(const double*, double*, double*);
54  void objective_function_wrapper(const double*, double*, bool*);
55  bool record_function_evaluation(const double*, double, bool);
56  void record_function_evaluation_pointer(const double*, double*, bool);
57 
58  // Methods that do not exist in the base class Solver:
59  double residuals_to_single_objective(double*);
60  void residual_function_wrapper(const double*, double*, bool*);
61  static void least_squares_to_single_objective(int*, const double*, double*, int*, mango::Problem*, void*);
62  void finite_difference_Jacobian(const double*, double*, double*); // Not an override due to the different arguments from the method in Solver.
63  };
64 }
65 
66 #endif
mango::Least_squares_solver::current_residuals
double * current_residuals
Definition: Least_squares_solver.hpp:45
mango::Least_squares_solver::record_function_evaluation_pointer
void record_function_evaluation_pointer(const double *, double *, bool)
Definition: residual_function_wrapper.cpp:53
mango::Least_squares_solver::N_terms
int N_terms
Definition: Least_squares_solver.hpp:38
mango::Least_squares_solver::sigmas
double * sigmas
Definition: Least_squares_solver.hpp:40
mango::Least_squares_solver::least_squares_problem
Least_squares_problem * least_squares_problem
Definition: Least_squares_solver.hpp:46
mango::Least_squares_solver::print_residuals_in_output_file
bool print_residuals_in_output_file
Definition: Least_squares_solver.hpp:44
mango::Least_squares_solver::least_squares_to_single_objective
static void least_squares_to_single_objective(int *, const double *, double *, int *, mango::Problem *, void *)
Definition: optimize_least_squares.cpp:149
mango::Least_squares_solver::optimize
double optimize(MPI_Partition *)
Definition: optimize_least_squares.cpp:26
mango::Least_squares_solver
Definition: Least_squares_solver.hpp:28
Solver.hpp
mango::Least_squares_solver::residuals
double * residuals
Definition: Least_squares_solver.hpp:43
mango::Least_squares_solver::~Least_squares_solver
~Least_squares_solver()
Definition: Least_squares_solver.cpp:50
mango::vector_function_type
void(* vector_function_type)(int *N_parameters, const double *state_vector, int *N_terms, double *residuals, int *failed, mango::Problem *problem, void *user_data)
Format for the user-supplied subroutine that computes the residuals for a least-squares optimization ...
Definition: mango.hpp:439
mango::Least_squares_problem
Definition: mango.hpp:658
mango.hpp
mango::Least_squares_solver::residual_function
vector_function_type residual_function
Definition: Least_squares_solver.hpp:41
mango::Least_squares_solver::group_leaders_loop
void group_leaders_loop()
Definition: group_leaders_loop_least_squares.cpp:23
mango
This C++ namespace contains everything related to MANGO.
Definition: Imfil.hpp:7
mango::Least_squares_solver::finite_difference_Jacobian
void finite_difference_Jacobian(const double *, double *, double *)
Definition: Least_squares_solver.cpp:54
mango::Solver
Definition: Solver.hpp:31
mango::Least_squares_solver::Least_squares_solver
Least_squares_solver()
Definition: Least_squares_solver.cpp:44
mango::Least_squares_solver::finite_difference_gradient
void finite_difference_gradient(const double *, double *, double *)
Definition: finite_difference_Jacobian_to_gradient.cpp:26
mango::Least_squares_solver::objective_function_wrapper
void objective_function_wrapper(const double *, double *, bool *)
Definition: residual_function_wrapper.cpp:90
mango::Least_squares_solver::record_function_evaluation
bool record_function_evaluation(const double *, double, bool)
Definition: residual_function_wrapper.cpp:61
mango::MPI_Partition
A class for dividing the set of MPI processes into worker groups.
Definition: mango.hpp:195
mango::Least_squares_solver::residuals_to_single_objective
double residuals_to_single_objective(double *)
Definition: optimize_least_squares.cpp:183
mango::Least_squares_solver::residual_function_wrapper
void residual_function_wrapper(const double *, double *, bool *)
Definition: residual_function_wrapper.cpp:26
mango::Least_squares_solver::best_residual_function
double * best_residual_function
Definition: Least_squares_solver.hpp:42
mango::Problem
Definition: mango.hpp:442
mango::Least_squares_solver::targets
double * targets
Definition: Least_squares_solver.hpp:39