libSBML C API
5.18.0
|
The Constraint_t object class was introduced in SBML Level 2 Version 2 as a mechanism for stating the assumptions under which a model is designed to operate. The constraints are statements about permissible values of different quantities in a model. Constraints are not used to compute dynamical values for simulation or analysis, but rather, they serve an advisory role for simulation/analysis tools.
SBML's Constraint_t object class has one required attribute, "id", to give the parameter a unique identifier by which other parts of an SBML model definition can refer to it. A Constraint_t object can also have an optional "name" attribute of type string
. Identifiers and names must be used according to the guidelines described in the SBML specification (e.g., Section 3.3 in the Level 2 Version 4 specification).
Constraint_t has one subelement, "math", containing a MathML formula defining the condition of the constraint. This formula will return a Boolean value of true
when the model is a valid state. The formula can be an arbitrary expression referencing the variables and other entities in an SBML model. The evaluation of "math" and behavior of constraints are described in more detail below.
In SBML Level 2 and SBML Level 3 Version 1, the "math" subelement is required, and its formula must be a Boolean value. In SBML Level 3 Version 2, these restrictions were relaxed: the "math" subelement is optional, and numeric values are allowed in Boolean contexts (a '0' is interpreted as false
, and all other values are interpreted as true
). If a Constraint_t with no "math" is present in a Model_t, no restriction on the Model_t's behavior is implied or enforced.
A Constraint_t structure also has an optional subelement called "message". This can contain a message in XHTML format that may be displayed to the user when the condition of the formula in the "math" subelement evaluates to a value of false
. Software tools are not required to display the message, but it is recommended that they do so as a matter of best practice. The XHTML content within a "message" subelement must follow the same restrictions as for the "notes" element on SBase_t described in in the SBML Level 2 specification; please consult the SBML specification document corresponding to the SBML Level and Version of your model for more information about the requirements for "notes" content.
Constraint_t was introduced in SBML Level 2 Version 2. It is not available in earlier versions of Level 2 nor in any version of Level 1.
In the context of a simulation, a Constraint_t has effect at all times t 0. Each Constraint_t's "math" subelement is first evaluated after any InitialAssignment_t definitions in a model at t = 0 and can conceivably trigger at that point. (In other words, a simulation could fail a constraint immediately.)
Constraint_t structures cannot and should not be used to compute the dynamical behavior of a model as part of, for example, simulation. Constraints may be used as input to non-dynamical analysis, for instance by expressing flux constraints for flux balance analysis.
The results of a simulation of a model containing a constraint are invalid from any simulation time at and after a point when the function given by the "math" subelement returns a value of false
. Invalid simulation results do not make a prediction of the behavior of the biochemical reaction network represented by the model. The precise behavior of simulation tools is left undefined with respect to constraints. If invalid results are detected with respect to a given constraint, the "message" subelement may optionally be displayed to the user. The simulation tool may also halt the simulation or clearly delimit in output data the simulation time point at which the simulation results become invalid.
SBML does not impose restrictions on duplicate Constraint_t definitions or the order of evaluation of Constraint_t objects in a model. It is possible for a model to define multiple constraints all with the same mathematical expression. Since the failure of any constraint indicates that the model simulation has entered an invalid state, a system is not required to attempt to detect whether other constraints in the model have failed once any one constraint has failed.
Public Member Functions | |
Constraint_t * | Constraint_clone (const Constraint_t *c) |
Creates and returns a deep copy of the given Constraint_t structure. More... | |
Constraint_t * | Constraint_create (unsigned int level, unsigned int version) |
Creates a new Constraint_t structure using the given SBML level and version values. More... | |
Constraint_t * | Constraint_createWithNS (SBMLNamespaces_t *sbmlns) |
Creates a new Constraint_t structure using the given SBMLNamespaces_t structure. More... | |
void | Constraint_free (Constraint_t *c) |
Frees the given Constraint_t structure. More... | |
const ASTNode_t * | Constraint_getMath (const Constraint_t *c) |
Get the mathematical expression of this Constraint_t. More... | |
const XMLNode_t * | Constraint_getMessage (const Constraint_t *c) |
Get the message, if any, associated with this Constraint_t. More... | |
char * | Constraint_getMessageString (const Constraint_t *c) |
Get the message string, if any, associated with this Constraint_t. More... | |
const XMLNamespaces_t * | Constraint_getNamespaces (Constraint_t *c) |
Returns a list of XMLNamespaces_t associated with this Constraint_t structure. More... | |
int | Constraint_isSetMath (const Constraint_t *c) |
Predicate returning 1 (true) or 0 (false) depending on whether a mathematical formula is defined for this Constraint_t. More... | |
int | Constraint_isSetMessage (const Constraint_t *c) |
Predicate returning 1 (true) or 0 (false) depending on whether a message is defined for this Constraint_t. More... | |
int | Constraint_setMath (Constraint_t *c, const ASTNode_t *math) |
Sets the mathematical expression of this Constraint_t. More... | |
int | Constraint_setMessage (Constraint_t *c, const XMLNode_t *xhtml) |
Sets the message of this Constraint_t. More... | |
int | Constraint_unsetMessage (Constraint_t *c) |
Unsets the "message" subelement of this Constraint_t. More... | |
Constraint_t * Constraint_clone | ( | const Constraint_t * | c | ) |
Creates and returns a deep copy of the given Constraint_t structure.
c | the Constraint_t structure to copy. |
Constraint_t * Constraint_create | ( | unsigned int | level, |
unsigned int | version | ||
) |
Creates a new Constraint_t structure using the given SBML level
and version
values.
level | an unsigned int, the SBML Level to assign to this Constraint_t. |
version | an unsigned int, the SBML Version to assign to this Constraint_t. |
Constraint_t * Constraint_createWithNS | ( | SBMLNamespaces_t * | sbmlns | ) |
Creates a new Constraint_t structure using the given SBMLNamespaces_t structure.
sbmlns | SBMLNamespaces_t, a pointer to an SBMLNamespaces_t structure to assign to this Constraint_t. |
void Constraint_free | ( | Constraint_t * | c | ) |
Frees the given Constraint_t structure.
const ASTNode_t * Constraint_getMath | ( | const Constraint_t * | c | ) |
Get the mathematical expression of this Constraint_t.
c | the Constraint_t structure. |
const XMLNode_t * Constraint_getMessage | ( | const Constraint_t * | c | ) |
Get the message, if any, associated with this Constraint_t.
c | the Constraint_t structure. |
char * Constraint_getMessageString | ( | const Constraint_t * | c | ) |
Get the message string, if any, associated with this Constraint_t.
c | the Constraint_t structure. |
NULL
is returned if the message is not set.const XMLNamespaces_t * Constraint_getNamespaces | ( | Constraint_t * | c | ) |
Returns a list of XMLNamespaces_t associated with this Constraint_t structure.
c | the Constraint_t structure. |
int Constraint_isSetMath | ( | const Constraint_t * | c | ) |
Predicate returning 1
(true) or 0
(false) depending on whether a mathematical formula is defined for this Constraint_t.
c | the Constraint_t structure. |
1
(true) if the "math" subelement for this Constraint_t is set, 0
(false) otherwise. int Constraint_isSetMessage | ( | const Constraint_t * | c | ) |
Predicate returning 1
(true) or 0
(false) depending on whether a message is defined for this Constraint_t.
c | the Constraint_t structure. |
1
(true) if the "message" subelement for this Constraint_t is set, 0
(false) otherwise. int Constraint_setMath | ( | Constraint_t * | c, |
const ASTNode_t * | math | ||
) |
Sets the mathematical expression of this Constraint_t.
c | the Constraint_t structure. |
math | an ASTNode_t expression to be assigned as the "math" subelement of this Constraint_t. |
int Constraint_setMessage | ( | Constraint_t * | c, |
const XMLNode_t * | xhtml | ||
) |
Sets the message of this Constraint_t.
c | the Constraint_t structure. |
xhtml | an XML tree containing XHTML content. |
int Constraint_unsetMessage | ( | Constraint_t * | c | ) |
Unsets the "message" subelement of this Constraint_t.
c | the Constraint_t structure. |