[GSoC-PortA] Random Portfolios Speed Improvement with Rcpp

Brian G. Peterson brian at braverock.com
Fri Nov 15 11:51:41 CET 2013


On 11/14/2013 10:25 PM, Ross Bennett wrote:
> I think I found the culprit for the slow performance of
> constrained_objective. It has to do with the moments being re-calculated
> in set.portfolio.moments at each iteration of constrained_objective.
>
> You can verify this putting a print(str(momentargs)) or browser()
> statement at the beginning of set.portfolio.moments.
>
> Here is a small reproducible example to mimic how the moments are passed
> from optimize.portfolio to constrained_objective.

Well, the whole point was always that those were to be calculated once 
and then passed in.

If that was somehow no longer happening (we did significantly rewrite a 
lot of that code this year), then yes, it would really slow things down.

<... code removed ...>

 > You can see that '...' is prepended when the list is constructed in
 > fun2. This is why set.portfolio.moments can't find momentargs$mu,
 > momentargs$sigma, etc. and has to be recalculated at each iteration.
 > So the problem is '...' is actually the first element of the list.
 >
 > Have any of you run into this before? Any suggestions for a fix?
 >
 > I think we could add a formal "moments" argument to constrained
 > objective and pass the moments set in optimize.portfolio to
 > constrained_objective directly through the "moments" argument. Is
 > there any downside to this approach that I might be overlooking?

No, this sounds like it should work.  we control constrained_objective, 
so being more explicit about what it receives should help.

Thanks,

Brian

-- 
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock


More information about the GSoC-PortA mailing list