market models code

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

market models code

Mark joshi-2
Dear All,

as you'll have noticed I've been doing some fiddling with the market
models code.

What do you think of the idea of a new example project based on the
market model code?
I would do it all. I might then use it in my quantlib and LMM training course:

http://www.moneyscience.com/training/pricing-exotic-interest-rate-derivatives-the-libor-market-model-in-quantlib.html

best

Mark

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: market models code

Luigi Ballabio
On Tue, 2009-11-10 at 14:07 +1100, Mark joshi wrote:
> as you'll have noticed I've been doing some fiddling with the market
> models code.

Yes, I noticed.  Do you have other interface changes in mind?  I'd like
to freeze them after 1.0 to keep backward compatibility, so this would
be the time to do them.

> What do you think of the idea of a new example project based on the
> market model code?
> I would do it all. I might then use it in my quantlib and LMM training course

Sounds good.

Thanks,
        Luigi


--

No, I'm not interested in developing a powerful brain. All I'm after
is just a mediocre brain, something like the president of American
Telephone and Telegraph Company.
-- Alan Turing on the possibilities of a thinking machine, 1943.



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: market models code

Mark joshi-2
I don't have any other ideas for interface changes.

I would advocate banning vector<bool> and getting rid of it elsewhere
in the code, however.

best

Mark


2009/11/10 Luigi Ballabio <[hidden email]>:

> On Tue, 2009-11-10 at 14:07 +1100, Mark joshi wrote:
>> as you'll have noticed I've been doing some fiddling with the market
>> models code.
>
> Yes, I noticed.  Do you have other interface changes in mind?  I'd like
> to freeze them after 1.0 to keep backward compatibility, so this would
> be the time to do them.
>
>> What do you think of the idea of a new example project based on the
>> market model code?
>> I would do it all. I might then use it in my quantlib and LMM training course
>
> Sounds good.
>
> Thanks,
>        Luigi
>
>
> --
>
> No, I'm not interested in developing a powerful brain. All I'm after
> is just a mediocre brain, something like the president of American
> Telephone and Telegraph Company.
> -- Alan Turing on the possibilities of a thinking machine, 1943.
>
>
>



--
Quant Job Interview Questions and Answers is now out: www.markjoshi.com

Assoc Prof Mark Joshi
Centre for Actuarial Studies
University of Melbourne
My website is www.markjoshi.com

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: market models code

Dimathematician
I'd love to see an market model example project!

2009/11/10 Mark joshi <[hidden email]>
I don't have any other ideas for interface changes.

I would advocate banning vector<bool> and getting rid of it elsewhere
in the code, however.

best

Mark


2009/11/10 Luigi Ballabio <[hidden email]>:
> On Tue, 2009-11-10 at 14:07 +1100, Mark joshi wrote:
>> as you'll have noticed I've been doing some fiddling with the market
>> models code.
>
> Yes, I noticed.  Do you have other interface changes in mind?  I'd like
> to freeze them after 1.0 to keep backward compatibility, so this would
> be the time to do them.
>
>> What do you think of the idea of a new example project based on the
>> market model code?
>> I would do it all. I might then use it in my quantlib and LMM training course
>
> Sounds good.
>
> Thanks,
>        Luigi
>
>
> --
>
> No, I'm not interested in developing a powerful brain. All I'm after
> is just a mediocre brain, something like the president of American
> Telephone and Telegraph Company.
> -- Alan Turing on the possibilities of a thinking machine, 1943.
>
>
>



--
Quant Job Interview Questions and Answers is now out: www.markjoshi.com

Assoc Prof Mark Joshi
Centre for Actuarial Studies
University of Melbourne
My website is www.markjoshi.com

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: market models code

Luigi Ballabio
In reply to this post by Mark joshi-2
On Tue, 2009-11-10 at 14:07 +1100, Mark joshi wrote:
> as you'll have noticed I've been doing some fiddling with the market
> models code.

Mark,
        just for future reference: when using gcc, the test suite was failing
