BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
FitObjective Class Reference

Holds vector of SimDataPairs (experimental data and simulation results) for use in fitting. More...

Public Member Functions

SimulationResult absoluteDifference (size_t i_item=0) const
 Returns absolute value of difference between simulation and experimental data in the form of SimulationResult.
 
template<class T >
void addSimulationAndData (PyBuilderCallback &callback, const T &data, const T &uncertainties, double weight=1.0)
 Constructs simulation/data pair for later fit. More...
 
template<class T >
void addSimulationAndData (PyBuilderCallback &callback, const T &data, double weight=1.0)
 Constructs simulation/data pair for later fit. More...
 
bool allPairsHaveUncertainties () const
 Returns true if all the data pairs in FitObjective instance contain uncertainties.
 
bool containsUncertainties (size_t i_item) const
 Returns true if the specified DataPair element contains uncertainties.
 
virtual double evaluate (const mumufit::Parameters &params)
 
virtual std::vector< double > evaluate_residuals (const mumufit::Parameters &params)
 
std::vector< double > experimental_array () const
 Returns one dimensional array representing merged experimental data. More...
 
SimulationResult experimentalData (size_t i_item=0) const
 Returns experimental data in the form of SimulationResult.
 
void finalize (const mumufit::MinimizerResult &result)
 Should be explicitely called on last iteration to notify all observers.
 
unsigned fitObjectCount () const
 
void initPlot (int every_nth, PyObserverCallback &callback)
 Initializes observer callback to be called on every_nth fit iteration.
 
void initPrint (int every_nth)
 Initializes printing to standard output on every_nth fit iteration.
 
IterationInfo iterationInfo () const
 
mumufit::MinimizerResult minimizerResult () const
 
size_t numberOfFitElements () const
 
SimulationResult relativeDifference (size_t i_item=0) const
 Returns relative difference between simulation and experimental data in the form of SimulationResult.
 
void run_simulations (const mumufit::Parameters &params)
 
void setChiSquaredModule (const IChiSquaredModule &module)
 
void setObjectiveMetric (const std::string &metric)
 
void setObjectiveMetric (const std::string &metric, const std::string &norm)
 Sets objective metric to the FitObjective. More...
 
std::vector< double > simulation_array () const
 Returns one dimensional array representing merged simulated intensities data. More...
 
SimulationResult simulationResult (size_t i_item=0) const
 Returns simulation result in the form of SimulationResult.
 
std::vector< double > uncertainties () const
 Returns one-dimensional array representing merged data uncertainties. More...
 
SimulationResult uncertaintyData (size_t i_item=0) const
 Returns experimental data uncertainties in the form of SimulationResult.
 
std::vector< double > weights_array () const
 Returns one-dimensional array representing merged user weights. More...
 

Static Public Member Functions

static std::string availableMetricOptions ()
 Returns available metrics and norms.
 

Detailed Description

Holds vector of SimDataPairs (experimental data and simulation results) for use in fitting.

Member Function Documentation

◆ addSimulationAndData() [1/2]

template<class T >
void FitObjective::addSimulationAndData ( PyBuilderCallback callback,
const T &  data,
const T &  uncertainties,
double  weight = 1.0 
)

Constructs simulation/data pair for later fit.

Parameters
callbacksimulation builder capable of producing simulations
dataexperimental data array
uncertaintiesdata uncertainties array
weightweight of dataset in metric calculations

◆ addSimulationAndData() [2/2]

template<class T >
void FitObjective::addSimulationAndData ( PyBuilderCallback callback,
const T &  data,
double  weight = 1.0 
)

Constructs simulation/data pair for later fit.

Parameters
callbacksimulation builder capable of producing simulations
dataexperimental data array
weightweight of dataset in metric calculations

◆ experimental_array()

std::vector< double > FitObjective::experimental_array ( ) const

Returns one dimensional array representing merged experimental data.

The area outside of the region of interest is not included, masked data is nullified.

◆ setObjectiveMetric()

void FitObjective::setObjectiveMetric ( const std::string &  metric,
const std::string &  norm 
)

Sets objective metric to the FitObjective.

Parameters
metricmetric name
normmetric norm name (defaults to L2-norm)

◆ simulation_array()

std::vector< double > FitObjective::simulation_array ( ) const

Returns one dimensional array representing merged simulated intensities data.

The area outside of the region of interest is not included, masked data is nullified.

◆ uncertainties()

std::vector< double > FitObjective::uncertainties ( ) const

Returns one-dimensional array representing merged data uncertainties.

The area outside of the region of interest is not included, masked data is nullified.

◆ weights_array()

std::vector< double > FitObjective::weights_array ( ) const

Returns one-dimensional array representing merged user weights.

The area outside of the region of interest is not included, masked data is nullified.