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.

  • 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 in model according to the values in params, 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 altering steady_state_time. The larger it is, the closer the results will be to a steady state.


The best model parameters found




The history of the best cost at each iteration


List of float


The history of the mean particle best at each iteration


List of float


__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])


Generate all plots


Plot the cost history


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