001/* ---------------------------------------------------------------------------- 002 * This file was automatically generated by SWIG (http://www.swig.org). 003 * Version 3.0.10 004 * 005 * Do not make changes to this file unless you know what you are doing--modify 006 * the SWIG interface file instead. 007 * ----------------------------------------------------------------------------- */ 008 009package org.sbml.libsbml; 010 011/** 012 * A discontinuous SBML <em>event</em>. 013 <p> 014 * An SBML {@link Event} object defines when the event can occur, the variables 015 * that are affected by it, how the variables are affected, and the event's 016 * relationship to other events. The effect of the event can optionally be 017 * delayed after the occurrence of the condition which invokes it. 018 <p> 019 * The operation of {@link Event} is divided into two phases (even when the event 020 * is not delayed): one when the event is <em>triggered</em>, and the other when 021 * the event is <em>executed</em>. {@link Trigger} objects define the conditions for 022 * triggering an event, {@link Delay} objects define when the event is actually 023 * executed, {@link EventAssignment} objects define the effects of executing the 024 * event, and (in SBML Level 3) {@link Priority} objects influence the order 025 * of {@link EventAssignment} performance in cases of simultaneous events. Please 026 * consult the descriptions of {@link Trigger}, {@link Delay}, {@link EventAssignment} and {@link Priority} 027 * for more information. 028 <p> 029 * <h2>SBML Level/Version differences</h2> 030 <p> 031 * <h3>SBML Level 3</h3> 032 <p> 033 * SBML Level 3 introduces several changes to the structure and components 034 * of Events compared to SBML Level 2. These changes fall into two 035 * main categories: changes to what is optional or required, and additions 036 * of new attributes and elements. 037 * <ul> 038 * <li> The attribute 'useValuesFromTriggerTime' on {@link Event} is mandatory (it 039 * was optional in Level 2); 040 * <li> {@link Event}'s 'listOfEventAssignments' element (of class 041 * {@link ListOfEventAssignments}) is optional (it was mandatory in Level 2); 042 * <li> {@link Event}'s 'priority' element (of class {@link Priority}) is new in 043 * Level 3; and 044 * <li> The {@link Trigger} object gains new mandatory attributes (described as part 045 * of the definition of {@link Trigger}). 046 * </ul> 047 <p> 048 * The changes to the attributes of {@link Event} are described below; the changes 049 * to {@link Trigger} and {@link Priority} are described in their respective sections. 050 <p> 051 * <h3>SBML Level 2</h3> 052 <p> 053 * In SBML Level 2 versions before Version 4, the semantics of 054 * {@link Event} time delays were defined such that the expressions in the event's 055 * assignments were always evaluated at the time the event was 056 * <em>triggered</em>. This definition made it difficult to define an event 057 * whose assignment formulas were meant to be evaluated at the time the 058 * event was <em>executed</em> (i.e., after the time period defined by the 059 * value of the {@link Delay} element). In SBML Level 2 Version 4 and in 060 * Level 3, the attribute 'useValuesFromTriggerTime' on {@link Event} allows a 061 * model to indicate the time at which the event's assignments are intended 062 * the values of the assignment formulas are computed at the moment the 063 * event is triggered, not after the delay. If 'useValuesFromTriggerTime'= 064 * <code>false</code>, it means that the formulas in the event's assignments are to be 065 * computed <em>after</em> the delay, at the time the event is executed. 066 <p> 067 * The definition of {@link Event} in SBML Level 2 Versions 1 and 2 includes 068 * an additional attribute called 'timeUnits', which allowed the time units 069 * of the {@link Delay} to be set explicitly. Later Versions of SBML Level 2 070 * as well as SBML Level 3 do not define this attribute. LibSBML 071 * supports this attribute for compatibility with previous versions of SBML 072 * Level 2; however, if a model in SBML Level 3 or Level 2 073 * Versions 3–4 format sets the attribute, the 074 * consistency-checking method {@link SBMLDocument#checkConsistency()} will report 075 * an error. 076 <p> 077 * The attribute 'useValuesFromTriggerTime' was introduced in SBML 078 * Level 2 Version 4. Models defined in prior Versions of SBML 079 * Level 2 cannot use this attribute, and 080 * {@link SBMLDocument#checkConsistency()} will report an error if they do. 081 <p> 082 * <h2>Semantics of events in SBML Level 3 Version 1</h2> 083 <p> 084 * The detailed semantics of events are described in the specification 085 * documents for each SBML Level/Version. Here we include the description 086 * from the SBML Level 1 Version 1. 087 * Any transition of a {@link Trigger} object's 'math' formula from the value 088 * <code>false</code> to <code>true</code> will cause the enclosing {@link Event} object to 089 * <em>trigger</em>. Such a transition is not possible at the very start 090 * of a simulation (i.e., at time <em>t = 0</em>) unless the {@link Trigger} 091 * object's 'initialValue' attribute has a value of <code>false</code>; this defines 092 * the value of the trigger formula to be <code>false</code> immediately prior to the 093 * start of simulation, thereby giving it the potential to change in value 094 * from <code>false</code> to <code>true</code> when the formula is evaluated at <em>t = 095 * 0</em>. If 'initialValue'=<code>true</code>, then the trigger expression cannot 096 * transition from <code>false</code> to <code>true</code> at <em>t = 0</em> but may do so at 097 * some time <em>t > 0</em>. 098 <p> 099 * Consider an {@link Event} object definition <EM>E</EM> with delay <em>d</em> in 100 * which the {@link Trigger} object's 'math' formula makes a transition in value 101 * from <code>false</code> to <code>true</code> at times <em>t<sub>1</sub></em> and 102 * <em>t<sub>2</sub></em>. The {@link EventAssignment} within the {@link Event} object 103 * will have effect at <em>t<sub>1</sub> + d</em> and 104 * <em>t<sub>2</sub> + d</em> irrespective of the relative times of 105 * <em>t<sub>1</sub></em> and <em>t<sub>2</sub></em>. For example, events 106 * can 'overlap' so that <em>t<sub>1</sub> < t<sub>2</sub> < 107 * t<sub>1</sub> + d</em> still causes an event assignments to occur at 108 * <em>t<sub>1</sub> + d</em> and <em>t<sub>2</sub> + d</em>. 109 <p> 110 * It is entirely possible for two events to be executed simultaneously, 111 * and it is possible for events to trigger other events (i.e., an event 112 * assignment can cause an event to trigger). This leads to several 113 * points: 114 * <ul> 115 <p> 116 * <li> A software package should retest all event triggers after executing 117 * an event assignment in order to account for the possibility that the 118 * assignment causes another event trigger to transition from <code>false</code> to 119 * <code>true.</code> This check should be made after each individual {@link Event} object's 120 * execution, even when several events are to be executed simultaneously. 121 <p> 122 * <li> Any {@link Event} object whose {@link Trigger} 'persistent' attribute has the value 123 * <code>false</code> must have its trigger expression reevaluated continuously 124 * between when the event is triggered and when it is executed. If 125 * its trigger expression ever evaluates to <code>false</code>, it must be removed 126 * from the queue of events pending execution and treated as any other 127 * event whose trigger expression evaluates to <code>false.</code> 128 <p> 129 * <li> Although the precise time at which events are executed is not 130 * resolved beyond the given execution point in simulated time, it is 131 * assumed that the order in which the events occur <em>is</em> resolved. 132 * This order can be significant in determining the overall outcome of a 133 * given simulation. When an event <EM>X</EM> <em>triggers</em> another 134 * event <EM>Y</EM> and event <EM>Y</EM> has zero delay, then event 135 * <EM>Y</EM> is added to the existing set of simultaneous events that are 136 * pending <em>execution</em>. Events <EM>X</EM> and <EM>Y</EM> form a 137 * cascade of events at the same point in simulation time. An event such 138 * as <EM>Y</EM> may have a special priority if it contains a {@link Priority} 139 * subobject. 140 <p> 141 * <li> All events in a model are open to being in a cascade. The position 142 * of an event in the event queue does not affect whether it can be in the 143 * cascade: event <EM>Y</EM> can be triggered whether it is before or after 144 * <EM>X</EM> in the queue of events pending execution. A cascade of 145 * events can be potentially infinite (never terminate); when this occurs a 146 * simulator should indicate this has occurred—it is incorrect for a 147 * simulator to break a cascade arbitrarily and continue the simulation 148 * without at least indicating that the infinite cascade occurred. 149 <p> 150 * <li> Simultaneous events having no defined priorities are executed in an 151 * undefined order. This does not mean that the behavior of the simulation 152 * is completely undefined; merely that the <em>order</em> of execution of 153 * these particular events is undefined. A given simulator may use any 154 * algorithm to choose an order as long as every event is executed exactly 155 * once. 156 <p> 157 * <li> Events with defined priorities are executed in the order implied by 158 * their {@link Priority} 'math' formula values, with events having higher 159 * priorities being executed ahead of events with lower priorities, and 160 * events with identical priorities being executed in a random order with 161 * respect to one another (as determined at run-time by some random 162 * algorithm equivalent to coin-flipping). Newly-triggered events that are 163 * to be executed immediately (i.e., if they define no delays) should be 164 * inserted into the queue of events pending execution according to their 165 * priorities: events with higher priority values value must be inserted 166 * ahead of events with lower priority values and after any pending events 167 * with even higher priorities, and inserted randomly among pending events 168 * with the same priority values. Events without {@link Priority} objects must be 169 * inserted into the queue in some fashion, but the algorithm used to place 170 * it in the queue is undefined. Similarly, there is no restriction on the 171 * order of a newly-inserted event with a defined {@link Priority} with respect to 172 * any other pending {@link Event} without a defined {@link Priority}. 173 <p> 174 * <li> A model variable that is the target of one or more event 175 * assignments can change more than once when simultaneous events are 176 * processed at some time point <em>t</em>. The model's behavior (output) 177 * for such a variable is the value of the variable at the end of 178 * processing all the simultaneous events at time <em>t</em>. 179 <p> 180 * </ul> 181 <p> 182 * @see Trigger 183 * @see Priority 184 * @see Delay 185 * @see EventAssignment 186 */ 187 188public class Event extends SBase { 189 private long swigCPtr; 190 191 protected Event(long cPtr, boolean cMemoryOwn) 192 { 193 super(libsbmlJNI.Event_SWIGUpcast(cPtr), cMemoryOwn); 194 swigCPtr = cPtr; 195 } 196 197 protected static long getCPtr(Event obj) 198 { 199 return (obj == null) ? 0 : obj.swigCPtr; 200 } 201 202 protected static long getCPtrAndDisown (Event obj) 203 { 204 long ptr = 0; 205 206 if (obj != null) 207 { 208 ptr = obj.swigCPtr; 209 obj.swigCMemOwn = false; 210 } 211 212 return ptr; 213 } 214 215 protected void finalize() { 216 delete(); 217 } 218 219 public synchronized void delete() { 220 if (swigCPtr != 0) { 221 if (swigCMemOwn) { 222 swigCMemOwn = false; 223 libsbmlJNI.delete_Event(swigCPtr); 224 } 225 swigCPtr = 0; 226 } 227 super.delete(); 228 } 229 230 231/** 232 * Creates a new {@link Event} using the given SBML <code>level</code> and <code>version</code> 233 * values. 234 <p> 235 * @param level a long integer, the SBML Level to assign to this {@link Event} 236 <p> 237 * @param version a long integer, the SBML Version to assign to this 238 * {@link Event} 239 <p> 240 * <p> 241 * @throws SBMLConstructorException 242 * Thrown if the given <code>level</code> and <code>version</code> combination are invalid 243 * or if this object is incompatible with the given level and version. 244 <p>