indii/ml/sde/StochasticNumericalSolver.hpp

00001 #ifndef INDII_ML_SDE_STOCHASTICNUMERICALSOLVER_HPP
00002 #define INDII_ML_SDE_STOCHASTICNUMERICALSOLVER_HPP
00003 
00004 #include "../ode/NumericalSolver.hpp"
00005 #include "../aux/WienerProcess.hpp"
00006 
00007 #include <stack>
00008 
00009 namespace indii {
00010   namespace ml {
00011     namespace sde {
00012 /**
00013  * Abstract numerical solver for a system of stochastic differential
00014  * equations.
00015  *
00016  * @author Lawrence Murray <lawrence@indii.org>
00017  * @version $Rev: 582 $
00018  * @date $Date: 2008-12-15 17:03:50 +0000 (Mon, 15 Dec 2008) $
00019  */
00020 class StochasticNumericalSolver : public indii::ml::ode::NumericalSolver {
00021 public:
00022   /**
00023    * Constructor.
00024    *
00025    * @param dimensions Dimensionality of the state space.
00026    * @param noises Dimensionality of the noise space.
00027    *
00028    * The time is initialised to zero, but the state is uninitialised
00029    * and should be set with setVariable() or setState().
00030    */
00031   StochasticNumericalSolver(const unsigned int dimensions,
00032       const unsigned int noises);
00033 
00034   /**
00035    * Constructor.
00036    *
00037    * @param y0 Initial state.
00038    * @param noises Dimensionality of the noise space.
00039    *
00040    * The time is initialised to zero and the state to that given.
00041    */
00042   StochasticNumericalSolver(const indii::ml::aux::vector& y0,
00043       const unsigned int noises);
00044 
00045   /**
00046    * Destructor.
00047    */
00048   virtual ~StochasticNumericalSolver();
00049 
00050 protected:
00051   /**
00052    * Wiener process system noise.
00053    */
00054   indii::ml::aux::WienerProcess<double> W;
00055 
00056   /**
00057    * \f$t_1,t_2,\ldots > t\f$; future times.
00058    */
00059   std::stack<double> tf;
00060 
00061   /**
00062    * \f$\Delta\mathbf{W}(t_1),\Delta\mathbf{W}(t_2),\ldots\f$; Wiener process
00063    * increments at future times.
00064    */
00065   std::stack<indii::ml::aux::vector> dWf;
00066 
00067   /**
00068    * Sample Wiener process noise. This conditions on previous samples
00069    * of the Wiener trajectory at future times resulting from time
00070    * steps rejected by the adaptive step size control. This ensures
00071    * that steps are rejected only due to error bounds being exceeded
00072    * and not due to an improbable but perfectly valid Wiener
00073    * trajectory.
00074    *
00075    * @param ts \f$t_s\f$; the time at which to sample the noise. If this
00076    * is greater than the earliest time in the future path, will be adjusted
00077    * to this earliest time on return.
00078    *
00079    * @return True if a new Wiener increment was sampled, false if an
00080    * existing increment has been used.
00081    *
00082    * Let \f$t\f$ be the current time and \f$t_s\f$ the time at which
00083    * to sample the noise.
00084    *
00085    * Of the stored Wiener increments at times \f$t_1,t_2,\ldots >
00086    * t\f$, let \f$t_l\f$ be the greatest time less than or equal to
00087    * \f$t_s\f$, and \f$t_u\f$ the least time greater than
00088    * \f$t_s\f$. \f$\Delta\mathbf{W}(t_l)\f$ and
00089    * \f$\Delta\mathbf{W}(t_u)\f$ are the corresponding Wiener
00090    * increments.
00091    *
00092    * If \f$t_l\f$ does not exist, set \f$t_l \leftarrow t\f$.
00093    *
00094    * Then, if \f$t_s \neq t_l\f$, draw \f$\mathbf{\delta} \sim
00095    * \mathcal{N}(0,\sqrt{t_s-t_l})\f$. If \f$t_u\f$ does not exist,
00096    * set \f$\Delta\mathbf{W}(t_s) \leftarrow
00097    * \mathbf{\delta}\f$. Otherwise, set:
00098    *
00099    * \f{eqnarray*}
00100    * \Delta\mathbf{W}(t_s) &\leftarrow& \frac{t_s - t_l}{t_u -
00101    * t_l}\Delta\mathbf{W}(t_u) + \mathbf{\delta} \\
00102    * \Delta\mathbf{W}(t_u) &\leftarrow& \frac{t_u - t_s}{t_u -
00103    * t_l}\Delta\mathbf{W}(t_u) - \mathbf{\delta} \\
00104    * \f}
00105    *
00106    * and store.
00107    */
00108   bool sampleNoise(double* ts);
00109 
00110   virtual void reset();
00111 
00112 };
00113 
00114     }
00115   }
00116 }
00117 
00118 #endif
00119 

Generated on Wed Dec 17 15:11:57 2008 for dysii Dynamical Systems Library by  doxygen 1.5.3