I have an optimisation problem.

I wish to maximise a function subject to a constraint. It is the constraint that is causing me problems. I am using an addin in Matlab which does the optimisation however the constraints that I have used before have been in the format of the line below.

 b_l <= Ax <= b_u

The constraint is,

 Sum(x .* stock)*BetaBM - 0.1 <= Sum(x .* stock.*BetaSK) <= Sum(x .*stock)*BetaBM + 0.1


 x is 2000 by 1 vector
 stock is 2000 by 1 vector
 BetaBM is a scalar
 BetaSK is 2000 by 1 vector

 x - is the weight of each stock in the fund. It cannot be more than 100% but can be less.
 stock - I am looking at M&A deals. The stock variable is a number between 0 and 1 which represents how much of the deal is being paid for in the acquires stock. 0 would mean the deal is purely cash. If there is part of the deal being paid in stock I will hedge the beta exposure against the S&P Index.

 BetaBM - is the S&P beta.
 BetaSK - contains all the individual beta for all the stocks in the fund

I need to get the constraint in the format b_l <= Ax <= b_u if at all possible?

  • 1
    $\begingroup$ please, check your question: something is missing BetaSK is. $\endgroup$ – Arrigo Sep 29 '14 at 14:40
  • 1
    $\begingroup$ I think there is something to correct: in MATLAB, x*stock will not work if both vectors have the same dimensions (2000x1) because it is not a correct matrix product. Do you mean matrix product or dot product when you use *? $\endgroup$ – Arrigo Sep 29 '14 at 14:56
  • $\begingroup$ sorry if I was using matlab your right they would not work. I meant to use .* $\endgroup$ – mHelpMe Sep 29 '14 at 15:16
  • $\begingroup$ is this a programming question? If yes .. off-topic. If no: then please write something about what the variables mean and what the constraint means. $\endgroup$ – Ric Sep 29 '14 at 15:28
  • $\begingroup$ @Richard - please see my revised post. If it is not clear please let me know $\endgroup$ – mHelpMe Sep 29 '14 at 15:46

If you have a vector of weights $w=(w_1,\ldots,w_n)^T$ then $(1,\ldots,1)* w = \sum_{i=1}^n w_i$ thus a sum condtion can be formulated by multiplication with a row of ones. A $\le$ can be put into an $\ge$ by multiplying with $(-1)$ and if you have to put all your constraints into on $A$ then you usually stack all the row vectors together. In your case the matrix $A$ will consist of rows of ones. As long as you don't explain your constraint I can not add more.

I will try: If you want to put a constraint on your porfolio beta then you should use a constraint: $$(\beta_1,\ldots,\beta_n) * w \le \beta_{BM}+0.1$$ and $$(\beta_1,\ldots,\beta_n)*w \ge \beta_{BM}-0.1$$ which the same as $$ -(\beta_1,\ldots,\beta_n)*w \le 0.1-\beta_{BM}$$. So you could use a matrix $$A = (\beta_1,\ldots,\beta_n;-\beta_1,\ldots,-\beta_n)$$ and right hand side $b = (\beta_{BM}+0.1;0.1-\beta_{BM})$ then your condition is: $$ A w \le b. $$

EDIT after a remark by PO: If you have $$ (\sum_{i=1}^n w_i stock_i) \beta_{BM} -0.1 \le \sum_{i=1}^n w_i stock_i \beta_i $$ then this is equivalent to $$ \sum_{i=1}^n w_i stock_i (\beta_{BM} - \beta_i) \le 0.1 $$ then you define scalars $k_i = stock_i (\beta_{BM} - \beta_i)$ and the same as above holds for $\sum_{i=1}^n w_i k_i \le 0.1$. For the right hand side you get $$ \sum_{i=1}^n w_i (-k_i) \le 0.1. $$ Your matrix $A$ has two rows, one $(k_1,\ldots,k_n)$ and one $(-k_1,\ldots,-k_n)$ the rhs is $(0.1, 0.1)$.

  • $\begingroup$ Firstly thanks for such a clear answer. I have a silly question (maths is not primary skill which you can probably tell). Doing it this way have we broken the contraint b_l <= Ax <= b_u into two seperate contraints which will achieve the same goal? I.e we Ax <= b where b is (0.1, 0.1). I believe in Matlab I can just put b_l equal to [ ]. $\endgroup$ – mHelpMe Sep 30 '14 at 8:02
  • $\begingroup$ It is quite some time ago that I used Matlab. But it should work that you only define b_u and leave b_l empty. Or you use a formulation where you still stack to rows together for A but keep a b_l. Give it a try and tell us. $\endgroup$ – Ric Sep 30 '14 at 8:25
  • $\begingroup$ I'm pretty sure that setting b_l to [ ] will work. I will try that now. Sorry I do not quite follow where you say 'keep a b_l'. I understand that A will be stacked (i.e. two rows, k & -k) that you mentioned in your post $\endgroup$ – mHelpMe Sep 30 '14 at 8:30
  • 1
    $\begingroup$ I though that maybe there is a way to keep the $B_l \le A \le b_u$ formulation. But please forget it for now. It is quite usualy to formulate the constraint as $A x \le b_u$. This is fully general as you can always multiply rows and rhs by (-1). $\endgroup$ – Ric Sep 30 '14 at 8:39
  • 1
    $\begingroup$ I guess actually if needs be in matlab I can put B_l to -inf. I will mark the answer as correct, thank-you again. $\endgroup$ – mHelpMe Sep 30 '14 at 9:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.