/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* Copyright (C) 2006 Mark Joshi Copyright (C) 2006 StatPro Italia srl This file is part of QuantLib, a free-software/open-source library for financial quantitative analysts and developers - http://quantlib.org/ QuantLib is free software: you can redistribute it and/or modify it under the terms of the QuantLib license. You should have received a copy of the license along with this program; if not, please email . The license is also available online at . This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. */ #ifndef quantlib_upper_bound_engine_hpp #define quantlib_upper_bound_engine_hpp #include #include #include #include #include namespace QuantLib { class MarketModelEvolver; class MarketModelDiscounter; class MarketModelMultiProduct; class MarketModelExerciseValue; //! Market-model %engine for upper-bound estimation /*! \pre product and hedge must have the same rate times and exercise times */ class UpperBoundEngine { public: UpperBoundEngine( const boost::shared_ptr& evolver, const std::vector >& innerEvolvers, const MarketModelMultiProduct& underlying, const MarketModelExerciseValue& rebate, const MarketModelMultiProduct& hedge, const MarketModelExerciseValue& hedgeRebate, const ExerciseStrategy& hedgeStrategy, Real initialNumeraireValue); void multiplePathValues(Statistics& stats, Size outerPaths, Size innerPaths); std::pair singlePathValue(Size innerPaths); private: Real collectCashFlows(Size currentStep, Real principalInNumerairePortfolio, Size beginProduct, Size endProduct) const; boost::shared_ptr evolver_; std::vector > innerEvolvers_; MultiProductComposite composite_; Real initialNumeraireValue_; Size underlyingSize_, rebateSize_, hedgeSize_, hedgeRebateSize_; Size underlyingOffset_, rebateOffset_, hedgeOffset_, hedgeRebateOffset_; Size numberOfProducts_; Size numberOfSteps_; std::vector isExerciseTime_; // workspace std::vector numberCashFlowsThisStep_; std::vector > cashFlowsGenerated_; std::vector discounters_; }; } #endif