001/* ---------------------------------------------------------------------------- 002 * This file was automatically generated by SWIG (http://www.swig.org). 003 * Version 3.0.8 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 * An SBML <em>rate rule</em> representing <em>dx/dt = f(<b>Y</b>)</em>. 013 <p> 014 * The rule type {@link RateRule} is derived from the parent class {@link Rule}. It is 015 * used to express equations that determine the rates of change of 016 * variables. The left-hand side (the 'variable' attribute) can refer to 017 * the identifier of a species, compartment, or parameter (but not a 018 * reaction). The entity identified must have its 'constant' attribute set 019 * to <code>false.</code> The effects of a {@link RateRule} are in general terms the same, 020 * but differ in the precise details depending on which variable is being 021 * set: 022 <p> 023 * <ul> <li> <em>In the case of a species</em>, a {@link RateRule} sets the rate of 024 * change of the species' quantity (<em>concentration</em> or <em>amount of 025 * substance</em>) to the value determined by the formula in the 'math' 026 * subelement of the {@link RateRule} object. The overall units of the formula in 027 * 'math' <em>should</em> (in SBML Level 2 Version 4 and in SBML Level 3) or 028 * <em>must</em> (in SBML releases prior to Level 2 version 4) be equal to 029 * the unit of <em>species quantity</em> divided by the model-wide unit of 030 * <em>time</em>. <em>Restrictions</em>: There must not be both a {@link RateRule} 031 * 'variable' attribute and a {@link SpeciesReference} 'species' attribute having 032 * the same value, unless that species has its 'boundaryCondition' 033 * attribute is set to <code>true.</code> This means a rate rule cannot be defined 034 * for a species that is created or destroyed in a reaction, unless that 035 * species is defined as a boundary condition in the model. 036 <p> 037 * <li> (For SBML Level 3 only) <em>In the case of a species 038 * reference</em>, a {@link RateRule} sets the rate of change of the stoichiometry 039 * of the referenced reactant or product to the value determined by the 040 * formula in 'math'. The unit associated with the value produced by the 041 * 'math' formula should be consistent with the unit 'dimensionless' 042 * divided by the model-wide unit of <em>time</em>. 043 <p> 044 * <li> <em>In the case of a compartment</em>, a {@link RateRule} sets the rate of 045 * change of the compartment's size to the value determined by the formula 046 * in the 'math' subelement of the {@link RateRule} object. The overall units of 047 * the formula <em>should</em> (in SBML Level 2 Version 4 and in SBML 048 * Level 3) or <em>must</em> (in SBML releases prior to Level 2 049 * version 4) be the units of the compartment's <em>size</em> divided 050 * by the model-wide unit of <em>time</em>. 051 <p> 052 * <li> <em>In the case of a parameter</em>, a {@link RateRule} sets the rate of 053 * change of the parameter's value to that determined by the formula in the 054 * 'math' subelement of the {@link RateRule} object. The overall units of the 055 * formula <em>should</em> (in SBML Level 2 Version 4 and in SBML 056 * Level 3) or <em>must</em> (in SBML releases prior to Level 2 057 * version 4) be the {@link Parameter} object's 'unit' attribute value divided 058 * by the model-wide unit of <em>time</em>. </ul> 059 <p> 060 * In the context of a simulation, rate rules are in effect for simulation 061 * time <em>t</em> < <em>0</em>. Please consult the relevant SBML 062 * specification for additional information about the semantics of 063 * assignments, rules, and entity values for simulation time <em>t</em> 064 * ≤ <em>0</em>. 065 <p> 066 * As mentioned in the description of {@link AssignmentRule}, a model must not 067 * contain more than one {@link RateRule} or {@link AssignmentRule} object having the same 068 * value of 'variable'; in other words, in the set of all assignment rules 069 * and rate rules in an SBML model, each variable appearing in the 070 * left-hand sides can only appear once. This simply follows from the fact 071 * that an indeterminate system would result if a model contained more than 072 * one assignment rule for the same variable or both an assignment rule and 073 * a rate rule for the same variable. 074 <p> 075 * <p> 076 * <h2>General summary of SBML rules</h2> 077 <p> 078 * In SBML Level 3 as well as Level 2, rules are separated into three 079 * subclasses for the benefit of model analysis software. The three 080 * subclasses are based on the following three different possible functional 081 * forms (where <em>x</em> is a variable, <em>f</em> is some arbitrary 082 * function returning a numerical result, <b><em>V</em></b> is a vector of 083 * variables that does not include <em>x</em>, and <b><em>W</em></b> is a 084 * vector of variables that may include <em>x</em>): 085 <p> 086 * <table border='0' cellpadding='0' class='centered' style='font-size: small'> 087 * <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> 088 * <tr><td><em>Assignment:</em></td><td>left-hand side is a scalar:</td><td><em>x = f(<b>V</b>)</em></td></tr> 089 * <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> 090 * </table> 091 <p> 092 * In their general form given above, there is little to distinguish 093 * between <em>assignment</em> and <em>algebraic</em> rules. They are treated as 094 * separate cases for the following reasons: 095 <p> 096 * <ul> 097 * <li> <em>Assignment</em> rules can simply be evaluated to calculate 098 * intermediate values for use in numerical methods. They are statements 099 * of equality that hold at all times. (For assignments that are only 100 * performed once, see {@link InitialAssignment}.) 101<p> 102 * <li> SBML needs to place restrictions on assignment rules, for example 103 * the restriction that assignment rules cannot contain algebraic loops. 104 <p> 105 * <li> Some simulators do not contain numerical solvers capable of solving 106 * unconstrained algebraic equations, and providing more direct forms such 107 * as assignment rules may enable those simulators to process models they 108 * could not process if the same assignments were put in the form of 109 * general algebraic equations; 110 <p> 111 * <li> Those simulators that <em>can</em> solve these algebraic equations make a 112 * distinction between the different categories listed above; and 113 <p> 114 * <li> Some specialized numerical analyses of models may only be applicable 115 * to models that do not contain <em>algebraic</em> rules. 116 * 117 * </ul> <p> 118 * The approach taken to covering these cases in SBML is to define an 119 * abstract {@link Rule} structure containing a subelement, 'math', to hold the 120 * right-hand side expression, then to derive subtypes of {@link Rule} that add 121 * attributes to distinguish the cases of algebraic, assignment and rate 122 * rules. The 'math' subelement must contain a MathML expression defining the 123 * mathematical formula of the rule. This MathML formula must return a 124 * numerical value. The formula can be an arbitrary expression referencing 125 * the variables and other entities in an SBML model. 126 <p> 127 * Each of the three subclasses of {@link Rule} (AssignmentRule, {@link AlgebraicRule}, 128 * {@link RateRule}) inherit the the 'math' subelement and other fields from {@link SBase}. 129 * The {@link AssignmentRule} and {@link RateRule} classes add an additional attribute, 130 * 'variable'. See the definitions of {@link AssignmentRule}, {@link AlgebraicRule} and 131 * {@link RateRule} for details about the structure and interpretation of each one. 132 <p> 133 * <h2>Additional restrictions on SBML rules</h2> 134 <p> 135 * An important design goal of SBML rule semantics is to ensure that a 136 * model's simulation and analysis results will not be dependent on when or 137 * how often rules are evaluated. To achieve this, SBML needs to place two 138 * restrictions on rule use. The first concerns algebraic loops in the system 139 * of assignments in a model, and the second concerns overdetermined systems. 140 <p> 141 * <h3>A model must not contain algebraic loops</h3> 142 <p> 143 * The combined set of {@link InitialAssignment}, {@link AssignmentRule} and {@link KineticLaw} 144 * objects in a model constitute a set of assignment statements that should be 145 * considered as a whole. (A {@link KineticLaw} object is counted as an assignment 146 * because it assigns a value to the symbol contained in the 'id' attribute of 147 * the {@link Reaction} object in which it is defined.) This combined set of 148 * assignment statements must not contain algebraic loops—dependency 149 * chains between these statements must terminate. To put this more formally, 150 * consider a directed graph in which nodes are assignment statements and 151 * directed arcs exist for each occurrence of an SBML species, compartment or 152 * parameter symbol in an assignment statement's 'math' subelement. Let the 153 * directed arcs point from the statement assigning the symbol to the 154 * statements that contain the symbol in their 'math' subelement expressions. 155 * This graph must be acyclic. 156 <p> 157 * SBML does not specify when or how often rules should be evaluated. 158 * Eliminating algebraic loops ensures that assignment statements can be 159 * evaluated any number of times without the result of those evaluations 160 * changing. As an example, consider the set of equations <em>x = x + 1</em>, 161 * <em>y = z + 200</em> and <em>z = y + 100</em>. If this set of equations 162 * were interpreted as a set of assignment statements, it would be invalid 163 * because the rule for <em>x</em> refers to <em>x</em> (exhibiting one type 164 * of loop), and the rule for <em>y</em> refers to <em>z</em> while the rule 165 * for <em>z</em> refers back to <em>y</em> (exhibiting another type of loop). 166 * Conversely, the following set of equations would constitute a valid set of 167 * assignment statements: <em>x = 10</em>, <em>y = z + 200</em>, and <em>z = x 168 * + 100</em>. 169 <p> 170 * <h3>A model must not be overdetermined</h3> 171 <p> 172 * An SBML model must not be overdetermined; that is, a model must not 173 * define more equations than there are unknowns in a model. An SBML model 174 * that does not contain {@link AlgebraicRule} structures cannot be overdetermined. 175 <p> 176 * LibSBML implements the static analysis procedure described in 177 * Appendix B of the SBML Level 3 Version 1 Core 178 * specification for assessing whether a model is overdetermined. 179 <p> 180 * (In summary, assessing whether a given continuous, deterministic, 181 * mathematical model is overdetermined does not require dynamic analysis; it 182 * can be done by analyzing the system of equations created from the model. 183 * One approach is to construct a bipartite graph in which one set of vertices 184 * represents the variables and the other the set of vertices represents the 185 * equations. Place edges between vertices such that variables in the system 186 * are linked to the equations that determine them. For algebraic equations, 187 * there will be edges between the equation and each variable occurring in the 188 * equation. For ordinary differential equations (such as those defined by 189 * rate rules or implied by the reaction rate definitions), there will be a 190 * single edge between the equation and the variable determined by that 191 * differential equation. A mathematical model is overdetermined if the 192 * maximal matchings of the bipartite graph contain disconnected vertexes 193 * representing equations. If one maximal matching has this property, then 194 * all the maximal matchings will have this property; i.e., it is only 195 * necessary to find one maximal matching.) 196 <p> 197 * <h2>Rule types for SBML Level 1</h2> 198 <p> 199 * SBML Level 1 uses a different scheme than SBML Level 2 and Level 3 for 200 * distinguishing rules; specifically, it uses an attribute whose value is 201 * drawn from an enumeration of 3 values. LibSBML supports this using methods 202 * that work with the enumeration values listed below. 203 <p> 204 * <ul> 205 * <li> {@link libsbmlConstants#RULE_TYPE_RATE RULE_TYPE_RATE}: Indicates 206 * the rule is a 'rate' rule. 207 * <li> {@link libsbmlConstants#RULE_TYPE_SCALAR RULE_TYPE_SCALAR}: 208 * Indicates the rule is a 'scalar' rule. 209 * <li> {@link libsbmlConstants#RULE_TYPE_INVALID RULE_TYPE_INVALID}: 210 * Indicates the rule type is unknown or not yet set. 211 * 212 * </ul> 213 */ 214 215public class RateRule extends Rule { 216 private long swigCPtr; 217 218 protected RateRule(long cPtr, boolean cMemoryOwn) 219 { 220 super(libsbmlJNI.RateRule_SWIGUpcast(cPtr), cMemoryOwn); 221 swigCPtr = cPtr; 222 } 223 224 protected static long getCPtr(RateRule obj) 225 { 226 return (obj == null) ? 0 : obj.swigCPtr; 227 } 228 229 protected static long getCPtrAndDisown (RateRule obj) 230 { 231 long ptr = 0; 232 233 if (obj != null) 234 { 235 ptr = obj.swigCPtr; 236 obj.swigCMemOwn = false; 237 } 238 239 return ptr; 240 } 241 242 protected void finalize() { 243 delete(); 244 } 245 246 public synchronized void delete() { 247 if (swigCPtr != 0) { 248 if (swigCMemOwn) { 249 swigCMemOwn = false; 250 libsbmlJNI.delete_RateRule(swigCPtr); 251 } 252 swigCPtr = 0; 253 } 254 super.delete(); 255 } 256 257 258/** 259 * Creates a new {@link RateRule} using the given SBML <code>level</code> and <code>version</code> 260 * values. 261 <p> 262 * @param level a long integer, the SBML Level to assign to this {@link RateRule} 263 <p> 264 * @param version a long integer, the SBML Version to assign to this 265 * {@link RateRule} 266 <p> 267 * <p> 268 * @throws SBMLConstructorException 269 * Thrown if the given <code>level</code> and <code>version</code> combination are invalid 270 * or if this object is incompatible with the given level and version. 271 <p> 272 * <p> 273 * @note Attempting to add an object to an {@link SBMLDocument} having a different 274 * combination of SBML Level, Version and XML namespaces than the object 275 * itself will result in an error at the time a caller attempts to make the 276 * addition. A parent object must have compatible Level, Version and XML 277 * namespaces. (Strictly speaking, a parent may also have more XML 278 * namespaces than a child, but the reverse is not permitted.) The 279 * restriction is necessary to ensure that an SBML model has a consistent 280 * overall structure. This requires callers to manage their objects 281 * carefully, but the benefit is increased flexibility in how models can be 282 * created by permitting callers to create objects bottom-up if desired. In 283 * situations where objects are not yet attached to parents (e.g., 284 * {@link SBMLDocument}), knowledge of the intented SBML Level and Version help 285 * libSBML determine such things as whether it is valid to assign a 286 * particular value to an attribute. 287 */ public 288 RateRule(long level, long version) throws org.sbml.libsbml.SBMLConstructorException { 289 this(libsbmlJNI.new_RateRule__SWIG_0(level, version), true); 290 } 291 292 293/** 294 * Creates a new {@link RateRule} using the given {@link SBMLNamespaces} object 295 * <code>sbmlns</code>. 296 <p> 297 * <p> 298 * The {@link SBMLNamespaces} object encapsulates SBML Level/Version/namespaces 299 * information. It is used to communicate the SBML Level, Version, and (in 300 * Level 3) packages used in addition to SBML Level 3 Core. A 301 * common approach to using libSBML's {@link SBMLNamespaces} facilities is to create an 302 * {@link SBMLNamespaces} object somewhere in a program once, then hand that object 303 * as needed to object constructors that accept {@link SBMLNamespaces} as arguments. 304 <p> 305 * @param sbmlns an {@link SBMLNamespaces} object. 306 <p> 307 * <p> 308 * @throws SBMLConstructorException 309 * Thrown if the given <code>sbmlns</code> is inconsistent or incompatible 310 * with this object. 311 <p> 312 * <p> 313 * @note Attempting to add an object to an {@link SBMLDocument} having a different 314 * combination of SBML Level, Version and XML namespaces than the object 315 * itself will result in an error at the time a caller attempts to make the 316 * addition. A parent object must have compatible Level, Version and XML 317 * namespaces. (Strictly speaking, a parent may also have more XML 318 * namespaces than a child, but the reverse is not permitted.) The 319 * restriction is necessary to ensure that an SBML model has a consistent 320 * overall structure. This requires callers to manage their objects 321 * carefully, but the benefit is increased flexibility in how models can be 322 * created by permitting callers to create objects bottom-up if desired. In 323 * situations where objects are not yet attached to parents (e.g., 324 * {@link SBMLDocument}), knowledge of the intented SBML Level and Version help 325 * libSBML determine such things as whether it is valid to assign a 326 * particular value to an attribute. 327 */ public 328 RateRule(SBMLNamespaces sbmlns) throws org.sbml.libsbml.SBMLConstructorException { 329 this(libsbmlJNI.new_RateRule__SWIG_1(SBMLNamespaces.getCPtr(sbmlns), sbmlns), true); 330 } 331 332 333/** 334 * Creates and returns a deep copy of this {@link RateRule} object. 335 <p> 336 * @return the (deep) copy of this {@link RateRule} object. 337 */ public 338 RateRule cloneObject() { 339 long cPtr = libsbmlJNI.RateRule_cloneObject(swigCPtr, this); 340 return (cPtr == 0) ? null : new RateRule(cPtr, true); 341 } 342 343 344/** 345 * Predicate returning <code>true</code> if 346 * all the required attributes for this {@link RateRule} object 347 * have been set. 348 <p> 349 * In SBML Levels 2–3, the only required attribute for a 350 * {@link RateRule} object is 'variable'. For Level 1, where the equivalent 351 * attribute is known by different names ('compartment', 'species', or 352 * 'name', depending on the type of object), there is an additional 353 * required attribute called 'formula'. 354 <p> 355 * @return <code>true</code> if the required attributes have been set, <code>false</code> 356 * otherwise. 357 */ public 358 boolean hasRequiredAttributes() { 359 return libsbmlJNI.RateRule_hasRequiredAttributes(swigCPtr, this); 360 } 361 362 363/** 364 * <p> 365 * Replaces all uses of a given <code>SIdRef</code> type attribute value with another 366 * value. 367 <p> 368 * <p> 369 * In SBML, object identifiers are of a data type called <code>SId</code>. 370 * In SBML Level 3, an explicit data type called <code>SIdRef</code> was 371 * introduced for attribute values that refer to <code>SId</code> values; in 372 * previous Levels of SBML, this data type did not exist and attributes were 373 * simply described to as 'referring to an identifier', but the effective 374 * data type was the same as <code>SIdRef</code>in Level 3. These and 375 * other methods of libSBML refer to the type <code>SIdRef</code> for all 376 * Levels of SBML, even if the corresponding SBML specification did not 377 * explicitly name the data type. 378 <p> 379 * This method works by looking at all attributes and (if appropriate) 380 * mathematical formulas in MathML content, comparing the referenced 381 * identifiers to the value of <code>oldid</code>. If any matches are found, the 382 * matching values are replaced with <code>newid</code>. The method does <em>not</em> 383 * descend into child elements. 384 <p> 385 * @param oldid the old identifier 386 * @param newid the new identifier 387 */ public 388 void renameSIdRefs(String oldid, String newid) { 389 libsbmlJNI.RateRule_renameSIdRefs(swigCPtr, this, oldid, newid); 390 } 391 392}