BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
ObjectiveFunctionAdapter.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Fit/Adapter/ObjectiveFunctionAdapter.cpp
6 //! @brief Implements class ObjectiveFunctionAdapter.
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 
20 
21 using namespace mumufit;
22 
24 
26 
27 const RootScalarFunction*
29 {
30  std::unique_ptr<ScalarFunctionAdapter> tem_adapter(new ScalarFunctionAdapter(fcn, parameters));
31  const auto* result = tem_adapter->rootObjectiveFunction();
32  m_adapter = std::move(tem_adapter);
33  return result;
34 }
35 
38 {
39  std::unique_ptr<ResidualFunctionAdapter> tem_adapter(
40  new ResidualFunctionAdapter(fcn, parameters));
41  const auto* result = tem_adapter->rootResidualFunction();
42  m_adapter = std::move(tem_adapter);
43  return result;
44 }
45 
47 {
48  return m_adapter ? m_adapter->numberOfCalls() : 0;
49 }
50 
52 {
53  return m_adapter ? m_adapter->numberOfGradientCalls() : 0;
54 }
std::function< double(const mumufit::Parameters &)> fcn_scalar_t
Definition: Types.h:40
std::function< std::vector< double >(const mumufit::Parameters &)> fcn_residual_t
Definition: Types.h:41
Declares class ObjectiveFunctionAdapter.
Defines class ResidualFunctionAdapter.
Declares class RootResidualFunction.
Defines classes RootScalarFunction.
Defines class ScalarFunctionAdapter.
Minimizer function with access to single data element residuals, required by Fumili2 and GSLMultiMin ...
The chi2 function for use in minimizers.
std::unique_ptr< IFunctionAdapter > m_adapter
const RootResidualFunction * rootResidualFunction(fcn_residual_t fcn, const Parameters &parameters)
const RootScalarFunction * rootObjectiveFunction(fcn_scalar_t fcn, const Parameters &parameters)
A collection of fit parameters.
Definition: Parameters.h:26
Provides RootResidualFunction which will be minimizer by ROOT. Converts ROOT calls to the call of fcn...
Converts user objective function to chi2 like function which ROOT expects.
The multi-library, multi-algorithm fit wrapper library.