diff --git a/NEWS.txt b/NEWS.txt deleted file mode 100644 index 8608d71d..00000000 --- a/NEWS.txt +++ /dev/null @@ -1,6 +0,0 @@ - SBMLsimulator core NEWS -- History of user-visible changes - -====================================================================== -Version 0.9 (2011-09-28) -====================================================================== - diff --git a/README.txt b/README.txt deleted file mode 100644 index f6886ac1..00000000 --- a/README.txt +++ /dev/null @@ -1,21 +0,0 @@ -$Id$ -$URL$ -$Rev$ - -This file is part of SBMLsimulator, a Java-based simulator for models -of biochemical processes encoded in the modeling language SBML. - -Copyright (C) 2007-2011 by the University of Tuebingen, Germany. - -This library is free software; you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as -published by the Free Software Foundation. A copy of the license -agreement is provided in the file named "LICENSE.txt" included with -this software distribution and also available online as -. - - -The SBMLsimulator core project can be found at -. - -Please cite the original work and the authors when using this program. \ No newline at end of file diff --git a/dist/SBMLsimulatorCore_v0.9.jar b/dist/SBMLsimulatorCore_v0.9.jar deleted file mode 100644 index 05b9cf37..00000000 Binary files a/dist/SBMLsimulatorCore_v0.9.jar and /dev/null differ diff --git a/dist/SBMLsimulatorCore_v0.9_src.jar b/dist/SBMLsimulatorCore_v0.9_src.jar deleted file mode 100644 index 951e03c8..00000000 Binary files a/dist/SBMLsimulatorCore_v0.9_src.jar and /dev/null differ diff --git a/doc/posters/VLN-Retreat/VLN_poster_abstract.doc b/doc/posters/VLN-Retreat/VLN_poster_abstract.doc deleted file mode 100644 index aadbc221..00000000 Binary files a/doc/posters/VLN-Retreat/VLN_poster_abstract.doc and /dev/null differ diff --git a/src/org/sbml/simulator/math/SBMLinterpreter.java b/src/org/sbml/simulator/math/SBMLinterpreter.java index 3d0ea419..dd7764a6 100644 --- a/src/org/sbml/simulator/math/SBMLinterpreter.java +++ b/src/org/sbml/simulator/math/SBMLinterpreter.java @@ -34,13 +34,10 @@ import org.sbml.jsbml.ASTNode; import org.sbml.jsbml.Assignment; import org.sbml.jsbml.AssignmentRule; -import org.sbml.jsbml.CallableSBase; import org.sbml.jsbml.Compartment; import org.sbml.jsbml.Event; -import org.sbml.jsbml.FunctionDefinition; import org.sbml.jsbml.InitialAssignment; import org.sbml.jsbml.KineticLaw; -import org.sbml.jsbml.LocalParameter; import org.sbml.jsbml.Model; import org.sbml.jsbml.Parameter; import org.sbml.jsbml.RateRule; @@ -52,12 +49,6 @@ import org.sbml.jsbml.Variable; import org.sbml.jsbml.validator.ModelOverdeterminedException; import org.sbml.jsbml.validator.OverdeterminationValidator; -import org.sbml.simulator.math.astnode.ASTNodeInterpreterWithTime; -import org.sbml.simulator.math.astnode.ASTNodeObject; -import org.sbml.simulator.math.astnode.CompartmentOrParameterValue; -import org.sbml.simulator.math.astnode.LocalParameterValue; -import org.sbml.simulator.math.astnode.ReactionValue; -import org.sbml.simulator.math.astnode.SpeciesValue; import org.sbml.simulator.math.odes.AbstractDESSolver; import org.sbml.simulator.math.odes.DESAssignment; import org.sbml.simulator.math.odes.DESystem; @@ -221,21 +212,6 @@ public class SBMLinterpreter implements ValueHolder, EventDESystem, * */ private int level; - - /** - * - */ - private List kineticLawRoots; - - /** - * - */ - private List nodes; - - /** - * - */ - private ASTNodeInterpreterWithTime nodeInterpreterWithTime; /** *

@@ -1070,129 +1046,6 @@ public void init() throws ModelOverdeterminedException, SBMLException { initialValues = new double[Y.length]; System.arraycopy(Y, 0, initialValues, 0, initialValues.length); - createSimplifiedSyntaxTree(); - - } - - /** - * - */ - private void createSimplifiedSyntaxTree() { - nodes = new LinkedList(); - kineticLawRoots = new LinkedList(); - for(Reaction r: model.getListOfReactions()) { - KineticLaw kl = r.getKineticLaw(); - if(kl!=null) { - kineticLawRoots.add(copyAST(kl.getMath())); - } - } - - } - - /** - * - * @param node - * @return - */ - private ASTNode copyAST(ASTNode node) { - String nodeString = node.toString(); - ASTNode copiedAST=null; - for(ASTNode current: nodes) { - if(current.toString().equals(nodeString)) { - copiedAST=current; - break; - } - } - if(copiedAST==null) { - copiedAST=new ASTNode(node.getType()); - if(node.isSetUnits()) { - copiedAST.setUnits(node.getUnits()); - } - switch (node.getType()) { - case REAL: - copiedAST.setUserObject(new ASTNodeObject(nodeInterpreterWithTime, copiedAST)); - copiedAST.setValue(node.getMantissa(),node.getExponent()); - break; - case INTEGER: - copiedAST.setUserObject(new ASTNodeObject(nodeInterpreterWithTime, copiedAST)); - copiedAST.setValue(node.getInteger()); - break; - - case RATIONAL: - copiedAST.setUserObject(new ASTNodeObject(nodeInterpreterWithTime, copiedAST)); - copiedAST.setValue(node.getNumerator(), node.getDenominator()); - break; - case NAME_TIME: - copiedAST.setUserObject(new ASTNodeObject(nodeInterpreterWithTime, copiedAST)); - copiedAST.setName(node.getName()); - break; - case FUNCTION_DELAY: - copiedAST.setUserObject(new ASTNodeObject(nodeInterpreterWithTime, copiedAST)); - copiedAST.setName(node.getName()); - break; - /* - * Names of identifiers: parameters, functions, species etc. - */ - case NAME: - copiedAST.setName(node.getName()); - CallableSBase variable = node.getVariable(); - - if (variable != null) { - copiedAST.setVariable(variable); - if (variable instanceof FunctionDefinition) { - copiedAST.setUserObject(new ASTNodeObject(nodeInterpreterWithTime, copiedAST)); - } - else if(variable instanceof Species){ - copiedAST.setUserObject(new SpeciesValue(nodeInterpreterWithTime, copiedAST, (Species)variable, this)); - } - else if ((variable instanceof Compartment) || (variable instanceof Parameter)) { - copiedAST.setUserObject(new CompartmentOrParameterValue(nodeInterpreterWithTime, copiedAST, variable, this)); - } - else if (variable instanceof LocalParameter) { - copiedAST.setUserObject(new LocalParameterValue(nodeInterpreterWithTime, copiedAST, (LocalParameter)variable)); - } - else if (variable instanceof Reaction) { - copiedAST.setUserObject(new ReactionValue(nodeInterpreterWithTime, copiedAST, (Reaction)variable)); - } - } - break; - - case NAME_AVOGADRO: - copiedAST.setUserObject(new ASTNodeObject(nodeInterpreterWithTime, copiedAST)); - copiedAST.setName(node.getName()); - break; - case REAL_E: - copiedAST.setUserObject(new ASTNodeObject(nodeInterpreterWithTime, copiedAST)); - copiedAST.setValue(node.getMantissa(),node.getExponent()); - break; - case FUNCTION: { - copiedAST.setUserObject(new ASTNodeObject(nodeInterpreterWithTime, copiedAST)); - copiedAST.setName(node.getName()); - variable = node.getVariable(); - - if (variable != null) { - copiedAST.setVariable(variable); - if (variable instanceof FunctionDefinition) { - copiedAST.setUserObject(new ASTNodeObject(nodeInterpreterWithTime, copiedAST)); - } - } - break; - } - case FUNCTION_PIECEWISE: - copiedAST.setUserObject(new ASTNodeObject(nodeInterpreterWithTime, copiedAST)); - break; - case LAMBDA: - copiedAST.setUserObject(new ASTNodeObject(nodeInterpreterWithTime, copiedAST)); - break; - default: - copiedAST.setUserObject(new ASTNodeObject(nodeInterpreterWithTime, copiedAST)); - break; - } - for(ASTNode child: node.getChildren()) { - copiedAST.addChild(copyAST(child)); - } - } - return copiedAST; } /** diff --git a/src/org/sbml/simulator/math/astnode/ASTNodeInterpreterWithTime.java b/src/org/sbml/simulator/math/astnode/ASTNodeInterpreterWithTime.java deleted file mode 100644 index 3e37f3b9..00000000 --- a/src/org/sbml/simulator/math/astnode/ASTNodeInterpreterWithTime.java +++ /dev/null @@ -1,515 +0,0 @@ -/* - *--------------------------------------------------------------------- - * This file is part of SBMLsimulator, a Java-based simulator for models - * of biochemical processes encoded in the modeling language SBML. - * - * Copyright (C) 2007-2011 by the University of Tuebingen, Germany. - * - * This library is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation. A copy of the license - * agreement is provided in the file named "LICENSE.txt" included with - * this software distribution and also available online as - * . - * --------------------------------------------------------------------- - */ - -package org.sbml.simulator.math.astnode; - -import java.util.Hashtable; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.logging.Logger; - -import org.sbml.jsbml.ASTNode; -import org.sbml.jsbml.CallableSBase; -import org.sbml.jsbml.Compartment; -import org.sbml.jsbml.FunctionDefinition; -import org.sbml.jsbml.LocalParameter; -import org.sbml.jsbml.Parameter; -import org.sbml.jsbml.Reaction; -import org.sbml.jsbml.SBMLException; -import org.sbml.jsbml.Species; -import org.sbml.jsbml.util.Maths; -import org.sbml.simulator.math.SBMLinterpreter; -import org.sbml.simulator.math.ValueHolder; - -/** - * - * @author Roland Keller - * @version $Rev: 22 $ - * @since 1.0 - */ -public class ASTNodeInterpreterWithTime { - /** - * A logger. - */ - public static final Logger logger = Logger.getLogger(SBMLinterpreter.class - .getName()); - /** - * This table is necessary to store the values of arguments when a function - * definition is evaluated. For an identifier of the argument the - * corresponding value will be stored. - */ - private Map funcArgs; - - - /** - * - */ - private ValueHolder valueHolder; - - - /** - * - * @param valueHolder - */ - public ASTNodeInterpreterWithTime(ValueHolder valueHolder) { - this.valueHolder = valueHolder; - } - - /** - * - */ - private void clearFuncArgs() { - funcArgs.clear(); - } - - - /** - * @param name - * @return - */ - private Double getFuncArg(String name) { - if ((funcArgs != null) && funcArgs.containsKey(name)) { - // replace the name by the associated value of the argument - return funcArgs.get(name).doubleValue(); - } - return null; - } - - - /** - * @param argValues - */ - private void setFuncArgs(Hashtable argValues) { - this.funcArgs = argValues; - } - - - public final String toString(ASTNode value) { - return value.toString(); - } - - - public double compileDouble(String name, double time) { - Double funcArg = getFuncArg(name); - double value; - if (funcArg != null) { - value = funcArg; - } else if (!Double.isNaN(valueHolder.getCurrentValueOf(name))) { - value = valueHolder.getCurrentValueOf(name); - } else { - value = Double.NaN; - } - return value; - } - - public double compileDouble(CallableSBase nsb, double time) throws SBMLException { - if (nsb instanceof Species) { - Species s = (Species) nsb; - String id=s.getId(); - double compartmentValue = valueHolder.getCurrentCompartmentValueOf(id); - if (compartmentValue == 0d) { - return valueHolder.getCurrentSpeciesValue(id); - } - - else if (s.isSetInitialAmount() && !s.getHasOnlySubstanceUnits()) { - return (valueHolder.getCurrentSpeciesValue(id) / compartmentValue); - - } - - else if (s.isSetInitialConcentration() && s.getHasOnlySubstanceUnits()) { - - return (valueHolder.getCurrentSpeciesValue(id) * compartmentValue); - } else { - return valueHolder.getCurrentSpeciesValue(id); - } - } - else if ((nsb instanceof Compartment) || (nsb instanceof Parameter)) { - String id=nsb.getId(); - return valueHolder.getCurrentValueOf(id); - } - else if (nsb instanceof LocalParameter) { - LocalParameter p = (LocalParameter) nsb; - return p.getValue(); - - - } else if (nsb instanceof Reaction) { - Reaction r = (Reaction) nsb; - if (r.isSetKineticLaw()) { ((ASTNodeObject)r.getKineticLaw() - .getMath().getUserObject()).compileDouble(time); } - } - return Double.NaN; - } - - public boolean compileBoolean(CallableSBase nsb, double time) throws SBMLException { - if (nsb instanceof FunctionDefinition) { return functionBoolean( - (FunctionDefinition) nsb, new LinkedList(), time); } - return false; - } - - public double functionDouble(FunctionDefinition function, - List arguments, double time) throws SBMLException { - ASTNode lambda = function.getMath(); - Hashtable argValues = new Hashtable(); - for (int i = 0; i < arguments.size(); i++) { - argValues.put(compileString(lambda.getChild(i)), - ((ASTNodeObject)arguments.get(i).getUserObject()).compileDouble(time)); - } - setFuncArgs(argValues); - double value = ((ASTNodeObject)lambda.getRightChild().getUserObject()).compileDouble(time); - clearFuncArgs(); - return value; - } - - public String compileString(ASTNode child) { - if (child.isName()) { - return child.getName(); - } else { - return child.toString(); - } - } - - public double lambdaDouble(List nodes, double time) throws SBMLException { - double d[] = new double[Math.max(0, nodes.size() - 1)]; - for (int i = 0; i < nodes.size() - 1; i++) { - d[i++] = ((ASTNodeObject)nodes.get(i).getUserObject()).compileDouble(time); - } - // TODO: what happens with d? - return ((ASTNodeObject)nodes.get(nodes.size() - 1).getUserObject()).compileDouble(time); - } - - public boolean lambdaBoolean(List nodes, double time) throws SBMLException { - double d[] = new double[Math.max(0, nodes.size() - 1)]; - for (int i = 0; i < nodes.size() - 1; i++) { - d[i++] = ((ASTNodeObject)nodes.get(i).getUserObject()).compileDouble(time); - } - // TODO: what happens with d? - return ((ASTNodeObject)nodes.get(nodes.size() - 1).getUserObject()).compileBoolean(time); - - } - - public double piecewise(List nodes, double time) throws SBMLException { - int i; - for (i = 1; i < nodes.size() - 1; i += 2) { - if (((ASTNodeObject)nodes.get(i).getUserObject()).compileBoolean(time)) { return (((ASTNodeObject)nodes.get(i - 1).getUserObject()).compileDouble(time)); } - } - return ((ASTNodeObject)nodes.get(i - 1).getUserObject()).compileDouble(time); - - } - - public double log(ASTNodeObject userObject, double time) throws SBMLException { - return Math.log(userObject.compileDouble(time)); - } - - public double log(ASTNodeObject left, ASTNodeObject right, double time) throws SBMLException { - return Maths.log(left.compileDouble(time), right.compileDouble(time)); - } - - public double functionDouble(String functionDefinitionName, - List args) throws SBMLException { - // can not compile a function without an ASTNode representing its lambda - // expression - - return Double.NaN; - } - - public double tanh(ASTNodeObject userObject, double time) throws SBMLException { - return Math.tanh(userObject.compileDouble(time)); - } - - public double tan(ASTNodeObject userObject, double time) throws SBMLException { - return Math.tan(userObject.compileDouble(time)); - } - - public double sinh(ASTNodeObject userObject, double time) throws SBMLException { - return Math.sinh(userObject.compileDouble(time)); - } - - public double sin(ASTNodeObject userObject, double time) throws SBMLException { - return Math.sin(userObject.compileDouble(time)); - } - - public double sech(ASTNodeObject userObject, double time) throws SBMLException { - return Maths.sech(userObject.compileDouble(time)); - } - - public double sec(ASTNodeObject userObject, double time) throws SBMLException { - return Maths.sec(userObject.compileDouble(time)); - } - - public double root(ASTNodeObject rootExponent, ASTNodeObject radiant, double time) - throws SBMLException { - return root(rootExponent.compileDouble(time), radiant,time); - } - - public double root(double rootExponent, ASTNodeObject userObject, double time) - throws SBMLException { - return Maths.root(userObject.compileDouble(time), rootExponent); - } - - public double ln(ASTNodeObject userObject, double time) throws SBMLException { - return Maths.ln(userObject.compileDouble(time)); - } - - public double floor(ASTNodeObject userObject, double time) throws SBMLException { - return Math.floor(userObject.compileDouble(time)); - } - - public double factorial(ASTNodeObject userObject, double time) throws SBMLException { - return Maths.factorial((int) Math.round(userObject.compileDouble(time))); - } - - public double exp(ASTNodeObject userObject, double time) throws SBMLException { - return Math.exp(userObject.compileDouble(time)); - } - - public double csch(ASTNodeObject userObject, double time) throws SBMLException { - return Maths.csch(userObject.compileDouble(time)); - } - - public double csc(ASTNodeObject userObject, double time) throws SBMLException { - return Maths.csc(userObject.compileDouble(time)); - } - - public double coth(ASTNodeObject userObject, double time) throws SBMLException { - return Maths.coth(userObject.compileDouble(time)); - } - - public double cot(ASTNodeObject userObject, double time) throws SBMLException { - return Maths.cot(userObject.compileDouble(time)); - } - - public double cosh(ASTNodeObject userObject, double time) throws SBMLException { - return Math.cosh(userObject.compileDouble(time)); - } - - public double cos(ASTNodeObject userObject, double time) throws SBMLException { - return Math.cos(userObject.compileDouble(time)); - } - - public double ceiling(ASTNodeObject userObject, double time) throws SBMLException { - return Math.ceil(userObject.compileDouble(time)); - } - - public double arctanh(ASTNodeObject userObject, double time) throws SBMLException { - return Math.atan(userObject.compileDouble(time)); - } - - public boolean functionBoolean(String name, List children) { - // can not compile a function without an ASTNode representing its lambda - // expression - - return false; - } - - public boolean functionBoolean(FunctionDefinition function, - List arguments, double time) throws SBMLException { - ASTNode lambda = function.getMath(); - - Hashtable argValues = new Hashtable(); - for (int i = 0; i < arguments.size(); i++) { - argValues.put(compileString(lambda.getChild(i)), - ((ASTNodeObject)arguments.get(i).getUserObject()).compileDouble(time)); - } - setFuncArgs(argValues); - boolean value = ((ASTNodeObject)lambda.getRightChild().getUserObject()).compileBoolean(time); - clearFuncArgs(); - return value; - } - - public boolean lt(ASTNodeObject left, ASTNodeObject right, double time) throws SBMLException { - return (left.compileDouble(time) < right.compileDouble(time)); - } - - public boolean leq(ASTNodeObject left, ASTNodeObject right, double time) throws SBMLException { - return (left.compileDouble(time) <= right.compileDouble(time)); - } - - public boolean neq(ASTNodeObject left, ASTNodeObject right, double time) throws SBMLException { - return (left.compileDouble(time) != right.compileDouble(time)); - } - - public boolean gt(ASTNodeObject left, ASTNodeObject right, double time) throws SBMLException { - return (left.compileDouble(time) > right.compileDouble(time)); - } - - public boolean geq(ASTNodeObject left, ASTNodeObject right, double time) throws SBMLException { - return (left.compileDouble(time) >= right.compileDouble(time)); - } - - public boolean eq(ASTNodeObject left, ASTNodeObject right, double time) throws SBMLException { - return (left.compileDouble(time) == right.compileDouble(time)); - } - - public boolean not(ASTNodeObject node, double time) throws SBMLException { - return node.compileBoolean(time) ? false : true; - } - - public boolean or(List nodes, double time) throws SBMLException { - for (ASTNode node : nodes) { - if (((ASTNodeObject)node.getUserObject()).compileBoolean(time)) { return true; } - } - return false; - } - - public boolean xor(List nodes, double time) throws SBMLException { - boolean value = false; - for (int i = 0; i < nodes.size(); i++) { - if (((ASTNodeObject)nodes.get(i).getUserObject()).compileBoolean(time)) { - if (value) { - return false; - } else { - value = true; - } - } - } - return value; - } - - public boolean and(List nodes, double time) throws SBMLException { - for (ASTNode node : nodes) { - if (!((ASTNodeObject)node.getUserObject()).compileBoolean(time)) { return false; } - } - return true; - } - - public double arctan(ASTNodeObject userObject, double time) throws SBMLException { - return Math.atan(userObject.compileDouble(time)); - } - - public double arcsinh(ASTNodeObject userObject, double time) throws SBMLException { - return Maths.arcsinh(userObject.compileDouble(time)); - } - - public double arcsin(ASTNodeObject userObject, double time) throws SBMLException { - return Math.asin(userObject.compileDouble(time)); - } - - public double arcsech(ASTNodeObject userObject, double time) throws SBMLException { - return Maths.arcsech(userObject.compileDouble(time)); - } - - public double arcsec(ASTNodeObject userObject, double time) throws SBMLException { - return Maths.arcsec(userObject.compileDouble(time)); - } - - public double arccsch(ASTNodeObject userObject, double time) throws SBMLException { - return Maths.arccsch(userObject.compileDouble(time)); - } - - public double arccsc(ASTNodeObject userObject, double time) throws SBMLException { - return Maths.arccsc(userObject.compileDouble(time)); - } - - public double arccoth(ASTNodeObject userObject, double time) throws SBMLException { - return Maths.arccoth(userObject.compileDouble(time)); - } - - public double arccot(ASTNodeObject userObject, double time) throws SBMLException { - return Maths.arccot(userObject.compileDouble(time)); - } - - public double arccosh(ASTNodeObject userObject, double time) throws SBMLException { - return Maths.arccosh(userObject.compileDouble(time)); - } - - public double arccos(ASTNodeObject userObject, double time) throws SBMLException { - return Math.acos(userObject.compileDouble(time)); - } - - public double abs(ASTNodeObject userObject, double time) throws SBMLException { - return Math.abs(userObject.compileDouble(time)); - } - - public double compile(double mantissa, int exponent, String units) { - return (mantissa * Math.pow(10, exponent)); - } - - public double delay(String name, ASTNode leftChild, ASTNode rightChild, - String units) { - // TODO Auto-generated method stub - return 0; - } - - public double symbolTime(String name) { - return (valueHolder.getCurrentTime()); - } - - public double frac(int numerator, int denominator) { - return (numerator / denominator); - } - - public double frac(ASTNodeObject left, ASTNodeObject right, double time) throws SBMLException { - return (left.compileDouble(time) / right.compileDouble(time)); - } - - public double times(List nodes, double time) throws SBMLException { - int size = nodes.size(); - if (size == 0) { - return (0d); - } else { - double value = 1d; - - for (int i = 0; i != size; i++) { - value *= ((ASTNodeObject)nodes.get(i).getUserObject()).compileDouble(time); - } - return value; - } - } - - public double minus(List nodes, double time) throws SBMLException { - int size = nodes.size(); - - double value = 0d; - if (size > 0) { - value = ((ASTNodeObject)nodes.get(0).getUserObject()).compileDouble(time); - } - for (int i = 1; i < size; i++) { - value -= ((ASTNodeObject)nodes.get(i).getUserObject()).compileDouble(time); - } - return value; - } - - public double plus(List nodes, double time) throws SBMLException { - int size = nodes.size(); - double value = 0d; - for (int i = 0; i != size; i++) { - value += ((ASTNodeObject)nodes.get(i).getUserObject()).compileDouble(time); - } - return value; - } - - public double pow(ASTNodeObject left, ASTNodeObject right, double time) throws SBMLException { - double l = left.compileDouble(time); - double r = right.compileDouble(time); - double result= Math.pow(l,r); - return result; - } - - public double compile(double value, String units) { - // TODO: units! - return value; - } - - public double sqrt(ASTNodeObject userObject, double time) throws SBMLException { - return Math.sqrt(userObject.compileDouble(time)); - } - - public double uMinus(ASTNodeObject userObject, double time) throws SBMLException { - return (-userObject.compileDouble(time)); - } -} - diff --git a/src/org/sbml/simulator/math/astnode/ASTNodeObject.java b/src/org/sbml/simulator/math/astnode/ASTNodeObject.java deleted file mode 100644 index dffe7618..00000000 --- a/src/org/sbml/simulator/math/astnode/ASTNodeObject.java +++ /dev/null @@ -1,532 +0,0 @@ -/* - * --------------------------------------------------------------------- - * This file is part of SBMLsimulator, a Java-based simulator for models - * of biochemical processes encoded in the modeling language SBML. - * - * Copyright (C) 2007-2011 by the University of Tuebingen, Germany. - * - * This library is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation. A copy of the license - * agreement is provided in the file named "LICENSE.txt" included with - * this software distribution and also available online as - * . - * --------------------------------------------------------------------- - */ -package org.sbml.simulator.math.astnode; - -import java.util.logging.Logger; - -import org.sbml.jsbml.ASTNode; -import org.sbml.jsbml.CallableSBase; -import org.sbml.jsbml.FunctionDefinition; -import org.sbml.jsbml.SBMLException; -import org.sbml.jsbml.util.Maths; - -/** - * - * @author Roland Keller - * @version $Rev: 22 $ - * @since 1.0 - */ -public class ASTNodeObject { - /** - * - */ - protected double time; - - /** - * - */ - protected boolean booleanValue; - - /** - * - */ - protected double doubleValue; - - /** - * - */ - protected boolean isDouble; - - - /** - * - */ - protected ASTNode node; - - - /** - * - */ - protected ASTNodeInterpreterWithTime interpreter; - - /** - * - */ - public static final Logger logger = Logger.getLogger(ASTNodeObject.class.getName()); - - /** - * - * @param interpreter - * @param node - */ - public ASTNodeObject(ASTNodeInterpreterWithTime interpreter, ASTNode node) { - this.interpreter=interpreter; - this.node=node; - } - - /** - * - * @return - */ - public double getTime() { - return time; - } - - /** - * - */ - public void setTime(double time) { - this.time=time; - } - - - /** - * - * @param time - * @return - */ - public Object getValue(double time) { - if(isDouble) { - return compileDouble(time); - } - else { - return compileBoolean(time); - } - } - - /** - * - * @param time - * @return - */ - public double compileDouble(double time) { - - if (this.time != time) { - isDouble=true; - this.time = time; - computeDoubleValue(); - } - return doubleValue; - } - - /** - * - * @param time - * @return - */ - public boolean compileBoolean(double time) { - if (this.time != time) { - isDouble=false; - this.time = time; - computeBooleanValue(); - } - return booleanValue; - } - - /** - * - */ - protected void computeDoubleValue() { - switch (node.getType()) { - /* - * Numbers - */ - case REAL: - double real = node.getReal(); - if (Double.isInfinite(real)) { - doubleValue = (real > 0d) ? Double.POSITIVE_INFINITY - : Double.NEGATIVE_INFINITY; - } else { - doubleValue = interpreter.compile(real, node.getUnits()); - } - break; - case INTEGER: - doubleValue = interpreter.compile(node.getInteger(), node.getUnits()); - break; - /* - * Operators - */ - case POWER: - doubleValue = interpreter.pow((ASTNodeObject) node.getLeftChild() - .getUserObject(), (ASTNodeObject) node.getRightChild() - .getUserObject(), time); - break; - case PLUS: - doubleValue = interpreter.plus(node.getChildren(), time); - break; - case MINUS: - if (node.getChildCount() == 1) { - doubleValue = interpreter.uMinus((ASTNodeObject) node.getLeftChild() - .getUserObject(), time); - } else { - doubleValue = interpreter.minus(node.getChildren(), time); - } - break; - case TIMES: - doubleValue = interpreter.times(node.getChildren(), time); - break; - case DIVIDE: - if (node.getChildCount() != 2) { throw new SBMLException( - String - .format( - "Fractions must have one numerator and one denominator, here %s elements are given.", - node.getChildCount())); } - doubleValue = interpreter.frac((ASTNodeObject) node.getLeftChild() - .getUserObject(), (ASTNodeObject) node.getRightChild() - .getUserObject(), time); - break; - case RATIONAL: - doubleValue = interpreter.frac(node.getNumerator(), node.getDenominator()); - break; - case NAME_TIME: - doubleValue = interpreter.symbolTime(node.getName()); - break; - case FUNCTION_DELAY: - doubleValue = interpreter.delay(node.getName(), node.getLeftChild(), - node.getRightChild(), node.getUnits()); - break; - - /* - * Names of identifiers: parameters, functions, species etc. - */ - case NAME: - CallableSBase variable = node.getVariable(); - - if (variable != null) { - if (variable instanceof FunctionDefinition) { - doubleValue = interpreter.functionDouble((FunctionDefinition) variable, - node.getChildren(), time); - } else { - doubleValue = interpreter.compileDouble(variable, time); - } - } else { - doubleValue = interpreter.compileDouble(node.getName(), time); - } - break; - /* - * Type: pi, e, true, false, Avogadro - */ - case CONSTANT_PI: - doubleValue = Math.PI; - break; - case CONSTANT_E: - doubleValue = Math.E; - break; - - case NAME_AVOGADRO: - doubleValue = Maths.AVOGADRO; - break; - case REAL_E: - doubleValue = interpreter.compile(node.getMantissa(), node.getExponent(), - node.isSetUnits() ? node.getUnits() : null); - break; - /* - * Basic Functions - */ - case FUNCTION_LOG: - if (node.getChildCount() == 2) { - doubleValue = interpreter.log((ASTNodeObject)node.getLeftChild().getUserObject(), (ASTNodeObject)node.getRightChild().getUserObject(), time); - } else { - doubleValue = interpreter.log((ASTNodeObject) node.getRightChild() - .getUserObject(), time); - } - break; - case FUNCTION_ABS: - doubleValue = interpreter.abs((ASTNodeObject) node.getRightChild() - .getUserObject(), time); - break; - case FUNCTION_ARCCOS: - doubleValue = interpreter.arccos((ASTNodeObject) node.getLeftChild() - .getUserObject(), time); - break; - case FUNCTION_ARCCOSH: - doubleValue = interpreter.arccosh((ASTNodeObject) node.getLeftChild() - .getUserObject(), time); - break; - case FUNCTION_ARCCOT: - doubleValue = interpreter.arccot((ASTNodeObject) node.getLeftChild() - .getUserObject(), time); - break; - case FUNCTION_ARCCOTH: - doubleValue = interpreter.arccoth((ASTNodeObject) node.getLeftChild() - .getUserObject(), time); - break; - case FUNCTION_ARCCSC: - doubleValue = interpreter.arccsc((ASTNodeObject) node.getLeftChild() - .getUserObject(), time); - break; - case FUNCTION_ARCCSCH: - doubleValue = interpreter.arccsch((ASTNodeObject) node.getLeftChild() - .getUserObject(), time); - break; - case FUNCTION_ARCSEC: - doubleValue = interpreter.arcsec((ASTNodeObject) node.getLeftChild() - .getUserObject(), time); - break; - case FUNCTION_ARCSECH: - doubleValue = interpreter.arcsech((ASTNodeObject) node.getLeftChild() - .getUserObject(), time); - break; - case FUNCTION_ARCSIN: - doubleValue = interpreter.arcsin((ASTNodeObject) node.getLeftChild() - .getUserObject(), time); - break; - case FUNCTION_ARCSINH: - doubleValue = interpreter.arcsinh((ASTNodeObject) node.getLeftChild() - .getUserObject(), time); - break; - case FUNCTION_ARCTAN: - doubleValue = interpreter.arctan((ASTNodeObject) node.getLeftChild() - .getUserObject(), time); - break; - case FUNCTION_ARCTANH: - doubleValue = interpreter.arctanh((ASTNodeObject) node.getLeftChild() - .getUserObject(), time); - break; - case FUNCTION_CEILING: - doubleValue = interpreter.ceiling((ASTNodeObject) node.getLeftChild() - .getUserObject(), time); - break; - case FUNCTION_COS: - doubleValue = interpreter.cos((ASTNodeObject) node.getLeftChild() - .getUserObject(), time); - break; - case FUNCTION_COSH: - doubleValue = interpreter.cosh((ASTNodeObject) node.getLeftChild() - .getUserObject(), time); - break; - case FUNCTION_COT: - doubleValue = interpreter.cot((ASTNodeObject) node.getLeftChild() - .getUserObject(), time); - break; - case FUNCTION_COTH: - doubleValue = interpreter.coth((ASTNodeObject) node.getLeftChild() - .getUserObject(), time); - break; - case FUNCTION_CSC: - doubleValue = interpreter.csc((ASTNodeObject) node.getLeftChild() - .getUserObject(), time); - break; - case FUNCTION_CSCH: - doubleValue = interpreter.csch((ASTNodeObject) node.getLeftChild() - .getUserObject(), time); - break; - case FUNCTION_EXP: - doubleValue = interpreter.exp((ASTNodeObject) node.getLeftChild() - .getUserObject(), time); - break; - case FUNCTION_FACTORIAL: - doubleValue = interpreter.factorial((ASTNodeObject) node.getLeftChild() - .getUserObject(), time); - break; - case FUNCTION_FLOOR: - doubleValue = interpreter.floor((ASTNodeObject) node.getLeftChild() - .getUserObject(), time); - break; - case FUNCTION_LN: - doubleValue = interpreter.ln((ASTNodeObject) node.getLeftChild() - .getUserObject(), time); - break; - case FUNCTION_POWER: - doubleValue = interpreter.pow((ASTNodeObject) node.getLeftChild() - .getUserObject(), (ASTNodeObject) node.getRightChild() - .getUserObject(), time); - break; - case FUNCTION_ROOT: - ASTNode left = node.getLeftChild(); - if (node.getChildCount() == 2) { - if (left.isInteger()) { - int leftdoubleValue = left.getInteger(); - if (leftdoubleValue == 2) { - doubleValue = interpreter.sqrt((ASTNodeObject) node.getRightChild() - .getUserObject(), time); - } else { - doubleValue = interpreter.root(leftdoubleValue, (ASTNodeObject)node.getRightChild().getUserObject(), time); - } - } else if (left.isReal()) { - double leftdoubleValue = left.getReal(); - if (leftdoubleValue == 2d) { - doubleValue = interpreter.sqrt((ASTNodeObject) node.getRightChild() - .getUserObject(), time); - } else { - doubleValue = interpreter.root(leftdoubleValue, (ASTNodeObject) node - .getRightChild().getUserObject(), time); - } - } else { - doubleValue = interpreter.root((ASTNodeObject) left.getUserObject(), - (ASTNodeObject) node.getRightChild().getUserObject(), time); - } - } else if (node.getChildCount() == 1) { - doubleValue = interpreter.sqrt((ASTNodeObject) node.getRightChild() - .getUserObject(), time); - } else { - doubleValue = interpreter.root((ASTNodeObject) left.getUserObject(), - (ASTNodeObject) node.getRightChild().getUserObject(), time); - } - break; - case FUNCTION_SEC: - doubleValue = interpreter.sec((ASTNodeObject) node.getLeftChild() - .getUserObject(), time); - break; - case FUNCTION_SECH: - doubleValue = interpreter.sech((ASTNodeObject) node.getLeftChild() - .getUserObject(), time); - break; - case FUNCTION_SIN: - doubleValue = interpreter.sin((ASTNodeObject) node.getLeftChild() - .getUserObject(), time); - break; - case FUNCTION_SINH: - doubleValue = interpreter.sinh((ASTNodeObject) node.getLeftChild() - .getUserObject(), time); - break; - case FUNCTION_TAN: - doubleValue = interpreter.tan((ASTNodeObject) node.getLeftChild() - .getUserObject(), time); - break; - case FUNCTION_TANH: - doubleValue = interpreter.tanh((ASTNodeObject) node.getLeftChild() - .getUserObject(), time); - break; - case FUNCTION: { - variable = node.getVariable(); - - if (variable != null) { - if (variable instanceof FunctionDefinition) { - doubleValue = interpreter.functionDouble((FunctionDefinition) variable, - node.getChildren(), time); - } else { - logger - .warning("ASTNode of type FUNCTION but the variable is not a FunctionDefinition !! (" - + node.getName() + ", " + node.getParentSBMLObject() + ")"); - throw new SBMLException( - "ASTNode of type FUNCTION but the variable is not a FunctionDefinition !! (" - + node.getName() + ", " + node.getParentSBMLObject() + ")"); - // doubleValue = compiler.compile(variable); - } - } else { - logger - .warning("ASTNode of type FUNCTION but the variable is null !! (" - + node.getName() + ", " + node.getParentSBMLObject() + "). " - + "Check that your object is linked to a Model."); - doubleValue = interpreter.functionDouble(node.getName(), node.getChildren()); - } - break; - } - case FUNCTION_PIECEWISE: - doubleValue = interpreter.piecewise(node.getChildren(), time); - break; - case LAMBDA: - doubleValue = interpreter.lambdaDouble(node.getChildren(), time); - break; - default: // UNKNOWN: - doubleValue = Double.NaN; - break; - } - } - - /** - * - */ - protected void computeBooleanValue() { - switch (node.getType()) { - /* - * Logical and relational functions - */ - case LOGICAL_AND: - booleanValue = interpreter.and(node.getChildren(),time); - break; - case LOGICAL_XOR: - booleanValue = interpreter.xor(node.getChildren(),time); - break; - case LOGICAL_OR: - booleanValue = interpreter.or(node.getChildren(),time); - break; - case LOGICAL_NOT: - booleanValue = interpreter.not((ASTNodeObject)node.getLeftChild().getUserObject(),time); - break; - case RELATIONAL_EQ: - booleanValue = interpreter.eq((ASTNodeObject)node.getLeftChild().getUserObject(), (ASTNodeObject)node.getRightChild().getUserObject(),time); - break; - case RELATIONAL_GEQ: - booleanValue = interpreter.geq((ASTNodeObject)node.getLeftChild().getUserObject(), (ASTNodeObject)node.getRightChild().getUserObject(),time); - break; - case RELATIONAL_GT: - booleanValue = interpreter.gt((ASTNodeObject)node.getLeftChild().getUserObject(), (ASTNodeObject)node.getRightChild().getUserObject(),time); - break; - case RELATIONAL_NEQ: - booleanValue = interpreter.neq((ASTNodeObject)node.getLeftChild().getUserObject(), (ASTNodeObject)node.getRightChild().getUserObject(),time); - break; - case RELATIONAL_LEQ: - booleanValue = interpreter.leq((ASTNodeObject)node.getLeftChild().getUserObject(), (ASTNodeObject)node.getRightChild().getUserObject(),time); - break; - case RELATIONAL_LT: - booleanValue = interpreter.lt((ASTNodeObject)node.getLeftChild().getUserObject(), (ASTNodeObject)node.getRightChild().getUserObject(),time); - break; - case CONSTANT_TRUE: - booleanValue = true; - break; - case CONSTANT_FALSE: - booleanValue = false; - break; - case NAME: - CallableSBase variable=node.getVariable(); - - if (variable != null) { - if (variable instanceof FunctionDefinition) { - booleanValue = interpreter.functionBoolean((FunctionDefinition) variable, - node.getChildren(), time); - } else { - booleanValue = interpreter.compileBoolean(variable, time); - } - } - break; - - case FUNCTION: { - variable=node.getVariable(); - - if (variable != null) { - if (variable instanceof FunctionDefinition) { - booleanValue = interpreter.functionBoolean((FunctionDefinition) variable, - node.getChildren(), time); - } else { - logger - .warning("ASTNode of type FUNCTION but the variable is not a FunctionDefinition !! (" - + node.getName() + ", " + node.getParentSBMLObject() + ")"); - throw new SBMLException( - "ASTNode of type FUNCTION but the variable is not a FunctionDefinition !! (" - + node.getName() + ", " + node.getParentSBMLObject() + ")"); - // value = compiler.compile(variable); - } - } else { - logger - .warning("ASTNode of type FUNCTION but the variable is null !! (" - + node.getName() + ", " + node.getParentSBMLObject() + "). " - + "Check that your object is linked to a Model."); - booleanValue = interpreter.functionBoolean(node.getName(), node.getChildren()); - } - break; - } - case LAMBDA: - booleanValue = interpreter.lambdaBoolean(node.getChildren(), time); - break; - default: - booleanValue=false; - break; - } - } - -} diff --git a/src/org/sbml/simulator/math/astnode/CompartmentOrParameterValue.java b/src/org/sbml/simulator/math/astnode/CompartmentOrParameterValue.java deleted file mode 100644 index ab083156..00000000 --- a/src/org/sbml/simulator/math/astnode/CompartmentOrParameterValue.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * --------------------------------------------------------------------- - * This file is part of SBMLsimulator, a Java-based simulator for models - * of biochemical processes encoded in the modeling language SBML. - * - * Copyright (C) 2007-2011 by the University of Tuebingen, Germany. - * - * This library is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation. A copy of the license - * agreement is provided in the file named "LICENSE.txt" included with - * this software distribution and also available online as - * . - * --------------------------------------------------------------------- - */ -package org.sbml.simulator.math.astnode; - -import org.sbml.jsbml.ASTNode; -import org.sbml.jsbml.CallableSBase; -import org.sbml.simulator.math.ValueHolder; - -/** - * - * @author Roland Keller - * @version $Rev: 22 $ - * @since 1.0 - */ -public class CompartmentOrParameterValue extends ASTNodeObject { - protected CallableSBase sb; - protected String id; - protected ValueHolder valueHolder; - - /** - * - * @param interpreter - * @param node - * @param sb - * @param valueHolder - */ - public CompartmentOrParameterValue(ASTNodeInterpreterWithTime interpreter, ASTNode node, - CallableSBase sb, ValueHolder valueHolder) { - super(interpreter, node); - this.sb = sb; - this.id=sb.getId(); - this.valueHolder = valueHolder; - } - - /* - * (non-Javadoc) - * @see org.sbml.simulator.math.astnode.ASTNodeObject#computeDoubleValue() - */ - protected void computeDoubleValue() { - doubleValue=valueHolder.getCurrentValueOf(id); - } -} diff --git a/src/org/sbml/simulator/math/astnode/LocalParameterValue.java b/src/org/sbml/simulator/math/astnode/LocalParameterValue.java deleted file mode 100644 index 00b92c96..00000000 --- a/src/org/sbml/simulator/math/astnode/LocalParameterValue.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * --------------------------------------------------------------------- - * This file is part of SBMLsimulator, a Java-based simulator for models - * of biochemical processes encoded in the modeling language SBML. - * - * Copyright (C) 2007-2011 by the University of Tuebingen, Germany. - * - * This library is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation. A copy of the license - * agreement is provided in the file named "LICENSE.txt" included with - * this software distribution and also available online as - * . - * --------------------------------------------------------------------- - */ -package org.sbml.simulator.math.astnode; - -import org.sbml.jsbml.ASTNode; -import org.sbml.jsbml.LocalParameter; - -/** - * - * @author Roland Keller - * @version $Rev: 22 $ - * @since 1.0 - */ -public class LocalParameterValue extends ASTNodeObject { - protected LocalParameter lp; - - /** - * - * @param interpreter - * @param node - * @param lp - */ - public LocalParameterValue(ASTNodeInterpreterWithTime interpreter, ASTNode node, - LocalParameter lp) { - super(interpreter, node); - this.lp=lp; - } - - /* - * (non-Javadoc) - * @see org.sbml.simulator.math.astnode.ASTNodeObject#computeDoubleValue() - */ - protected void computeDoubleValue() { - doubleValue=lp.getValue();; - } -} diff --git a/src/org/sbml/simulator/math/astnode/ReactionValue.java b/src/org/sbml/simulator/math/astnode/ReactionValue.java deleted file mode 100644 index 61908653..00000000 --- a/src/org/sbml/simulator/math/astnode/ReactionValue.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * --------------------------------------------------------------------- - * This file is part of SBMLsimulator, a Java-based simulator for models - * of biochemical processes encoded in the modeling language SBML. - * - * Copyright (C) 2007-2011 by the University of Tuebingen, Germany. - * - * This library is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation. A copy of the license - * agreement is provided in the file named "LICENSE.txt" included with - * this software distribution and also available online as - * . - * --------------------------------------------------------------------- - */ -package org.sbml.simulator.math.astnode; - -import org.sbml.jsbml.ASTNode; -import org.sbml.jsbml.Reaction; - -/** - * - * @author Roland Keller - * @version $Rev: 22 $ - * @since 1.0 - */ -public class ReactionValue extends ASTNodeObject { - protected Reaction r; - protected ASTNodeObject kineticLawUserObject; - - /** - * - * @param interpreter - * @param node - * @param r - */ - public ReactionValue(ASTNodeInterpreterWithTime interpreter, ASTNode node, - Reaction r) { - super(interpreter, node); - this.r = r; - if (r.isSetKineticLaw()) { - this.kineticLawUserObject = (ASTNodeObject) r.getKineticLaw().getMath() - .getUserObject(); - } else { - this.kineticLawUserObject = null; - } - } - - /* - * (non-Javadoc) - * @see org.sbml.simulator.math.astnode.ASTNodeObject#computeDoubleValue() - */ - protected void computeDoubleValue() { - doubleValue = Double.NaN; - if (kineticLawUserObject != null) { - doubleValue = kineticLawUserObject.compileDouble(time); - } - } -} diff --git a/src/org/sbml/simulator/math/astnode/SpeciesReferenceValue.java b/src/org/sbml/simulator/math/astnode/SpeciesReferenceValue.java deleted file mode 100644 index 2b4516cb..00000000 --- a/src/org/sbml/simulator/math/astnode/SpeciesReferenceValue.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * $Id$ - * $URL$ - * --------------------------------------------------------------------- - * This file is part of SBMLsimulator, a Java-based simulator for models of biochemical processes encoded in the modeling language SBML. - * - * Copyright (C) 2007-2011 by the University of Tuebingen, Germany. - * - * This library is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation. A copy of the license - * agreement is provided in the file named "LICENSE.txt" included with - * this software distribution and also available online as - * . - * --------------------------------------------------------------------- - */ -package org.sbml.simulator.math.astnode; - -import org.sbml.jsbml.ASTNode; -import org.sbml.jsbml.SpeciesReference; -import org.sbml.simulator.math.ValueHolder; - -/** - * @author Roland Keller - * @version $Rev$ - */ -public class SpeciesReferenceValue extends ASTNodeObject { - - private ValueHolder valueHolder; - private String id; - - /** - * @param interpreter - * @param node - */ - public SpeciesReferenceValue(ASTNodeInterpreterWithTime interpreter, - ASTNode node, SpeciesReference sr, ValueHolder valueHolder) { - super(interpreter, node); - this.id=sr.getId(); - this.valueHolder=valueHolder; - } - - /* - * (non-Javadoc) - * @see org.sbml.simulator.math.astnode.ASTNodeObject#computeDoubleValue() - */ - protected void computeDoubleValue() { - doubleValue = valueHolder.getCurrentStoichiometry(id); - } -} diff --git a/src/org/sbml/simulator/math/astnode/SpeciesValue.java b/src/org/sbml/simulator/math/astnode/SpeciesValue.java deleted file mode 100644 index 06535b13..00000000 --- a/src/org/sbml/simulator/math/astnode/SpeciesValue.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * --------------------------------------------------------------------- - * This file is part of SBMLsimulator, a Java-based simulator for models - * of biochemical processes encoded in the modeling language SBML. - * - * Copyright (C) 2007-2011 by the University of Tuebingen, Germany. - * - * This library is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation. A copy of the license - * agreement is provided in the file named "LICENSE.txt" included with - * this software distribution and also available online as - * . - * --------------------------------------------------------------------- - */ -package org.sbml.simulator.math.astnode; - -import org.sbml.jsbml.ASTNode; -import org.sbml.jsbml.Species; -import org.sbml.simulator.math.ValueHolder; - -/** - * - * @author Roland Keller - * @version $Rev: 22 $ - * @since 1.0 - */ -public class SpeciesValue extends ASTNodeObject { - protected Species s; - protected String id; - protected ValueHolder valueHolder; - protected boolean isSetInitialAmount; - protected boolean hasOnlySubstanceUnits; - protected boolean isSetInitialConcentration; - - /** - * - * @param interpreter - * @param node - * @param s - * @param valueHolder - */ - public SpeciesValue(ASTNodeInterpreterWithTime interpreter, ASTNode node, - Species s, ValueHolder valueHolder) { - super(interpreter, node); - this.s = s; - this.id=s.getId(); - this.valueHolder = valueHolder; - this.isSetInitialAmount=s.isSetInitialAmount(); - this.isSetInitialConcentration=s.isSetInitialConcentration(); - this.hasOnlySubstanceUnits=s.getHasOnlySubstanceUnits(); - } - - /* - * (non-Javadoc) - * @see org.sbml.simulator.math.astnode.ASTNodeObject#computeDoubleValue() - */ - protected void computeDoubleValue() { - double compartmentValue = valueHolder.getCurrentCompartmentValueOf(id); - if (compartmentValue == 0d) { - doubleValue = valueHolder.getCurrentSpeciesValue(id); - } - - else if (isSetInitialAmount && hasOnlySubstanceUnits) { - doubleValue = valueHolder.getCurrentSpeciesValue(id) / compartmentValue; - - } - - else if (isSetInitialConcentration && hasOnlySubstanceUnits) { - doubleValue = valueHolder.getCurrentSpeciesValue(id) * compartmentValue; - } else { - doubleValue = valueHolder.getCurrentSpeciesValue(id); - - } - } - -}