hard (access violations and such.)  It turns out that according to the C
++ standard, the valarray assignment operator is only required to work
when the two sides of the assignment have the same size (yes, one never
ends learning C++.)   More details in the standard and at
<http://groups.google.com/group/comp.lang.c
++/browse_thread/thread/b9ac323fd7f5578b/dba133d7b15e91e0?hl=en&ie=UTF-8>.

Therefore, when one writes

valarray<Foo> v1;
v1 = some_function();

where some_function returns a (presumably not empty) valarray, the
behavior is undefined (the above effectively occurs, for instance, when
a valarray data member is initialized in the constructor body.)  Visual
C++ tries to help the average programmer and does what one would expect
(i.e., resize v1 and copy.)  Instead, gcc silently ignore the assignment
so that v1 ends up still empty.  You say it's kind of snob of gcc? My
reaction exactly.  Well, my second reaction.  The first involved a lot
of cursing.

Conclusion: I committed a few changes to keep the code portable.
Basically, one has to include a few valarray.resize() calls before
assignment. Unfortunately, we'll have to keep that in mind when we write
new valarray code.

Luigi


P.S. About the MarketModel example: please whistle in my general
direction when it's done, so I can backport it to the 1.0 branch.
Thanks.



--

I'd never join any club that would have the likes of me as a member.
-- Groucho Marx



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: market models code

Mark joshi-2
Ok you've convinced me that valarray is bad. I hate classes where =
doesn't do what you expect!

vector<bool> is bad too.

Maybe we should be using a boost class for arrays of bools.

best

mark


2009/11/13 Luigi Ballabio <[hidden email]>:

> On Tue, 2009-11-10 at 14:07 +1100, Mark joshi wrote:
>> as you'll have noticed I've been doing some fiddling with the market
>> models code.
>
> Mark,
>        just for future reference: when using gcc, the test suite was failing
> hard (access violations and such.)  It turns out that according to the C
> ++ standard, the valarray assignment operator is only required to work
> when the two sides of the assignment have the same size (yes, one never
> ends learning C++.)   More details in the standard and at
> <http://groups.google.com/group/comp.lang.c
> ++/browse_thread/thread/b9ac323fd7f5578b/dba133d7b15e91e0?hl=en&ie=UTF-8>.
>
> Therefore, when one writes
>
> valarray<Foo> v1;
> v1 = some_function();
>
> where some_function returns a (presumably not empty) valarray, the
> behavior is undefined (the above effectively occurs, for instance, when
> a valarray data member is initialized in the constructor body.)  Visual
> C++ tries to help the average programmer and does what one would expect
> (i.e., resize v1 and copy.)  Instead, gcc silently ignore the assignment
> so that v1 ends up still empty.  You say it's kind of snob of gcc? My
> reaction exactly.  Well, my second reaction.  The first involved a lot
> of cursing.
>
> Conclusion: I committed a few changes to keep the code portable.
> Basically, one has to include a few valarray.resize() calls before
> assignment. Unfortunately, we'll have to keep that in mind when we write
> new valarray code.
>
> Luigi
>
>
> P.S. About the MarketModel example: please whistle in my general
> direction when it's done, so I can backport it to the 1.0 branch.
> Thanks.
>
>
>
> --
>
> I'd never join any club that would have the likes of me as a member.
> -- Groucho Marx
>
>
>



--
Quant Job Interview Questions and Answers is now out: www.markjoshi.com

Assoc Prof Mark Joshi
Centre for Actuarial Studies
University of Melbourne
My website is www.markjoshi.com

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: market models code

Klaus Spanderen-2
Hi Mark,

On Friday 13 November 2009 21:01:57 Mark joshi wrote:
> Ok you've convinced me that valarray is bad. I hate classes where =
> doesn't do what you expect!
>
> vector<bool> is bad too.
>
> Maybe we should be using a boost class for arrays of bools.

I'm using deque<bool> as a drop-in replacement for vector<bool> because
deque<bool> is usually faster than vector<bool> (but needs more memory).

cheers
 Klaus

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: market models code

Dominick Samperi
In reply to this post by Mark joshi-2
I discovered this odd property of valarray just weeks ago.

