Hi all, I get an exception running the EuropeanOption
example while running the last calculation (MC Longstaff – Achwartz) (ql
version 0.9.7, boost version 1.37) The exception occurs in the LinearLeastSquaresRegression
class (used for the calibration of the LS-pathpricer). A matrix nxm (n=5097,
m=4) is created and then std::transform is called. n is the number of (x,y)
elements to match and v is the vector with the functions for which we want to
find the best coefficients. For i=0 the method std::transform evals the
function for each of the 5097 x’s but then when it wants to return it
tries to destroy some function and inside the destructor I have the exception. Code: template
<class ArgumentType> inline
LinearLeastSquaresRegression<ArgumentType>::LinearLeastSquaresRegression( const std::vector<ArgumentType> & x, const std::vector<Real>
& y, const std::vector<boost::function1<Real, ArgumentType>
> & v) : a_ (v.size(), 0.0), err_(v.size(), 0.0) { […] Matrix
A(n, m); for (i=0; i<m; ++i)
std::transform(x.begin(), x.end(), A.column_begin(i), v[i]); // ß exception here And inside transform(): template<class
_InIt, class _OutIt, class _Fn1> inline _OutIt
transform(_InIt _First, _InIt _Last, _OutIt _Dest, _Fn1 _Func) { // transform [_First, _Last) with _Func for (; _First != _Last; ++_First, ++_Dest) *_Dest
= _Func(*_First); return (_Dest); // ß exception here (for loop has finished) } Here is the call stack.
Did somebody experience the same problem? Is the boost
version too old? Do you have a workaround for this? Thank you in advance Giorgio Pazmandi ------------------------------------------------------------------------------ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
This does look like to be a bug in boost on your platform/compiler combination. The std::transform takes a copy of the function (i.e., fourth) argument and boost seems to trip up when it is time to destroy it. I would try expanding out the transform code in the leastsquares code. Something as simple as below should do I think as a first check. Best, Bojan --- a/ql/math/linearleastsquaresregression.hpp +++ b/ql/math/linearleastsquaresregression.hpp @@ -106,7 +106,11 @@ Matrix A(n, m); for (i=0; i<m; ++i) - std::transform(x.begin(), x.end(), A.column_begin(i), v[i]); + for(size_t j=0; j<x.size(); ++j) + { + A[j][i]=v[i](x[j]); + } + const SVD svd(A); const Matrix& V = svd.V(); -- Bojan Nikolic || http://www.bnikolic.co.uk ------------------------------------------------------------------------------ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Hi Bojan, thank you for your tip, without calling std::transform everything
works correctly. I have also seen that the original code works fine with boost 1.34, so I can either use your patch or the older boost installation. Thank you again for your help Giorgio Pazmandi > -----Original Message----- > From: Bojan Nikolic [mailto:[hidden email]] > Sent: giovedì, 26. marzo 2009 16:57 > To: Giorgio Pazmandi > Cc: [hidden email] > Subject: Re: [Quantlib-users] Exception running EuropeanOption example > (maybe boost problem?) > > > > This does look like to be a bug in boost on your platform/compiler > combination. The std::transform takes a copy of the function (i.e., > fourth) argument and boost seems to trip up when it is time to destroy > it. > > I would try expanding out the transform code in the leastsquares > code. Something as simple as below should do I think as a first check. > > Best, > Bojan > > --- a/ql/math/linearleastsquaresregression.hpp > +++ b/ql/math/linearleastsquaresregression.hpp > @@ -106,7 +106,11 @@ > > Matrix A(n, m); > for (i=0; i<m; ++i) > - std::transform(x.begin(), x.end(), A.column_begin(i), > v[i]); > + for(size_t j=0; j<x.size(); ++j) > + { > + A[j][i]=v[i](x[j]); > + } > + > > const SVD svd(A); > const Matrix& V = svd.V(); > > > -- > Bojan Nikolic || http://www.bnikolic.co.uk > > ----------------------------------------------------------------------- > ------- > _______________________________________________ > QuantLib-users mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/quantlib-users ------------------------------------------------------------------------------ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
I want to do some pricing of equity derivative products in Python 2.5
on Vista and figured QuantLib looks like an interesting project to work with. At the moment I am just trying to get all the dependencies installed, but I'm not sure which Boost installation I need: multi-thread, single- thread, static, DLL etc. Please could someone let me know. Thanks Tom ------------------------------------------------------------------------------ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Tom Picking <[hidden email]> writes: > At the moment I am just trying to get all the dependencies installed, > but I'm not sure which Boost installation I need: multi-thread, single- > thread, static, DLL etc. Please could someone let me know. The majority of boost libraries are header-only libraries, i.e., they have no compiled code. I believe QuantLib only uses this subset, so in fact it shouldn't matter which variant of Boost you install since the compiled parts will not be used. In general I would suggest installing at least the single-threaded release-mode DLL. On unix you can install multiple variants which is the best solution, but I'm not sure if that is easy to achieve on Windows. Best, Bojan -- Bojan Nikolic || http://www.bnikolic.co.uk ------------------------------------------------------------------------------ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
On Mon, 2009-04-06 at 16:00 +0100, Bojan Nikolic wrote:
> Tom Picking <[hidden email]> writes: > > > At the moment I am just trying to get all the dependencies installed, > > but I'm not sure which Boost installation I need: multi-thread, single- > > thread, static, DLL etc. Please could someone let me know. > > The majority of boost libraries are header-only libraries, i.e., they > have no compiled code. I believe QuantLib only uses this subset, so in > fact it shouldn't matter which variant of Boost you install since the > compiled parts will not be used. That's correct as long as you don't try and compile the test suite. You'll require Boost libraries for the latter. I'm assuming that you'll use VC7, since that's what is commonly used to compile Python extensions. I'm also assuming that you're using the latest QuantLib (0.9.7.) Correct me if that's not the case. In VC7, you'll have to compile QuantLib in "Release" configuration and install the "Multithread" flavor of Boost; in both cases, that's the configuration that will give you libraries with a -mt- filename (not -mt-s- or -mt-whatever.) Hope this helps, Luigi -- Never mistake motion for action. -- Ernest Hemingway ------------------------------------------------------------------------------ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Free forum by Nabble | Edit this page |