<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Brian and Ross,<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>I couldn’t agree more with the proposal to separate constraints and objectives (Brian, as you and I have discussed earlier this year or last year).<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>I will have further comments on checking validity of adding constraints late tomorrow or early Wed. after I have completed grading of my spring quarter course.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Doug<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> gsoc-porta-bounces@lists.r-forge.r-project.org [mailto:gsoc-porta-bounces@lists.r-forge.r-project.org] <b>On Behalf Of </b>Ross Bennett<br><b>Sent:</b> Monday, June 17, 2013 7:09 AM<br><b>To:</b> PortfolioAnalytics<br><b>Cc:</b> gsoc-porta@r-forge.wu-wien.ac.at<br><b>Subject:</b> Re: [GSoC-PortA] structure of the specification objects<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal>Brian,<o:p></o:p></p><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>I really like your thoughts on separating constraints and objectives. I learned objectives and constraints in the same way that you mention them. Intuitively, it is easier to understand that the user would create the constraint object, the objective object, and then combine in a portfolio object.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Separating out the objectives and creating templates of objectives for minimum variance and other basic objective functions should make it easy to understand for the user as well how it is handled with the solvers.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>The way the constraints object looks today seems to be very similar to what you have in mind for the portfoliospec object. Was that your intent so that the solvers see pretty much the same object in the call to optimize.portfolio? Only now the portfoliospec object will be passed instead of the constraints object, is my understanding of your intentions correct?<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>This is what I am thinking the code will look *something* like to run a simple optimization problem.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>#### Example R code<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal># Specify a constraints object and add box constraints<o:p></o:p></p></div><div><p class=MsoNormal>gen.constr = constraint(assets, min_sum=1, max_sum=1)<o:p></o:p></p></div><div><p class=MsoNormal>gen.constr = add.constraint(gen.constr, min_weight=0.10, max_weight=0.4, type="box")<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal># Specify an objective object for global minimum variance<o:p></o:p></p></div><div><p class=MsoNormal>gen.obj = objective(type="GMV")<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal># Specify a portfolio object<o:p></o:p></p></div><div><p class=MsoNormal>port.spec = portfoliospec(gen.constr, gen.obj)<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal># Run the optimization<o:p></o:p></p></div><div><p class=MsoNormal>solution = optimize.portfolio(data, port.spec)<o:p></o:p></p></div><div><p class=MsoNormal>#####<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Thanks,<o:p></o:p></p></div><div><p class=MsoNormal>Ross Bennett<o:p></o:p></p></div></div><div><p class=MsoNormal style='margin-bottom:12.0pt'><o:p> </o:p></p><div><p class=MsoNormal>On Mon, Jun 17, 2013 at 6:51 AM, Brian G. Peterson <<a href="mailto:brian@braverock.com" target="_blank">brian@braverock.com</a>> wrote:<o:p></o:p></p><p class=MsoNormal>I've been thinking a lot about this over the last week, and I'm going to propose an architecture for discussion.<br><br>Right now, we have an object of type 'constraints' which also includes 'objectives'.<br><br>I have always logically separated objectives from constraints in my head by saying that<br>- constraints are something that are:<br> 1. operable only on the weight vector and<br> 2. metadata information about the portfolio (e.g. groups, asset names)<br> 3. describe the *inputs* to the objective function<br><br>- objectives are part of the *objective function* that<br> 1. you calculate on the weight vector<br> 2. describe business objectives for the *outcome* of the optimization<br><br>I think we need to split these apart explicitly, and make the distinctions, and why they exist, more obvious to the user.<br><br>First, I think we need a container object of type 'portfolio' or 'portfoliospec' that know what assets you have, and how you want to group them (e.g. sectors, size, whatever). This is data about the portfolio, and is *independent* of and constraints or objectives you might have on that portfolio.<br><br>Next, I think we need a constraints object. Constraints, by their nature, are tied to the portfolio that they are created for. They require knowledge of the portfolio metadata, or at the very least things like box constraints are typically derived from the size of the portfolio.<br><br>Finally, I think we need a separate 'objectives' object. To have objectives objects, with names, that specify things like minimum variance, maximum Sharpe ratio, or risk parity objectives. These can be completely separate from the assets in the portfolio, and we could provide a number of template objective objects with the package. I think the current way objectives are added and manipulated is fine, we just need to break it off a bit.<br><br>For the template objectives that can be acted on by specific more efficient solvers, I think separating the objectives out will make it easier to identify that.<br><br>optimize.portfolio needs all three of these components, even today, to do anything. So I think we need to sort out how to specify them, then how to combine them.<br><br>I suggest that we start by getting these specifications right first. Then we can start surgery in other parts of the code to use the new specification forms.<br><br>My current thoughts are that a portfolio *contains* one or more constraints objects, since the constraints objects are dependent on the portfolio composition. Then you optimize a portfolio by passing a portfolio specification into the optimizer, and telling it which constraints object to use (if you have more than one attached to the portfolio) and what objectives object you want to apply.<br><br>Hopefully this is clear. It's a proposal, so comments/critique/ideas always welcome.<br><br>Today is officially the first day of coding, so we need to get moving.<br><br>Regards,<br><br>Brian<br><br><br><br><br>On 06/06/2013 06:54 AM, Ross Bennett wrote:<o:p></o:p></p><p class=MsoNormal>Professor Martin,<br><br>Thank you for the feedback. Based on the suggestions from yourself and<br>Brian Peterson, I will start with the constraints portion. I'll spend<br>some more time looking at Kirk Li's code to understand it better and<br>think about how to best integrate into PortfolioAnalytics. I should be<br>able to use some ideas from it.<br><br>I have been reviewing the code for PortfolioAnalytics and it seems that<br>there is already a lot of the infrastructure in place for the constraint<br>object and the optimizer so I don't want to maintain the interface to<br>the optimize.portfolio function as much as possible.<br><br>As an example, here is a code snippet of how box constraints and group<br>constraints are currently specified.<br># General constraints object<br># Box constraints of minimum weight = 0.1 and maximum weight = 0.5 for<br>assets<br>gen.constr <- constraint(assets = colnames(edhec), min=0.1, max =0.5,<br>min_sum=1, max_sum=1)<br><br># Add group constraints to the gen.constr object<br>groups <- c(3,3,3,4)<br>gen.constr$groups <- groups<br>gen.constr$cLO <- rep(0.15,length(groups))<br>gen.constr$cUP <- rep(0.30,length(groups))<br><br>Following the outline on the GSOC2013 PortfolioAnalytics rwiki page, we<br>would remove box constraints from the constraint() function and create<br>an add.constraint() function to add/update box, group, and other<br>constraint types as applicable.<br><br># Create the initial constraint object<br># Pass in a character vector of asset names for assets<br># Portfolio weights must sum to 1 (min_sum=1 and max_sum=1)<br>gen.constr <- constraint(assets = colnames(edhec), min_sum=1, max_sum=1)<br><br># Add box constraints with asset weights greater than 0.1 and less than 0.5<br>gen.constr <- add.constraint(constraints=gen.constr, type="box",<br> min=0.1, max=0.5)<br><br># Group constraints for 10 assets<br># Separate assets into groups of 3, 3, and 4 assets<br># Specify the group weights as a vector<br># The first 3 assets shall have a group weight of greater than 0.15 and<br>less than 0.3<br># The next 3 assets shall have a group weight of greater than 0.1 and<br>less than 0.35<br># The last 4 assets shall have a group weight greater than 0 and less<br>than 0.4<br>constr <- add.constraint(constraints=constr, type="group",<br> groups=c(3, 3, 4),<br> group_min=c(0.15, 0.1, 0),<br> group_max=c(0.3, 0.35, 0.4))<br><br>This keeps the constraint object and interface to optimize.portfolio()<br>consistent with the existing code, but simplifies it and makes adding<br>box and group constraints very similar.<br><br>I will continue to review the PortfolioAnalytics source code and we can<br>revisit this so that I can hit the ground running when finals are over<br>and start as soon as possible.<br><br>Regards,<br>Ross Bennett<br><br><br>On Wed, Jun 5, 2013 at 9:23 AM, Doug Martin <<a href="mailto:martinrd@comcast.net" target="_blank">martinrd@comcast.net</a><br><mailto:<a href="mailto:martinrd@comcast.net" target="_blank">martinrd@comcast.net</a>>> wrote:<br><br> Ross and all,____<br><br> __ __<br><br> I think starting with the constraints is a good idea. But I think a<br> review of where PortfolioAnalytics functionality is as of last<br> year’s GSoC should be the first priority. How planning on that week<br> after next (Guy, Eric and I all have finals week to get out of the<br> way next week).____<br><br> __ __<br><br> With regard to constraints, that approach that Kirk Li (UW<br> Statistics Ph.D. student and AMATH 543 TA this spring) developed<br> looks useful. Ross you already have the code which I posted to the<br> class web site. I have attached it here for others on this project<br> to have a look at. Let’s review that after the end of next week<br> when final exams and the spring quarter are completely behind us.____<br><br> __ __<br><br> Doug____<br><br> __ __<br><br> __ __<br><br> *From:*<a href="mailto:gsoc-porta-bounces@lists.r-forge.r-project.org" target="_blank">gsoc-porta-bounces@lists.r-forge.r-project.org</a><br> <mailto:<a href="mailto:gsoc-porta-bounces@lists.r-forge.r-project.org" target="_blank">gsoc-porta-bounces@lists.r-forge.r-project.org</a>><br> [mailto:<a href="mailto:gsoc-porta-bounces@lists.r-forge.r-project.org" target="_blank">gsoc-porta-bounces@lists.r-forge.r-project.org</a><br> <mailto:<a href="mailto:gsoc-porta-bounces@lists.r-forge.r-project.org" target="_blank">gsoc-porta-bounces@lists.r-forge.r-project.org</a>>] *On Behalf<br> Of *Ross Bennett<br> *Sent:* Wednesday, June 05, 2013 4:22 AM<br> *To:* <a href="mailto:gsoc-porta@lists.r-forge.r-project.org" target="_blank">gsoc-porta@lists.r-forge.r-project.org</a><br> <mailto:<a href="mailto:gsoc-porta@lists.r-forge.r-project.org" target="_blank">gsoc-porta@lists.r-forge.r-project.org</a>><br> *Subject:* [GSoC-PortA] Schedule for PortfolioAnalytics Coding____<br><br> __ __<br><br> All,____<br><br> __ __<br><br> In my GSOC proposal, the order of what components I planned to write<br> code for was as follows:____<br><br> 1. Utility Functions (print, summary, plot, etc.)____<br> 2. Constraints____<br> 3. Example Functionality____<br><br> In speaking with Brian Peterson at R/Finance, he suggested that the<br> constraints portion be done first. I am fine with doing constraints<br> first. Would you like me to submit a revised schedule and<br> implementation plan with constraints first?____<br><br> __ __<br><br> Thanks,____<br><br> Ross Bennett____<o:p></o:p></p><p class=MsoNormal>_______________________________________________<br>GSoC-PortA mailing list<br><a href="mailto:GSoC-PortA@lists.r-forge.r-project.org" target="_blank">GSoC-PortA@lists.r-forge.r-project.org</a><br><a href="http://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/gsoc-porta" target="_blank">http://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/gsoc-porta</a><o:p></o:p></p></div><p class=MsoNormal><o:p> </o:p></p></div></div></body></html>