In his book Bjarne Stroustrup says the C++ standard on
valarray gives compiler writers much latitude so that they can use
tricks behind the scenes to speed up code.

Thus there may be a reason for this madness.

This is too bad, because valarray gives a nice way to do vector
processing and selecting (using valarray<bool>). Unfortunately,
you need to know how many items will be selected before the
code is run that does the selection! This greatly reduces the
utility and elegance of the approach.

Dominick

Mark joshi wrote:

> Ok you've convinced me that valarray is bad. I hate classes where =
> doesn't do what you expect!
>
> vector<bool> is bad too.
>
> Maybe we should be using a boost class for arrays of bools.
>
> best
>
> mark
>
>
> 2009/11/13 Luigi Ballabio <[hidden email]>:
>  
>> On Tue, 2009-11-10 at 14:07 +1100, Mark joshi wrote:
>>    
>>> as you'll have noticed I've been doing some fiddling with the market
>>> models code.
>>>      
>> Mark,
>>        just for future reference: when using gcc, the test suite was failing
>> hard (access violations and such.)  It turns out that according to the C
>> ++ standard, the valarray assignment operator is only required to work
>> when the two sides of the assignment have the same size (yes, one never
>> ends learning C++.)   More details in the standard and at
>> <http://groups.google.com/group/comp.lang.c
>> ++/browse_thread/thread/b9ac323fd7f5578b/dba133d7b15e91e0?hl=en&ie=UTF-8>.
>>
>> Therefore, when one writes
>>
>> valarray<Foo> v1;
>> v1 = some_function();
>>
>> where some_function returns a (presumably not empty) valarray, the
>> behavior is undefined (the above effectively occurs, for instance, when
>> a valarray data member is initialized in the constructor body.)  Visual
>> C++ tries to help the average programmer and does what one would expect
>> (i.e., resize v1 and copy.)  Instead, gcc silently ignore the assignment
>> so that v1 ends up still empty.  You say it's kind of snob of gcc? My
>> reaction exactly.  Well, my second reaction.  The first involved a lot
>> of cursing.
>>
>> Conclusion: I committed a few changes to keep the code portable.
>> Basically, one has to include a few valarray.resize() calls before
>> assignment. Unfortunately, we'll have to keep that in mind when we write
>> new valarray code.
>>
>> Luigi
>>
>>
>> P.S. About the MarketModel example: please whistle in my general
>> direction when it's done, so I can backport it to the 1.0 branch.
>> Thanks.
>>
>>
>>
>> --
>>
>> I'd never join any club that would have the likes of me as a member.
>> -- Groucho Marx
>>
>>
>>
>>    
>
>
>
>  


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: market models code

Luigi Ballabio
In reply to this post by Klaus Spanderen-2
On Fri, 2009-11-13 at 21:52 +0100, Klaus Spanderen wrote:
> I'm using deque<bool> as a drop-in replacement for vector<bool> because
> deque<bool> is usually faster than vector<bool> (but needs more memory).

deque looks good. Mark, would you try it out and see whether you get the
same speed improvement as valarray?

Luigi



--

I have yet to see any problem, however complicated, which, when you
looked at it in the right way, did not become still more complicated.
-- Poul Anderson



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: market models code

Mark joshi-2
I'll put it on the "todo" list which is rather large right now...


2009/11/16 Luigi Ballabio <[hidden email]>:

> On Fri, 2009-11-13 at 21:52 +0100, Klaus Spanderen wrote:
>> I'm using deque<bool> as a drop-in replacement for vector<bool> because
>> deque<bool> is usually faster than vector<bool> (but needs more memory).
>
> deque looks good. Mark, would you try it out and see whether you get the
> same speed improvement as valarray?
>
> Luigi
>
>
>
> --
>
> I have yet to see any problem, however complicated, which, when you
> looked at it in the right way, did not become still more complicated.
> -- Poul Anderson
>
>
>



--
Quant Job Interview Questions and Answers is now out: www.markjoshi.com

