Login  Register

Re: Question on new implementation of Lattice class

Posted by Luigi Ballabio on Feb 25, 2005; 4:29am
URL: http://quantlib.414.s1.nabble.com/Possible-problem-on-bermuda-swaptions-2-tp3621p3626.html

On 02/25/05 11:53:12, Luca Berardi wrote:

>
> I have a question on the new Lattice implementation, regarding the
> rollback method:
>
> - in QuantLib 0.3.7 in the implementation of the rollAlmostBack()
>   method we have the following lines of code:
>
> 00082         for (Integer i=iFrom-1; i>=iTo; i--) {
> 00083             Array newValues(size(i));
> 00084             stepback(i, asset->values(), newValues);
> 00085             asset->time() = t_[i];
> 00086             asset->values() = newValues;
> 00087             // skip the very last post-adjustment
> 00088             if (i != iTo)
> 00089                 asset->adjustValues();
> 00090             else
> 00091                 asset->preAdjustValues();
> 00092         }
> 00093     }
>
> - in QuantLib 0.3.8, in the implementation of partialRollBack() -which
>   replaces rollAlmostBack- we have the following lines of code:
>
> 00077         for (Integer i=iFrom-1; i>=iTo; i--) {
> 00078             Array newValues(size(i));
> 00079             stepback(i, asset.values(), newValues);
> 00080             asset.time() = t_[i];
> 00081             asset.values() = newValues;
> 00082             // skip the very last adjustment
> 00083             if (i != iTo)
> 00084                 asset.adjustValues();
> 00085         }
> 00086     }
>
> It seems that the 'else' section of code has been thrown away, while
> the implementation of the rollBack() method has remained the same
> between the two releases.
>
> Is there any particular reason for this? Shouldn't it be a source of
> mismatch between the two QuantLib releases?

Luca,
        apologies---this should have been documented better. Upon migrating  
between the two releases, client code should be modified (which has been  
done in the library, so there's no mismatch due to the change.) See for  
example DiscretizedOption::postAdjustValues(): the 0.3.7 version is:

    void DiscretizedOption::postAdjustValues() {
        method()->rollAlmostBack(underlying_, time());
        switch (exerciseType_) {
          ...
    }

while the 0.3.8 version is:

    void DiscretizedOption::postAdjustValuesImpl() {
        underlying_->partialRollback(time());
        underlying_->preAdjustValues();
        switch (exerciseType_) {
          ...
    }

I'm sure there is a reason for this, but I can't recall it right now. :)
The purpose seems to be that of allowing behavior to be inserted between  
rollback and pre-adjustment, which isn't bad...

Later,
        Luigi

----------------------------------------

Though this be madness, yet there is method in't.
-- Hamlet, Act II, scene II