Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.commons.math.ode
Class ContinuousOutputModel

    java.lang.Object
      org.apache.commons.math.ode.ContinuousOutputModel

All Implemented Interfaces:
  java.io.Serializable, StepHandler

    public class ContinuousOutputModel

extends java.lang.Object
implements StepHandler, java.io.Serializable

This class stores all information provided by an ODE integrator during the integration process and build a continuous model of the solution from this.

This class act as a step handler from the integrator point of view. It is called iteratively during the integration process and stores a copy of all steps information in a sorted collection for later use. Once the integration process is over, the user can use the `setInterpolatedTime` and `getInterpolatedState` to retrieve this information at any time. It is important to wait for the integration to be over before attempting to call `setInterpolatedTime` because some internal variables are set only once the last step has been handled.

This is useful for example if the main loop of the user application should remain independent from the integration process or if one needs to mimic the behaviour of an analytical model despite a numerical model is used (i.e. one needs the ability to get the model value at any time or to navigate through the data).

If problem modeling is done with several separate integration phases for contiguous intervals, the same ContinuousOutputModel can be used as step handler for all integration phases as long as they are performed in order and in the same direction. As an example, one can extrapolate the trajectory of a satellite with one model (i.e. one set of differential equations) up to the beginning of a maneuver, use another more complex model including thrusters modeling and accurate attitude control during the maneuver, and revert to the first model after the end of the maneuver. If the same continuous output model handles the steps of all integration phases, the user do not need to bother when the maneuver begins or ends, he has all the data available in a transparent manner.

An important feature of this class is that it implements the `Serializable` interface. This means that the result of an integration can be serialized and reused later (if stored into a persistent medium like a filesystem or a database) or elsewhere (if sent to another application). Only the result of the integration is stored, there is no reference to the integrated problem by itself.

One should be aware that the amount of data stored in a ContinuousOutputModel instance can be important if the state vector is large, if the integration interval is long or if the steps are small (which can result from small tolerance settings in `adaptive step size integrators`).

Since:
  1.2
Version:
  $Revision: 811827 $ $Date: 2009-09-06 11:32:50 -0400 (Sun, 06 Sep 2009) $
See Also:
  `StepHandler`, `StepInterpolator`, Serialized Form

Field Summary
`private double` | `finalTime` Final integration time.
`private boolean` | `forward` Integration direction indicator.
`private int` | `index` Current interpolator index.
`private double` | `initialTime` Initial integration time.
`private static long` | `serialVersionUID` Serializable version identifier
`private java.util.List<StepInterpolator>` | `steps` Steps table.

Constructor Summary
`ContinuousOutputModel()` Simple constructor.

Method Summary
`void` | `append(ContinuousOutputModel model)` Append another model at the end of the instance.
`double` | `getFinalTime()` Get the final integration time.
`double` | `getInitialTime()` Get the initial integration time.
`double[]` | `getInterpolatedState()` Get the state vector of the interpolated point.
`double` | `getInterpolatedTime()` Get the time of the interpolated point.
`void` | `handleStep(StepInterpolator interpolator, boolean isLast)` Handle the last accepted step.
`private int` | `locatePoint(double time, StepInterpolator interval)` Compare a step interval and a double.
`boolean` | `requiresDenseOutput()` Determines whether this handler needs dense output.
`void` | `reset()` Reset the step handler.
`void` | `setInterpolatedTime(double time)` Set the time of the interpolated point.

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

### initialTime

    private double initialTime

  Initial integration time.

### finalTime

    private double finalTime

  Final integration time.

### forward

    private boolean forward

  Integration direction indicator.

### index

    private int index

  Current interpolator index.

### steps

    private java.util.List<StepInterpolator> steps

  Steps table.

Constructor Detail

### ContinuousOutputModel

    public ContinuousOutputModel()

  Simple constructor. Build an empty continuous output model.

Method Detail

### append

    public void append(ContinuousOutputModel model)
                throws DerivativeException

  Append another model at the end of the instance.

  Parameters:
    `model` - model to add at the end of the instance
  Throws:
    `DerivativeException` - if some step interpolators from the appended model cannot be copied
    `java.lang.IllegalArgumentException` - if the model to append is not compatible with the instance (dimension of the state vector, propagation direction, hole between the dates)

### requiresDenseOutput

    public boolean requiresDenseOutput()

  Determines whether this handler needs dense output.

  The essence of this class is to provide dense output over all steps, hence it requires the internal steps to provide themselves dense output. The method therefore returns always true.

  Specified by:
    `requiresDenseOutput` in interface `StepHandler`
  Returns:
    always true

### reset

    public void reset()

  Reset the step handler. Initialize the internal data as required before the first step is handled.

  Specified by:
    `reset` in interface `StepHandler`

### handleStep

    public void handleStep(StepInterpolator interpolator,
                           boolean isLast)
                    throws DerivativeException

  Handle the last accepted step. A copy of the information provided by the last step is stored in the instance for later use.

  Specified by:
    `handleStep` in interface `StepHandler`
  Parameters:
    `interpolator` - interpolator for the last accepted step.
    `isLast` - true if the step is the last one
  Throws:
    `DerivativeException` - this exception is propagated to the caller if the underlying user function triggers one

### getInitialTime

    public double getInitialTime()

  Get the initial integration time.

  Returns:
    initial integration time

### getFinalTime

    public double getFinalTime()

  Get the final integration time.

  Returns:
    final integration time

### getInterpolatedTime

    public double getInterpolatedTime()

  Get the time of the interpolated point. If `setInterpolatedTime(double)` has not been called, it returns the final integration time.

  Returns:
    interpolation point time

### setInterpolatedTime

    public void setInterpolatedTime(double time)

  Set the time of the interpolated point.

  This method should not be called before the integration is over because some internal variables are set only once the last step has been handled.

  Setting the time outside of the integration interval is now allowed (it was not allowed up to version 5.9 of Mantissa), but should be used with care since the accuracy of the interpolator will probably be very poor far from this interval. This allowance has been added to simplify implementation of search algorithms near the interval endpoints.

  Parameters:
    `time` - time of the interpolated point

### getInterpolatedState

    public double[] getInterpolatedState()
                                  throws DerivativeException

  Get the state vector of the interpolated point.

  Returns:
    state vector at time `getInterpolatedTime()`
  Throws:
    `DerivativeException` - if this call induces an automatic step finalization that throws one

### locatePoint

    private int locatePoint(double time,
                            StepInterpolator interval)

  Compare a step interval and a double.

  Parameters:
    `time` - point to locate
    `interval` - step interval
  Returns:
    -1 if the double is before the interval, 0 if it is in the interval, and +1 if it is after the interval, according to the interval direction

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright (c) 2003-2011 Apache Software Foundation