/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* Copyright (C) 2006 Mark Joshi 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. */ #include #include #include #include #include namespace QuantLib { typedef MarketModelMultiProduct::CashFlow CashFlow; LongstaffSchwartzExerciseStrategy::LongstaffSchwartzExerciseStrategy( const Clone& basisSystem, const std::vector >& basisCoefficients, const EvolutionDescription& evolution, const std::vector& numeraires, const Clone& exercise, const Clone& control) : basisSystem_(basisSystem), basisCoefficients_(basisCoefficients), exercise_(exercise), control_(control), numeraires_(numeraires) { checkCompatibility(evolution, numeraires); relevantTimes_ = evolution.evolutionTimes(); isBasisTime_ = isInSubset(relevantTimes_, basisSystem_->evolution().evolutionTimes()); isRebateTime_ = isInSubset(relevantTimes_, exercise_->evolution().evolutionTimes()); isControlTime_ = isInSubset(relevantTimes_, control_->evolution().evolutionTimes()); exerciseIndex_ = std::vector(relevantTimes_.size()); isExerciseTime_ = std::vector(relevantTimes_.size(),false); std::vector v = exercise_->isExerciseTime(); Size exercises = 0; Size i; for (i=0; i rateTimes = evolution.rateTimes(); std::vector