Re: [Quantlib-users] Least Squares Monte Carlo

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: [Quantlib-users] Least Squares Monte Carlo

Luigi Ballabio-2
At 04:48 PM 7/24/03 +0100, Neil P Firth wrote:
>Finally, the Binomial PricingEngines don't give me the correct price.
>Presumably I haven't set them up correctly, but I can't see what's wrong.

Neil,
         I fixed the binomial engine---they give the correct price now in
your example. Also, I've added the number of time steps as an input to your
least-square engine. The changes are on the branch.

The remaining problem is, the least-square engine might be leaky, or at
least a memory hog---on my Windows box the example runs with 200000
samples, but on my Linux laptop it fails with bad allocation with as few as
10000. Do you have any idea where all the memory could go?

Bye,
         Luigi


P.S. I have a few more data which might get you on track.

5000 samples, 3 time steps:   runs
10000 samples, 3 time steps:  not enough memory
5000 samples, 100 time steps: runs happily.

Which seems to suggest that the memory used depends more on the first
parameter...



Reply | Threaded
Open this post in threaded view
|

Least Squares Monte Carlo - memory leak

Neil P Firth
Hi,

Thanks for fixing the BinomialEngine for Americans.

Having done most of my programming in Java I'm not too tidy on memory
management... There are only a couple of new's called, and they are not in
the loops. I guess the obvious place to look is the SVD class, as a lot of
the work is done there, and there are many containers used, but they
should all be on the stack and disposed of after each timestep.

I was wondering whether I should be using Disposable<> somewhere..

Looking at the code again, in SVD::getV() the Matrix is passed in by
reference, but another Matrix is constructed inside the function. If the
least squares problem is rank deficient the the matrices may be different
sizes.

It may also be due to my naive port of the TNT::Array2D to Math::Matrix.

Have you a tool like OptimizeIt for Java, that will show where the problem
is?

Hope that this is some help...

Neil

---------------------------------------------------
  Neil Firth
  Brasenose College Oxford OX1 4AJ United Kingdom
  Office: 01865 280616
  [hidden email]
  http://www.maths.ox.ac.uk/~firth
---------------------------------------------------