|
From: Theo B. <tb...@ao...> - 2012-11-28 16:11:39
|
Hi, Looking at the vanillaswap it values swaps with fixed for floating schedules or legs. I cant see anything doing float for float or am I missing something. Regards Theo -----Original Message----- From: quantlib-dev-request <qua...@li...> To: quantlib-dev <qua...@li...> Sent: Tue, 27 Nov 2012 9:27 Subject: QuantLib-dev Digest, Vol 78, Issue 12 Send QuantLib-dev mailing list submissions to qua...@li... To subscribe or unsubscribe via the World Wide Web, visit https://lists.sourceforge.net/lists/listinfo/quantlib-dev or, via email, send a message with subject or body 'help' to qua...@li... You can reach the person managing the list at qua...@li... When replying, please edit your Subject line so it is more specific than "Re: Contents of QuantLib-dev digest..." Today's Topics: 1. Re: Black Vega (Luigi Ballabio) 2. Re: Black Vega (Luigi Ballabio) 3. Re: thread safe session handling via TSS (Riccardo Ghetta) 4. [ quantlib-Patches-3582579 ] Differential Evolution improvement (SourceForge.net) ---------------------------------------------------------------------- Message: 1 Date: Mon, 26 Nov 2012 16:39:44 +0100 From: Luigi Ballabio <lui...@gm...> Subject: Re: [Quantlib-dev] Black Vega To: Peter Caspers <pca...@gm...> Cc: "qua...@li..." <qua...@li...> Message-ID: <CAJ...@ma...> Content-Type: text/plain; charset=ISO-8859-1 Yes, you're correct. I'll fix it. Luigi On Mon, Nov 12, 2012 at 11:49 AM, Peter Caspers <pca...@gm...> wrote: > Hi, > > in blackformula.cpp , blackFormulaStdDevDerivative(...) the limit case > stdDev == 0.0 seems to be treated false, lines 307ff > > if (stdDev==0.0) { > if (forward>strike) > return discount * forward; > else > return 0.0; > } > > should be > > if (stdDev==0.0) return 0.0; > > because \phi(x) -> 0 whenever |x| -> \infty, right ? > > Thanks > Peter > > > ------------------------------------------------------------------------------ > Everyone hates slow websites. So do we. > Make your web apps faster with AppDynamics > Download AppDynamics Lite for free today: > http://p.sf.net/sfu/appdyn_d2d_nov > _______________________________________________ > QuantLib-dev mailing list > Qua...@li... > https://lists.sourceforge.net/lists/listinfo/quantlib-dev > ------------------------------ Message: 2 Date: Mon, 26 Nov 2012 17:59:06 +0100 From: Luigi Ballabio <lui...@gm...> Subject: Re: [Quantlib-dev] Black Vega To: Peter Caspers <pca...@gm...> Cc: "qua...@li..." <qua...@li...> Message-ID: <CAJ...@ma...> Content-Type: text/plain; charset=ISO-8859-1 Fixed, thanks. Luigi On Mon, Nov 26, 2012 at 4:39 PM, Luigi Ballabio <lui...@gm...> wrote: > Yes, you're correct. I'll fix it. > > Luigi > > > On Mon, Nov 12, 2012 at 11:49 AM, Peter Caspers <pca...@gm...> wrote: >> Hi, >> >> in blackformula.cpp , blackFormulaStdDevDerivative(...) the limit case >> stdDev == 0.0 seems to be treated false, lines 307ff >> >> if (stdDev==0.0) { >> if (forward>strike) >> return discount * forward; >> else >> return 0.0; >> } >> >> should be >> >> if (stdDev==0.0) return 0.0; >> >> because \phi(x) -> 0 whenever |x| -> \infty, right ? >> >> Thanks >> Peter >> >> >> ------------------------------------------------------------------------------ >> Everyone hates slow websites. So do we. >> Make your web apps faster with AppDynamics >> Download AppDynamics Lite for free today: >> http://p.sf.net/sfu/appdyn_d2d_nov >> _______________________________________________ >> QuantLib-dev mailing list >> Qua...@li... >> https://lists.sourceforge.net/lists/listinfo/quantlib-dev >> ------------------------------ Message: 3 Date: Mon, 26 Nov 2012 18:07:13 +0100 From: Riccardo Ghetta <rg...@la...> Subject: Re: [Quantlib-dev] thread safe session handling via TSS To: Luigi Ballabio <lui...@gm...> Cc: Ferdinando Ametrano <na...@am...>, "qua...@li..." <qua...@li...> Message-ID: <50B...@la...> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Well, Singleton returns an instance ... perhaps we could mix the two solutions at this level ... What about changing a little the default ? Instead of defaulting to a single session per application, default to a single session per thread (via TSS). When the user registers a sessionId function (via setSessionIdFunc), switch to lock+map. If you want, I'll try to concoct an implementation along these lines. I am a bit uncomfortable, however, with a sessionId-based solution. IMO is inherently fragile: one must ensure than no one will modify the same session from different threads. So the application must be single-threaded, or use some other method to avoid trashing the singletons. This even when Singleton is using locks, as in Mortoray implementation. A lock in this case protects only the mapping id-singleton, not the singleton data. Consider this example, with a default sessionId(), i.e. one returning always 0: thread 1 calls Settings::instance().evaluationDate()= Date(1, Jan, 2012); meanwhile thread 2 calls Settings::instance().evaluationDate()= Date(15, Jan, 2012); Settings::instance() can be accessed by one thread at time, but afterward both threads have a reference to the same instance, so no one knows really what value will have the evaluation date. To avoid this race you have to lock the entire sequence, or associate a session to a single thread, perhaps via thread storage :). Riccardo -------- Original Message -------- Subject: Re: [Quantlib-dev] thread safe session handling via TSS From: Luigi Ballabio <lui...@gm...> To: Riccardo Ghetta <rg...@la...> CC: "qua...@li..." <qua...@li...>, Ferdinando Ametrano <na...@am...> Date: Monday, November 26, 2012 16:21:14 > It might be reasonable. But as mortoray argued, one might want to > switch between the two possibilities without recompiling; especially > those that don't compile the library and get it packaged from a Linux > distribution. If we provide such a switch, linking libboost_thread > would be required anyway. What do you think? > > A future possibility would be to rework mortoray's patch so that the > pluggable function returns the instance directly instead of an integer > id; in such an implementation, your technique would just provide a > particular function. However, that's not backward compatible... > > Luigi > > > On Tue, Oct 23, 2012 at 3:43 PM, Riccardo Ghetta <rg...@la...> wrote: >> Not directly, no. >> I've looked at mortoray patch. Unfortunately that scheme is not compatible >> with thread storage; having a per-thread instance makes all the >> sessionId/sessionIdFunc machinery useless. In a way, is implicitly handled. >> Likewise for the instances_ map. >> >> On the other hand, perhaps I can rework the tss patch to avoid including >> boost thread headers in singleton.hpp, if we don't want to force quantlib >> users to compile with boost:thread. >> That should preserve the main qualities of the above patch, i.e. being >> thread-safe and not requiring libboost_thread, plus the added safety, >> simplicity and performance of tss. >> >> it might be a reasonable solution ? >> Ciao, >> >> R >> >> >> -------- Original Message -------- >> Subject: Re: [Quantlib-dev] thread safe session handling via TSS >> From: Luigi Ballabio <lui...@gm...> >> To: Riccardo Ghetta <rg...@la...> >> CC: qua...@li..., Ferdinando Ametrano >> <na...@am...> >> Date: Tuesday, October 23, 2012 12:10:59 >>> Riccardo, >>> >>> I just had a look at your patch. Is there any chance that it can >>> be made to work together with the pending patch at >>> >>> <https://github.com/mortoray/quantlib/commit/dbf6b23429b21cccb0982d6f3e5c13f5860842e1>? >>> (Yes, we have stuff all over the place and it's not easy to find it. >>> Our bad.) >>> >>> About the contributor agreement: in the past we used something like >>> the document I'm attaching. You can scan the signed document and send >>> it to me and Ferdinando (whose address is in cc). >>> >>> Thanks, >>> Luigi >>> >>> >>> On Fri, Oct 19, 2012 at 3:22 PM, Riccardo Ghetta <rg...@la...> wrote: >>>> Hi, >>>> I've just posted a patch to enable thread safe session handling. It >>>> should also solve bug 3441748. >>>> The company I work for, Thema Consulting SA (www.themaconsulting.ch), >>>> uses QuantLib in its MasterFinance product and has other patches we like >>>> to contribute back (as soon they're cleared by management/legal). >>>> >>>> BTW, is the contributor agreement needed ? Where should be sent ? >>>> I searched the mailing list, but without luck. >>>> >>>> Ciao, >>>> Riccardo Ghetta >>>> Thema Consulting SA >>>> >>>> >>>> ------------------------------------------------------------------------------ >>>> Everyone hates slow websites. So do we. >>>> Make your web apps faster with AppDynamics >>>> Download AppDynamics Lite for free today: >>>> http://p.sf.net/sfu/appdyn_sfd2d_oct >>>> _______________________________________________ >>>> QuantLib-dev mailing list >>>> Qua...@li... >>>> https://lists.sourceforge.net/lists/listinfo/quantlib-dev >> ------------------------------ Message: 4 Date: Mon, 26 Nov 2012 14:13:54 -0800 From: SourceForge.net <no...@so...> Subject: [Quantlib-dev] [ quantlib-Patches-3582579 ] Differential Evolution improvement To: SourceForge.net <no...@so...> Message-ID: <mai...@li...> Content-Type: text/plain; charset=UTF-8 Patches item #3582579, was opened at 2012-11-01 15:38 Message generated for change (Comment added) made by fenixcitizen You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=312740&aid=3582579&group_id=12740 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Closed Resolution: Accepted Priority: 5 Private: No Submitted By: Mateusz Kapturski (fenixcitizen) Assigned to: Luigi Ballabio (lballabio) Summary: Differential Evolution improvement Initial Comment: Hi All, I have come across the new implementation of Differential Evolution that appeared in QuantLib HEAD source code recently. I decided to improve it slightly. I took performance very seriously as the DE implementation should be light in order to avoid unnecessary time overhead. The most significant change is that I use DiffEvolConfiguration object that defines the behavior of the algorithm. The reason is that it makes the implementation more flexible. There are dozens of DE variants... I tried to be in line with current QuantLib optimization interface. Important changes: 1) DE Optimizer consumes configuration object that defines its behavior - as I mentioned, the number of variations of the DE algorithm is huge. This approach makes it possible to extend the implementations in the future. 2) Constraints that define search space are not the part of the algorithm itself - this is why additional upperBound and lowerBound functions were added to Constraint object. NonhomogeneousBoundaryConstraint to define box constraints was added too. The other aspect is if the bounds are going to be valid for emerging populations - practical advise is that it should as for certain parameters, new populations seem to diverge. On the other hand, it adds some additional overhead. General observation is that it is always possible to improve performance for a given objective function. One needs to find appropriate DE configuration only. 3) I added three different crossover types: normal, binomial and exponential (the name for the first crossover type comes from the fact that assuming binomial crossover, the number of mutants taken into account in a given population converges in distribution to normal variable for growing problem size) 4) There are 6 methods available in this implementation. However, it is possible to go further and implement various base element types, differences of a given size, various weights distributions for the differences etc. Implemented approaches are the most common used in practice as the more complicated recombination procedure, the higher computation cost is. 5) For ModFourthDeJong objective function as I was able to find a point for which the objective function value is 8.86549 which is significantly lower than 12.3724219287 : DE type: bestMemberWithJitter Crossover type: normal Apply Bounds: true CrossoverProb: 0.25 NumOfPopulationMembers: 500 PrintFullInfo: false StepsizeWeight: 0.2 MaxIterations Point: [ 0.299015; 0.352861; -0.0306954; -0.349516; 0.202407; 0.111475; 0.0783742; -0.0640798; 0.284987; -0.00386122; 0.134481; -0.174184; -0.0188605; 0.217705; 0.0557937; 0.176954; -0.0757169; 0.219995; -0.079788; -0.142831; -0.129607; 0.135615; -0.152286; 0.0420379; -0.193061; 0.0582583; -0.0617313; -0.238126; -0.11224; -0.069721 ] Objective function value: 8.86549 However, this is the best result only. Usually, the algorithm was stuck in several local minimas - most of them in [10;15] range. Further investigation is needed. 6) I have problem with Griewangk function too. I am not able to find fully successful method although the objective function value oscillated around 0.1 which is not bad. It needs to be verified. I find the bestMemberWithJitter method the most successful and this is the only reason I set it as default method to be used. Hope it helps. I am happy to answer your questions. In case my patch does not work properly, please use changed files directly. Kind regards, Mateusz Kapturski ---------------------------------------------------------------------- Comment By: Mateusz Kapturski (fenixcitizen) Date: 2012-11-26 14:13 Message: Hi Luigi, thank you for your amendments. The logic has not changed and it works for me. All tests passed. However, I had to change Makefile.am file in ql/math/optimisation directory and put -std=c++0x flag as you used Initializer list (feature from c++11). I compile QL using gcc. I wonder, if other users may experience similar problems. Is there a simple way to use this flag in the whole project? I tried to compile it using VS2010 and VS2012 but both failed (initializer lists are still missing in VS). Regards, Mateusz ---------------------------------------------------------------------- Comment By: Luigi Ballabio (lballabio) Date: 2012-11-21 01:26 Message: Mateusz, I've added your code to the repository. I've made a few refactorings to make it more in line with the style we've been using in the library, so you might want to check that everything still works. In particular: - I've replaced the use of boost::random with our mersenne-twister generator; - I've turned the configuration class into an inner class; - I've removed setters, which don't play well with observability; - I've removed pointer data members; - plus some minor cleanup. Thanks, Luigi ---------------------------------------------------------------------- Comment By: https://www.google.com/accounts () Date: 2012-11-12 07:24 Message: Hi Mateusz, good that the adaptive method seems to add some value to your implemetation ;-) When I run the test cases, 4 out of 5 pass now. However, for the ModFourthDeJong objective function, I get 12.0945 instead of your 10.964. Maybe this is due to the fact that I'm using a different boost version (1.47.0) and that boost's MT impementation has changed, but I don't know if it's worth investgating on this issue or rather exclude the ModFourthDeJong test case for now (because both values are valid). Ralph ---------------------------------------------------------------------- Comment By: Mateusz Kapturski (fenixcitizen) Date: 2012-11-11 13:35 Message: Hi Ralph, Luigi you were right - self adapting method is quite successful. I have already added it to my implementation. All tests are passed now. I would be grateful if you double check my results. I think this is a stable version that can go to QL trunk. QL users have much more options now. Recent changes/remarks: 1) Crossover self-adaptation is a separate option - it was very easy to implement it that way. 2) User can decide if DE should use fixed seed or not (as discussed earlier) 3) Adaptation is performed on the population member basis as stated in the paper. 4) Additional rotation was added to the self-adaptive method to improve its performance. 5) Extracted some logic into separate private methods. 6) Original Griewangk function is usually defined on [-600, 600]^n box and my DE implementation is successful on this search domain. ---------------------------------------------------------------------- Comment By: https://www.google.com/accounts () Date: 2012-11-08 00:23 Message: Hi Mateusz, thank you for your reply. The adaptive method can be found here (section V): Brest, J. et al., 2006, "Self-Adapting Control Parameters in Differential Evolution: A Comparative Study on Numerical Benchmark Problems." ( A link which worked for me is http://150.214.190.154/docencia/sf1/Brest06.pdf) And yes, the adaptive method always found the minimum of the Griewanck function when I played around with it. Ralph ---------------------------------------------------------------------- Comment By: Mateusz Kapturski (fenixcitizen) Date: 2012-11-07 14:44 Message: Hi Ralph, thank you for your remarks. 1) Fixing the seed for reproducibility is a great idea. I simply forgot to do it. I tested my implementation against current time as seed to be perfectly sure that results are reliable. I added an optional config param. One may want "increase randomness" using the useFixedSeed_=false parameter. Therefore, both options are available now. 2) This is a philosophical aspect. I used Boost as it was just easier for me and I find it a reliable tool. It does not add external dependency as QL already uses Boost libraries. The question is if there is value added if we change it. In my view - not significant. If you would like to change it, just go for it. 3) I see your point now with respect to ModFourthDeJong. My random results were connected with your first observation - after fixing the seed, I obtained stable minimum equal to 10.409792. I have already amended the test case. 4) The adaptive method is not implemented yet but it can be easily added. Could you provide more details on the method as I could not find it in the literature. The most important aspects are: how many differences are taken into account and how are weights applied to it? Was crossover important aspect for this method? And last practical question: Was the adaptive strategy successful for every chosen seed in your implementation? Griewangk objective function is probably the last major issue to resolve now. Thanks Mateusz ---------------------------------------------------------------------- Comment By: https://www.google.com/accounts () Date: 2012-11-07 00:42 Message: Hi Mateusz, I have some remarks/questions concerning your DE implementation: 1. You are using time(0) for the seed in the generation of the initial population (differentialevolution.cpp, line 27). Wouldn't a fix seed be better for reproducability, in the sense that the same data yield the same result? 2. As a part of QuantLib, shouldn't one choose QuantLib's random number generator instead of boost's? 3. For the ModFourthDeJong you mention that you find a lower minimum than the previous implementation. But that's not the point. If you take a look at the function, you see the uniform random part, i.e. the functional minimum is f(0) <= 30*Expectation(uniform) = 15. Therefore you'll get different realizations for different random numbers, which is ok as long as the minimum found is below 15. 4. For the Griewangk function, the adaptive method in the current DE implementation succeeds to find the minimum f(0) = 0. Is the adaptive method implemented (or implementable) in your code as well? Thanks, Ralph ---------------------------------------------------------------------- Comment By: Mateusz Kapturski (fenixcitizen) Date: 2012-11-06 16:15 Message: Hi Luigi, I have a habit of constant auto forrmatting when coding in Eclipse... Unfortunately, the autoformat profile cannot be adjusted to QL style easily. I removed unnecessary changes in order to make the patch more readable. Mateusz BTW. Is it possible to use other external tool (e.g. vim or emacs) to format source code file in line with QL style? First line in each QL file specifies autoformat options, doesn't it? ---------------------------------------------------------------------- Comment By: Luigi Ballabio (lballabio) Date: 2012-11-06 00:29 Message: Mateusz, thanks for the contribution. However, the patch is made practically unreadable by the fact that you re-indented the files (for instance, the Constraint class shows as completely changed, whereas you only actually added the lowerBound and upperBound methods). May you reformat the files so that they match the original indentation, and therefore so that the patch only contains the actual differences? This might seem picky on my part, and I know I'm asking some work; but on the one hand, as I said, the patch (and the diffs from version-control, once your changes get in) would be made more clearly readable, and on the other hand, having a consistent format in the library sources makes it easier to see the context. Thanks, Luigi ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=312740&aid=3582579&group_id=12740 ------------------------------ ------------------------------------------------------------------------------ Monitor your physical, virtual and cloud infrastructure from a single web console. Get in-depth insight into apps, servers, databases, vmware, SAP, cloud infrastructure, etc. Download 30-day Free Trial. Pricing starts from $795 for 25 servers or applications! http://p.sf.net/sfu/zoho_dev2dev_nov ------------------------------ _______________________________________________ QuantLib-dev mailing list Qua...@li... https://lists.sourceforge.net/lists/listinfo/quantlib-dev End of QuantLib-dev Digest, Vol 78, Issue 12 ******************************************** |