fitbenchmarking.controllers.base_controller module¶
Implements the base class for the fitting software controllers.
-
class
fitbenchmarking.controllers.base_controller.
Controller
(problem)¶ Bases:
object
Base class for all fitting software controllers. These controllers are intended to be the only interface into the fitting software, and should do so by implementing the abstract classes defined here.
-
VALID_FLAGS
= [0, 1, 2, 3]¶
-
check_attributes
()¶ A helper function which checks all required attributes are set in software controllers
-
cleanup
()¶ Retrieve the result as a numpy array and store results.
Convert the fitted parameters into a numpy array, saved to
self.final_params
, and store the error flag asself.flag
.The flag corresponds to the following messages:
-
flag
() - 0: Successfully converged1: Software reported maximum number of iterations exceeded2: Software run but didn’t converge to solution3: Software raised an exception
-
-
eval_chisq
(params, x=None, y=None, e=None)¶ Computes the chisq value
Parameters: - params (list) – The parameters to calculate residuals for
- x (numpy array, optional) – x data points, defaults to self.data_x
- y (numpy array, optional) – y data points, defaults to self.data_y
- e (numpy array, optional) – error at each data point, defaults to self.data_e
Returns: The sum of squares of residuals for the datapoints at the given parameters
Return type: numpy array
-
fit
()¶ Run the fitting.
This will be timed so should include only what is needed to fit the data.
-
flag
¶ - 0: Successfully converged1: Software reported maximum number of iterations exceeded2: Software run but didn’t converge to solution3: Software raised an exception
-
prepare
()¶ Check that function and minimizer have been set. If both have been set, run self.setup().
-
setup
()¶ Setup the specifics of the fitting.
Anything needed for “fit” that can only be done after knowing the minimizer to use and the function to fit should be done here. Any variables needed should be saved to self (as class attributes).
-
validate_minimizer
(minimizer, algorithm_type)¶ Helper function which checks that the selected minimizer from the options (options.minimizer) exists and whether the minimizer is in self.algorithm_check[options.algorithm_type] (this is a list set in the controller)
Parameters: - minimizer (str) – string of minimizers selected from the options
- algorithm_type (str) – the algorithm type selected from the options
-