biouml.plugins.simulation
Class SimulationEngine

java.lang.Object
  extended bycom.beanexplorer.beans.Option
      extended bybiouml.plugins.simulation.SimulationEngine
Direct Known Subclasses:
JavaSimulationEngine, MatlabSimulationEngine

public abstract class SimulationEngine
extends com.beanexplorer.beans.Option

General class for simulation engine. It defines common contract (properties and methods) for any simulation engine.


Nested Class Summary
static class SimulationEngine.VariableType
           
 
Field Summary
protected  double absTolerance
           
protected  java.util.ResourceBundle childResources
          Resource bundle containing necessary String data.
protected  java.lang.String currentIndent
           
static double DEFAULT_ABSOLUTE_TOLERANCE
           
static double DEFAULT_RELATIVE_TOLERANCE
           
protected  Diagram diagram
           
protected static java.lang.String endl
           
protected  java.util.List equationList
          List of all equations.
protected  java.util.Map equationMap
          Stores list of equations for used diagram variable.
protected  EModel executableModel
           
protected  boolean hasConstVariables
          Indicates whether model has boundary variables that should be treated as constants.
protected  org.apache.log4j.Category log
           
protected  java.util.Map macros
          maps "variable name" -> "scalar equation, calculating this variable"
protected  int modelType
          Type of the model: STATIC, ODE, etc.
 boolean needToShowPlot
           
protected  java.lang.String outputDir
          Output directory where the code will be generated.
protected static java.util.ResourceBundle parentResources
          Common description is located in biouml.plugins.simulation.resources.MessagesBundle.
protected  double relTolerance
           
protected  java.util.ResourceBundle resources
          Resource bundle containing necessary String data.
protected  java.lang.String solverName
           
static java.lang.String srcDir
           
protected  int status
          Math processing status.
protected  java.lang.String tab
           
protected  java.lang.String tab2
           
protected  java.lang.String tab3
           
protected  java.lang.String tab4
           
protected  java.util.List usedVariableList
          List of all variables however used in model.
protected  MathWriter writer
           
 
Fields inherited from class com.beanexplorer.beans.Option
notificationEnabled, propagationEnabled
 
Constructor Summary
SimulationEngine()
           
 
Method Summary
 void clearContext()
           
 boolean containsDelays()
          Returns true if the differential equations contain delays when derivatives computing.
 void error(java.lang.String message)
           
 void error(java.lang.String messageBundleKey, java.lang.String[] params)
           
 void error(java.lang.String messageBundleKey, java.lang.String[] params, java.lang.Throwable t)
           
 void fillSimulationResult(SimulationResult result)
           
protected  SimulationEngine.VariableType findVariable(java.lang.String name)
           
abstract  java.io.File[] generateModel()
           
abstract  java.lang.String generateVariableCodeName(int n)
           
 double getAbsTolerance()
           
 double getCompletionTime()
           
 Diagram getDiagram()
           
 EModel getExecutableModel()
           
abstract  Formatter getFormatter()
          Returns formatter corresponding for given engine.
 double getInitialTime()
           
 boolean getNeedToShowPlot()
           
 java.lang.String getOutputDir()
           
 java.lang.String getQualifiedName(java.lang.String name, DiagramElement de)
          Resolves brief varibale name to fully qualified variable name.
 double getRelTolerance()
           
 java.util.ResourceBundle getResourceBundle()
           
 java.lang.String getResourceString(java.lang.String key)
          Returns string from the resource bundle for the specified key.
protected  Equation[] getScalarEquations()
           
 java.lang.String getSolverName()
           
 double getTimeIncrement()
           
protected  void init()
          Initilaze internal structures for model generation: 1) map: variable - List(equations) 2) variables type. 3) status, errors
protected  void initAlgebraic(DiagramElement de)
           
protected  void initMath(DiagramElement de)
          Initialize variable types and equations map.
protected  void initResources(java.lang.String resourceBundleName, java.lang.Class c)
          Initialize resources necessary to retrieve localized strings.
protected  boolean isSignificantVariable(java.lang.String type)
           
 java.lang.String normalize(java.lang.String name)
          Normalize name to be valid simulation script name.
protected  void parseAssignments(Assignment[] assignments, Role role)
           
protected  void parseEquation(DiagramElement de)
           
protected  void processMath(Node node, Role role)
          Substitutes BioUML variable names with variable names used in simulation script.
