Main Content


Update initial assignment rules to remove order dependencies



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.

ans = 
   SimBiology Species Array

   Index:    Compartment:    Name:    Value:    Units:
   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.

ans = 
   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 = logical

ruleChanges=1×3 table
        UpdatedRule        OldAssignment    NewAssignment
    ___________________    _____________    _____________

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

newParas = 
   SimBiology Parameter Array

   Index:    Name:    Value:    Units:
   1         z0       0               

backup = 
   SimBiology Model - lotka (copy) 

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

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.

Version History

Introduced in R2017b