SERVING THE QUANTITATIVE FINANCE COMMUNITY

 
User avatar
Polter
Posts: 2526
Joined: April 29th, 2008, 4:55 pm

The ultimate Monte Carlo framework

January 27th, 2012, 5:52 pm

QuoteOriginally posted by: outrunGood idea. Let's look into that, and lock-free in general.Cool!BTW, Boost.Lockfree might also be of interest:http://www.ohloh.net/p/lockfreehttp://t ... kfree/It's been already accepted to Boost:http://lists.boost.org/boost-announce/2 ... hpQuoteBtw: why are they building the fastest trading platform in JAVA??http://groups.google.com/group/lmax-dis ... 70535908e4
 
User avatar
Cuchulainn
Posts: 62982
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

The ultimate Monte Carlo framework

January 27th, 2012, 6:58 pm

QuoteOriginally posted by: PolterQuoteOriginally posted by: CuchulainnUnfortuntely, Boost has no libs for concurrent containers nor parallel design. So1. Make your own (it's 2012)2. Use PPL, TPL, MKL etc.3. .. PPL QuoteTPL v.s. boost threadTPL/PPL have patterns; Boost thread not. Huge gap.Hey, Cuch (and anyone else interested in chiming in for that matter), I'm wondering, what's your opinion on the Disruptor in this context?Originally developed in Java: http://code.google.com/p/disruptor/More info: http://stackoverflow.com/questions/6559 ... 4#6561784C++ versions:using Boost/C++11:http://www.2robots.com/2011/08/13/a-c-d ... tor--using the GNU Atomic Builtins:http://mechanical-sympathy.blogspot.com ... cy.htmlSee also:Is there a C++ port of the Disruptor pattern in the works?http://groups.google.com/group/lmax-dis ... 9b5837ca2I am not familiar with Disruptor, so difficult to say. In general, I now prefer tasks to tweaking naked threads because 1) the task libraries hide detail and 2) they do optimised scheduling for the developers and are optimised for h/w.
Last edited by Cuchulainn on January 26th, 2012, 11:00 pm, edited 1 time in total.
Step over the gap, not into it. Watch the space between platform and train.
http://www.datasimfinancial.com
http://www.datasim.nl
 
User avatar
Traden4Alpha
Posts: 23951
Joined: September 20th, 2002, 8:30 pm

The ultimate Monte Carlo framework

January 30th, 2012, 4:03 pm

The GPU vs. CPU debate may be prolonged by products such as the 36 core TILE-Gx 64-bit processor which puts greater parallelism of x86-compatible processing power on a half-height PCIe cards. They may not beat GPUs on raw core count, but they may offer better flexibility and programability that improves throughput as measured by both MC samples/second and programmer productivity.
 
User avatar
Cuchulainn
Posts: 62982
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

The ultimate Monte Carlo framework

February 1st, 2012, 8:06 pm

QuoteOriginally posted by: Traden4AlphaThe GPU vs. CPU debate may be prolonged by products such as the 36 core TILE-Gx 64-bit processor which puts greater parallelism of x86-compatible processing power on a half-height PCIe cards. They may not beat GPUs on raw core count, but they may offer better flexibility and programability that improves throughput as measured by both MC samples/second and programmer productivity.Indeed; raw speed comes at a cost. These cards may be 'good' enough. Can we get a 4-day simulation down to in that takes 2 days? If it takes 4 weeks of external resources to get it to 1 day, well is it worth it?
Step over the gap, not into it. Watch the space between platform and train.
http://www.datasimfinancial.com
http://www.datasim.nl
 
User avatar
Cuchulainn
Posts: 62982
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

The ultimate Monte Carlo framework

March 29th, 2012, 9:47 am

This is an attempt at a wiring diagram (UML component diagram) to describe loosely-coupled systems. You customise/extend the application by implementing the interfaces.Of course, this is only one form of communication.Feedback welcome.
Last edited by Cuchulainn on March 28th, 2012, 10:00 pm, edited 1 time in total.
Step over the gap, not into it. Watch the space between platform and train.
http://www.datasimfinancial.com
http://www.datasim.nl
 
User avatar
Polter
Posts: 2526
Joined: April 29th, 2008, 4:55 pm

The ultimate Monte Carlo framework

March 29th, 2012, 1:20 pm

Cuch, Interesting! I'm wondering, what was the design rationale and trade-offs between choosing Boost Function, Boost Signals, and Template Parameters (I guess this one is a Policy?) and Messages (Class Methods) for communication b/w different (sub)systems (or is it just an example for now)?
 
User avatar
Cuchulainn
Posts: 62982
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

The ultimate Monte Carlo framework

March 29th, 2012, 1:57 pm

QuoteOriginally posted by: PolterCuch, Interesting! I'm wondering, what was the design rationale and trade-offs between choosing Boost Function, Boost Signals, and Template Parameters (I guess this one is a Policy?) and Messages (Class Methods) for communication b/w different (sub)systems (or is it just an example for now)?Good question! Let me ponder this for a bit. In general, some criteria are:. Push versus pull (Function/Signals)?. Single/multiple (parallel) sinks?. Some classes are inherently generic (e.g. SDE, RNG). Visitor already exists and I don't know yet how to do it with Boost Function. (I could have used Function and bind it to a OO Visitor). In a next version, I would replace Visitor by something else but it might be over-engineered.. Passive/active objects? EventsBTW the actual number of systems is well-known as all analogous systems (of RAT type) have the same structure. So, this part is easy and subsumes many specific systems.
Last edited by Cuchulainn on March 28th, 2012, 10:00 pm, edited 1 time in total.
Step over the gap, not into it. Watch the space between platform and train.
http://www.datasimfinancial.com
http://www.datasim.nl
 
User avatar
MiloRambaldi
Posts: 273
Joined: July 26th, 2010, 12:27 am

The ultimate Monte Carlo framework

September 6th, 2012, 12:55 pm

I moved the present discussion over here, where I should have started it.QuoteOriginally posted by: CuchulainnThat's nice!I have assembled some ppt and pdfs on these Domain Architectures, especially MIS and RAT, here Duffy 2004 == Domain Architecture book (Wiley).The most important part of DA is that initial context/component diagram.Thanks for the documents, which I've looked through except for the book chapter I haven't got to yet.QuoteQuoteI have been looking into MC1. I decided to make a more user friendly version of TestMC as a way of getting acquainted with MC1. I used boost:rogram_options for parameters, so it is now command line rather than interactive input. For starters, I allow the user to select which PRNG to use. I assume this would be a more useful program if the user could also select the model and the FDM scheme using command line parameters as well? This will probably be my next step. It is possible to combine command line and interactive option the same main() by Abstract Factory (GOF) or using Boost Function Factory.I can't think of any reason why not. For example, I should think it could be incorporated into your "Initialization/configuration" scheme from "Software Frameworks in Quant. Finance, Part II".At this stage the input is still so simple and configuration is trivial so nothing like an Abstract Factory is needed. For now, I could simply have a command line parameter that indicates that interactive input is to be used. QuoteQuoteI replaced the statistics functions called from MCReporter with calls to the statistics library I mentioned in another thread (there was a typo causing the wrong sd and se to be given, btw). Here is a run of the program with no parameters given. It displays the available command line parameters to let the user know they are available:My MCReporter was very simple. It can be replaced by yours, of course. Does the interface remain stable?No. I changed it by adding parameters to the constructor to control the output (e.g. whether to draw a histogram). (I didn't really give this any thought.)QuoteQuoteThe code has been checked into qfcl/random because I don't have write access to qfcl/MC1. In any case, there are also dependencies so that it is easier to download everything from qfcl/random.We can ask Admin to give you write access if you wish.Actually, it is easier the way it is. Anyone can check out qfcl/random and build everything (only tested with MS VC so far). I know that a single library (analogous to boost) was not what outrun had in mind, but if we are going to keep things in separate modules then we will need a method of handling inter-dependencies (e.g. TestMC1 depends on qfcl/statistics).
 
User avatar
Cuchulainn
Posts: 62982
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

The ultimate Monte Carlo framework

September 6th, 2012, 5:23 pm

QuoteMy MCReporter was very simple. It can be replaced by yours, of course. Does the interface remain stable?QuoteNo. I changed it by adding parameters to the constructor to control the output (e.g. whether to draw a histogram). (I didn't really give this any thought.)Each implementation will need its own ctors before the output can be done. I had used 1 hard-coded ctor in MC1 and then done the output. What is usually done is that client main() delegates to a polymorphic factory if you use OOP or COM style [or Boost Factory (but less good IMO) for the generics folk ] Then the client gets a pointer and off you go. Information hiding! Mark Joshi has some nice examples of Factory Method in his C++ book. Putting all this config stuff together gives us a Builder pattern. It is used in many systems. It builds the complete application.Factory Method GOF Boost Functional/Factory Each choice has its pros and cons.
Last edited by Cuchulainn on September 6th, 2012, 10:00 pm, edited 1 time in total.
Step over the gap, not into it. Watch the space between platform and train.
http://www.datasimfinancial.com
http://www.datasim.nl
 
User avatar
MiloRambaldi
Posts: 273
Joined: July 26th, 2010, 12:27 am

The ultimate Monte Carlo framework

September 21st, 2012, 3:09 am

QuoteOriginally posted by: CuchulainnQuoteMy MCReporter was very simple. It can be replaced by yours, of course. Does the interface remain stable?QuoteNo. I changed it by adding parameters to the constructor to control the output (e.g. whether to draw a histogram). (I didn't really give this any thought.)Each implementation will need its own ctors before the output can be done. I had used 1 hard-coded ctor in MC1 and then done the output. What is usually done is that client main() delegates to a polymorphic factory if you use OOP or COM style [or Boost Factory (but less good IMO) for the generics folk ] Then the client gets a pointer and off you go. Information hiding! Mark Joshi has some nice examples of Factory Method in his C++ book. Putting all this config stuff together gives us a Builder pattern. It is used in many systems. It builds the complete application.Factory Method GOF Boost Functional/Factory Each choice has its pros and cons.Yes, I see MCReporter needs to be fixed to use a factory. Also the same choice of factory presumably should be used for everything else, like the FDM scheme, the payoff, etc ...I have read MJ's book and I've used his implementation of the Factory Method before. It uses a run-time polymorphic factory, which means that the family of classes generated by each factory must have a common base class. For example, it would not work with the random engines unless they were modified to all share a common base class. You are saying this is still the best way (or did you mean something else by "polymorphic factory")?I just finished some TMP code that allows run-time type selection among classes with no common base class. I have applied it so that test_MC now allows the user to specify which FDM scheme to use (this is in the new version 0.4 of qfcl/random):test_MC.exe 100000 500 -i 10000 -e TT800 -f MilsteinTMP is time consuming (at least for me), but I could not see any other way to do this. I'll have a look at Boost Factory to see if it could have been used instead of writing TMP.
 
User avatar
Cuchulainn
Posts: 62982
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

The ultimate Monte Carlo framework

September 21st, 2012, 5:29 am

QuoteI have read MJ's book and I've used his implementation of the Factory Method before. It uses a run-time polymorphic factory, which means that the family of classes generated by each factory must have a common base class. For example, it would not work with the random engines unless they were modified to all share a common base class. You are saying this is still the best way (or did you mean something else by "polymorphic factory")?The best way depends on the context. I you not want a plethora of classes, then Boost Factory is a good alternative, e.g. when you do not want/cannot have a commopn bas base, indeed. I have some exmples from my Boost II book that I will post.The more extended GOF Abstract Factory (for family of related classes) leads to even more classes, in which a combination of Tuple and Boost Factory is a good antidote.QuoteTMP is time consuming (at least for me), but I could not see any other way to do this. I'll have a look at Boost Factory to see if it could have been used instead of writing TMP.TMP seems to be overill here and indeed time-consuming. edit: the zip file contains an example of Boost factory where we can switch between choices 1,2,... I have included just enough code to get an idea. Analogies can be made with the current case.
Attachments
BoostFactoryExample.zip
(1.16 KiB) Downloaded 16 times
Last edited by Cuchulainn on September 20th, 2012, 10:00 pm, edited 1 time in total.
Step over the gap, not into it. Watch the space between platform and train.
http://www.datasimfinancial.com
http://www.datasim.nl
 
User avatar
MiloRambaldi
Posts: 273
Joined: July 26th, 2010, 12:27 am

The ultimate Monte Carlo framework

September 23rd, 2012, 11:27 pm

QuoteOriginally posted by: CuchulainnQuoteMy MCReporter was very simple. It can be replaced by yours, of course. Does the interface remain stable?QuoteNo. I changed it by adding parameters to the constructor to control the output (e.g. whether to draw a histogram). (I didn't really give this any thought.)Each implementation will need its own ctors before the output can be done. I had used 1 hard-coded ctor in MC1 and then done the output. What is usually done is that client main() delegates to a polymorphic factory if you use OOP or COM style [or Boost Factory (but less good IMO) for the generics folk ] Then the client gets a pointer and off you go. Information hiding! Mark Joshi has some nice examples of Factory Method in his C++ book. Putting all this config stuff together gives us a Builder pattern. It is used in many systems. It builds the complete application.I would like to clarify concerning the Builder pattern and MC1. According to the comments in your code, MCTypeDMediator is to play the role of Director in the Builder pattern. Currently, the FDM for example is passed in to the constructor, while the MCReporter is simply hard-coded. To actually use the Builder pattern then, an FDM_builder, an MCReporter_builder and other builders would instead be passed to MCTypeDMediator's ctor, yes?
ABOUT WILMOTT

PW by JB

Wilmott.com has been "Serving the Quantitative Finance Community" since 2001. Continued...


Twitter LinkedIn Instagram

JOBS BOARD

JOBS BOARD

Looking for a quant job, risk, algo trading,...? Browse jobs here...


GZIP: On