protected  void processVarNode(AstVarNode node, Role role)
           
 void setAbsTolerance(double absTolerance)
           
 void setCompletionTime(double completionTime)
           
 void setDiagram(Diagram diagram)
           
 void setInitialTime(double initialTime)
           
 void setNeedToShowPlot(boolean value)
           
 void setOutputDir(java.lang.String outputDir)
           
 void setRelTolerance(double relTolerance)
           
 void setSolverName(java.lang.String solverName)
           
 void setTimeIncrement(double timeIncrement)
           
abstract  java.lang.String simulate(java.io.File[] files)
           
 void warn(java.lang.String messageBundleKey, java.lang.String[] params)
           
 void writeAssignment(java.lang.String variable, java.lang.String expression, Role role)
           
protected  void writeAssignmentImpl(java.lang.String variable, java.lang.String expression, Role role, boolean declare)
           
abstract  void writeComment(java.lang.String comment)
           
 void writeFile(java.lang.String source, java.lang.String outDir, java.lang.String outFile, boolean rewrite)
          Utility method to write needed source files from the specified source to the specified directory.
protected  void writeFunctionDeclarations()
           
protected  void writeInitialStateEntering()
           
protected  void writeMath(java.lang.String math, Role role)
           
protected  void writeRateEquation(java.util.List list)
           
protected  void writeRules()
           
protected  void writeRulesImpl(boolean acceptInternal)
          Write rules that are equations with type TYPE_SCALAR.
protected  void writeScalarRule(Equation equation, boolean acceptInternal)
           
protected  void writeSignificantRules()
           
protected  void writeTransition(State currentState, Transition transition)
           
 
Methods inherited from class com.beanexplorer.beans.Option
addPropertyChangeListener, copyListenersTo, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getParent, isNotificationEnabled, isPropagationEnabled, removePropertyChangeListener, setNotificationEnabled, setParent, setPropagationEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

endl

protected static java.lang.String endl

currentIndent

protected java.lang.String currentIndent

tab

protected java.lang.String tab

tab2

protected java.lang.String tab2

tab3

protected java.lang.String tab3

tab4

protected java.lang.String tab4

DEFAULT_RELATIVE_TOLERANCE

public static final double DEFAULT_RELATIVE_TOLERANCE
See Also:
Constant Field Values

DEFAULT_ABSOLUTE_TOLERANCE

public static final double DEFAULT_ABSOLUTE_TOLERANCE
See Also:
Constant Field Values

srcDir

public static final java.lang.String srcDir
See Also:
Constant Field Values

log

protected org.apache.log4j.Category log

equationMap

protected java.util.Map equationMap
Stores list of equations for used diagram variable.


equationList

protected java.util.List equationList
List of all equations.


usedVariableList

protected java.util.List usedVariableList
List of all variables however used in model.


hasConstVariables

protected boolean hasConstVariables
Indicates whether model has boundary variables that should be treated as constants.


macros

protected java.util.Map macros
maps "variable name" -> "scalar equation, calculating this variable"


modelType

protected int modelType
Type of the model: STATIC, ODE, etc.


status

protected int status
Math processing status.

See Also:
ru.biosoft.math.model.Parser.

writer

protected MathWriter writer

diagram

protected Diagram diagram

executableModel

protected EModel executableModel

outputDir

protected java.lang.String outputDir
Output directory where the code will be generated.


solverName

protected java.lang.String solverName

absTolerance

protected double absTolerance

relTolerance

protected double relTolerance

needToShowPlot

public boolean needToShowPlot

resources

protected java.util.ResourceBundle resources
Resource bundle containing necessary String data. This resource bundle contains join of childResources with parentResources.


childResources

protected java.util.ResourceBundle childResources
Resource bundle containing necessary String data.


parentResources

protected static java.util.ResourceBundle parentResources
Common description is located in biouml.plugins.simulation.resources.MessagesBundle. This bundle is used as parent bundle for resources.

Constructor Detail

SimulationEngine

public SimulationEngine()
Method Detail

generateVariableCodeName

public abstract java.lang.String generateVariableCodeName(int n)

generateModel

public abstract java.io.File[] generateModel()
                                      throws java.lang.Exception
Throws:
java.lang.Exception

simulate

public abstract java.lang.String simulate(java.io.File[] files)
                                   throws java.lang.Exception
Throws:
java.lang.Exception

clearContext

public void clearContext()
                  throws java.lang.Exception
Throws:
java.lang.Exception

getFormatter

public abstract Formatter getFormatter()
Returns formatter corresponding for given engine.


containsDelays

public boolean containsDelays()
Returns true if the differential equations contain delays when derivatives computing.


getDiagram

public Diagram getDiagram()

setDiagram

public void setDiagram(Diagram diagram)

getExecutableModel

public EModel getExecutableModel()

