Package boxmin :: Package tests :: Module FitParameters :: Class FitParameters
[hide private]

Class FitParameters

source code

class FitParameters

A fitting engine adjusts parameters to find a minimum value. The user will want to guide the fit by fixing some of the parameters at a specific value or to a specific range. The fit application will need to switch easily between different parameter sets, e.g., to keep hold of the current best parameters while restarting the fit at a different point, so the fit parameters must be stored separately from the model structure.

By allowing simple expressions instead of just values for fit parameters users can create sophisticated derived models with no programming effort. This includes simultaneous fitting of related models, with the parameters for dependent models computed from the values in the base model. Some care will be required when updating the results. Much like a spreadsheet, an expression must be evaluated before any of the expressions which depend on it, and cycles must be avoided. A cell reference such as model.parameter[index] would work automatically in python with the appropriate dictionary. Rather than hardcoding index numbers, using a variable such as i to represent the current index would be convenient, making it easy to copy a formula from cell to cell.

Consider allowing expressions for upper and lower bounds as well in a later release. In the current implementation of genetic algorithms changing the bounds is an expensive operation because the variables are mapped into the range [0,1], so any time the bounds change the entire population needs to be remapped.

To keep its programming interface simple, the fitting engine will see the fit parameters as contiguous arrays of values and bounds. Normally this will require shuffling parameters between the fit and the model. In cases were speed is critical, the model can operate directly off the fitting engine parameters with no copying required. A choice between [v lo hi v lo hi ...], [v v ...] [lo hi lo hi ...], and [v v ...] [lo lo ...] [hi hi ...] must be made for the interface to the fitting engine. Locality of reference favours the first while programming flexibility favours the last.

The user needs to be able to save and restore the entire state of the fit. A extensible text format such as XML will be used, with each model component stored in a different section with tag identifying the type of model. The application will be responsible for saving and restoring the model, presumably delegating to the various model components which make up the fit for converting to and from their own representation in the model file. Saving and restoring information the actual model values, the expressions, which parameters are varying and the user specified bounds on all parameters is the responsibility of fit parameter object.

Global parameters not associated with any particular model can be added to a generic model and referenced as any other external model.

Instance Methods [hide private]
 
add(self, model)
Add a model to the fit
source code
 
title(self, n=None)
Return title for model n or for the whole fit
source code
 
tip(self, n=None)
Return tip for model n or for the whole fit
source code
 
__init__(self, title, tip=None)
Construct a set of fit parameters
source code
 
_count_varying(self) source code
 
_generate(self) source code