Base Optimisation Problem

class pbparam.BaseOptimisationProblem(*args, cost_function=None, data=None, model=None, parameters=None, variables_to_fit=None, weights=None)[source]

Base optimisation problem class

This class provides a base for defining optimization problems and contains methods that should be overridden in subclasses to provide specific implementations.

This base class will always have the following properties, in subclasses they may be renamed to be more specific to the problem being solved but for internal use they will be renamed back to the generic names. Use in subclasses will use the generic names. Non generic names are for use in the constructor only as a communication to the user.

Parameters (required)

modelpybamm.Simulation (or pandas.DataFrame)

The object to be used in optimisation of simulation parameters.

datapandas.DataFrame

The experimental or reference data to be used in optimisation of simulation parameters.

Parameters (optional)

cost_functionpbparam.BaseCostFunction

Cost function class to be used in minimisation algorithm.

parametersdict

The parameters to be optimised. They should be provided as a dictionary where the keys are the names of the variables to be optimised and the values are a tuple with the initial guesses and the lower and upper bounds of the optimisation.

variables_to_fitstr or list of str

The variable or variables to optimise in the cost function.

weightsdict

The custom weights of individual variables. Default is 1 for all variables. It can be int or list of int that has same length with the data.

Properties (non user settable defined in constructor)

x0array-like

Initial guess for the optimization problem

boundstuple

bounds of the optimization problem

scalingsarray-like

scalings for the optimization problem

calculate_solution()[source]

Placeholder method for calculating the solution of the optimization problem

Subclasses will override this method to provide specific implementations

objective_function(x)[source]

Placeholder method for the objective function

Subclasses will override this method to provide specific implementations

Parameters:

x (array-like) – independent variable for the objective function

Returns:

the value of the objective function

Return type:

float

process_and_clean_data()[source]

Placeholder for data cleaning and preperation routines

This method should be overridden in subclasses to provide specific implementations.

setup_objective_function()[source]

Placeholder method for setting up the objective function

Subclasses will override this method to provide specific implementations

update_simulation_parameters(simulation)[source]

Update the simulation object with new parameter values