How can I model my objective function for optimization? in quadprog

x(1)+x(2)+x(3)+x(4)+x(5)+x(6)+x(7)+0.3*x(5)^2+0.3*x(6)^2+0.3*x(7)^2
If someone know please help.
Thank You.

 採用された回答

Alan Weiss
Alan Weiss 2018 年 7 月 2 日

2 投票

As the function reference page for quadprog states, the objective function in terms of the matrices H and f is
1/2*x'*H*x + f'*x
You have a 7-dimensional x. So f = ones(7,1) for the first seven terms of your sum. Then you have three terms for quadratic terms. Take
H = spalloc(7,7,3); % Sparse 7-by-7 array with 3 nonzero entries
H(5,5) = 2*0.3;
H(6,6) = 2*0.3;
H(7,7) = 2*0.3;
The reason you multiply those entries by 2 is because of the 1/2 in the definition of the quadprog objective function.
Alan Weiss
MATLAB mathematical toolbox documentation

5 件のコメント

NIKET shah
NIKET shah 2018 年 7 月 2 日
thank you.
it would be 4 nonzero entries, instead of three.
and also
can i solve this objective function with the help of quadprog..
{x(1)+x(2)+x(3)+x(4)+x(5)+x(6)+x(7)+0.3*x(5)^2+0.3*x(6)^2+0.3*x(7)^2)/{x(1)+x(2)+x(3)+x(4)+x(5)+x(6)+x(7)+x(8)+x(9)+0.3*x(5)^2+0.3*x(6)^2+0.3*x(7)^2+0.3*x(7)^2+0.3*x(9)^2).. Can i create a different function file in quadprog.?
Alan Weiss
Alan Weiss 2018 年 7 月 2 日
It looks like you have a quotient of two quadratics there. The answer is no, quadprog does not address a quotient of quadratics. For that, you can use fmincon or fminunc.
Alan Weiss
MATLAB mathematical toolbox documentation
NIKET shah
NIKET shah 2018 年 7 月 2 日
okay. I have used fmincon but it doesn't returns integer argument. like MILP. is there another solver for quadratic objective function.
Alan Weiss
Alan Weiss 2018 年 7 月 2 日
I don't know what you are trying to do exactly. You could look at a Mixed-Integer Quadratic Programming example. There are more examples of this type of problem in Financial Toolbox documentation.
Alan Weiss
MATLAB mathematical toolbox documentation
NIKET shah
NIKET shah 2018 年 7 月 2 日
okay thank you.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeQuadratic Programming and Cone Programming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by