fitbenchmarking.parsing.fitting_problem module
Implements the FittingProblem class, this will be the object that inputs are parsed into before being passed to the controllers
- class fitbenchmarking.parsing.fitting_problem.FittingProblem(options)
Bases:
object
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.
- additional_info
dict Container for software specific information. This should be avoided if possible.
- correct_data()
Strip data that overruns the start and end x_range, and approximate errors if not given. Modifications happen on member variables.
- data_e
numpy array The errors or weights
- data_x
numpy array The x-data
- data_y
numpy array The y-data
- description
string Description of the fitting problem
- end_x
float The end of the range to fit model data over (if different from entire range) (/float/)
- equation
string Equation (function or model) to fit against 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
- format
string Name of the problem definition type (e.g., ‘cutest’)
- function
Callable function
- get_function_params(params)
Return the function definition in a string format for output
- Parameters
params (list) – The parameters to use in the function string
- Returns
Representation of the function example format: ‘b1 * (b2+x) | b1=-2.0, b2=50.0’
- Return type
string
- hessian
Callable function for the Hessian
- ini_y(parameter_set=0)
Return the result of evaluating the problem at the initial parameters for plotting.
- Parameters
parameter_set (int, optional) – The initial parameters to use, defaults to 0
- Returns
The initial estimates
- Return type
numpy.ndarray
- jacobian
Callable function for the Jacobian
- multifit
bool Used to check if a problem is using multifit.
- multivariate
bool Whether the function has been wrapped to reduce the dimension of x on function calls
- name
string Name (title) of the fitting problem
- property param_names
Utility function to get the parameter names
- Returns
the names of the parameters
- Return type
list of str
- plot_scale
string The plot scale for the y and x data
- set_value_ranges(value_ranges)
Function to format parameter bounds before passing to controllers, so self.value_ranges is a list of tuples, which contain lower and upper bounds (lb,ub) for each parameter in the problem
- Parameters
value_ranges (dict) –
- dictionary of bounded parameter names with
lower and upper bound values e.g.
{p1_name: [p1_min, p1_max], ...}
- sorted_index
numpy array The index for sorting the data (used in plotting)
- start_x
float The start of the range to fit model data over (if different from entire range)
- starting_values: list
list of dict Starting values of the fitting parameters
e.g.
[{p1_name: p1_val1, p2_name: p2_val1, ...}, {p1_name: p1_val2, ...}, ...]
- value_ranges
list Smallest and largest values of interest in the data
e.g.
[(p1_min, p1_max), (p2_min, p2_max),...]
- verify()
Basic check that minimal set of attributes have been set.
Raise FittingProblemError if object is not properly initialised.
- fitbenchmarking.parsing.fitting_problem.correct_data(x, y, e, startx, endx, use_errors)
Strip data that overruns the start and end x_range, and approximate errors if not given.
- Parameters
x (np.array) – x data
y (np.array) – y data
e (np.array) – error data
startx (float) – minimum x value
endx (float) – maximum x value
use_errors (bool) – whether errors should be added if not present