Skip to content

Applying the Benchmark Models using Matlab

Helge Hass edited this page Oct 29, 2018 · 11 revisions

One possibility for applying the presented benchmark models is based on Matlab without any modelling environment or toolbox. On this page we describe how the models can be used in the Matlab programming environment. Matlab code can also be found in 'Matlab_scripts/Example_SimulationWithMatlab.m'.

An alternative strategy based on Data2Dynamics (which also runs in Matlab) is decribed here.

Another alternative is using SBML (described here).

Loading the models in Matlab

The following functions are provided for loading models and data in Matlab:

  • ReadBenchmarks can be used for loading the whole benchmark model including all data sets. This function calls all three functions briefly described in the following.
  • ReadModelFiles only loads a model file as found in the folders
  • ReadInfoFiles only loads the model information as stored in
  • ReadDataFiles can be used to load specific data sets.

Example code

cd Benchmark-Models            % set working directory
addpath('../Matlab_scripts/')  % add matlab function in folder Matlab_scripts to search path
folder = 'Becker_Science2010'; % folder name of the model to be loaded
[Is,ms,ds] = ReadBenchmarks(folder)  % loading of general info in Is, models in variable ms, data sets in variable ds
m=ms(1);   % simulate 1st model 
d=ds(1);   % simulate for the 1st data set
ode_tolerances = 1e-6;
status = WriteMatlabODEs(Is,m,d,ode_tolerances);    % writing ODE_call.m and ODE_file.m 
ODE_call    % simulation and comparison with the reference simulation
who         % shows all variables which are created in ODE_call

After calling ODE_call all states and parameters are available as Matlab variables.

For further illustration please check the automatically generated code ODE_call. As example, we provide the ODE_call as generated for the Becker model [here|Matlab-Example-Becker].

Simulated data

In some circumstances it might be intended to use simulated data for benchmarking purposes instead of the experimental data. Simulated data can be generated via SimulateExpData, after calling ReadDataFiles. This function generates data points at the same observables and time points as in the original data set(s). Moreover, normally distributed measurement errors are simulated with the same standard deviation as specified model or in the respective original data. Example code

ds = SimulateExpData(ds,1); 
%second input is noise of simulated data in multiples of std.dev of the known (fitted) model uncertainty
%third input, if set, marks the randomseed

Spline inputs in the Swameye model

One benchmark model (Swameye et al.) requires an input function based on smoothing splines. We provide c functions spline.c and spline_pos5.c which can be found in folder 'Matlab_scripts' and can be compiled via mex spline.c and mex spline_pos5.c to guarantee that exactly the same spline functions are applied.

Remarks

Please note, that our Matlab tools only provide functionality for basic simulations of the models. This might be very helpful for testing correct implementations. However, please note that these tools do not provide advanced numerical or methodological functionalilty (like forward- or adjoint sensitivities) which is usually essential for high-performance analysis. The generated code is only based on Matlab's ode15s integrator which might generate numerically inaccurate solutions without any additional methodological considerations.