BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
ObjectiveFunctionAdapter.cpp
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Fit/RootAdapter/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 Fit;
22 
24 
26 
27 const RootScalarFunction*
29 {
30  std::unique_ptr<ScalarFunctionAdapter> temp_adapter(new ScalarFunctionAdapter(fcn, parameters));
31  auto result = temp_adapter->rootObjectiveFunction();
32  m_adapter.reset(temp_adapter.release());
33  return result;
34 }
35 
38 {
39  std::unique_ptr<ResidualFunctionAdapter> temp_adapter(
40  new ResidualFunctionAdapter(fcn, parameters));
41  auto result = temp_adapter->rootResidualFunction();
42  m_adapter.reset(temp_adapter.release());
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< std::vector< double >(const Fit::Parameters &)> fcn_residual_t
Definition: KernelTypes.h:38
std::function< double(const Fit::Parameters &)> fcn_scalar_t
Definition: KernelTypes.h:37
Declares class ObjectiveFunctionAdapter.
Defines class ResidualFunctionAdapter.
Declares class RootResidualFunction.
Defines classes RootScalarFunction.
Defines class ScalarFunctionAdapter.
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:28
Provides RootResidualFunction which will be minimizer by ROOT.
Converts user objective function to chi2 like function which ROOT expects.
Minimizer function with access to single data element residuals, required by Fumili2 and GSLMultiMin ...
The chi2 function for use in minimizers.
Objective function types.