Adding new Jacobians
FitBenchmarking allows the use of custom methods for evaluating the Jacobian of the model. This section describes how to add further methods within FitBenchmarking
In order to add a new Jacobian evaluation method,
you will need to:
fitbenchmarking/jacobian/<jac_method>_jacobian.py, which contains a new subclass of
Jacobian. Then implement the method:
- abstract Jacobian.eval()
Evaluates Jacobian of the model, \(\nabla_p f(x,p)\), at the point given by the parameters.
params (list) – The parameter values at which to evaluate the Jacobian
- Return type
The numerical method is set sequentially within
loop_over_jacobians()by using the
methodattribute of the class.
VALID_FITTINGdictionary so that the element associated with the
jac_methodkey contains the new
VALID_JACOBIANdictionary to have a new key
<jac_method>, with the associated element being a list of valid options for this Jacobian.
DEFAULT_JACOBIANdictionary to have a new key
<jac_method>, with the associated element being a subset of the valid options added in
VALID_JACOBIANin the previous step.
Amend the file
fitbenchmarking/utils/tests/test_options_jacobian.pyto include tests for the new options.
Document the available Jacobians by:
adding a list of available
methodoptions to the docs for Jacobian Options, and including licencing information, if appropriate.
updating any example files in the
Create tests for the Jacobian evaluation in
When adding new Jacobian, you will find it helpful to make use of the
following members of the
- class fitbenchmarking.parsing.fitting_problem.FittingProblem(options)
Definition of a fitting problem, which will be populated by a parser from a problem definition file.
Onces populated, this should include the data, the function and any other additional requirements from the data.
numpy array The errors or weights
numpy array The x-data
numpy array The y-data
- eval_model(params, **kwargs)
Function evaluation method
params (list) – parameter value(s)
data values evaluated from the function of the problem
- Return type