org.apache.commons.math.ode
Class SwitchingFunctionsHandler

java.lang.Object
  extended by org.apache.commons.math.ode.SwitchingFunctionsHandler

public class SwitchingFunctionsHandler
extends java.lang.Object

This class handles several switching functions during integration.

Since:
1.2
Version:
$Revision: 657612 $ $Date: 2008-05-18 21:37:23 +0200 (dim., 18 mai 2008) $
See Also:
SwitchingFunction

Constructor Summary
SwitchingFunctionsHandler()
          Simple constructor.
 
Method Summary
 void addSwitchingFunction(SwitchingFunction function, double maxCheckInterval, double convergence, int maxIterationCount)
          Add a switching function.
 void clearSwitchingFunctions()
          Remove all the switching functions that have been added to the handler.
 boolean evaluateStep(StepInterpolator interpolator)
          Evaluate the impact of the proposed step on all handled switching functions.
 double getEventTime()
          Get the occurrence time of the first event triggered in the last evaluated step.
 java.util.Collection<org.apache.commons.math.ode.SwitchState> getSwitchingFunctions()
          Get all the switching functions that have been added to the handler.
 boolean isEmpty()
          Check if the handler does not have any condition.
 boolean reset(double t, double[] y)
          Let the switching functions reset the state if they want.
 void stepAccepted(double t, double[] y)
          Inform the switching functions that 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
 

Constructor Detail

SwitchingFunctionsHandler

public SwitchingFunctionsHandler()
Simple constructor. Create an empty handler

Method Detail

addSwitchingFunction

public void addSwitchingFunction(SwitchingFunction function,
                                 double maxCheckInterval,
                                 double convergence,
                                 int maxIterationCount)
Add a switching function.

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
See Also:
getSwitchingFunctions(), clearSwitchingFunctions()

getSwitchingFunctions

public java.util.Collection<org.apache.commons.math.ode.SwitchState> getSwitchingFunctions()
Get all the switching functions that have been added to the handler.

Returns:
an unmodifiable collection of the added switching functions
See Also:
addSwitchingFunction(SwitchingFunction, double, double, int), clearSwitchingFunctions()

clearSwitchingFunctions

public void clearSwitchingFunctions()
Remove all the switching functions that have been added to the handler.

See Also:
addSwitchingFunction(SwitchingFunction, double, double, int), getSwitchingFunctions()

isEmpty

public boolean isEmpty()
Check if the handler does not have any condition.

Returns:
true if handler is empty

evaluateStep

public boolean evaluateStep(StepInterpolator interpolator)
                     throws DerivativeException,
                            IntegratorException
Evaluate the impact of the proposed step on all handled switching functions.

Parameters:
interpolator - step interpolator for the proposed step
Returns:
true if at least one 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
IntegratorException - if an event cannot be located

getEventTime

public double getEventTime()
Get the occurrence time of the first event triggered in the last evaluated step.

Returns:
occurrence time of the first event triggered in the last evaluated step, or Double.NaN if no event is triggered

stepAccepted

public void stepAccepted(double t,
                         double[] y)
                  throws IntegratorException
Inform the switching functions that 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:
IntegratorException - if the value of one of the switching functions 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)
              throws IntegratorException
Let the switching functions reset the state if they want.

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
Throws:
IntegratorException - if one of the switching functions that should reset the state fails to do it


Copyright © 2003-2008 The Apache Software Foundation. All Rights Reserved.