How can I model my objective function for optimization?

2 views (last 30 days)
I have an objective function in microsoft excel, which is expressed as: SQRT(MMULT(MMULT(TRANSPOSE((AI25:AI54)*E5:E34),G5:AJ34),(AI25:AI54)*E5:E34)),
  • AI25:AI54 - is a 29x1 matrix of unknowns
  • E5:E34 - is a 29x1 matrix of constants
  • G5:AJ34 - is 29x29 covariance matrix of constants
I am not sure how to write this function in MATLAB terminology, but I can explain mathematically of what is happening:
  • Step 1: ((AI25:AI54)*E5:E34) , here suppose the first matrix is [1,2,3] and second matrix is [3,2,1], then the resultant matrix will be [1x3,2x2,3x1], which is [3,4,3] . I think * operation is similar to .* operation of MATLAB with matrices. Resultant is a 29x1 matrix.
  • Step 2: A transpose of resultant of step 1 is taken, which results in 1x29 matrix.
  • Step 3: Resultant of step 2 is matrix multiplied(normal matrix multiplication) with G5:AJ34, which results into a 1x29 matrix. You can observe all the elements are linear.
  • Step 4: Resultant of step 3 is matrix multiplied with the resultant of step 1, which results into a 1x1 matrix. You can observe the element in the matrix is in quadratic form
  • Step 5: Square root of the resultant of step 4, which results into my objective function
I want to model the resultant of step 5 in MATLAB with something like quadprog as my objective function, which is to be minimized. I choose quadprog, as my objective function is quadratic and all my constraints are linear in nature.
Can someone please help me with putting this objective function in the form of quadprog objective function?

Accepted Answer

Matt J
Matt J on 13 Jun 2013
Edited: Matt J on 13 Jun 2013
Let
x=AI25:AI54
e=E5:E34
G=G5:AJ34
Then you would call QUADPROG as
quadprog(diag(e)*G*diag(e), zeros(29,1) , ... constraints ...)
  3 Comments
Matt J
Matt J on 15 Jun 2013
Edited: Matt J on 15 Jun 2013
Do you think the first parameter of quadprog should also be multiplied by 2?
When QUADPROG is called as I proposed, it is the function
f1(x) = x.'*diag(e)*G*diag(e)*x/2
that is being minimized (see also here). So, if you instead want to receive as output the minimum of
f2(x) = x.'*diag(e)*G*diag(e)*x
then multiplying the input by 2 will give that to you. You could also wait until the optimization of f1(x) is finished and multiply that final output by 2, which involves less computation.
However, both f1(x) and f2(x) will be minimized by the same x, which is often what people are more interested in, so it's questionable if the factor of 2 really matters.
Do you think the step 5 of the objective function, i.e. is the square root of the whole objective function is not included in the model you have suggested
Again, f1(x) and sqrt(f1(x)) are monotonically related and are minimized at the same x. You can take the sqrt of the final value for f1(x) given to you by QUADPROG if it's important to you for some reason that the objective is measured that way.
Siddharth
Siddharth on 19 Jun 2013
Thank you for your invaluable inputs, I was able to model the desired optimization model.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!