Serializable, org.apache.commons.math.ode.FirstOrderDifferentialEquations, DelayedDESystem, DelayValueHolder, DESystem, EventDESystem, FastProcessDESystem, RichDESystem, SBMLValueHolderpublic class SBMLinterpreter extends Object implements DelayedDESystem, EventDESystem, FastProcessDESystem, RichDESystem, SBMLValueHolder
This differential equation system (DESystem) takes a model in
SBML
format and maps it to a data structure that is understood by the
AbstractDESSolver. Therefore, this class implements all necessary
functions expected by SBML.
| Modifier and Type | Field | Description |
|---|---|---|
protected org.sbml.jsbml.Reaction |
currentReaction |
This field is necessary to also consider local parameters of the current
reaction because it is not possible to access these parameters from the
model.
|
protected double[] |
initialValues |
An array, which stores all computed initial values of the model.
|
protected org.sbml.jsbml.Model |
model |
The model to be simulated.
|
protected Map<String,Double> |
stoichiometricCoefHash |
This
Map saves the current stoichiometric coefficients for those
SpeciesReference objects that are a target to an Assignment
. |
static String |
TEMP_VALUE |
Key to memorize user objects in
ASTNode |
protected double[] |
v |
An array of the velocities of each reaction within the model system.
|
protected double[] |
Y |
An array of the current concentration of each species within the model
system.
|
| Constructor | Description |
|---|---|
SBMLinterpreter(org.sbml.jsbml.Model model) |
This constructs a new
DESystem for the given SBML Model. |
SBMLinterpreter(org.sbml.jsbml.Model model,
double defaultSpeciesValue,
double defaultParameterValue,
double defaultCompartmentValue) |
|
SBMLinterpreter(org.sbml.jsbml.Model model,
double defaultSpeciesValue,
double defaultParameterValue,
double defaultCompartmentValue,
Map<String,Boolean> amountHash) |
Creates a new
SBMLinterpreter |
| Modifier and Type | Method | Description |
|---|---|---|
boolean |
addConstraintListener(ConstraintListener listener) |
Adds the given
ConstraintListener to this interpreter's list of
listeners. |
double |
compileReaction(int reactionIndex) |
|
double |
computeDelayedValue(double time,
String id,
DESystem DES,
double[] initialValues,
int yIndex) |
Returns the value for the element with the given id at a time point in
the past, where the time gives the amount of time in the past.
|
void |
computeDerivatives(double time,
double[] Y,
double[] changeRate) |
|
boolean |
containsEventsOrRules() |
This method is used to check if this differential equation system contains
any events or rules that would require a special treatment by the numerical
solver.
|
boolean |
containsFastProcesses() |
|
int |
getAdditionalValueCount() |
Gives the number of intermediate results that are computed by this class.
|
String[] |
getAdditionalValueIds() |
This provides the column/row identifiers of all intermediate results: one
identifier per result.
|
double[] |
getAdditionalValues(double t,
double[] Y) |
Computes and/or delivers the intermediate results at the given time and
for the given results from the previous time step.
|
int |
getConstraintListenerCount() |
|
double |
getCurrentCompartmentSize(String id) |
Returns the size of the compartment with the given id.
|
double |
getCurrentCompartmentValueOf(String speciesId) |
Checks if the given symbol id refers to a
Species and returns the
value of its Compartment or 1d otherwise |
double |
getCurrentParameterValue(String id) |
Returns the value of the parameter with the given id.
|
double |
getCurrentSpeciesValue(String id) |
Returns the value of the species with the given id.
|
double |
getCurrentStoichiometry(String id) |
Returns the value of the stoichiometry of the species reference with the given id.
|
double |
getCurrentTime() |
Returns the timepoint where the simulation is currently situated
|
double |
getCurrentValueOf(int position) |
Returns the current value of the Y vector at the given position.
|
double |
getCurrentValueOf(String id) |
Returns the current value of the SBase with the given id.
|
int |
getDimension() |
|
int |
getEventCount() |
Counts the number of events in this system.
|
String[] |
getIdentifiers() |
|
double[] |
getInitialValues() |
Returns the initial values of the model to be simulated.
|
org.sbml.jsbml.Model |
getModel() |
Returns the model that is used by this object.
|
EventInProgress |
getNextEventAssignments(double t,
double previousTime,
double[] Y) |
Returns a list with event assignments for the events triggered either by
the time t or by the concentrations of the species stored in Y.
|
boolean |
getNoDerivatives() |
|
int |
getParameterCount() |
This method tells you the complete number of parameters within the model.
|
int |
getPositionOfParameters() |
|
int |
getPositiveValueCount() |
|
int |
getRuleCount() |
Counts the number of rules to be evaluated in each time point.
|
void |
init() |
This method initializes the differential equation system for simulation.
|
void |
init(boolean refreshTree) |
This method initializes the differential equation system for simulation.
|
void |
init(boolean renewTree,
double defaultSpeciesValue,
double defaultParameterValue,
double defaultCompartmentValue) |
This method initializes the differential equation system for simulation.
|
void |
init(boolean renewTree,
double defaultSpeciesValue,
double defaultParameterValue,
double defaultCompartmentValue,
Map<String,Boolean> amountHash) |
This method initializes the differential equation system for simulation.
|
boolean |
processAssignmentRules(double t,
double[] Y) |
Calculates the changes or assignments that are defined by all rules in the system
at the given simulation time point.
|
void |
processInitialAssignments(double time,
double[] Y) |
Processes the initial assignments
|
boolean |
processRules(double time,
double[] changeRate,
double[] Y,
boolean initialCalculations) |
Processes the rules
|
protected void |
processVelocities(double[] changeRate,
double time) |
This method computes the multiplication of the stoichiometric matrix of the
given model system with the reaction velocities vector passed to this
method.
|
void |
registerDelayValueHolder(DelayValueHolder dvh) |
|
ConstraintListener |
removeConstraintListener(int index) |
Removes the
ConstraintListener with the given index from this
interpreter. |
boolean |
removeConstraintListener(ConstraintListener listener) |
Removes the given
ConstraintListener from this interpreter. |
void |
setDelaysIncluded(boolean delaysIncluded) |
|
void |
setFastProcessComputation(boolean isProcessing) |
|
void |
setParameters(double[] params) |
This method allows us to set the parameters of the model to the specified
values in the given array.
|
public static final String TEMP_VALUE
ASTNodeprotected org.sbml.jsbml.Reaction currentReaction
protected double[] initialValues
protected org.sbml.jsbml.Model model
protected double[] v
protected Map<String,Double> stoichiometricCoefHash
Map saves the current stoichiometric coefficients for those
SpeciesReference objects that are a target to an Assignment
.protected double[] Y
public SBMLinterpreter(org.sbml.jsbml.Model model)
throws org.sbml.jsbml.validator.ModelOverdeterminedException,
org.sbml.jsbml.SBMLException
This constructs a new DESystem for the given SBML Model.
Note that only a maximum of Integer.MAX_VALUE Species can
be simulated. If the model contains more Species, this class is not
applicable.
Note that currently, units are not considered.
model - org.sbml.jsbml.validator.ModelOverdeterminedExceptionorg.sbml.jsbml.SBMLExceptionpublic SBMLinterpreter(org.sbml.jsbml.Model model,
double defaultSpeciesValue,
double defaultParameterValue,
double defaultCompartmentValue)
throws org.sbml.jsbml.SBMLException,
org.sbml.jsbml.validator.ModelOverdeterminedException
model - defaultSpeciesValue - defaultParameterValue - defaultCompartmentValue - org.sbml.jsbml.SBMLExceptionorg.sbml.jsbml.validator.ModelOverdeterminedExceptionpublic SBMLinterpreter(org.sbml.jsbml.Model model,
double defaultSpeciesValue,
double defaultParameterValue,
double defaultCompartmentValue,
Map<String,Boolean> amountHash)
throws org.sbml.jsbml.SBMLException,
org.sbml.jsbml.validator.ModelOverdeterminedException
SBMLinterpretermodel - the model to interpretdefaultSpeciesValue - the default value for species, if no value is givendefaultParameterValue - the default value for parameters, if no value is givendefaultCompartmentValue - the default value for compartments, if no value is givenamountHash - a hash that states for the species in the model, whether their
amount or their concentration should be computedorg.sbml.jsbml.SBMLExceptionorg.sbml.jsbml.validator.ModelOverdeterminedExceptionpublic boolean addConstraintListener(ConstraintListener listener)
ConstraintListener to this interpreter's list of
listeners.listener - the element to be added.true if this operation was successful, false
otherwise.NullPointerExceptionList.add(Object)public boolean removeConstraintListener(ConstraintListener listener)
ConstraintListener from this interpreter.listener - the element to be removed.true if this operation was successful, false
otherwise.NullPointerExceptionList.remove(Object)public ConstraintListener removeConstraintListener(int index)
ConstraintListener with the given index from this
interpreter.index - of the ConstraintListener to be removed.true if this operation was successful, false
otherwise.IndexOutOfBoundsExceptionList.remove(int)public int getConstraintListenerCount()
ConstraintListeners currently assigned to
this interpreter.public boolean containsFastProcesses()
containsFastProcesses in interface FastProcessDESystempublic String[] getAdditionalValueIds()
RichDESystemString array must equal the length of the array returned by
RichDESystem.getAdditionalValues(double, double[]).getAdditionalValueIds in interface RichDESystempublic double[] getAdditionalValues(double t,
double[] Y)
throws org.apache.commons.math.ode.DerivativeException
RichDESystemgetAdditionalValues in interface RichDESystemt - The time point for which intermediate results are to be
computed.Y - The result vector from the previous time step.org.apache.commons.math.ode.DerivativeException - If the system cannot be solved for the given configuration or
no intermediate results can be computed in this step.public double getCurrentCompartmentValueOf(String speciesId)
Species and returns the
value of its Compartment or 1d otherwisegetCurrentCompartmentValueOf in interface SBMLValueHolderspeciesId - public double getCurrentCompartmentSize(String id)
SBMLValueHoldergetCurrentCompartmentSize in interface SBMLValueHolderpublic double getCurrentParameterValue(String id)
SBMLValueHoldergetCurrentParameterValue in interface SBMLValueHolderpublic double getCurrentSpeciesValue(String id)
SBMLValueHoldergetCurrentSpeciesValue in interface SBMLValueHolderpublic double getCurrentStoichiometry(String id)
SBMLValueHoldergetCurrentStoichiometry in interface SBMLValueHolderpublic int getDimension()
getDimension in interface org.apache.commons.math.ode.FirstOrderDifferentialEquationspublic EventInProgress getNextEventAssignments(double t, double previousTime, double[] Y) throws org.apache.commons.math.ode.DerivativeException
EventDESystemgetNextEventAssignments in interface EventDESystemt - The current simulation time.Y - The current change of the system.org.apache.commons.math.ode.DerivativeExceptionpublic String[] getIdentifiers()
DESystemStrings that describe the content of each
dimension of the resulting array of this DESystem.getIdentifiers in interface DESystemStrings which has the same length than the
number given by FirstOrderDifferentialEquations.getDimension(). Each
String describes the content of the given dimension.public double[] getInitialValues()
public org.sbml.jsbml.Model getModel()
public int getAdditionalValueCount()
RichDESystemRichDESystem.getAdditionalValueIds() and
RichDESystem.getAdditionalValues(double, double[]).getAdditionalValueCount in interface RichDESystempublic int getEventCount()
EventDESystemgetEventCount in interface EventDESystempublic int getParameterCount()
int value, whereas the SBML model may
contain int values.public int getRuleCount()
EventDESystemgetRuleCount in interface EventDESystempublic int getPositionOfParameters()
public double getCurrentTime()
getCurrentTime in interface SBMLValueHolderpublic void computeDerivatives(double time,
double[] Y,
double[] changeRate)
throws org.apache.commons.math.ode.DerivativeException
computeDerivatives in interface org.apache.commons.math.ode.FirstOrderDifferentialEquationsorg.apache.commons.math.ode.DerivativeExceptionpublic double getCurrentValueOf(String id)
SBMLValueHoldergetCurrentValueOf in interface SBMLValueHolderpublic void init()
throws org.sbml.jsbml.validator.ModelOverdeterminedException,
org.sbml.jsbml.SBMLException
This method initializes the differential equation system for simulation. In
more detail: the initial amounts or concentration will be assigned to every
Species or InitialAssignments if any are executed.
To save computation time the results of this method should be stored in an array. Hence this method must only be called once. However, if the SBML model to be simulated contains initial assignments, this can lead to wrong simulation results because initial assignments may depend on current parameter values.
org.sbml.jsbml.validator.ModelOverdeterminedExceptionorg.sbml.jsbml.SBMLExceptioninit(boolean, double, double, double)public void init(boolean refreshTree)
throws org.sbml.jsbml.validator.ModelOverdeterminedException,
org.sbml.jsbml.SBMLException
ASTNodes has to be refreshed.refreshTree - org.sbml.jsbml.validator.ModelOverdeterminedExceptionorg.sbml.jsbml.SBMLExceptionpublic void init(boolean renewTree,
double defaultSpeciesValue,
double defaultParameterValue,
double defaultCompartmentValue)
throws org.sbml.jsbml.validator.ModelOverdeterminedException,
org.sbml.jsbml.SBMLException
ASTNodes has to be
refreshed and give some default values.renewTree - defaultSpeciesValue - defaultParameterValue - defaultCompartmentValue - org.sbml.jsbml.validator.ModelOverdeterminedExceptionorg.sbml.jsbml.SBMLExceptionpublic void init(boolean renewTree,
double defaultSpeciesValue,
double defaultParameterValue,
double defaultCompartmentValue,
Map<String,Boolean> amountHash)
throws org.sbml.jsbml.validator.ModelOverdeterminedException,
org.sbml.jsbml.SBMLException
ASTNodes has to be
refreshed, give some default values and state whether a Species
is seen as an amount or a concentration.renewTree - defaultSpeciesValue - defaultParameterValue - defaultCompartmentValue - amountHash - org.sbml.jsbml.validator.ModelOverdeterminedExceptionorg.sbml.jsbml.SBMLExceptionpublic boolean processAssignmentRules(double t,
double[] Y)
throws org.apache.commons.math.ode.DerivativeException
EventDESystemprocessAssignmentRules in interface EventDESystemt - The current simulation time.Y - The current change of the system.true if there has been a change in the Y vector
caused by the rules.org.apache.commons.math.ode.DerivativeExceptionpublic void processInitialAssignments(double time,
double[] Y)
throws org.sbml.jsbml.SBMLException
time - the ASTNode timeY - the Y vectororg.sbml.jsbml.SBMLExceptionpublic boolean processRules(double time,
double[] changeRate,
double[] Y,
boolean initialCalculations)
throws org.sbml.jsbml.SBMLException
time - the current timechangeRate - the changeRate vectorY - the Y vectorinitialCalculations - org.sbml.jsbml.SBMLExceptionprotected void processVelocities(double[] changeRate,
double time)
throws org.sbml.jsbml.SBMLException
changeRate - An array containing the rates of change for each species in the
model system of this class.time - org.sbml.jsbml.SBMLExceptionpublic void setFastProcessComputation(boolean isProcessing)
setFastProcessComputation in interface FastProcessDESystemisProcessing - Should there be a splitting of fast and slow reactions in the simulation?public void setParameters(double[] params)
params - An array of parameter values to be set for this model. If the number
of given parameters does not match the number of model parameters,
an exception will be thrown.public boolean containsEventsOrRules()
DESystemcontainsEventsOrRules in interface DESystemtrue if any events or rules are contained
in the differential equation system.public double getCurrentValueOf(int position)
SBMLValueHoldergetCurrentValueOf in interface SBMLValueHolderpublic int getPositiveValueCount()
getPositiveValueCount in interface DESystempublic void registerDelayValueHolder(DelayValueHolder dvh)
registerDelayValueHolder in interface DelayedDESystemdvh - the delay value holder to be registeredpublic double computeDelayedValue(double time,
String id,
DESystem DES,
double[] initialValues,
int yIndex)
DelayValueHoldercomputeDelayedValue in interface DelayValueHoldertime - the time point (in the past) at which the value is to be
computed for the element with the given id.id - the id of the delayed valueDES - the DESysteminitialValues - the initialValues of the DESyIndex - the index corresponding to the id in the vector of the DESpublic boolean getNoDerivatives()
getNoDerivatives in interface EventDESystemtrue, if the change vector is always
zero in the system.public double compileReaction(int reactionIndex)
reactionIndex - index of the reactionpublic void setDelaysIncluded(boolean delaysIncluded)
setDelaysIncluded in interface DESystemdelaysIncluded - Determines whether delay expression should be included in the calculation.Copyright © 2007–2018. All rights reserved.