libSBML C API  libSBML 5.8.0 C API
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
SBMLRuleConverter Class Reference

Detailed Description

SBML converter for reordering rules and assignments in a model.

This class of objects is defined by libSBML only and has no direct equivalent in terms of SBML components. It is a class used in the implementation of extra functionality provided by libSBML.

This converter reorders assignments in a model. Specifically, it sorts the list of assignment rules (i.e., the AssignmentRule objects contained in the ListOfAssignmentRules within the Model object) and the initial assignments (i.e., the InitialAssignment objects contained in the ListOfInitialAssignments) such that, within each set, assignments that depend on prior values are placed after the values are set. For example, if there is an assignment rule stating a = b + 1, and another rule stating b = 3, the list of rules is sorted and the rules are arranged so that the rule for b = 3 appears before the rule for a = b + 1. Similarly, if dependencies of this sort exist in the list of initial assignments in the model, the initial assignments are sorted as well.

Beginning with SBML Level 2, assignment rules have no ordering required—the order in which the rules appear in an SBML file has no significance. Software tools, however, may need to reorder assignments for purposes of evaluating them. For example, for simulators that use time integration methods, it would be a good idea to reorder assignment rules such as the following,

b = a + 10 seconds
a = time

so that the evaluation of the rules is independent of integrator step sizes. (This is due to the fact that, in this case, the order in which the rules are evaluated changes the result.) This converter can be used to reorder the SBML objects regardless of whether the input file contained them in the desired order. Here is a code fragment to illustrate how to do that:

ConversionProperties props;
props.addOption("sortRules", true, "sort rules");

SBMLConverter converter;
converter.setProperties(&props);
converter.setDocument(&doc);
converter.convert(); 
Note
The two sets of assignments (list of assignment rules on the one hand, and list of initial assignments on the other hand) are handled independently. In an SBML model, these entities are treated differently and no amount of sorting can deal with inter-dependencies between assignments of the two kinds.
See Also
SBMLFunctionDefinitionConverter
SBMLInitialAssignmentConverter
SBMLLevelVersionConverter
SBMLStripPackageConverter
SBMLUnitsConverter