de.grogra.numeric
Class GraphODE

java.lang.Object
  extended by de.grogra.numeric.GraphODE
All Implemented Interfaces:
ODE

public abstract class GraphODE
extends java.lang.Object
implements ODE

This abstract class represents an ODE on a graph. The state will be automatically copied into the graph prior evaluation of the rate function. The user must implement the abstract function getRate() to evaluate the rates, and can make use of graph queries and rules. The class RGG internally implements this class and provides helper functions that forward to the same functions in this class.

Author:
Reinhard Hemmerling

Constructor Summary
GraphODE()
           
 
Method Summary
abstract  void getRate()
          Use graph queries to evaluate rate function.
 void getRate(double[] out, double t, double[] state)
          Calculate the rate (derivative of state) of the system for a given time and state.
static java.util.List<RateAssignment> getRateAssignments(Registry r)
          Query the registry for all classes belonging to the current project and extract the rate assignments from all $ODEHelper classes.
 Solver getSolver()
          Get the currently set solver for numerical integration.
 void integrate(double duration)
          Integrate over a time interval.
 void monitor(VoidToDouble g)
          Install a monitor function that generates an event when the returned value changes its sign.
 void monitor(VoidToDouble g, java.lang.Runnable r)
          Install a monitor function that generates an event when the returned value changes its sign.
 void monitorPeriodic(double period, java.lang.Runnable r)
          Trigger an event in regular intervals and call the event handler.
 void setSolver(Solver solver)
          Set a new solver to use for numerical integration.
 void unmonitor()
          Remove all monitors.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GraphODE

public GraphODE()
Method Detail

getRate

public abstract void getRate()
Use graph queries to evaluate rate function.


getRate

public final void getRate(double[] out,
                          double t,
                          double[] state)
Description copied from interface: ODE
Calculate the rate (derivative of state) of the system for a given time and state.

Specified by:
getRate in interface ODE
Parameters:
out - provides memory for storing the rate
t - current time
state - current state

getRateAssignments

public static java.util.List<RateAssignment> getRateAssignments(Registry r)
Query the registry for all classes belonging to the current project and extract the rate assignments from all $ODEHelper classes.

Parameters:
r -
Returns:

getSolver

public Solver getSolver()
Get the currently set solver for numerical integration.

Returns:

integrate

public void integrate(double duration)
               throws NumericException
Integrate over a time interval. The method takes care of memory allocation for the node attributes in the graph and copying from graph to state vector prior integration, and back from state vector to graph afterwards.

Parameters:
duration - time interval to integrate over
Throws:
NumericException

monitor

public void monitor(VoidToDouble g)
Install a monitor function that generates an event when the returned value changes its sign. The monitor must not modify the state of the graph. Integration will stop when the event triggers.

Parameters:
g - monitor function

monitor

public void monitor(VoidToDouble g,
                    java.lang.Runnable r)
Install a monitor function that generates an event when the returned value changes its sign. The monitor must not modify the state of the graph. When the event triggers, the event handler is called. Integration will stop when the event triggers. The event handler may modify the graph.

Parameters:
g - monitor function
r - event handler

monitorPeriodic

public void monitorPeriodic(double period,
                            java.lang.Runnable r)
Trigger an event in regular intervals and call the event handler. The event handler must not modify the graph.

Parameters:
period - interval between events
r - event handler

setSolver

public void setSolver(Solver solver)
Set a new solver to use for numerical integration.

Parameters:
solver -

unmonitor

public void unmonitor()
Remove all monitors.