Assoc Prof Mark Joshi
Centre for Actuarial Studies
University of Melbourne
My website is www.markjoshi.com

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: market models code

Luigi Ballabio
On Tue, 2009-11-17 at 13:03 +1100, Mark joshi wrote:
> I'll put it on the "todo" list which is rather large right now...

If it's just trying the timing, I can do that (I'd settle the thing for
the 1.0 release---I'm not in a big hurry, but sometime in the next month
or so would be nice.)

Luigi


--

Father's got the sack from the water-works
For smoking of his old cherry-briar;
Father's got the sack from the water-works
'Cos he might set the water-works on fire.



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: market models code

Mark joshi-2
Well all that really needs to be done is changing all the valarrays I
changed to deques and timing the testsuite. The only slight subtlety
is that the argument orders tend to be different for valarrays.

best

mark


2009/11/17 Luigi Ballabio <[hidden email]>:

> On Tue, 2009-11-17 at 13:03 +1100, Mark joshi wrote:
>> I'll put it on the "todo" list which is rather large right now...
>
> If it's just trying the timing, I can do that (I'd settle the thing for
> the 1.0 release---I'm not in a big hurry, but sometime in the next month
> or so would be nice.)
>
> Luigi
>
>
> --
>
> Father's got the sack from the water-works
> For smoking of his old cherry-briar;
> Father's got the sack from the water-works
> 'Cos he might set the water-works on fire.
>
>
>



--
Pricing exotic interest rate derivatives - The LIBOR Market Model in
QuantLib June 2009, London,
http://www.moneyscience.com/training/index.html

Assoc Prof Mark Joshi
Centre for Actuarial Studies
University of Melbourne
My website is www.markjoshi.com

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: market models code

Luigi Ballabio
On Tue, 2009-11-17 at 20:09 +1100, Mark joshi wrote:
> Well all that really needs to be done is changing all the valarrays I
> changed to deques and timing the testsuite. The only slight subtlety
> is that the argument orders tend to be different for valarrays.

Ok, done.  I've run the market-model test cases.  On VC9, deque is about
1.5 % faster than vector (about 10 seconds out of 10 minutes) and
valarray is 2.5% faster than deque (another 15 sec.)  Optimizations were
as specified in release mode.
With gcc and -O2, it makes hardly any difference in timing.

So what do we do? Do we switch to deque?

Luigi


--

The first thing we do, let's kill all the lawyers.
-- W. Shakespeare, "King Henry VI, Part II"



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: market models code

Mark joshi-2
I would suggest sticking with valarray. We all know the issue with
resizing now.

best

Mark


2009/11/18 Luigi Ballabio <[hidden email]>:

> On Tue, 2009-11-17 at 20:09 +1100, Mark joshi wrote:
>> Well all that really needs to be done is changing all the valarrays I
>> changed to deques and timing the testsuite. The only slight subtlety
>> is that the argument orders tend to be different for valarrays.
>
> Ok, done.  I've run the market-model test cases.  On VC9, deque is about
> 1.5 % faster than vector (about 10 seconds out of 10 minutes) and
> valarray is 2.5% faster than deque (another 15 sec.)  Optimizations were
> as specified in release mode.
> With gcc and -O2, it makes hardly any difference in timing.
>
> So what do we do? Do we switch to deque?
>
> Luigi
>
>
> --
>
> The first thing we do, let's kill all the lawyers.
> -- W. Shakespeare, "King Henry VI, Part II"
>
>
>



--
Pricing exotic interest rate derivatives - The LIBOR Market Model in
QuantLib June 2009, London,
http://www.moneyscience.com/training/index.html

Assoc Prof Mark Joshi
Centre for Actuarial Studies
University of Melbourne
My website is www.markjoshi.com

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: market models code

Luigi Ballabio
On Wed, 2009-11-18 at 20:31 +1100, Mark joshi wrote:
> I would suggest sticking with valarray. We all know the issue with
> resizing now.

Ok.

Luigi


--

I've finally learned what `upward compatible' means. It means we
get to keep all our old mistakes.
-- Dennie van Tassel



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev