Top Description Inners Fields Constructors Methods
org.apache.commons.math3.ode.events

public Class EventState

extends Object
Class Inheritance
Imports
org.apache.commons.math3.analysis.UnivariateFunction, org.apache.commons.math3.analysis.solvers.AllowedSolution, .BracketedUnivariateSolver, .PegasusSolver, .UnivariateSolver, .UnivariateSolverUtils, org.apache.commons.math3.exception.MaxCountExceededException, .NoBracketingException, org.apache.commons.math3.ode.EquationsMapper, .ExpandableStatefulODE, org.apache.commons.math3.ode.sampling.StepInterpolator, org.apache.commons.math3.util.FastMath

This class handles the state for one event handler during integration steps.

Each time the integrator proposes a step, the event handler switching function should be checked. This class handles the state of one handler during one integration step, with references to the state at the end of the preceding step. This information is used to decide if the handler should trigger an event or not during the proposed step.

Since
1.2

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
EventState.LocalMaxCountExceededException

Local wrapper to propagate exceptions.

Field Summary

Modifier and TypeField and Description
private final double
convergence

Convergence threshold for event localization.

private ExpandableStatefulODE
expandable

Equation being integrated.

private boolean
forward

Integration direction.

private double
g0

Value of the events handler at the beginning of the step.

private boolean
g0Positive

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

private final EventHandler
handler

Event handler.

private boolean
increasing

Variation direction around pending event.

private final double
maxCheckInterval

Maximal time interval between events handler checks.

private final int
maxIterationCount

Upper limit in the iteration count for event localization.

private EventHandler.Action
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 final UnivariateSolver
solver

Root-finding algorithm to use to detect state events.

private double
t0

Time at the beginning of the step.

Constructor Summary

AccessConstructor and Description
public
EventState(final EventHandler
event handler
handler
,
final double
maximal time interval between switching function checks (this interval prevents missing sign changes in case the integration steps becomes very large)
maxCheckInterval
,
final double
convergence threshold in the event time search
convergence
,
final int
upper limit of the iteration count in the event time search
maxIterationCount
,
final UnivariateSolver
Root-finding algorithm to use to detect state events
solver
)

Simple constructor.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if the event handler triggers an event before the end of the proposed step
evaluateStep
(final StepInterpolator
step interpolator for the proposed step
interpolator
)

Evaluate the impact of the proposed step on the event handler.

private double[]

Returns:

complete state
getCompleteState
(final StepInterpolator
interpolator to use
interpolator
)

Get the complete state (primary and secondary).

public double

Returns:

convergence threshold for event localization
getConvergence
()

Get the convergence threshold for event localization.

public EventHandler

Returns:

underlying event handler
getEventHandler
()

Get the underlying event handler.

public double

Returns:

occurrence time of the event triggered in the current step or infinity if no events are triggered
getEventTime
()

Get the occurrence time of the event triggered in the current step.

public double

Returns:

maximal time interval between events handler checks
getMaxCheckInterval
()

Get the maximal time interval between events handler checks.

public int

Returns:

upper limit in the iteration count for event localization
getMaxIterationCount
()

Get the upper limit in the iteration count for event localization.

public void
reinitializeBegin(final StepInterpolator
valid for the current step
interpolator
)

Reinitialize the beginning of the step.

public boolean

Returns:

true if the integrator should reset the derivatives too
reset
(final double
value of the independent time variable at the beginning of the next step
t
,
final double[]
array were to put the desired state vector at the beginning of the next step
y
)

Let the event handler reset the state if it wants.

public void
setExpandable(final ExpandableStatefulODE
equation being integrated
expandable
)

Set the equation.

public void
stepAccepted(final double
value of the independent time variable at the end of the step
t
,
final double[]
array containing the current value of the state vector at the end of the step
y
)

Acknowledge the fact the step has been accepted by the integrator.

public boolean

Returns:

true if the integration should be stopped
stop
()

Check if the integration should be stopped at the end of the current step.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

convergenceback to summary
private final double convergence

Convergence threshold for event localization.

expandableback to summary
private ExpandableStatefulODE expandable

Equation being integrated.

forwardback to summary
private boolean forward

Integration direction.

g0back to summary
private double g0

Value of the events handler at the beginning of the step.

g0Positiveback to summary
private boolean g0Positive

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

handlerback to summary
private final EventHandler handler

Event handler.

increasingback to summary
private boolean increasing

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

maxCheckIntervalback to summary
private final double maxCheckInterval

Maximal time interval between events handler checks.

maxIterationCountback to summary
private final int maxIterationCount

Upper limit in the iteration count for event localization.

nextActionback to summary
private EventHandler.Action nextAction

Next action indicator.

pendingEventback to summary
private boolean pendingEvent

Indicator of event expected during the step.

