Can anyone help me in coding matlab code for Quadratically Constrained Quadratic Program (QCQP)?
조회 수: 5 (최근 30일)
이전 댓글 표시
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?
댓글 수: 0
답변 (1개)
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
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 Exchange에서 MPC Design에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!