This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Update initial assignment rules to remove order dependencies


[tfUpdated, ruleChanges, newParameters, modelBackup] = updateInitialAssignments(model)



updateInitialAssignments(model) updates the active initial assignment rules in a SimBiology model to recover the same simulation results at time = 0, as in R2017a or earlier when the initial assignment rules were evaluated according to the order appeared in the model. As of R2017b, the order in which the initial assignment rules appear in the model has no effect on the simulation results. For details, see Evaluation Order of Rules.


[tfUpdated, ruleChanges, newParameters, modelBackup] = updateInitialAssignments(model) returns a boolean indicating whether the model is updated, tfUpdated, a table of changes made to the rules, ruleChanges, a vector of newly added parameters, newParameters, and a backup copy of the original model, appending the text " (copy)" to the original model name.


collapse all

Load a sample model.

sbioloadproject lotka

Show the list of species and their initial amounts.

   SimBiology Species Array

   Index:    Compartment:    Name:    InitialAmount:    InitialAmountUnits:
   1         unnamed         x        1                 
   2         unnamed         y1       900               
   3         unnamed         y2       900               
   4         unnamed         z        0                 

Add two initial assignment rules that can result in different outcomes depending on the order of the rules that appear in the model.

addrule(m1,'x = z','initialAssignment');
addrule(m1,'z = 100','initialAssignment');

Display the rules.

   SimBiology Rule Array

   Index:    RuleType:            Rule:
   1         initialAssignment    x = z
   2         initialAssignment    z = 100

Remove the rule order dependencies from the model. tf is a boolean indicating whether the model was updated, ruleChanges is a summary table of changes made to the rules, and newParas is a vector of newly added parameter objects. backup is the copy of the original (unchanged) model.

[tf,ruleChanges,newParas,backup] = updateInitialAssignments(m1)
tf =



ruleChanges =

  1x3 table

         UpdatedRule         OldAssignment    NewAssignment
    _____________________    _____________    _____________

    [1x1 SimBiology.Rule]    "x = z"          "x = z0"     

   SimBiology Parameter Array

   Index:    Name:    Value:    ValueUnits:
   1         z0       0         

   SimBiology Model - lotka (copy) 

   Model Components:
     Compartments:      1
     Events:            0
     Parameters:        3
     Reactions:         3
     Rules:             2
     Species:           4

In order to remove order dependencies, SimBiology updated the initial assignment expression x = z to x = z0, where z0 is a newly added parameter.

Input Arguments

collapse all

SimBiology model, specified as a model object.

Example: m1

Output Arguments

collapse all

Whether the model is updated, returned as true or false.

Table of changes made to initial assignment rules, returned as a table with one row per rule. The table contains the following columns.

UpdatedRuleVector of the updated rule objects in the model.
OldAssignmentString vector of the original Rule property values in the model.
NewAssignmentString vector of the new Rule property values in the model.

Newly added parameters, returned as a vector of parameter objects that are referenced in the updated rules.

Backup copy of the original model, returned as a model object.

Introduced in R2017b

Was this topic helpful?