fmincon constrain a row to be fixed
1 view (last 30 days)
Show older comments
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.
0 Comments
Accepted Answer
Matt J
on 26 Apr 2020
Edited: Matt J
on 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.
More Answers (0)
See Also
Categories
Find more on Linear Least Squares in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!