Adding new Hessians
This section describes how to add further methods to approximate the Hessian within FitBenchmarking
In order to add a new Hessian evaluation method, <hes_method>,
you will need to:
Create
fitbenchmarking/hessian/<hes_method>_hessian.py, which contains a new subclass ofhessian. Then implement the method:- abstract Hessian.eval()
Evaluates Hessian of the model
- Parameters:
params (list) – The parameter values to find the Hessian at
- Returns:
Computed Hessian
- Return type:
3D numpy array
The method is set sequentially within
loop_over_hessians()by using themethodattribute of the class.Enable the new method as an option in Fitting Options, following the instructions in Adding new Options. Specifically:
Amend the
VALID_FITTINGdictionary so that the element associated with thehes_methodkey contains the new<hes_method>.
Document the available Hessians by:
adding to the list of available
methodoptions underhes_methodin Fitting Options.updating any example files in the
examplesdirectory
Create tests for the Hessian evaluation in
fitbenchmarking/hessian/tests/test_hessians.py.
The FittingProblem and Jacobian
When adding new Hessian, you will find it helpful to make use of the
following members of the FittingProblem
and subclasses of Jacobian:
- class fitbenchmarking.parsing.fitting_problem.FittingProblem(options)
Definition of a fitting problem, which will be populated by a parser from a problem definition file.
Once populated, this should include the data, the function and any other additional requirements from the data.
- data_e
numpy array The errors or weights
- data_x
numpy array The x-data
- data_y
numpy array The y-data
- eval_model(params, **kwargs)
Function evaluation method
- Parameters:
params (list) – parameter value(s)
- Returns:
data values evaluated from the function of the problem
- Return type:
numpy array
- class fitbenchmarking.jacobian.base_jacobian.Jacobian(problem)
Base class for Jacobian.
- abstract eval(params, **kwargs)
Evaluates Jacobian of the model, \(\nabla_p f(x,p)\), at the point given by the parameters.
- Parameters:
params (list) – The parameter values at which to evaluate the Jacobian
- Returns:
Computed Jacobian
- Return type:
numpy array