Can anyone help me in coding matlab code for Quadratically Constrained Quadratic Program (QCQP)?

5 ビュー (過去 30 日間)
Dinoma Degefa
Dinoma Degefa 2019 年 5 月 9 日
編集済み: Torsten 2019 年 5 月 10 日
I used fmincon but it is not working for me. i might miss something. The following is just the simplest which i want to ask for my understanding to work further for large dimensions.
subject to
where H=[2 0 0;0 2 0;0 0 2]; f=[-1; -2 ;-3], R=[7 0 0;0 7 0;0 0 7]; h=[-4 ;-5 ;-6]; c=88.
Can anyone give me a code for this problem?

回答 (1 件)

Torsten
Torsten 2019 年 5 月 9 日
編集済み: Torsten 2019 年 5 月 9 日
function main
H = [2 0 0;0 2 0;0 0 2];
f = [-1; -2 ;-3];
R = [7 0 0;0 7 0;0 0 7];
h = [-4 ;-5 ;-6];
c = 88;
x0 = [1; 1; 1];
obj = @(x)0.5*x.'*H*x+f.'*x;
sol = fmincon(obj,x0,[],[],[],[],[],[],@(x)nonlcon(x,R,h,c))
end
function [cineq,ceq] = nonlcon(x,R,h,c)
cineq(1) = 0.5*x.'*R*x+h.'*x+c;
end
  2 件のコメント
Dinoma Degefa
Dinoma Degefa 2019 年 5 月 9 日
Torsten it is not working.
Error in drow (line 9)
sol = fmincon(obj,x0,[],[],[],[],[],[],@(x)nonlcon(x,R,h,c))
Caused by:
Failure in initial user-supplied objective function evaluation. FMINCON cannot continue.
Torsten
Torsten 2019 年 5 月 10 日
編集済み: Torsten 2019 年 5 月 10 日
I can't test the code since I don't have a licence for the optimization toolbox.
First change "nonlcon" to
function [cineq,ceq] = nonlcon(x,R,h,c)
cineq(1) = 0.5*x.'*R*x+h.'*x+c;
ceq = [];
end
Secondly supply x0 as a row vector:
x0 = [1,1,1];
Test again.
If it still doesn't work, post the code you are using.

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

カテゴリ

Help Center および File ExchangeMPC Design についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by