1 //------------------------------------------------------------------------------ 2 // <auto-generated /> 3 // 4 // This file was automatically generated by SWIG (http://www.swig.org). 5 // Version 4.0.2 6 // 7 // Do not make changes to this file unless you know what you are doing--modify 8 // the SWIG interface file instead. 9 //------------------------------------------------------------------------------ 10 11 namespace libsbml { 12 13 using System; 14 using System.Runtime.InteropServices; 15 16 /** 17 * @sbmlpackage{core} 18 * 19 @htmlinclude pkg-marker-core.html An SBML <em>algebraic rule</em> representing <em>0 = f(<b>W</b>)</em>. 20 * 21 * The rule type AlgebraicRule is derived from the parent class Rule. It 22 * is used to express equations that are neither assignments of model 23 * variables nor rates of change. AlgebraicRule does not add any 24 * attributes to the basic Rule; its role is simply to distinguish this 25 * case from the other cases. 26 * 27 * In the context of a simulation, algebraic rules are in effect at all 28 * times, <em>t</em> >= <em>0</em>. For purposes of evaluating 29 * expressions that involve the delay 'csymbol' (see the SBML 30 * specification), algebraic rules are considered to apply also at 31 * <em>t</em> <= <em>0</em>. Please consult the relevant SBML 32 * specification for additional information about the semantics of 33 * assignments, rules, and entity values for simulation time <em>t</em> 34 * <= <em>0</em>. 35 * 36 * An SBML model must not be overdetermined. The ability to define 37 * arbitrary algebraic expressions in an SBML model introduces the 38 * possibility that a model is mathematically overdetermined by the overall 39 * system of equations constructed from its rules, reactions and events. 40 * Therefore, if an algebraic rule is introduced in a model, for at least 41 * one of the entities referenced in the rule's 'math' element the value of 42 * that entity must not be completely determined by other constructs in the 43 * model. This means that at least this entity must not have the attribute 44 * 'constant'=@c true and there must also not be a rate rule or assignment 45 * rule for it. Furthermore, if the entity is a Species object, its value 46 * must not be determined by reactions, which means that it must either 47 * have the attribute 'boundaryCondition'=@c true or else not be involved 48 * in any reaction at all. These restrictions are explained in more detail 49 * in the SBML specification documents. 50 * 51 * In SBML Levels 2 and 3, Reaction object identifiers can be 52 * referenced in the 'math' expression of an algebraic rule, but reaction 53 * rates can never be <em>determined</em> by algebraic rules. This is true 54 * even when a reaction does not contain a KineticLaw 55 * @if conly structure @else object@endif. (In such cases of missing 56 * kinetic law definitions, the model is valid but incomplete; the rates of 57 * reactions lacking kinetic laws are simply undefined, and not determined by 58 * the algebraic rule.) 59 * 60 * In SBML Level 2 and Level 3 Version 1, the 'math' 61 * subelement of the AlgebraicRule is required. In SBML Level 3 62 * Version 2, this rule is relaxed, and the subelement is 63 * optional. If an AlgebraicRule with no 'math' child is present 64 * in the model, no additional mathematical constraints on the model are 65 * added by the rule. This may represent a situation where the model itself 66 * is unfinished, or the missing information may be provided by an 67 * SBML Level 3 package. 68 * 69 * Finally, any symbol that appears as the target of a rateOf csymbol 70 * (@link libsbml#AST_FUNCTION_RATE_OF AST_FUNCTION_RATE_OF@endlink, introduced in 71 * SBML Level 3 Version 2) may 72 * not be determined by an AlgebraicRule. This is because the rateOf 73 * csymbol is defined as applying only to symbols whose rates of change 74 * are easily determinable. 75 * 76 * Users should note that these rules about what symbols may not be 77 * determined by an AlgebraicRule may be used to discover what symbol 78 * is being determined by an AlgebraicRule. If three symbols appear in 79 * the math element of an AlgebraicRule, the first of which is flagged 80 * constant=@c true, and the second of which appears as the target of a 81 * rateOf csymbol, one may conclude that the AlgebraicRule must be used 82 * to determine the value of the third symbol. This is, in fact, a 83 * principle use (outside of validation) of the constant attribute: its 84 * use in allowing software to properly identify the dependent variable 85 * in an AlgebraicRule. 86 * 87 * 88 * @section rules-general General summary of SBML rules 89 * 90 * In SBML Level 3 as well as Level 2, rules are separated into three 91 * subclasses for the benefit of model analysis software. The three 92 * subclasses are based on the following three different possible functional 93 * forms (where <em>x</em> is a variable, <em>f</em> is some arbitrary 94 * function returning a numerical result, <b><em>V</em></b> is a vector of 95 * variables that does not include <em>x</em>, and <b><em>W</em></b> is a 96 * vector of variables that may include <em>x</em>): 97 * 98 * <table border='0' cellpadding='0' class='centered' style='font-size: small'> 99 * <tr><td width='120px'><em>Algebraic:</em></td><td width='250px'>left-hand side is zero</td><td><em>0 = f(<b>W</b>)</em></td></tr> 100 * <tr><td><em>Assignment:</em></td><td>left-hand side is a scalar:</td><td><em>x = f(<b>V</b>)</em></td></tr> 101 * <tr><td><em>Rate:</em></td><td>left-hand side is a rate-of-change:</td><td><em>dx/dt = f(<b>W</b>)</em></td></tr> 102 * </table> 103 * 104 * In their general form given above, there is little to distinguish 105 * between <em>assignment</em> and <em>algebraic</em> rules. They are treated as 106 * separate cases for the following reasons: 107 * 108 * @li <em>Assignment</em> rules can simply be evaluated to calculate 109 * intermediate values for use in numerical methods. They are statements 110 * of equality that hold at all times. (For assignments that are only 111 * performed once, see InitialAssignment.) 112 113 * @li SBML needs to place restrictions on assignment rules, for example 114 * the restriction that assignment rules cannot contain algebraic loops. 115 * 116 * @li Some simulators do not contain numerical solvers capable of solving 117 * unconstrained algebraic equations, and providing more direct forms such 118 * as assignment rules may enable those simulators to process models they 119 * could not process if the same assignments were put in the form of 120 * general algebraic equations; 121 * 122 * @li Those simulators that <em>can</em> solve these algebraic equations make a 123 * distinction between the different categories listed above; and 124 * 125 * @li Some specialized numerical analyses of models may only be applicable 126 * to models that do not contain <em>algebraic</em> rules. 127 * 128 * The approach taken to covering these cases in SBML is to define an 129 * abstract Rule structure containing a subelement, 'math', to hold the 130 * right-hand side expression, then to derive subtypes of Rule that add 131 * attributes to distinguish the cases of algebraic, assignment and rate 132 * rules. The 'math' subelement must contain a MathML expression defining the 133 * mathematical formula of the rule. This MathML formula must return a 134 * numerical value. The formula can be an arbitrary expression referencing 135 * the variables and other entities in an SBML model. 136 * 137 * Each of the three subclasses of Rule (AssignmentRule, AlgebraicRule, 138 * RateRule) inherit the the 'math' subelement and other fields from SBase. 139 * The AssignmentRule and RateRule classes add an additional attribute, 140 * 'variable'. See the definitions of AssignmentRule, AlgebraicRule and 141 * RateRule for details about the structure and interpretation of each one. 142 * 143 * @section rules-restrictions Additional restrictions on SBML rules 144 * 145 * An important design goal of SBML rule semantics is to ensure that a 146 * model's simulation and analysis results will not be dependent on when or 147 * how often rules are evaluated. To achieve this, SBML needs to place two 148 * restrictions on rule use. The first concerns algebraic loops in the system 149 * of assignments in a model, and the second concerns overdetermined systems. 150 * 151 * @subsection rules-no-loops A model must not contain algebraic loops 152 * 153 * The combined set of InitialAssignment, AssignmentRule and KineticLaw 154 * objects in a model constitute a set of assignment statements that should be 155 * considered as a whole. (A KineticLaw object is counted as an assignment 156 * because it assigns a value to the symbol contained in the 'id' attribute of 157 * the Reaction object in which it is defined.) This combined set of 158 * assignment statements must not contain algebraic loops---dependency 159 * chains between these statements must terminate. To put this more formally, 160 * consider a directed graph in which nodes are assignment statements and 161 * directed arcs exist for each occurrence of an SBML species, compartment or 162 * parameter symbol in an assignment statement's 'math' subelement. Let the 163 * directed arcs point from the statement assigning the symbol to the 164 * statements that contain the symbol in their 'math' subelement expressions. 165 * This graph must be acyclic. 166 * 167 * Similarly, the combined set of RateRule and Reaction objects constitute 168 * a set of definitions for the rates of change of various model entities 169 * (namely, the objects identified by the values of the 'variable' attributes 170 * of the RateRule objects, and the 'species' attributes of the SpeciesReference 171 * objects in each Reaction). In SBML Level 3 Version 2, these rates 172 * of change may be referenced directly 173 * using the <em>rateOf</em> csymbol, but may not thereby contain algebraic 174 * loops---dependency chains between these statements must terminate. More 175 * formally, consider a directed graph in which the nodes are the definitions 176 * of different variables' rates of change, and directed arcs exist for each 177 * occurrence of a variable referenced by a <em>rateOf</em> csymbol from any 178 * RateRule or KineticLaw object in the model. Let the directed arcs point 179 * from the variable referenced by the <em>rateOf</em> csymbol (call it 180 * <em>x</em>) to the variable(s) determined by the 'math' expression in which 181 * <em>x</em> appears. This graph must be acyclic. 182 * 183 * SBML does not specify when or how often rules should be evaluated. 184 * Eliminating algebraic loops ensures that assignment statements can be 185 * evaluated any number of times without the result of those evaluations 186 * changing. As an example, consider the set of equations <em>x = x + 1</em>, 187 * <em>y = z + 200</em> and <em>z = y + 100</em>. If this set of equations 188 * were interpreted as a set of assignment statements, it would be invalid 189 * because the rule for <em>x</em> refers to <em>x</em> (exhibiting one type 190 * of loop), and the rule for <em>y</em> refers to <em>z</em> while the rule 191 * for <em>z</em> refers back to <em>y</em> (exhibiting another type of loop). 192 * Conversely, the following set of equations would constitute a valid set of 193 * assignment statements: <em>x = 10</em>, <em>y = z + 200</em>, and <em>z = x 194 * + 100</em>. 195 * 196 * @subsection rules-not-overdetermined A model must not be overdetermined 197 * 198 * An SBML model must not be overdetermined; that is, a model must not 199 * define more equations than there are unknowns in a model. A valid SBML model 200 * that does not contain AlgebraicRule structures cannot be overdetermined. 201 * 202 * LibSBML implements the static analysis procedure described in 203 * Appendix B of the SBML Level 3 204 * specification for assessing whether a model is overdetermined. 205 * 206 * (In summary, assessing whether a given continuous, deterministic, 207 * mathematical model is overdetermined does not require dynamic analysis; it 208 * can be done by analyzing the system of equations created from the model. 209 * One approach is to construct a bipartite graph in which one set of vertices 210 * represents the variables and the other the set of vertices represents the 211 * equations. Place edges between vertices such that variables in the system 212 * are linked to the equations that determine them. For algebraic equations, 213 * there will be edges between the equation and each variable occurring in the 214 * equation. For ordinary differential equations (such as those defined by 215 * rate rules or implied by the reaction rate definitions), there will be a 216 * single edge between the equation and the variable determined by that 217 * differential equation. A mathematical model is overdetermined if the 218 * maximal matchings of the bipartite graph contain disconnected vertexes 219 * representing equations. If one maximal matching has this property, then 220 * all the maximal matchings will have this property; i.e., it is only 221 * necessary to find one maximal matching.) 222 * 223 * @section RuleType_t Rule types for SBML Level 1 224 * 225 * SBML Level 1 uses a different scheme than SBML Level 2 and Level 3 for 226 * distinguishing rules; specifically, it uses an attribute whose value is 227 * drawn from an enumeration of 3 values. LibSBML supports this using methods 228 * that work @if clike a libSBML enumeration type, 229 * @link Rule::RuleType_t RuleType_t@endlink, whose values 230 * are @else with the enumeration values @endif listed below. 231 * 232 * @li @link libsbml#RULE_TYPE_RATE RULE_TYPE_RATE@endlink: Indicates 233 * the rule is a 'rate' rule. 234 * @li @link libsbml#RULE_TYPE_SCALAR RULE_TYPE_SCALAR@endlink: 235 * Indicates the rule is a 'scalar' rule. 236 * @li @link libsbml#RULE_TYPE_INVALID RULE_TYPE_INVALID@endlink: 237 * Indicates the rule type is unknown or not yet set. 238 * 239 * 240 */ 241 242 public class AlgebraicRule : Rule { 243 private HandleRef swigCPtr; 244 AlgebraicRule(IntPtr cPtr, bool cMemoryOwn)245 internal AlgebraicRule(IntPtr cPtr, bool cMemoryOwn) : base(libsbmlPINVOKE.AlgebraicRule_SWIGUpcast(cPtr), cMemoryOwn) 246 { 247 //super(libsbmlPINVOKE.AlgebraicRuleUpcast(cPtr), cMemoryOwn); 248 swigCPtr = new HandleRef(this, cPtr); 249 } 250 getCPtr(AlgebraicRule obj)251 internal static HandleRef getCPtr(AlgebraicRule obj) 252 { 253 return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; 254 } 255 getCPtrAndDisown(AlgebraicRule obj)256 internal static HandleRef getCPtrAndDisown (AlgebraicRule obj) 257 { 258 HandleRef ptr = new HandleRef(null, IntPtr.Zero); 259 260 if (obj != null) 261 { 262 ptr = obj.swigCPtr; 263 obj.swigCMemOwn = false; 264 } 265 266 return ptr; 267 } 268 Dispose(bool disposing)269 protected override void Dispose(bool disposing) { 270 lock(this) { 271 if (swigCPtr.Handle != global::System.IntPtr.Zero) { 272 if (swigCMemOwn) { 273 swigCMemOwn = false; 274 libsbmlPINVOKE.delete_AlgebraicRule(swigCPtr); 275 } 276 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); 277 } 278 base.Dispose(disposing); 279 } 280 } 281 282 283 /** 284 * Creates a new AlgebraicRule object using the given SBML @p level and @p 285 * version values. 286 * 287 * @param level the SBML Level to assign to this AlgebraicRule object. 288 * 289 * @param version the SBML Version to assign to this AlgebraicRule object. 290 * 291 * 292 * @throws SBMLConstructorException 293 * Thrown if the given @p level and @p version combination are invalid 294 * or if this object is incompatible with the given level and version. 295 * 296 * 297 * 298 * 299 * @note Attempting to add an object to an SBMLDocument having a different 300 * combination of SBML Level, Version and XML namespaces than the object 301 * itself will result in an error at the time a caller attempts to make the 302 * addition. A parent object must have compatible Level, Version and XML 303 * namespaces. (Strictly speaking, a parent may also have more XML 304 * namespaces than a child, but the reverse is not permitted.) The 305 * restriction is necessary to ensure that an SBML model has a consistent 306 * overall structure. This requires callers to manage their objects 307 * carefully, but the benefit is increased flexibility in how models can be 308 * created by permitting callers to create objects bottom-up if desired. In 309 * situations where objects are not yet attached to parents (e.g., 310 * SBMLDocument), knowledge of the intented SBML Level and Version help 311 * libSBML determine such things as whether it is valid to assign a 312 * particular value to an attribute. 313 * 314 * 315 */ public AlgebraicRule(long level, long version)316 AlgebraicRule(long level, long version) : this(libsbmlPINVOKE.new_AlgebraicRule__SWIG_0(level, version), true) { 317 if (libsbmlPINVOKE.SWIGPendingException.Pending) throw libsbmlPINVOKE.SWIGPendingException.Retrieve(); 318 } 319 320 321 /** 322 * Creates a new AlgebraicRule object using the given SBMLNamespaces object 323 * @p sbmlns. 324 * 325 * 326 * 327 * The SBMLNamespaces object encapsulates SBML Level/Version/namespaces 328 * information. It is used to communicate the SBML Level, Version, and (in 329 * Level 3) packages used in addition to SBML Level 3 Core. A 330 * common approach to using libSBML's SBMLNamespaces facilities is to create an 331 * SBMLNamespaces object somewhere in a program once, then hand that object 332 * as needed to object constructors that accept SBMLNamespaces as arguments. 333 * 334 * 335 * 336 * @param sbmlns an SBMLNamespaces object. 337 * 338 * 339 * @throws SBMLConstructorException 340 * Thrown if the given @p sbmlns is inconsistent or incompatible 341 * with this object. 342 * 343 * 344 * 345 * 346 * @note Attempting to add an object to an SBMLDocument having a different 347 * combination of SBML Level, Version and XML namespaces than the object 348 * itself will result in an error at the time a caller attempts to make the 349 * addition. A parent object must have compatible Level, Version and XML 350 * namespaces. (Strictly speaking, a parent may also have more XML 351 * namespaces than a child, but the reverse is not permitted.) The 352 * restriction is necessary to ensure that an SBML model has a consistent 353 * overall structure. This requires callers to manage their objects 354 * carefully, but the benefit is increased flexibility in how models can be 355 * created by permitting callers to create objects bottom-up if desired. In 356 * situations where objects are not yet attached to parents (e.g., 357 * SBMLDocument), knowledge of the intented SBML Level and Version help 358 * libSBML determine such things as whether it is valid to assign a 359 * particular value to an attribute. 360 * 361 * 362 */ public AlgebraicRule(SBMLNamespaces sbmlns)363 AlgebraicRule(SBMLNamespaces sbmlns) : this(libsbmlPINVOKE.new_AlgebraicRule__SWIG_1(SBMLNamespaces.getCPtr(sbmlns)), true) { 364 if (libsbmlPINVOKE.SWIGPendingException.Pending) throw libsbmlPINVOKE.SWIGPendingException.Retrieve(); 365 } 366 367 368 /** 369 * Creates and returns a deep copy of this AlgebraicRule object. 370 * 371 * @return the (deep) copy of this Rule object. 372 */ public new clone()373 AlgebraicRule clone() { 374 global::System.IntPtr cPtr = libsbmlPINVOKE.AlgebraicRule_clone(swigCPtr); 375 AlgebraicRule ret = (cPtr == global::System.IntPtr.Zero) ? null : new AlgebraicRule(cPtr, true); 376 return ret; 377 } 378 379 380 /** 381 * Predicate returning @c true if all the required attributes for this 382 * AlgebraicRule object have been set. 383 * 384 * In SBML Levels 2–3, there is no required attribute 385 * for an AlgebraicRule object. For Level 1, the only required 386 * attribute is 'formula'. 387 * 388 * @return @c true if the required attributes have been set, @c false 389 * otherwise. 390 */ public new hasRequiredAttributes()391 bool hasRequiredAttributes() { 392 bool ret = libsbmlPINVOKE.AlgebraicRule_hasRequiredAttributes(swigCPtr); 393 return ret; 394 } 395 396 } 397 398 } 399