Error using barrier. Nonlinear constraint function is undefined at initial point. Fmincon cannot continue.

24 次查看(过去 30 天)
My problem is a minimization problem, witht he following code:
x0 = [Pch; Pdis; zeros(N,1); zeros(N,1); 2*Eessmin];
SOC0 = 0;
C = [r ls Cinv Effch Effdis Ncyc Cmaint expPrice];
lb = [zeros(N,1); zeros(N,1); zeros(N,1); zeros(N,1); Eessmin]; % lower bounds of 0 and Essmin
ub = [Pch; Pdis; Pch; Pdis; Inf];
ot = ones(N,1);
beq = Prem ;
Aeq = spdiags([ot -ot ot -ot],[0 N 2*N 3*N],N,4*N+1);
X = sym('x',[4*N+1,1]);
G = sym('G', [N,1]);
s0 = sym('s0');
c = sym({'c1','c2','c3','c4','c5','c6','c7','c8'}.','real');
where I create a file for my non-linear constraints:
PBch = X(1:N)/X(2*N+1);
PBdis = X(N+1:2*N)/X(2*N+1);
nlc1 = s0 + cumsum(PBch*c(4)) - cumsum(PBdis*c(5)) - 1;
nlc2 = -s0 - cumsum(PBch*c(4)) + cumsum(PBdis*c(5));
nlc = [nlc1; nlc2];
nlceq = [];
nlc = subs(nlc, [c;s0], [C';SOC0]);
matlabFunction(nlc,nlceq,'vars',{X},'file','NLConsRev1');
and my objective function, Ctot, to be minimized:
matlabFunction(Ctot,'vars',{X},'file','objFcnRev1');
When using fmincon solver:
options = optimset('MaxFunEvals',Inf,'MaxIter',5000,'Algorithm','interior-point','Display','iter');
[x1, fval1,] = fmincon(@objFcnRev1,x0,Aeq,beq,[],[],lb,ub,@NLConsRev1,options);
I receive the following error:
Error using barrier
Nonlinear constraint function is undefined at initial point. Fmincon cannot continue.
Error in fmincon (line 797)
[X,FVAL,EXITFLAG,OUTPUT,LAMBDA,GRAD,HESSIAN] = barrier(funfcn,X,A,B,Aeq,Beq,l,u,confcn,options.HessFcn, ...
Error in OptRev1 (line 178)
[x1, fval1,] = fmincon(@objFcnRev1,x0,Aeq,beq,[],[],lb,ub,@NLConsRev1,options);
Any help would be greatly appreciated, thanks!

回答(3 个)

Alan Weiss
Alan Weiss 2017-9-7
You didn't give many of the parameters used in your code, such as N, so we cannot reproduce your problem.
However, it is clear that fmincon is complaining about your nonlinear constraint function. Try running
[c,ceq] = NLConsRev1(x0)
and see what transpires. Fix that, and maybe other things will work, too.
By the way, your fmincon call begins
fmincon(@objFcnRev1,x0,Aeq,beq,[],[],...
Did you mean to put Aeq and beq in the third and fourth arguments? Usually they are fifth and sixth.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation

kamilya MIMOUNI
kamilya MIMOUNI 2019-10-26
Error using sqpInterface
Objective function is undefined at initial point. Fmincon cannot continue.
Error in fmincon (line 823)
[X,FVAL,EXITFLAG,OUTPUT,LAMBDA,GRAD,HESSIAN] = sqpInterface(funfcn,X,full(A),full(B),full(Aeq),full(Beq), ...
Error in Test3 (line 89)
Control_optimal = fmincon(problem)
i have this problem in matlab

kamilya MIMOUNI
kamilya MIMOUNI 2019-10-26
what do I do

标签

Community Treasure Hunt

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

Start Hunting!

Translated by