Skip to content

Latest commit

 

History

History
599 lines (369 loc) · 17.9 KB

Settings_file.rst

File metadata and controls

599 lines (369 loc) · 17.9 KB

.. _stg: .. _f_settings:

Settings file

A place for the user to define all the relevant properties of model simulation that are not stored in SBtab. This are usually things that need to change during optimizations or model development.
These settings files can be found can be found on the respective model repository in the directory "Matlab/Settings", in the example model from our main repository in the directory "Matlab/model/Model_Example/Matlab/Settings", or by following these links:
.. toggle-header::
    :header: **Default settings code**

    .. literalinclude:: ../Matlab/Code/default_settings.m
       :linenos:
       :language: matlab

.. toggle-header::
    :header: **Example settings code**

    .. literalinclude:: ../Matlab/Model/Model_Example/Matlab/Settings/Example_model.m
       :linenos:
       :language: matlab

Import

.. toggle-header::
    :header: **Default settings code**

    .. literalinclude:: ../Matlab/Code/default_settings.m
       :linenos:
       :language: MATLAB
       :start-after: %% Import
       :end-before: %% Analysis

.. toggle-header::
    :header: **Example settings code**

    .. literalinclude:: ../Matlab/Model/Model_Example/Matlab/Settings/Example_model.m
       :linenos:
       :language: MATLAB
       :start-after: %% Import
       :end-before: %% Analysis

  • stg.import - (logical) Decide whether to run import functions
  • stg.sbtab_excel_name - (string) Name of the Excel file with the SBtab
  • stg.name - (string) Name of the model
  • stg.cname - (string) Name of the default model compartment
  • stg.sbtab_name - (string) Name of the SBtab saved in .mat format

Analysis

.. toggle-header::
    :header: **Default settings code**

    .. literalinclude:: ../Matlab/Code/default_settings.m
       :linenos:
       :language: MATLAB
       :start-after: %% Analysis
       :end-before: %% Simulation

.. toggle-header::
    :header: **Example settings code**

    .. literalinclude:: ../Matlab/Model/Model_Example/Matlab/Settings/Example_model.m
       :linenos:
       :language: MATLAB
       :start-after: %% Analysis
       :end-before: %% Simulation

  • stg.exprun - (double) Experiments to run
  • stg.useLog - (double) Choice between 0,1,2 and 3 to change either and how to apply log10 to the scores, check :ref:`results<rst>`:
  • stg.optmc - (logical) Decide whether to use multicore everywhere it is available
  • stg.rseed - (double) Choice of random seed
  • stg.simcsl - (logical) Decide whether to display simulation diagnostics in the console
  • stg.optcsl - (logical) Decide whether to display optimization results on console
  • stg.save_results - (logical) Decide whether to save results
  • stg.simdetail - (logical) Decide whether to run detailed simulation for plots

Simulation

.. toggle-header::
    :header: **Default settings code**

    .. literalinclude:: ../Matlab/Code/default_settings.m
       :linenos:
       :language: MATLAB
       :start-after: %% Simulation
       :end-before: %% Model

