QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
parametricexerciseadapter.cpp
Go to the documentation of this file.
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2006 StatPro Italia srl
5
6 This file is part of QuantLib, a free-software/open-source library
7 for financial quantitative analysts and developers - http://quantlib.org/
8
9 QuantLib is free software: you can redistribute it and/or modify it
10 under the terms of the QuantLib license. You should have received a
11 copy of the license along with this program; if not, please email
12 <quantlib-dev@lists.sf.net>. The license is also available online at
13 <http://quantlib.org/license.shtml>.
14
15 This program is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 FOR A PARTICULAR PURPOSE. See the license for more details.
18*/
19
23#include <utility>
24
25namespace QuantLib {
26
28 const MarketModelParametricExercise& exercise, std::vector<std::vector<Real> > parameters)
29 : exercise_(exercise), parameters_(std::move(parameters)),
30 isExerciseTime_(exercise.isExerciseTime()), numberOfVariables_(exercise.numberOfVariables()) {
31 std::vector<Time> evolutionTimes =
32 exercise_->evolution().evolutionTimes();
33 for (Size i=0; i<evolutionTimes.size(); ++i) {
34 if (isExerciseTime_[i])
35 exerciseTimes_.push_back(evolutionTimes[i]);
36 }
37 }
38
39 std::vector<Time> ParametricExerciseAdapter::exerciseTimes() const {
40 return exerciseTimes_;
41 }
42
43 std::vector<Time> ParametricExerciseAdapter::relevantTimes() const {
44 return exercise_->evolution().evolutionTimes();
45 }
46
48 exercise_->reset();
50 }
51
53 exercise_->nextStep(currentState);
57 }
58
59 bool ParametricExerciseAdapter::exercise(const CurveState& currentState) const {
61 exercise_->values(currentState, variables_);
62 return exercise_->exercise(currentExercise_-1,
65 }
66
67 std::unique_ptr<ExerciseStrategy<CurveState>> ParametricExerciseAdapter::clone() const {
68 return std::unique_ptr<ExerciseStrategy<CurveState>>(new ParametricExerciseAdapter(*this));
69 }
70
71}
Curve state for market-model simulations
Definition: curvestate.hpp:41
ParametricExerciseAdapter(const MarketModelParametricExercise &exercise, std::vector< std::vector< Real > > parameters)
Clone< MarketModelParametricExercise > exercise_
std::vector< Time > relevantTimes() const override
bool exercise(const CurveState &currentState) const override
std::unique_ptr< ExerciseStrategy< CurveState > > clone() const override
void nextStep(const CurveState &currentState) override
std::vector< Time > exerciseTimes() const override
std::vector< std::vector< Real > > parameters_
std::size_t Size
size of a container
Definition: types.hpp:58
Definition: any.hpp:35
STL namespace.
std::vector< Real > parameters_
const ParametricExercise & exercise_