dinjo.optimizer module¶
- class dinjo.optimizer.Optimizer(model: dinjo.model.ModelIVP, reference_state_variable: dinjo.model.StateVariable, reference_values: List[float], reference_t_values: List[float], integration_method: str = 'RK45')[source]¶
Bases:
objectOptimizes the initial value problem’s parameters, as defined in the class
ModelIVP.- model¶
the initial value problem to be optimized.
- Type
ModelIVP
- reference_state_variable :class:`StateVariable`
the state variable to be fitted to the solution of the IVP.
- reference_values¶
the ‘experimental data’ of the reference state variable to be used as the fitting variable.
- Type
list[float]
- reference_t_values¶
the corresponding times at which the reference_values are given.
- Type
list[float]
- integration_method¶
must be one of the methods accepted by
scipy.integrate.solve_ivp.- Type
str
- __init__(model: dinjo.model.ModelIVP, reference_state_variable: dinjo.model.StateVariable, reference_values: List[float], reference_t_values: List[float], integration_method: str = 'RK45') → None[source]¶
Initialize self. See help(type(self)) for accurate signature.
- cost_function(parameters: List[float], cost_method: str = 'root_mean_square')[source]¶
Function to be minimized by the optimizer. Initially this will be the root mean square of the difference between the observations and the numerical solution.
- Parameters
parameters (list[float]) – parameters of the model to be minimized. The order of the parameters must be the same as they appear in
self.model.parameters.cost_method (str) – Must be one of
['root_mean_square',].
- optimize(cost_method: str = 'root_mean_square', algorithm: str = 'differential_evolution', algorithm_kwargs: Dict[str, Any] = {}) → scipy.optimize.optimize.OptimizeResult[source]¶
Global minimization of cost function.
- Parameters
cost_function_method (str) – Must be one of the permitted values for cost_method parameter in
Optimize.cost_function().algorithm (str) – scipy.optimize algorithm used for the optimization. Must be one of
'differential_evolution','shgo','dual_annealing'.algorithm_kwargs (dict[str, any]) – parameters passed to the optimization algorithm. They are different depending on the algorithm.
- Returns
object containing the minimization result as returned by the appropiate scipy algorithm (e.g. if the chosen al).
- Return type
minimization
- property reference_t_values¶