libSBML C API  5.18.0
Trigger_t Class Reference

Detailed Description

The trigger expression for an SBML event.

An Event_t object defines when the event can occur, the variables that are affected by the event, and how the variables are affected. The Trigger_t construct in SBML is used to define a mathematical expression that determines when an Event_t is triggered.

A Trigger_t object in SBML Level 2 and Level 3 contains one subelement named "math" containing a MathML expression. The expression is evaluated as a value of type boolean. The exact moment at which the expression evaluates to true is the time point when the Event_t is triggered. In SBML Level 3, Trigger_t has additional attributes that must be assigned values; they are discussed in a separate section below.

In SBML Level 2 and SBML Level 3 Version 1, the "math" subelement is required, and it must evaluate to a boolean expression. In SBML Level 3 Version 2, those restrictions are relaxed: the "math" element 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 Trigger_t with no "math" is present in an Event_t, that Event_t will never trigger, unless that missing information is included in an SBML Level 3 package.

An event only triggers when its Trigger_t expression makes the transition in value from false to true. The event will also trigger at any subsequent time points when the trigger makes this transition; in other words, an event can be triggered multiple times during a simulation if its trigger condition makes the transition from false to true more than once. In SBML Level 3, the behavior at the very start of simulation (i.e., at t = 0, where t stands for time) is determined in part by the boolean flag "initialValue". This and other additional features introduced in SBML Level 3 are discussed further below.

Version differences

SBML Level 3 Version 1 introduces two required attributes on the Trigger_t object: "persistent" and "initialValue". The rest of this introduction describes these two attributes.

The "persistent" attribute on Trigger_t

In the interval between when an Event_t object triggers (i.e., its Trigger_t object expression transitions in value from false to true) and when its assignments are to be executed, conditions in the model may change such that the trigger expression transitions back from true to false. Should the event's assignments still be made if this happens? Answering this question is the purpose of the "persistent" attribute on Trigger_t.

If the boolean attribute "persistent" has a value of true, then once the event is triggered, all of its assignments are always performed when the time of execution is reached. The name persistent is meant to evoke the idea that the trigger expression does not have to be re-checked after it triggers if "persistent"=true. Conversely, if the attribute value is false, then the trigger expression is not assumed to persist: if the expression transitions in value back to false at any time between when the event triggered and when it is to be executed, the event is no longer considered to have triggered and its assignments are not executed. (If the trigger expression transitions once more to true after that point, then the event is triggered, but this then constitutes a whole new event trigger-and-execute sequence.)

The "persistent" attribute can be especially useful when Event_t objects contain Delay_t objects, but it is relevant even in a model without delays if the model contains two or more events. As explained in the introduction to this section, the operation of all events in SBML (delayed or not) is conceptually divided into two phases, triggering and execution; however, unless events have priorities associated with them, SBML does not mandate a particular ordering of event execution in the case of simultaneous events. Models with multiple events can lead to situations where the execution of one event affects another event's trigger expression value. If that other event has "persistent"=false, and its trigger expression evaluates to false before it is to be executed, the event must not be executed after all.

The "initialValue" attribute on Trigger_t

As mentioned above, an event triggers when the mathematical expression in its Trigger_t object transitions in value from false to true. An unanswered question concerns what happens at the start of a simulation: can event triggers make this transition at t = 0, where t stands for time?

In order to determine whether an event may trigger at t = 0, it is necessary to know what value the Trigger_t object's "math" expression had immediately prior to t = 0. This starting value of the trigger expression is determined by the value of the boolean attribute "initialValue". A value of true means the trigger expression is taken to have the value true immediately prior to t = 0. In that case, the trigger cannot transition in value from false to true at the moment simulation begins (because it has the value true both before and after t = 0), and can only make the transition from false to true sometime after t = 0. (To do that, it would also first have to transition to false before it could make the transition from false back to true.) Conversely, if "initialValue"=false, then the trigger expression is assumed to start with the value false, and therefore may trigger at t = 0 if the expression evaluates to true at that moment.

See also
Event_t
Delay_t
EventAssignment_t
Examples:
printAnnotation.c, printMath.c, and printNotes.c.

Public Member Functions

Trigger_tTrigger_clone (const Trigger_t *t)
 
Trigger_tTrigger_create (unsigned int level, unsigned int version)
 Creates a new Trigger_t structure using the given SBML level and version values. More...
 
Trigger_tTrigger_createWithNS (SBMLNamespaces_t *sbmlns)
 Creates a new Trigger_t structure using the given SBMLNamespaces_t structure. More...
 
void Trigger_free (Trigger_t *t)
 Frees the given Trigger_t. More...
 
int Trigger_getInitialValue (const Trigger_t *t)
 Get the value of the "initialValue" attribute of this Trigger_t. More...
 
const ASTNode_tTrigger_getMath (const Trigger_t *t)
 
const XMLNamespaces_tTrigger_getNamespaces (Trigger_t *t)
 Returns a list of XMLNamespaces_t associated with this Trigger_t structure. More...
 
int Trigger_getPersistent (const Trigger_t *t)
 Get the value of the "persistent" attribute of this Trigger_t. More...
 
int Trigger_hasRequiredAttributes (Trigger_t *t)
 Predicate returning true or false depending on whether all the required attributes for this Trigger_t structure have been set. More...
 
