Error with Fmincon nonlinear constraint
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Brian Noiret
el 27 de Mzo. de 2020
Comentada: Alan Weiss
el 30 de Mzo. de 2020
Hi! I encounter a problem trying to use fmincon to solve a nonlinear equation system. The message error:
Error in Untitled (line 12)
F=@(n) [n(1) + n(2) + n(3) + n(4) + n(5) + n(6) + n(7) + n(8) + w - n(9);...
Error in fmincon (line 639)
[ctmp,ceqtmp] = feval(confcn{3},X,varargin{:});
Error in Untitled (line 28)
n=fmincon(@(x)0,x0,[],[],[],[],lb,ub,[[],F],opts);
Caused by:
Failure in initial nonlinear constraint function evaluation. FMINCON cannot continue.
Hereunder you can find a simplified version of my code that returns that error as well. This being the first time I use fmincon, I assume I made a basic syntax error, can anyone help me with this?
nIt = 1;
for ii=1:nIt
% K01 = ;
% K02 = ;
% K03 = ;
% K04 = ;
%
% a = ; b = ; c = ;
% u = ; v = ; w = ; x = ; y = ; z = ;
F=@(n) [n(1) + n(2) + n(3) + n(4) + n(5) + n(6) + n(7) + n(8) + w - n(9);...
1 - (n(3) * n(2) / (n(1) * n(4)))/K01;...
1 - (n(7) / (n(8) * n(6)) * n(9) / u)/K02;...
1 - (n(2) / (n(5) * n(6)) * n(9) / u)/K03;...
1 - (n(6)^2 / n(4) * u / n(9))/K04;...
a*x - n(1) - n(3);...
4*(c) + a*y - 2*n(2) - 2*n(4) - n(5) - n(6) - n(7);...
c - n(7) - n(8);...
4*(c) + a*z - 2*n(1) - n(2) - n(3) - n(5) - 3*v];
lb = zeros(1,9); % Lower bound constraint
ub = 10*ones(1,9); %upper bound constraints
rng default % Reproducible initial point
x0 = exprnd(1,9); %initial values
opts = optimoptions(@fmincon,'Algorithm','interior-point','Display','off');
n=fmincon(@(x)0,x0,[],[],[],[],lb,ub,[[],F],opts);
end
0 comentarios
Respuesta aceptada
Alan Weiss
el 30 de Mzo. de 2020
2 comentarios
Alan Weiss
el 30 de Mzo. de 2020
Since it helped, please "accept" the answer.
Alan Weiss
MATLAB mathematical toolbox documentation
Más respuestas (0)
Ver también
Categorías
Más información sobre Systems of Nonlinear Equations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!