Exception running EuropeanOption example (maybe boost problem?)

Posted by Giorgio Pazmandi on
URL: http://quantlib.414.s1.nabble.com/Exception-running-EuropeanOption-example-maybe-boost-problem-tp7357.html

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.

msvcr71d.dll!strcmp()  Line 123

msvcr71d.dll!type_info::operator==(const type_info & rhs={...})  + 0x1a

EquityOption-vc71-mt-gd.exe!boost::detail::function::functor_manager<QuantLib::`anonymous namespace'::MonomialFct,std::allocator<boost::function_base> >::manager(const boost::detail::function::function_buffer & in_buffer={...}, boost::detail::function::function_buffer & out_buffer={...}, boost::detail::function::functor_manager_operation_type op=check_functor_type_tag, boost::mpl::bool_<1> __formal={...})  Line 292 + 0x10

EquityOption-vc71-mt-gd.exe!boost::detail::function::functor_manager<QuantLib::`anonymous namespace'::MonomialFct,std::allocator<boost::function_base> >::manager(const boost::detail::function::function_buffer & in_buffer={...}, boost::detail::function::function_buffer & out_buffer={...}, boost::detail::function::functor_manager_operation_type op=check_functor_type_tag, boost::detail::function::function_obj_tag __formal={...})  Line 368 + 0x20

EquityOption-vc71-mt-gd.exe!boost::detail::function::functor_manager<QuantLib::`anonymous namespace'::MonomialFct,std::allocator<boost::function_base> >::manage(const boost::detail::function::function_buffer & in_buffer={...}, boost::detail::function::function_buffer & out_buffer={...}, boost::detail::function::functor_manager_operation_type op=check_functor_type_tag)  Line 385 + 0x20

EquityOption-vc71-mt-gd.exe!boost::detail::function::basic_vtable1<double,double>::clear(boost::detail::function::function_buffer & functor={...})  Line 503 + 0x11

EquityOption-vc71-mt-gd.exe!boost::function1<double,double>::clear()  Line 851

EquityOption-vc71-mt-gd.exe!boost::function1<double,double>::~function1<double,double>()  Line 750 + 0x2b

EquityOption-vc71-mt-gd.exe!std::transform<std::vector<double,std::allocator<double> >::const_iterator,QuantLib::step_iterator<double *>,boost::function1<double,double> >(std::vector<double,std::allocator<double> >::const_iterator _First={...}, std::vector<double,std::allocator<double> >::const_iterator _Last={...}, QuantLib::step_iterator<double *> _Dest={...}, boost::function1<double,double> _Func={...})  Line 389 + 0x1d

EquityOption-vc71-mt-gd.exe!QuantLib::LinearLeastSquaresRegression<double>::LinearLeastSquaresRegression<double>(const std::vector<double,std::allocator<double> > & x={...}, const std::vector<double,std::allocator<double> > & y={...}, const std::vector<boost::function1<double,double>,std::allocator<boost::function1<double,double> > > & v={...})  Line 77 + 0x8a

EquityOption-vc71-mt-gd.exe!QuantLib::LongstaffSchwartzPathPricer<QuantLib::Path>::calibrate()  Line 152 + 0x1d

EquityOption-vc71-mt-gd.exe!QuantLib::MCLongstaffSchwartzEngine<QuantLib::OneAssetOption::engine,QuantLib::SingleVariate,QuantLib::GenericPseudoRandom<QuantLib::MersenneTwisterUniformRng,QuantLib::InverseCumulativeNormal>,QuantLib::GenericRiskStatistics<QuantLib::GenericGaussianStatistics<QuantLib::GeneralStatistics> > >::calculate()  Line 150 + 0x27

EquityOption-vc71-mt-gd.exe!QuantLib::Instrument::performCalculations()  Line 157 + 0x24

EquityOption-vc71-mt-gd.exe!QuantLib::LazyObject::calculate()  Line 140 + 0xd

EquityOption-vc71-mt-gd.exe!QuantLib::Instrument::calculate()  Line 145

EquityOption-vc71-mt-gd.exe!QuantLib::Instrument::NPV()  Line 173 + 0xc

EquityOption-vc71-mt-gd.exe!main(int __formal=1, int __formal=1)  Line 353 + 0xb

 

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