# Math for optimal asset allocation given constraints (linear/quadratic programming?)

Say we have a set of mutual funds, with various characteristics. I'd like to run some maths and give back the ideal mixture of these funds to meet the users constraints, and I'm unsure of whether this is a linear programming problem, or a quadratic program, or something altogether different.

Here's a quick example:

$$\begin{array}{c|c} Fund & \text{Price} & \text{Stock %} & \text{Bond %} & \text{Canadian %} & \text{US %}\\ \hline A & 10 & 90 & 10 & 80 & 20 \\ B & 8 & 30 & 70 & 40 & 60 \end{array}$$

And we have the following goals in allocating our portfolio:

• Not to exceed 10,000• Ideal target is 20% Canadian, 80% US • Ideal stock/bond ratio is 50/50 I've start down the road of treating this as a linear programming problem, but I'm assuming I've made an unnecessarily complex cost function, or this is a quadratic program instead; which I'm not familiar with. Let me lay out what I've done so far: Objective Function: minimize the difference in allocation from the desired allocation (desired - actual, squared to handle negativity and increase cost of outliers): \begin{align} \min \quad x &= (0.50-\frac{10x_{1}s_{1}+8x_{2}s_{2}}{10000})^2\\ &+ (0.50-\frac{10x_{1}b_{1}+8x_{2}b_{2}}{10000})^2\\ &+ (0.20-\frac{10x_{1}c_{1}+8x_{2}c_{2}}{10000})^2\\ &+ (0.80-\frac{10x_{1}u_{1}+8x_{2}u_{2}}{10000})^2\\ \end{align} Subject to: \begin{align} (10)(0.9)x_{1} + (8)(0.3)x_{2} &<= (10,000*0.5) \\ (10)(0.1)x_{1} + (8)(0.7)x_{2} &<= (10,000*0.5) \\ (10)(0.8)x_{1} + (8)(0.4)x_{2} &<= (10,000*0.2) \\ (10)(0.2)x_{1} + (8)(0.6)x_{2} &<= (10,000*0.8) \\ 10x_{1} + 8x_{2} &<= 10,000 \\ x_{1}, x_{2} &>= 0 \end{align} I'm new to linear programming however - but since my cost function isn't in fact linear - do I need to look into a different cost function? Or look in quadratic programming? Or is there a better method altogether to solving this? ## 1 Answer This looks like a goal programming problem. Here is a possible formulation: I added weights to the objective, so you can specify what are the important or less important goals. I dropped the goals for Canadian% and Bonds% as they essentially duplicate the US% and Stock% goals. I ignored the price as I am definingx_f\$ as the amount of money invested in each fund (not the number of shares). I think that makes more sense when calculating the goals.

This is indeed a Quadratic Programming problem. But it can be linearized by using a technique called variable splitting. In that case we minimize the sum of the absolute values of the deviations. Such a linear goal programming model can look like: The behavior of the linear and the quadratic model is somewhat different (you get different allocations). So I would recommend to try out both.