libSBML C API  5.18.0
Constraint_t Class Reference

Detailed Description

An SBML constraint, for stating validity assumptions.

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.

Semantics of Constraints

In the context of a simulation, a Constraint_t has effect at all times t $\geq$ 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.

Examples:
printAnnotation.c, printNotes.c, unsetAnnotation.c, and unsetNotes.c.

Public Member Functions

Constraint_tConstraint_clone (const Constraint_t *c)
 Creates and returns a deep copy of the given Constraint_t structure. More...
 
Constraint_tConstraint_create (unsigned int level, unsigned int version)
 Creates a new Constraint_t structure using the given SBML level and version values. More...
 
Constraint_tConstraint_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_tConstraint_getMath (const Constraint_t *c)
 Get the mathematical expression of this Constraint_t. More...
 
const XMLNode_tConstraint_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_tConstraint_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...
 

Member Function Documentation

Constraint_t * Constraint_clone ( const Constraint_t c)

Creates and returns a deep copy of the given Constraint_t structure.

Parameters
cthe Constraint_t structure to copy.
Returns
a (deep) copy of Constraint_t.
Constraint_t * Constraint_create ( unsigned int  level,
unsigned int  version 
)

Creates a new Constraint_t structure using the given SBML level and version values.

Parameters
levelan unsigned int, the SBML Level to assign to this Constraint_t.
versionan unsigned int, the SBML Version to assign to this Constraint_t.
Returns
a pointer to the newly created Constraint_t structure.
Note
Attempting to add an object to an SBMLDocument_t having a different combination of SBML Level, Version and XML namespaces than the object itself will result in an error at the time a caller attempts to make the addition. A parent object must have compatible Level, Version and XML namespaces. (Strictly speaking, a parent may also have more XML namespaces than a child, but the reverse is not permitted.) The restriction is necessary to ensure that an SBML model has a consistent overall structure. This requires callers to manage their objects carefully, but the benefit is increased flexibility in how models can be created by permitting callers to create objects bottom-up if desired. In situations where objects are not yet attached to parents (e.g., SBMLDocument_t), knowledge of the intented SBML Level and Version help libSBML determine such things as whether it is valid to assign a particular value to an attribute.
Constraint_t * Constraint_createWithNS ( SBMLNamespaces_t sbmlns)

Creates a new Constraint_t structure using the given SBMLNamespaces_t structure.

Parameters
sbmlnsSBMLNamespaces_t, a pointer to an SBMLNamespaces_t structure to assign to this Constraint_t.
Returns
a pointer to the newly created Constraint_t structure.
Note
Attempting to add an object to an SBMLDocument_t having a different combination of SBML Level, Version and XML namespaces than the object itself will result in an error at the time a caller attempts to make the addition. A parent object must have compatible Level, Version and XML namespaces. (Strictly speaking, a parent may also have more XML namespaces than a child, but the reverse is not permitted.) The restriction is necessary to ensure that an SBML model has a consistent overall structure. This requires callers to manage their objects carefully, but the benefit is increased flexibility in how models can be created by permitting callers to create objects bottom-up if desired. In situations where objects are not yet attached to parents (e.g., SBMLDocument_t), knowledge of the intented SBML Level and Version help libSBML determine such things as whether it is valid to assign a particular value to an attribute.
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.

Parameters
cthe Constraint_t structure.
Returns
the math for this Constraint_t, as an ASTNode_t.
const XMLNode_t * Constraint_getMessage ( const Constraint_t c)

Get the message, if any, associated with this Constraint_t.

Parameters
cthe Constraint_t structure.
Returns
the message for this Constraint_t, as an XMLNode_t.
char * Constraint_getMessageString ( const Constraint_t c)

Get the message string, if any, associated with this Constraint_t.

Parameters
cthe Constraint_t structure.
Returns
the message for this Constraint_t, as a string (char*). NULL is returned if the message is not set.
Note
returned char* should be freed with safe_free() by the caller.
const XMLNamespaces_t * Constraint_getNamespaces ( Constraint_t c)

Returns a list of XMLNamespaces_t associated with this Constraint_t structure.

Parameters
cthe Constraint_t structure.
Returns
pointer to the XMLNamespaces_t structure associated with this 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.

Parameters
cthe Constraint_t structure.
Returns
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.

Parameters
cthe Constraint_t structure.
Returns
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.

Parameters
cthe Constraint_t structure.
mathan ASTNode_t expression to be assigned as the "math" subelement of this Constraint_t.
Returns
integer value indicating success/failure of the function. The value is drawn from the enumeration OperationReturnValues_t. The possible values returned by this function are:
int Constraint_setMessage ( Constraint_t c,
const XMLNode_t xhtml 
)

Sets the message of this Constraint_t.

Parameters
cthe Constraint_t structure.
xhtmlan XML tree containing XHTML content.
Returns
integer value indicating success/failure of the function. The value is drawn from the enumeration OperationReturnValues_t. The possible values returned by this function are:
int Constraint_unsetMessage ( Constraint_t c)

Unsets the "message" subelement of this Constraint_t.

Parameters
cthe Constraint_t structure.
Returns
integer value indicating success/failure of the function. The value is drawn from the enumeration OperationReturnValues_t. The possible values returned by this function are: