#include <qle/methods/projectedvariatemultipathgenerator.hpp>
◆ ProjectedVariateMultiPathGenerator()
If projection(j) = i for state process indices i from the projected process and j from the original process, then stateProcessProjection[i] = j, i.e. a state process component index from the projected model is mapped to the state process component index of the original model.
Definition at line 23 of file projectedvariatemultipathgenerator.cpp.
29
30 for (Size s = 0; s <
process_->size(); ++s)
32
33 QL_REQUIRE(stateProcessProjection.size() == process->factors(),
34 "ProjectedVariateMultiPathGenerator: state process projection source size ("
35 << stateProcessProjection.size() << ") does not match process factors (" << process->factors());
36 QL_REQUIRE(!stateProcessProjection.empty(),
37 "ProjectedVariateMultiPathGenerator: state process projection is empty");
38
39 maxTargetIndex_ = *std::max_element(stateProcessProjection.begin(), stateProcessProjection.end());
40}
const QuantLib::ext::shared_ptr< StochasticProcess > process_
Sample< MultiPath > next_
const std::vector< Size > stateProcessProjection_
const QuantLib::ext::shared_ptr< MultiPathVariateGeneratorBase > variateGenerator_
◆ next()
const Sample< MultiPath > & next |
( |
| ) |
const |
|
overridevirtual |
Implements MultiPathGeneratorBase.
Definition at line 42 of file projectedvariatemultipathgenerator.cpp.
42 {
43
45 next_.weight = v.weight;
46
47 QL_REQUIRE(v.value.size() ==
timeGrid_.size() - 1,
48 "ProjectedVariateMultiPathGenerator::next(): variate generator returns "
49 << v.value.size() <<
" variates for " << (
timeGrid_.size() - 1) <<
" time steps to evolve");
50
51 QL_REQUIRE(v.value.size() == 0 ||
maxTargetIndex_ < v.value.front().size(),
52 "ProjectedVariateMultiPathGenerator::next(): variate generator returns variate of size "
53 << v.value.front().size() <<
", this is required to be > max target index (" <<
maxTargetIndex_
54 << ")");
55
58
59 Array dw(dim, 0.0);
60 Array state =
process_->initialValues();
61 for (Size i = 0; i <
timeGrid_.size() - 1; ++i) {
62 for (Size d = 0; d < dim; ++d)
65 for (Size s = 0; s < stateSize; ++s)
66 next_.value[s][i + 1] = state[s];
67 }
69}
◆ reset()
◆ process_
◆ timeGrid_
◆ stateProcessProjection_
const std::vector<Size> stateProcessProjection_ |
|
private |
◆ variateGenerator_
◆ maxTargetIndex_
◆ next_