19 [](
size_t sum,
const auto &creator) { return sum + creator->getDomainSize(); });
33 throw std::range_error(
"Function domain index is out of range.");
66 throw std::invalid_argument(
"Unknown SeqDomain type");
77 for (
size_t i = 0; i <
n; ++i) {
81 throw std::runtime_error(
"CostFunction: undefined FunctionValues.");
83 costFunction.
addVal(domain, values);
96 for (
size_t i = 0; i <
n; ++i) {
100 throw std::runtime_error(
"Rwp: undefined FunctionValues.");
102 rwp.
addVal(domain, values);
118 for (
size_t i = 0; i <
n; ++i) {
122 throw std::runtime_error(
"CostFunction: undefined FunctionValues.");
138 for (
size_t i = 0; i <
n; ++i) {
142 throw std::runtime_error(
"Rwp: undefined FunctionValues.");
DomainType
Type of domain to create.
A semi-abstract class for a cost function for fitting functions.
virtual void addVal(API::FunctionDomain_sptr domain, API::FunctionValues_sptr values) const =0
Increment to the cost function by evaluating it on a domain.
virtual void addValDerivHessian(API::IFunction_sptr function, API::FunctionDomain_sptr domain, API::FunctionValues_sptr values, bool evalDeriv=true, bool evalHessian=true) const =0
Increments the cost function and its derivatives by evaluating them on a domain.
virtual API::IFunction_sptr getFittingFunction() const
Get fitting function.
void addVal(API::FunctionDomain_sptr domain, API::FunctionValues_sptr values) const override
Add a contribution to the cost function value from the fitting function evaluated on a particular dom...
void addValDerivHessian(API::IFunction_sptr function, API::FunctionDomain_sptr domain, API::FunctionValues_sptr values, bool evalDeriv=true, bool evalHessian=true) const override
Update the cost function, derivatives and hessian by adding values calculated on a domain.
Cost function for Rwp = (sum_i (( obs_i - cal_i )/sigma_i)**2 ) / (sum_i (obs_i/sigma_i)**2)
An implementation of SeqDomain for parallel cost function and derivatives computation.
An implementation of CompositeDomain.
virtual void getDomainAndValues(size_t i, API::FunctionDomain_sptr &domain, API::FunctionValues_sptr &values) const
Create and return i-th domain and i-th values, (i-1)th domain is released.
size_t size() const override
Return the number of points in the domain.
std::vector< API::FunctionDomain_sptr > m_domain
Currently active domain.
size_t m_currentIndex
Current index.
virtual void additiveCostFunctionValDerivHessian(const CostFunctions::CostFuncFitting &costFunction, bool evalDeriv, bool evalHessian)
Calculate the value, first and second derivatives of an additive cost function.
void rwpValDerivHessian(const CostFunctions::CostFuncRwp &rwp, bool evalDeriv, bool evalHessian)
Calculate the value, first and second derivatives of a RWP cost function.
void rwpVal(const CostFunctions::CostFuncRwp &rwp)
Calculate the value of a Rwp cost function.
std::vector< API::FunctionValues_sptr > m_values
Currently active values.
void addCreator(const API::IDomainCreator_sptr &creator)
Add new domain creator.
virtual size_t getNDomains() const
Return the number of parts in the domain.
static SeqDomain * create(API::IDomainCreator::DomainType type)
Create an instance of SeqDomain in one of two forms: either SeqDomain for sequential domain creation ...
virtual void additiveCostFunctionVal(const CostFunctions::CostFuncFitting &costFunction)
Calculate the value of an additive cost function.
std::vector< std::shared_ptr< API::IDomainCreator > > m_creators
Domain creators.
std::shared_ptr< FunctionValues > FunctionValues_sptr
typedef for a shared pointer
std::shared_ptr< IDomainCreator > IDomainCreator_sptr
Typedef for a shared pointer to IDomainCreator.
std::shared_ptr< FunctionDomain > FunctionDomain_sptr
typedef for a shared pointer