getOutputDir

public java.lang.String getOutputDir()

setOutputDir

public void setOutputDir(java.lang.String outputDir)

getSolverName

public java.lang.String getSolverName()

setSolverName

public void setSolverName(java.lang.String solverName)

getInitialTime

public double getInitialTime()

setInitialTime

public void setInitialTime(double initialTime)

getCompletionTime

public double getCompletionTime()

setCompletionTime

public void setCompletionTime(double completionTime)

getTimeIncrement

public double getTimeIncrement()

setTimeIncrement

public void setTimeIncrement(double timeIncrement)

getAbsTolerance

public double getAbsTolerance()

setAbsTolerance

public void setAbsTolerance(double absTolerance)

getRelTolerance

public double getRelTolerance()

setRelTolerance

public void setRelTolerance(double relTolerance)

setNeedToShowPlot

public void setNeedToShowPlot(boolean value)

getNeedToShowPlot

public boolean getNeedToShowPlot()

getResourceBundle

public java.util.ResourceBundle getResourceBundle()

getResourceString

public java.lang.String getResourceString(java.lang.String key)
Returns string from the resource bundle for the specified key. If the sting is absent the key string is returned instead and the message is printed in log4j.Category.


initResources

protected void initResources(java.lang.String resourceBundleName,
                             java.lang.Class c)
Initialize resources necessary to retrieve localized strings.


error

public void error(java.lang.String message)

error

public void error(java.lang.String messageBundleKey,
                  java.lang.String[] params)

error

public void error(java.lang.String messageBundleKey,
                  java.lang.String[] params,
                  java.lang.Throwable t)

warn

public void warn(java.lang.String messageBundleKey,
                 java.lang.String[] params)

findVariable

protected SimulationEngine.VariableType findVariable(java.lang.String name)

getQualifiedName

public java.lang.String getQualifiedName(java.lang.String name,
                                         DiagramElement de)
Resolves brief varibale name to fully qualified variable name. Generates error if variable can not be resolved.

See Also:
EModel.getQualifiedName(java.lang.String, biouml.model.DiagramElement)

normalize

public java.lang.String normalize(java.lang.String name)
Normalize name to be valid simulation script name.


init

protected void init()
             throws java.lang.Exception
Initilaze internal structures for model generation: 1) map: variable - List(equations) 2) variables type. 3) status, errors

Throws:
java.lang.Exception

initMath

protected void initMath(DiagramElement de)
Initialize variable types and equations map.


initAlgebraic

protected void initAlgebraic(DiagramElement de)

parseEquation

protected void parseEquation(DiagramElement de)

parseAssignments

protected void parseAssignments(Assignment[] assignments,
                                Role role)

writeMath

protected void writeMath(java.lang.String math,
                         Role role)
                  throws java.lang.Exception
Throws:
java.lang.Exception

writeAssignmentImpl

protected void writeAssignmentImpl(java.lang.String variable,
                                   java.lang.String expression,
                                   Role role,
                                   boolean declare)

writeAssignment

public void writeAssignment(java.lang.String variable,
                            java.lang.String expression,
                            Role role)

writeComment

public abstract void writeComment(java.lang.String comment)

writeInitialStateEntering

protected void writeInitialStateEntering()

writeScalarRule

protected void writeScalarRule(Equation equation,
                               boolean acceptInternal)

writeRules

protected void writeRules()

writeSignificantRules

protected void writeSignificantRules()

writeRulesImpl

protected void writeRulesImpl(boolean acceptInternal)
Write rules that are equations with type TYPE_SCALAR.


writeRateEquation

protected void writeRateEquation(java.util.List list)

writeTransition

protected void writeTransition(State currentState,
                               Transition transition)

getScalarEquations

protected Equation[] getScalarEquations()

processMath

protected void processMath(Node node,
                           Role role)
Substitutes BioUML variable names with variable names used in simulation script.


processVarNode

protected void processVarNode(AstVarNode node,
                              Role role)

writeFunctionDeclarations

protected void writeFunctionDeclarations()

fillSimulationResult

public void fillSimulationResult(SimulationResult result)
                          throws java.lang.Exception
Throws:
java.lang.Exception

isSignificantVariable

protected boolean isSignificantVariable(java.lang.String type)

writeFile

public void writeFile(java.lang.String source,
                      java.lang.String outDir,
                      java.lang.String outFile,
                      boolean rewrite)
               throws java.lang.Exception
Utility method to write needed source files from the specified source to the specified directory.

Throws:
java.lang.Exception


Copyright © 2001-2003 Biosof.Ru. All Rights Reserved.