int Trigger_hasRequiredElements (Trigger_t *t)
 Predicate returning true or false depending on whether all the required elements for this Trigger_t structure have been set. More...
 
int Trigger_isSetInitialValue (const Trigger_t *t)
 Return true if the "initialValue" attribute of this Trigger_t is set. More...
 
int Trigger_isSetMath (const Trigger_t *t)
 
int Trigger_isSetPersistent (const Trigger_t *t)
 Return true if the "persistent" attribute of this Trigger_t is set. More...
 
int Trigger_setInitialValue (Trigger_t *t, int initialValue)
 Sets the "initialValue" attribute of this Trigger_t instance. More...
 
int Trigger_setMath (Trigger_t *t, const ASTNode_t *math)
 Sets the math of this Trigger_t to a copy of the given ASTNode_t. More...
 
int Trigger_setPersistent (Trigger_t *t, int persistent)
 Sets the "persistent" attribute of this Trigger_t instance. More...
 
int Trigger_unsetInitialValue (Trigger_t *t)
 Unsets the "initialValue" attribute of this Trigger_t instance. More...
 
int Trigger_unsetPersistent (Trigger_t *t)
 Unsets the "persistent" attribute of this Trigger_t instance. More...
 

Member Function Documentation

Trigger_t * Trigger_clone ( const Trigger_t t)
Returns
a (deep) copy of this Trigger_t.
Trigger_t * Trigger_create ( unsigned int  level,
unsigned int  version 
)

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

Parameters
levelan unsigned int, the SBML Level to assign to this Trigger_t.
versionan unsigned int, the SBML Version to assign to this Trigger_t.
Returns
a pointer to the newly created Trigger_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.
Trigger_t * Trigger_createWithNS ( SBMLNamespaces_t sbmlns)

Creates a new Trigger_t structure using the given SBMLNamespaces_t structure.

Parameters
sbmlnsSBMLNamespaces_t, a pointer to an SBMLNamespaces_t structure to assign to this Trigger_t.
Returns
a pointer to the newly created Trigger_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 Trigger_free ( Trigger_t t)

Frees the given Trigger_t.

int Trigger_getInitialValue ( const Trigger_t t)

Get the value of the "initialValue" attribute of this Trigger_t.

Parameters
tthe Trigger_t structure.
Returns
the "initialValue" attribute value in this Trigger_t.
const ASTNode_t * Trigger_getMath ( const Trigger_t t)
Returns
the math of this Trigger_t.
Examples:
printMath.c.
const XMLNamespaces_t * Trigger_getNamespaces ( Trigger_t t)

Returns a list of XMLNamespaces_t associated with this Trigger_t structure.

Parameters
tthe Trigger_t structure.
Returns
pointer to the XMLNamespaces_t structure associated with this structure
int Trigger_getPersistent ( const Trigger_t t)

Get the value of the "persistent" attribute of this Trigger_t.

Parameters
tthe Trigger_t structure.
Returns
the "persistent" attribute value in this Trigger_t.
int Trigger_hasRequiredAttributes ( Trigger_t t)

Predicate returning true or false depending on whether all the required attributes for this Trigger_t structure have been set.

The required attributes for a Trigger_t structure are:

  • persistent ( L3 onwards )
  • initialValue ( L3 onwards )
int Trigger_hasRequiredElements ( Trigger_t t)

Predicate returning true or false depending on whether all the required elements for this Trigger_t structure have been set.

Note
The required elements for a Trigger_t structure are:
  • math
int Trigger_isSetInitialValue ( const Trigger_t t)

Return true if the "initialValue" attribute of this Trigger_t is set.

Parameters
tthe Trigger_t structure.
Returns
1 (true) if the "initialValue" attribute value in this Trigger_t is set, 0 (false) otherwise.
int Trigger_isSetMath ( const Trigger_t t)
Returns
1 (true) if the math (or equivalently the formula) of this Trigger_t is set, 0 (false) otherwise.
int Trigger_isSetPersistent ( const Trigger_t t)

Return true if the "persistent" attribute of this Trigger_t is set.

Parameters
tthe Trigger_t structure.
Returns
1 (true) if the "persisent" attribute value in this Trigger_t is set, 0 (false) otherwise.
int Trigger_setInitialValue ( Trigger_t t,
int  initialValue 
)

Sets the "initialValue" attribute of this Trigger_t instance.

Parameters
tthe Trigger_t structure.
initialValuean integer representing the initialValue to be set, with nonzero indicating true, and zero indicating false.
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 Trigger_setMath ( Trigger_t t,
const ASTNode_t math 
)

Sets the math of this Trigger_t to a copy of the given ASTNode_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 Trigger_setPersistent ( Trigger_t t,
int  persistent 
)

Sets the "persistent" attribute of this Trigger_t instance.

Parameters
tthe Trigger_t structure.
persistentan integer representing the initialValue to be set, with nonzero indicating true, and zero indicating false.
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 Trigger_unsetInitialValue ( Trigger_t t)

Unsets the "initialValue" attribute of this Trigger_t instance.

Parameters
tthe Trigger_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:
int Trigger_unsetPersistent ( Trigger_t t)

Unsets the "persistent" attribute of this Trigger_t instance.

Parameters
tthe Trigger_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: