Need help for a nonlinear constraint optimization problem
Afficher commentaires plus anciens
Dear all,
I am going to solve the following nonlinear constraint optimization problem using MATLAB. I was wondering if you could please help me how to do that,
minimize -trace(W^-1)
subject to
(A-B1*k)W+W*(A-B1*k)'=-B2*B2';
sqrt(trace(C'*W*C)) <= 1;
max(eig(A-B1*k)) <= -1;
A, B1 and B2 are known matrices and k is the unknown 2*2 matrix. (W is also a 2*2 matrix).
I wrote the following code but got error,
function [c,ceq] = constr(k)
c(1) = (A-B1*k)*W+W*(A-B1*k)'+B2*B2';
c(2) = sqrt(trace(C'*W*C))-1;
c(3) = max(eig(A - B1*k))+1;
ceq = [];
end
clc
clear
close all
A = [-1 0
0 -2];
B1 = eye(2);
B2 = eye(2);
C = eye(2);
g2 = 3; g3 = -1;
x0=[1;1];
A=[];
b=[];
Aeq=[];
beq=[];
lb=[];
ub=[];
nonlcon = @constr;
fun = @(k)(-trace(inv(W)));
k = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon)
Thanks a lot.
6 commentaires
John D'Errico
le 20 Fév 2018
Nowhere in this code do you show how W is a function of k. Yes, you have written this:
fun = @(k)(-trace(inv(W)));
But that just uses some fixed matrix W, and ignores the value of k.
You cannot minimize a constant. Well you can try, but it will be rather boring.
Mohammad
le 20 Fév 2018
You will have to define 8 unknown variables (assuming W and k are arbitrary 2x2 matrices).
Let the first 4 of them form the matrix W and the last 4 of them form the matrix k:
W=[x(1) x(2);x(3) x(4)];
k=[x(5) x(6);x(7) x(8)];
Now your code has to work on this 8-element vector x, e.g.
function [c,ceq] = constr(x)
W=[x(1) x(2);x(3) x(4)];
k=[x(5) x(6);x(7) x(8)];
mat = (A-B1*k)*W+W*(A-B1*k)'+B2*B2';
ceq(1) = mat(1,1);
ceq(2) = mat(2,1);
ceq(3) = mat(1,2);
ceq(4) = mat(2,2);
c(1) = sqrt(trace(C'*W*C))-1;
c(2) = max(eig(A - B1*k))+1;
end
... although I ask myself how you want to prevent A-B1*k to have complex eigenvalues.
Best wishes
Torsten.
Torsten
le 21 Fév 2018
Your x0-vector contains 8 elements now ?
Best wishes
Torsten.
Mohammad
le 21 Fév 2018
Réponses (0)
Catégories
En savoir plus sur Systems of Nonlinear Equations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!