.. toggle-header::
    :header: **Example settings code**

    .. literalinclude:: ../Matlab/Model/Model_Example/Matlab/Settings/Example_model.m
       :linenos:
       :language: MATLAB
       :start-after: %% Simulation
       :end-before: %% Model

  • stg.maxt - (double) Maximum time for each individual function has to run in seconds
  • stg.eqt - (double) Equilibration time in seconds
  • stg.dimenanal - (logical) Decide whether to do Dimensional Analysis
  • stg.UnitConversion - (logical) Decide whether to do Unit conversion
  • stg.abstolscale - (logical) Decide whether to do Absolute Tolerance Scaling
  • stg.reltol - (double) Value of Relative tolerance
  • stg.abstol - (double) Value of Absolute tolerance
  • stg.simtime - (string) Time units for simulation
  • stg.sbioacc - (logical) Decide whether to run sbioaccelerate (after changing this value you need to run “clear functions” to see an effect)
  • stg.abstolstepsize_eq - (double) Absolute tolerance step size for equilibration (if empty MATLAB|Reg| decides whats best)
  • stg.maxstep - (double) Max step size in the simulation (if empty MATLAB|Reg| decides what's best)
  • stg.maxstepeq - (double) Max step size in the equilibration (if empty MATLAB|Reg| decides whats best)
  • stg.maxstepdetail - (double) Max step size in the detailed plots (if empty MATLAB|Reg| decides whats best)
  • stg.errorscore - (double) Default score when there is a simulation error, this is needed to keep the optimizations working.

Model

.. toggle-header::
    :header: **Default settings code**

    .. literalinclude:: ../Matlab/Code/default_settings.m
       :linenos:
       :language: MATLAB
       :start-after: %% Model
       :end-before: %% Diagnostics

.. toggle-header::
    :header: **Example settings code**

    .. literalinclude:: ../Matlab/Model/Model_Example/Matlab/Settings/Example_model.m
       :linenos:
       :language: MATLAB
       :start-after: %% Model
       :end-before: %% Diagnostics

  • stg.parnum - (double) Number of parameters to optimize

  • stg.tci - (double) Index for the parameters that have thermodynamic constraints

  • stg.tcm - (double) Parameters to multiply to the first parameter (in stg.partest to get to the correct thermodynamic constraint formula)

  • stg.tcd - (double) Parameters to divide to the first parameter (in stg.partest to get to the correct thermodynamic constraint formula)

  • stg.lb - (double) Lower bound of all parameters

    stg.lb = \begin{bmatrix}
            lb_{1} & lb_{2} & ... & lb_{i}
        \end{bmatrix}
    
    • i = Parameter index
  • stg.ub - (double) Upper bound of all parameters

    stg.up = \begin{bmatrix}
            ub_{1} & ub_{2} & ... & ub_{i}
        \end{bmatrix}
    
    • i = Parameter index

Diagnostics

.. toggle-header::
    :header: **Default settings code**

    .. literalinclude:: ../Matlab/Code/default_settings.m
       :linenos:
       :language: MATLAB
       :start-after: %% Diagnostics
       :end-before: %% Plots

.. toggle-header::
    :header: **Example settings code**

    .. literalinclude:: ../Matlab/Model/Model_Example/Matlab/Settings/Example_model.m
       :linenos:
       :language: MATLAB
       :start-after: %% Diagnostics
       :end-before: %% Plots

  • stg.partest - (double) Choice of which parameters to work on, since depending on the task, not all SBtab parameters are worked on. k indices correspond to the parameters in the SBtab and numbers up to i correspond to the parameters in the work set. This is the set that actually gets used for diagnostics, optimization, and sensitivity analyis.

    stg.partest_k = \begin{bmatrix}
            1_{k_1} & 2_{k_2} & ... & i_{k_{end}}
        \end{bmatrix}
    

    In our example model parameter 216 from the SBtab is parameter number 1 of the work set, parameter 217 from the SBtab is parameter number 2 of the work set, and successively.

    stg.partest_{[216:227]} = \begin{bmatrix}
            1_{216} & 2_{217} & ... & 6_{221} & 1_{222} & 2_{223} & ... & 6_{227}
        \end{bmatrix}
    
  • stg.pat - (double) Index(j) of the parameter set to work on

  • stg.pa - (double) All the parameter sets

    stg.pa = \begin{bmatrix}
            x_{1,1} & x_{2,1} & ... & x_{i,1} \\
                        x_{1,2} & x_{2,2} & ... & x_{i,2} \\
                        ... & ... & ... & ... \\
                        x_{1,j} & x_{2,j} & ... & x_{i,j}
        \end{bmatrix}
    
  • stg.bestpa - (double) Best parameter set found so far during optimization

    stg.bestx = \begin{bmatrix}
            bestx_{1} & bestx_{2} & ... & bestx_{i}
        \end{bmatrix}
    
    • x = Parameters being worked on
    • i = Index of Parameters being worked on
    • k = Index of the parameters in SBtab
    • j = Index of the Parameter set to work on

Plots

.. toggle-header::
    :header: **Default settings code**

    .. literalinclude:: ../Matlab/Code/default_settings.m
       :linenos:
       :language: MATLAB
       :start-after: %% Plots
       :end-before: %% Sensitivity analysis

.. toggle-header::
    :header: **Example settings code**

    .. literalinclude:: ../Matlab/Model/Model_Example/Matlab/Settings/Example_model.m
       :linenos:
       :language: MATLAB
       :start-after: %% Plots
       :end-before: %% Sensitivity analysis

  • stg.plot - (logical) Decide whether to plot results
  • stg.plotoln - (logical) Decide whether to use long names in the title of the output plots in f_plot_outputs.m

Global Sensitivity Analysis (GSA)

.. toggle-header::
    :header: **Default settings code**

    .. literalinclude:: ../Matlab/Code/default_settings.m
       :linenos:
       :language: MATLAB
       :start-after: %% Sensitivity analysis
       :end-before: %% Optimization

.. toggle-header::
    :header: **Example settings code**

    .. literalinclude:: ../Matlab/Model/Model_Example/Matlab/Settings/Example_model.m
       :linenos:
       :language: MATLAB
       :start-after: %% Sensitivity analysis
       :end-before: %% Optimization

  • stg.sansamples - (double) Number of samples to use in GSA (in total (2+npars)*sansamples simulations will be performed, where npars are the number of parameters).
  • stg.sasubmean - (logical) Decide whether to subtract mean before calculating :ref:`SI<rst.SA.SI>` and :ref:`STI<rst.SA.STI>`, see Halnes et al 2009.
  • stg.sasamplemode - (double) Choose the way you want to obtain the samples of the parameters for performing the GSA;
  1. Reciprocal (log uniform) distribution

X_{i} \sim Reciprocal(a_{i},b_{i})

  • i = Parameter index
  • a_{i} = stg.lb_{i}
  • b_{i} = stg.ub_{i}
.. toggle-header::
     :header: Example distribution with :math:`a = -1, b = 1`

      .. image:: ../Docs/Images/SA_Dist_1.png

  1. Log normal distribution with μ corresponding to the best value for a parameter, as recieved from the optimization, and σ as :ref:`stg.sasamplesigma<stg.sasamplesigma>` truncated at the parameter bounds

X_{i} \sim TruncatedLogNormal(\mu _{i}, \sigma , a_{i}, b_{i})

  • i = Parameter index
  • \mu _{i} = bestx_{i}
  • \sigma = stg.sasamplesigma
  • a_{i} = stg.lb_{i}
  • b_{i} = stg.ub_{i}
.. toggle-header::
     :header: Example distribution with :math:`μ = 0.5, σ = 1, a = -1, b = 1`

      .. image:: ../Docs/Images/SA_Dist_2.png

  1. same as 1 without truncation

X_{i} \sim LogNormal(\mu , \sigma )

  • i = Parameter index
  • \mu _{i} = bestx_{i}
  • \sigma = stg.sasamplesigma
.. toggle-header::
     :header: Example distribution with :math:`μ = 0.5, σ = 1`

      .. image:: ../Docs/Images/SA_Dist_3.png

  1. Log normal distribution with μ corresponding to the mean of the parameter bounds and σ as :ref:`stg.sasamplesigma<stg.sasamplesigma>` but truncated at the parameter bounds

X_{i} \sim TruncatedLogNormal(\mu _{i}, \sigma , a_{i}, b_{i})

  • i = Parameter index
  • \mu _{i} = \frac{stg.lb_{i} + (stg.ub_{i} - stg.lb_{i})}{2}
  • \sigma = stg.sasamplesigma
  • a_{i} = stg.lb_{i}
  • b_{i} = stg.ub_{i}
.. toggle-header::
     :header: Example distribution with :math:`μ = \frac{a+(b-a)}{2}, σ = 1, a = -1, b = 1`

      .. image:: ../Docs/Images/SA_Dist_4.png

  1. same as 3 without truncation.

X_{i} \sim LogNormal(mu_{i}, \sigma )

  • i = Parameter index
  • \mu _{i} = \frac{stg.lb_{i} + (stg.ub_{i} - stg.lb_{i})}{2}
  • \sigma = stg.sasamplesigma
.. toggle-header::
     :header: Example distribution with :math:`μ = \frac{a+(b-a)}{2}, σ = 1, a = -1, b = 1`

      .. image:: ../Docs/Images/SA_Dist_5.png

  • stg.sasamplesigma - (double) σ for creating the normal distribution of parameters to perform sensitivity analysis

Optimization

.. toggle-header::
    :header: **Default settings code**

    .. literalinclude:: ../Matlab/Code/default_settings.m
       :linenos:
       :language: MATLAB
       :start-after: %% Optimization

.. toggle-header::
    :header: **Example settings code**

    .. literalinclude:: ../Matlab/Model/Model_Example/Matlab/Settings/Example_model.m
       :linenos:
       :language: MATLAB
       :start-after: %% Optimization

  • stg.optt - (double) Time for the optimization in seconds (fmincon does not respect this time!!)
  • stg.popsize - (double) Population size (for the algorithms that use populations)
  • stg.osm - (double) optimization start method, choose between
    1. Get a random starting parameter set or group of starting parameter sets inside the bounds
    2. Get a random starting parameter set or group of starting parameter sets near the best parameter set
  • stg.dbpa - (double) Distance from best parameter set to be used in :ref:`stg.osm<stg.osm>` method 2
  • stg.mst - (logical) Decide whether to use one or multiple starting parameter sets for the optimization
  • stg.msts - (double) Number of starting parameter sets for the optimizations
  • stg.optplots - (logical) Decide whether to display optimiazation plots (They aren't ploted if running the code in multicore)
  • stg.fmincon - (logical) Decide whether to run fmincon (no gradient in our models so this doesn't work very well, does not respect :ref:`time set for the optimization<stg.optt>`!!)
  • stg.fm_options - (optim.options.Fmincon) Options for fmincon
  • stg.sa - (logical) Decide whether to run simulated annealing
  • stg.sa_options - (optim.options.SimulannealbndOptions) Options for simulated annealing
  • stg.psearch - (logical) Decide whether to run Pattern search
  • stg.psearch_options - (optim.options.PatternsearchOptions) Options for Pattern search
  • stg.ga - (logical) Decide whether to run Genetic algorithm
  • stg.ga_options - (optim.options.GaOptions) Options for Genetic algorithm
  • stg.pswarm - (logical) Decide whether to run Particle swarm
  • stg.pswarm_options - (optim.options.Particleswarm) Options for Particle swarm
  • stg.sopt - (logical) Decide whether to run Surrogate optimization
  • stg.sopt_options - (optim.options.Surrogateopt) Options for Surrogate optimization

Automatically generated at Import

  • stg.expn - (double) Total number of experiments stored in the SBtab
  • stg.outn - (double) Total number of experimental outputs specified in the SBtab

References

Halnes, G., Ulfhielm, E., Ljunggren, E.E., Kotaleski, J.H. and Rospars, J.P., 2009. Modelling and sensitivity analysis of the reactions involving receptor, G-protein and effector in vertebrate olfactory receptor neurons. Journal of Computational Neuroscience, 27(3), p.471.