Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
lgmfdsolver.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2024 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
19/*! \file lgmfdsolverx.hpp
20 \brief numeric fd solver for LGM model
21
22 \ingroup models
23*/
24
25#pragma once
26
29
30#include <ql/methods/finitedifferences/meshers/fdmmesher.hpp>
31#include <ql/methods/finitedifferences/solvers/fdmbackwardsolver.hpp>
32
33namespace QuantExt {
34
35//! Numerical FD solver for the LGM model
37public:
38 LgmFdSolver(const QuantLib::ext::shared_ptr<LinearGaussMarkovModel>& model, const Real maxTime = 50.0,
39 const QuantLib::FdmSchemeDesc scheme = QuantLib::FdmSchemeDesc::Douglas(),
40 const Size stateGridPoints = 64, const Size timeStepsPerYear = 24, const Real mesherEpsilon = 1E-4);
41 Size gridSize() const override;
42 RandomVariable stateGrid(const Real t) const override;
43 // if steps are not given, the time steps per year specified in the constructor
44 RandomVariable rollback(const RandomVariable& v, const Real t1, const Real t0,
45 Size steps = Null<Size>()) const override;
46 const QuantLib::ext::shared_ptr<LinearGaussMarkovModel>& model() const override;
47
48private:
49 QuantLib::ext::shared_ptr<LinearGaussMarkovModel> model_;
51 QuantLib::FdmSchemeDesc scheme_;
55
56 mutable QuantLib::ext::shared_ptr<FdmMesher> mesher_; // the mesher for the FD solver
57 mutable QuantLib::ext::shared_ptr<FdmLinearOpComposite> operator_; // the operator
58 mutable QuantLib::ext::shared_ptr<FdmBackwardSolver> solver_; // the sovler
59
61};
62
63} // namespace QuantExt
Interface for LGM1F backward solver.
Numerical FD solver for the LGM model.
Definition: lgmfdsolver.hpp:36
QuantLib::ext::shared_ptr< FdmLinearOpComposite > operator_
Definition: lgmfdsolver.hpp:57
RandomVariable rollback(const RandomVariable &v, const Real t1, const Real t0, Size steps=Null< Size >()) const override
Definition: lgmfdsolver.cpp:49
const QuantLib::ext::shared_ptr< LinearGaussMarkovModel > & model() const override
Definition: lgmfdsolver.cpp:47
Size gridSize() const override
Definition: lgmfdsolver.cpp:43
QuantLib::ext::shared_ptr< FdmBackwardSolver > solver_
Definition: lgmfdsolver.hpp:58
QuantLib::ext::shared_ptr< FdmMesher > mesher_
Definition: lgmfdsolver.hpp:56
RandomVariable stateGrid(const Real t) const override
Definition: lgmfdsolver.cpp:45
QuantLib::FdmSchemeDesc scheme_
Definition: lgmfdsolver.hpp:51
QuantLib::ext::shared_ptr< LinearGaussMarkovModel > model_
Definition: lgmfdsolver.hpp:49
RandomVariable mesherLocations_
Definition: lgmfdsolver.hpp:60
interface for LGM1F backward solver
std::vector< Size > steps