BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
FitStatus.h
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Core/Fitting/FitStatus.h
6 //! @brief Defines class FitStatus.
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************** //
14 
15 #ifndef BORNAGAIN_CORE_FITTING_FITSTATUS_H
16 #define BORNAGAIN_CORE_FITTING_FITSTATUS_H
17 
20 #include <functional>
21 #include <vector>
22 
23 namespace Fit
24 {
25 class MinimizerResult;
26 }
27 class FitObjective;
28 class FitPrintService;
29 
30 //! Contains status of the fitting (running, interupted etc) and all intermediate
31 //! information which has to be collected during the fit.
32 //! Owned by FitObjective.
33 
34 class FitStatus
35 {
36 public:
37  FitStatus(const FitObjective* fit_objective);
38  ~FitStatus();
39 
40  void setInterrupted();
41  bool isInterrupted() const;
42  bool isCompleted() const;
43 
44  void update(const Fit::Parameters& params, double chi2);
45 
46  void initPrint(int every_nth);
47 
48  void addObserver(int every_nth, fit_observer_t);
49 
50  IterationInfo iterationInfo() const;
51 
52  Fit::MinimizerResult minimizerResult() const;
53 
54  //! Should be explicitely called on last iteration to notify all observers.
55  void finalize(const Fit::MinimizerResult& result);
56 
57 private:
58  enum EFitStatus { IDLE, RUNNING, COMPLETED, FAILED, INTERRUPTED };
59  EFitStatus m_fit_status;
60  FitObserver<FitObjective> m_observers;
61  std::unique_ptr<FitPrintService> m_print_service;
62  const FitObjective* m_fit_objective;
63  IterationInfo m_iterationInfo;
64  std::unique_ptr<Fit::MinimizerResult> m_minimizer_result;
65 };
66 
67 #endif // BORNAGAIN_CORE_FITTING_FITSTATUS_H
Defines class FitObserver.
Defines class IterationInfo.
Holds vector of SimDataPairs (experimental data and simulation results) for use in fitting.
Definition: FitObjective.h:34
Prints fit statistics to standard output during minimizer iterations.
Contains status of the fitting (running, interupted etc) and all intermediate information which has t...
Definition: FitStatus.h:35
void finalize(const Fit::MinimizerResult &result)
Should be explicitely called on last iteration to notify all observers.
Definition: FitStatus.cpp:82
Result of minimization round.
A collection of fit parameters.
Definition: Parameters.h:28
Stores fit iteration info to track fit flow from various observers.
Definition: IterationInfo.h:26
Objective function types.