sme_contrib.optimize.SteadyState
- class sme_contrib.optimize.SteadyState(modelfile, imagefile, species, function_to_apply_params, lower_bounds, upper_bounds, simulation_time=1000, steady_state_time=200, timeout_seconds=10)
Steady state parameter fitting
Given a model and an image of the target steady state distribution of a species (or the sum of multiple species), this class tries to find a set of parameters where the simulated model has a steady state solution that is as close as possible to the target image.
- Parameters
modelfile (str) – The sbml file containing the model
imagefile (str) – The image file containing the target concentration Optionally this can instead be a dict of geometryimagefilename:targetconcentrationfilename, in which case the model is simultaneously fitted to the target concentration image steady state for each geometry image.
species (List of str) – The species to compare to the target concentration
function_to_apply_params – A function that sets the parameters in the model. This should be a function with signature
f(model, params)
, and which sets the value of the parameters to be fitted inmodel
according to the values inparams
, which will be a list of floats.lower_bounds (List of float) – The lower bound for each parameter to be fitted
upper_bounds (List of float) – The upper bound for each parameter to be fitted
simulation_time (float) – The length of time to simulate the model
steady_state_time (float) – The length of time to multiply the final rate of change of concentration. The cost function that is minimized is the sum of squares over all pixels of the difference between the final concentration and the target concentration, plus the sum of squares over all pixels of the difference between
steady_state_time
* dc/dt and zero. Multiplying the rate of change by a time makes the second term have the same units as the first term, and the relative importance of being close to steady state versus close to the desired concentration in the fit can be adjusted by alteringsteady_state_time
. The larger it is, the closer the results will be to a steady state.
- params
The best model parameters found
- Type
numpy.array
- cost_history
The history of the best cost at each iteration
- Type
List of float
- cost_history_pbest
The history of the mean particle best at each iteration
- Type
List of float
Methods
__init__
(modelfile, imagefile, species, ...)find
([particles, iterations, processes])Find parameters that result in a steady state concentration close to the target image
Returns the model with best parameters applied
hessian
([rel_eps, processes])plot_all
([cmap])Generate all plots
plot_cost_history
([ax])Plot the cost history
plot_cost_history_pbest
([ax])Plot the mean particle best cost history
plot_model_concentration
([index, ax, cmap])Plot the model concentration as a 2d heat map
plot_target_concentration
([index, ax, cmap])Plot the target concentration as a 2d heat map
plot_timeseries
(simulation_time, ...[, ax])Plot a timeseries of the sum of concentrations