32 const ext::shared_ptr<MarketModel>& marketModel,
34 const std::vector<Size>& numeraires,
36 : marketModel_(marketModel),
37 numeraires_(numeraires),
38 initialStep_(initialStep),
39 numberOfRates_(marketModel->numberOfRates()),
40 numberOfFactors_(marketModel_->numberOfFactors()),
41 curveState_(marketModel->evolution().rateTimes()),
42 forwards_(marketModel->initialRates()),
43 displacements_(marketModel->displacements()),
44 logForwards_(numberOfRates_), initialLogForwards_(numberOfRates_),
45 drifts1_(numberOfRates_), initialDrifts_(numberOfRates_),
46 brownians_(numberOfFactors_), correlatedBrownians_(numberOfRates_),
47 alive_(marketModel->evolution().firstAliveRate())
51 Size steps = marketModel->evolution().numberOfSteps();
59 for (
Size j=0; j<steps; ++j) {
86 "mismatch between forwards and rateTimes");
98 const std::vector<Size>& startIndexOfSwapRate,
99 const std::vector<Size>& endIndexOfSwapRate)
102 "Size mismatch in constraint specification.");
103 QL_REQUIRE(endIndexOfSwapRate.size() ==
numeraires_.size(),
"Size mismatch in constraint specification.");
115 "constrained euler currently only implemented for forward rates");
123 covariances[j] = cov;
132 const std::vector<Rate>& rateConstraints,
133 const std::valarray<bool>& isConstraintActive)
136 "wrong number of constraints specified");
139 "wrong number of isConstraintActive specified");
200 Real weightsEffect = 1.0;
204 Real shift = multiplier * A[index][k];
209 weightsEffect*= originalDensity/newDensity;
212 weight *= weightsEffect;
virtual ext::shared_ptr< BrownianGenerator > create(Size factors, Size steps) const =0
Cumulative normal distribution function.
Real derivative(Real x) const
Curve state for market-model simulations
virtual const std::vector< Rate > & forwardRates() const =0
void setOnForwardRates(const std::vector< Rate > &fwdRates, Size firstValidIndex=0)
std::vector< Size > startIndexOfSwapRate_
std::vector< Real > drifts1_
std::vector< Rate > rateConstraints_
std::vector< Rate > displacements_
Real advanceStep() override
std::vector< std::vector< Real > > covariances_
Real startNewPath() override
std::vector< Rate > forwards_
const CurveState & currentState() const override
void setForwards(const std::vector< Real > &forwards)
std::vector< Real > brownians_
LogNormalFwdRateEulerConstrained(const ext::shared_ptr< MarketModel > &, const BrownianGeneratorFactory &, const std::vector< Size > &numeraires, Size initialStep=0)
std::vector< Rate > logForwards_
Size currentStep() const override
std::vector< std::vector< Real > > fixedDrifts_
std::vector< std::vector< Real > > variances_
void setConstraintType(const std::vector< Size > &startIndexOfSwapRate, const std::vector< Size > &endIndexOfSwapRate) override
call once
std::vector< Size > alive_
std::vector< Rate > initialLogForwards_
ext::shared_ptr< MarketModel > marketModel_
void setThisConstraint(const std::vector< Rate > &rateConstraints, const std::valarray< bool > &isConstraintActive) override
call before each path
std::vector< Real > initialDrifts_
std::vector< Size > numeraires_
std::vector< Size > endIndexOfSwapRate_
const std::vector< Size > & numeraires() const override
std::vector< LMMDriftCalculator > calculators_
ext::shared_ptr< BrownianGenerator > generator_
LMMCurveState curveState_
std::valarray< bool > isConstraintActive_
void setInitialState(const CurveState &) override
Matrix used in linear algebra.
const_row_iterator row_begin(Size i) const
const_row_iterator row_end(Size i) const
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
LinearInterpolation variance
std::size_t Size
size of a container
Drift computation for Libor market model.
void checkCompatibility(const EvolutionDescription &evolution, const std::vector< Size > &numeraires)
normal, cumulative and inverse cumulative distributions