org.apache.commons.math.ode
Class SwitchState

java.lang.Object
  extended by org.apache.commons.math.ode.SwitchState
All Implemented Interfaces:
java.io.Serializable

 class SwitchState
extends java.lang.Object
implements java.io.Serializable

This class handles the state for one switching function during integration steps.

Each time the integrator proposes a step, the switching function should be checked. This class handles the state of one function during one integration step, with references to the state at the end of the preceding step. This information is used to determine if the function should trigger an event or not during the proposed step (and hence the step should be reduced to ensure the event occurs at a bound rather than inside the step).

Since:
1.2
Version:
$Revision: 620312 $ $Date: 2008-02-10 12:28:59 -0700 (Sun, 10 Feb 2008) $

Field Summary
private  double convergence
          Convergence threshold for event localisation.
private  SwitchingFunction function
          Switching function.
private  double g0
          Value of the switching function at the beginning of the step.
private  boolean g0Positive
          Simulated sign of g0 (we cheat when crossing events).
private  boolean increasing
          Variation direction around pending event.
private  double maxCheckInterval
          Maximal time interval between switching function checks.
private  int maxIterationCount
          Upper limit in the iteration count for event localisation.
private  int nextAction
          Next action indicator.
private  boolean pendingEvent
          Indicator of event expected during the step.
private  double pendingEventTime
          Occurrence time of the pending event.
private  double previousEventTime
          Occurrence time of the previous event.
private static long serialVersionUID
          Serializable version identifier.
private  double t0
          Time at the beginning of the step.
 
Constructor Summary
SwitchState(SwitchingFunction function, double maxCheckInterval, double convergence, int maxIterationCount)
          Simple constructor.
 
Method Summary
 boolean evaluateStep(StepInterpolator interpolator)
          Evaluate the impact of the proposed step on the switching function.
 double getEventTime()
          Get the occurrence time of the event triggered in the current step.
 void reinitializeBegin(double t0, double[] y0)
          Reinitialize the beginning of the step.
 boolean reset(double t, double[] y)
          Let the switching function reset the state if it wants.
 void stepAccepted(double t, double[] y)
          Acknowledge the fact the step has been accepted by the integrator.
 boolean stop()
          Check if the integration should be stopped at the end of the current step.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
Serializable version identifier.

See Also:
Constant Field Values

function

private SwitchingFunction function
Switching function.


maxCheckInterval

private double maxCheckInterval
Maximal time interval between switching function checks.


convergence

private double convergence
Convergence threshold for event localisation.


maxIterationCount

private int maxIterationCount
Upper limit in the iteration count for event localisation.


t0

private double t0
Time at the beginning of the step.


g0

private double g0
Value of the switching function at the beginning of the step.


g0Positive

private boolean g0Positive
Simulated sign of g0 (we cheat when crossing events).


pendingEvent

private boolean pendingEvent
Indicator of event expected during the step.


pendingEventTime

private double pendingEventTime
Occurrence time of the pending event.


previousEventTime

private double previousEventTime
Occurrence time of the previous event.


increasing

private boolean increasing
Variation direction around pending event. (this is considered with respect to the integration direction)


nextAction

private int nextAction
Next action indicator.

Constructor Detail

SwitchState

public SwitchState(SwitchingFunction function,
                   double maxCheckInterval,
                   double convergence,
                   int maxIterationCount)
Simple constructor.

Parameters:
function - switching function
maxCheckInterval - maximal time interval between switching function checks (this interval prevents missing sign changes in case the integration steps becomes very large)
convergence - convergence threshold in the event time search
maxIterationCount - upper limit of the iteration count in the event time search
Method Detail

reinitializeBegin

public void reinitializeBegin(double t0,
                              double[] y0)
                       throws FunctionEvaluationException
Reinitialize the beginning of the step.

Parameters:
t0 - value of the independent time variable at the beginning of the step
y0 - array containing the current value of the state vector at the beginning of the step
Throws:
FunctionEvaluationException - if the switching function value cannot be evaluated at the beginning of the step

evaluateStep

public boolean evaluateStep(StepInterpolator interpolator)
                     throws DerivativeException,
                            FunctionEvaluationException,
                            ConvergenceException
Evaluate the impact of the proposed step on the switching function.

Parameters:
interpolator - step interpolator for the proposed step
Returns:
true if the switching function triggers an event before the end of the proposed step (this implies the step should be rejected)
Throws:
DerivativeException - if the interpolator fails to compute the function somewhere within the step
FunctionEvaluationException - if the switching function cannot be evaluated
ConvergenceException - if an event cannot be located

getEventTime

public double getEventTime()
Get the occurrence time of the event triggered in the current step.

Returns:
occurrence time of the event triggered in the current step.

stepAccepted

public void stepAccepted(double t,
                         double[] y)
                  throws FunctionEvaluationException
Acknowledge the fact the step has been accepted by the integrator.

Parameters:
t - value of the independent time variable at the end of the step
y - array containing the current value of the state vector at the end of the step
Throws:
FunctionEvaluationException - if the value of the switching function cannot be evaluated

stop

public boolean stop()
Check if the integration should be stopped at the end of the current step.

Returns:
true if the integration should be stopped

reset

public boolean reset(double t,
                     double[] y)
Let the switching function reset the state if it wants.

Parameters:
t - value of the independent time variable at the beginning of the next step
y - array were to put the desired state vector at the beginning of the next step
Returns:
true if the integrator should reset the derivatives too