22#include <ql/math/interpolations/cubicinterpolation.hpp>
23#include <ql/methods/finitedifferences/meshers/fdmmeshercomposite.hpp>
24#include <ql/methods/finitedifferences/meshers/fdmsimpleprocess1dmesher.hpp>
29 const QuantLib::FdmSchemeDesc scheme,
const Size stateGridPoints,
const Size timeStepsPerYear,
30 const Real mesherEpsilon)
31 : model_(model), maxTime_(maxTime), scheme_(scheme), stateGridPoints_(stateGridPoints),
32 timeStepsPerYear_(timeStepsPerYear), mesherEpsilon_(mesherEpsilon) {
33 mesher_ = QuantLib::ext::make_shared<FdmMesherComposite>(QuantLib::ext::make_shared<FdmSimpleProcess1dMesher>(
34 stateGridPoints, QuantLib::ext::dynamic_pointer_cast<StochasticProcess1D>(
model->stateProcess()),
maxTime_,
37 operator_ = QuantLib::ext::make_shared<QuantExt::FdmLgmOp>(
38 mesher_, QuantLib::ext::dynamic_pointer_cast<StochasticProcess1D>(
model->stateProcess()));
39 solver_ = QuantLib::ext::make_shared<FdmBackwardSolver>(
40 operator_, std::vector<QuantLib::ext::shared_ptr<BoundaryCondition<FdmLinearOp>>>(),
nullptr,
scheme_);
52 QL_REQUIRE(t0 < t1,
"LgmCFdSolver::rollback(): t0 (" << t0 <<
") < t1 (" << t1 <<
") required.");
53 if (
steps == Null<Size>())
55 Array workingArray(v.
size());
58 if (QuantLib::close_enough(t0, 0.0)) {
59 Array x =
mesher_->locations(0);
60 MonotonicCubicNaturalSpline interpolation(x.begin(), x.end(), workingArray.begin());
61 interpolation.enableExtrapolation();
QuantLib::ext::shared_ptr< FdmLinearOpComposite > operator_
RandomVariable rollback(const RandomVariable &v, const Real t1, const Real t0, Size steps=Null< Size >()) const override
const QuantLib::ext::shared_ptr< LinearGaussMarkovModel > & model() const override
Size gridSize() const override
QuantLib::ext::shared_ptr< FdmBackwardSolver > solver_
QuantLib::ext::shared_ptr< FdmMesher > mesher_
RandomVariable stateGrid(const Real t) const override
QuantLib::FdmSchemeDesc scheme_
QuantLib::ext::shared_ptr< LinearGaussMarkovModel > model_
LgmFdSolver(const QuantLib::ext::shared_ptr< LinearGaussMarkovModel > &model, const Real maxTime=50.0, const QuantLib::FdmSchemeDesc scheme=QuantLib::FdmSchemeDesc::Douglas(), const Size stateGridPoints=64, const Size timeStepsPerYear=24, const Real mesherEpsilon=1E-4)
RandomVariable mesherLocations_
finite difference operator LGM model
bool deterministic() const
void copyToArray(QuantLib::Array &array) const
std::vector< Size > steps