Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
projectedbufferedmultipathgenerator.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2020 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
20
21namespace QuantExt {
22
24 const std::vector<Size>& stateProcessProjection,
25 const QuantLib::ext::shared_ptr<std::vector<std::vector<QuantLib::Path>>>& bufferedPaths)
26 : stateProcessProjection_(stateProcessProjection), bufferedPaths_(bufferedPaths), next_(MultiPath(), 1.0) {
27
28 QL_REQUIRE(bufferedPaths_, "ProjectedBufferedMultiPathGenerator: no buffered paths given (null)");
29 QL_REQUIRE(!bufferedPaths_->empty(), "ProjectedBufferedMultiPathGenerator: at least one buffered path required");
30
31 QL_REQUIRE(!stateProcessProjection.empty(),
32 "ProjectedBufferedMultiPathGenerator: state process projection is empty");
33
34 maxTargetIndex_ = *std::max_element(stateProcessProjection.begin(), stateProcessProjection.end());
35
36 reset();
37}
38
39const Sample<MultiPath>& ProjectedBufferedMultiPathGenerator::next() const {
40 QL_REQUIRE(currentPath_ < bufferedPaths_->size(),
41 "ProjectedBufferedMultiPathGenerator: run out of paths (" << bufferedPaths_->size() << ")");
42
43 QL_REQUIRE((*bufferedPaths_)[currentPath_].size() > maxTargetIndex_,
44 "ProjectedBufferedMultiPathGenerator: buffered path at sample "
45 << currentPath_ << " has insufficient dimension (" << (*bufferedPaths_)[currentPath_].size()
46 << "), need " << (maxTargetIndex_ + 1));
47
48 std::vector<Path> tmp;
49 for (Size d = 0; d < stateProcessProjection_.size(); ++d) {
51 }
52
54 next_.value = MultiPath(tmp);
55 return next_;
56}
57
59
60} // namespace QuantExt
const QuantLib::ext::shared_ptr< std::vector< std::vector< QuantLib::Path > > > bufferedPaths_
ProjectedBufferedMultiPathGenerator(const std::vector< Size > &stateProcessProjection, const QuantLib::ext::shared_ptr< std::vector< std::vector< QuantLib::Path > > > &bufferedPaths)
multi path generator projecting paths from a buffered state processr