I have a MINLP objective function and I want to fix some variables value into constant as an example described below:
A = [1 1 1];
b = 30;
x1 = zeros(1,3);
y=1;
x = fmincon(@(x)objfun(x,y),x1,A,b);
function f = objfun(x,y)
x(y) = 1;
f = x(1)^2 + x(2)^2 + x(3)^2;
end
However, the result of variable x
is all zeros. It seems that x(1)
cannot be forced to be 1
. How to fix this problem?