26#ifndef quantlib_montecarlo_path_generator_hpp
27#define quantlib_montecarlo_path_generator_hpp
34 class StochasticProcess;
35 class StochasticProcess1D;
73 mutable std::vector<Real>
temp_;
86 : brownianBridge_(brownianBridge), generator_(
std::move(generator)),
87 dimension_(generator_.dimension()), timeGrid_(length, timeSteps),
89 next_(
Path(timeGrid_), 1.0), temp_(dimension_), bb_(timeGrid_) {
91 "sequence generator dimensionality (" <<
dimension_
92 <<
") != timeSteps (" << timeSteps <<
")");
100 : brownianBridge_(brownianBridge), generator_(
std::move(generator)),
101 dimension_(generator_.dimension()), timeGrid_(
std::move(timeGrid)),
103 next_(
Path(timeGrid_), 1.0), temp_(dimension_), bb_(timeGrid_) {
105 "sequence generator dimensionality (" <<
dimension_
125 typedef typename GSG::sample_type sequence_type;
126 const sequence_type& sequence_ =
127 antithetic ? generator_.lastSequence()
128 : generator_.nextSequence();
130 if (brownianBridge_) {
131 bb_.transform(sequence_.value.begin(),
132 sequence_.value.end(),
135 std::copy(sequence_.value.begin(),
136 sequence_.value.end(),
140 next_.weight = sequence_.weight;
143 path.
front() = process_->x0();
146 Time t = timeGrid_[i-1];
147 Time dt = timeGrid_.dt(i-1);
148 path[i] = process_->evolve(
t, path[i-1], dt,
149 antithetic ? -temp_[i-1] :
Builds Wiener process paths using Gaussian variates.
Generates random paths using a sequence generator.
const sample_type & next() const
ext::shared_ptr< StochasticProcess1D > process_
const sample_type & antithetic() const
const TimeGrid & timeGrid() const
Sample< Path > sample_type
std::vector< Real > temp_
PathGenerator(const ext::shared_ptr< StochasticProcess > &, Time length, Size timeSteps, GSG generator, bool brownianBridge)
single-factor random walk
Real front() const
initial asset value
1-dimensional stochastic process
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
Real Time
continuous quantity with 1-year units
std::size_t Size
size of a container