fmincon constrain a row to be fixed

1 Ansicht (letzte 30 Tage)
AMIT PAWAR
AMIT PAWAR am 26 Apr. 2020
Kommentiert: AMIT PAWAR am 26 Apr. 2020
rng(4)
St = transpose(rand(9,10))
Stplus1 = transpose(rand(9,10))
fun = @(x) norm(transpose(St*x - Stplus1)*(St*x - Stplus1));
x0 = rand(9,9);
lb = zeros(1,81);
ub = ones(1,81)*0.999999;
A = [];
b = [];
Aeq = []
beq = []
nonlcon = [];
options = optimoptions(@fmincon,'MaxFunctionEvaluations',10000)
x = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon, options);
I am trying to minimize the function 'fun' with respect to argument x. I wanted to know if there is a way to set one row of x to be fixed with some constant values while using fmincon.

Akzeptierte Antwort

Matt J
Matt J am 26 Apr. 2020
Bearbeitet: Matt J am 26 Apr. 2020
Yes, you can simply not treat them as unknowns. Instead, rewrite the problem in terms of a smaller matrix z containing the unknown elements only. So, for example, if it is the first row x(1,:) is some known row-vector v, youwill solve for the matrix z=x(2:end,:) and your objective will reduce to,
A=St(:,2:end);
B=Stplus1-St(:,1)*v;
fun = @(z) norm(A*z-B,'fro').^2; %z=x(2:end,:)
Incidentally, your problem is a linear least squares optimization, so it would be sufficient to use lsqlin rather than fmincon.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by