IFitParameter and FitParameter

IFitParameter

IFitParameter class contains set of initial properties to setup the fitting engine.

double m_name;       //!< name of the fit parameter
double m_startValue; //!< starting value
double m_step;       //!< initial step 
double m_limits;     //!< Limits of the fit parameter

Two more properties

double m_value; //!< current value of the fit parameter
double m_error; //!< found parameter error

are updated by the engine in the course of the fitting. The current parameter value m_value is updated on every iteration using IFitParameter::setValue method, while parameter error m_error will be set at the end of the fit.

IFitParameter class doesn't contain any machinery to actually propagate the value of the fit parameter m_value during iterations toward the objective function (i.e. simulation model). It is supposed to be done in derived class by overloading the virtual ::setValue method.

FitParameter

FitParameter class main purpose is to propagate the value of the fit parameter, as suggested by the minimizer, to the model of the sample. It is designed in such a way that one FitParameter can steer the values of several sample parameters. This is done via RealParameter mechanism. For this purpose, FitParameter holds a vector of sample's RealParameter

std::vector<RealParameter*> m_pool_parameters; //!< linked parameters from pools

The overloaded method FitParameter::setValue(double value) looks like this:

for(par : m_pool_parameters)
    par->setValue(value)

Adding RealParameter's of the sample to the FitParameter.

Initially, the vector of linked sample parameters m_pool_parameters is empty. FitParameter doesn't have any knowledge about any simulation and possible sample parameters. Moreover, the simulation itself might be not yet existing.

To setup FitParameter for the following fitting, user has to define at least one wildcard-based patterns, which will be later used to fill m_pool_parameters with corresponding sample parameters.

Patterns are stored in the

std::vector<std::string> m_patterns;           //!< list of patterns to match from pool

The initial setup of the FitParameter can look like this:

FitParameter par;
par.setStartValue(1.0);
par.addPattern("*/Layer0/Thickness");
par.addPattern("*/Cylinder/Height");

Here we define a fit parameter with starting value 1.0 and add two patterns with sample parameter names.

What is going on after.

The following steps will be going on under the control of FitKernel engine

method FitSuiteImpl::link_fit_parameters()

  • The fit kernel constructs a ParameterPool containing all simulation parameters

pool = Simulation::createParameterTree()

  • For every fit parameters defined, the kernel runs a method FitParameter::addMatchedParameters(pool), which extracts all corresponding sample parameters for all wildcard patterns defined and fill local m_pool_parameters.
void FitParameter::addMatchedParameters(const ParameterPool& pool)
{
    for (auto wildcard : m_patterns) {
        for (auto par : pool.getMatchedParameters(wildcard))
            m_pool_parameters.push_back(par->clone());
    }
}

fit_parameter.png (31.5 KB) pospelov, 30 Jan 2017 14:05