pendingEventTimeback to summary
private double pendingEventTime

Occurrence time of the pending event.

previousEventTimeback to summary
private double previousEventTime

Occurrence time of the previous event.

solverback to summary
private final UnivariateSolver solver

Root-finding algorithm to use to detect state events.

t0back to summary
private double t0

Time at the beginning of the step.

Constructor Detail

EventStateback to summary
public EventState(final EventHandler handler, final double maxCheckInterval, final double convergence, final int maxIterationCount, final UnivariateSolver solver)

Simple constructor.

Parameters
handler:EventHandler

event handler

maxCheckInterval:double

maximal time interval between switching function checks (this interval prevents missing sign changes in case the integration steps becomes very large)

convergence:double

convergence threshold in the event time search

maxIterationCount:int

upper limit of the iteration count in the event time search

solver:UnivariateSolver

Root-finding algorithm to use to detect state events

Method Detail

evaluateStepback to summary
public boolean evaluateStep(final StepInterpolator interpolator) throws MaxCountExceededException, NoBracketingException

Evaluate the impact of the proposed step on the event handler.

Parameters
interpolator:StepInterpolator

step interpolator for the proposed step

Returns:boolean

true if the event handler triggers an event before the end of the proposed step

Exceptions
MaxCountExceededException:
if the interpolator throws one because the number of functions evaluations is exceeded
NoBracketingException:
if the event cannot be bracketed
getCompleteStateback to summary
private double[] getCompleteState(final StepInterpolator interpolator)

Get the complete state (primary and secondary).

Parameters
interpolator:StepInterpolator

interpolator to use

Returns:double[]

complete state

getConvergenceback to summary
public double getConvergence()

Get the convergence threshold for event localization.

Returns:double

convergence threshold for event localization

getEventHandlerback to summary
public EventHandler getEventHandler()

Get the underlying event handler.

Returns:EventHandler

underlying event handler

getEventTimeback to summary
public double getEventTime()

Get the occurrence time of the event triggered in the current step.

Returns:double

occurrence time of the event triggered in the current step or infinity if no events are triggered

getMaxCheckIntervalback to summary
public double getMaxCheckInterval()

Get the maximal time interval between events handler checks.

Returns:double

maximal time interval between events handler checks

getMaxIterationCountback to summary
public int getMaxIterationCount()

Get the upper limit in the iteration count for event localization.

Returns:int

upper limit in the iteration count for event localization

reinitializeBeginback to summary
public void reinitializeBegin(final StepInterpolator interpolator) throws MaxCountExceededException

Reinitialize the beginning of the step.

Parameters
interpolator:StepInterpolator

valid for the current step

Exceptions
MaxCountExceededException:
if the interpolator throws one because the number of functions evaluations is exceeded
resetback to summary
public boolean reset(final double t, final double[] y)

Let the event handler reset the state if it wants.

Parameters
t:double

value of the independent time variable at the beginning of the next step

y:double[]

array were to put the desired state vector at the beginning of the next step

Returns:boolean

true if the integrator should reset the derivatives too

setExpandableback to summary
public void setExpandable(final ExpandableStatefulODE expandable)

Set the equation.

Parameters
expandable:ExpandableStatefulODE

equation being integrated

stepAcceptedback to summary
public void stepAccepted(final double t, final double[] y)

Acknowledge the fact the step has been accepted by the integrator.

Parameters
t:double

value of the independent time variable at the end of the step

y:double[]

array containing the current value of the state vector at the end of the step

stopback to summary
public boolean stop()

Check if the integration should be stopped at the end of the current step.

Returns:boolean

true if the integration should be stopped

org.apache.commons.math3.ode.events back to summary

private Class EventState.LocalMaxCountExceededException

extends RuntimeException
Class Inheritance

Local wrapper to propagate exceptions.

Field Summary

Modifier and TypeField and Description
private static final long
private final MaxCountExceededException
wrapped

Wrapped exception.

Constructor Summary

AccessConstructor and Description
pack-priv
LocalMaxCountExceededException(final MaxCountExceededException
exception to wrap
exception
)

Simple constructor.

Method Summary

Modifier and TypeMethod and Description
public MaxCountExceededException

Returns:

wrapped exception
getException
()

Get the wrapped exception.

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.lang.RuntimeException.serialVersionUID.

Serializable UID.

wrappedback to summary
private final MaxCountExceededException wrapped

Wrapped exception.

Constructor Detail

LocalMaxCountExceededExceptionback to summary
pack-priv LocalMaxCountExceededException(final MaxCountExceededException exception)

Simple constructor.

Parameters
exception:MaxCountExceededException

exception to wrap

Method Detail

getExceptionback to summary
public MaxCountExceededException getException()

Get the wrapped exception.

Returns:MaxCountExceededException

wrapped exception