Info

This question is locked. 请重新打开它进行编辑或回答。

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

3 次查看(过去 30 天)
Hi, after running my code
R=readmatrix(filename1);
R=R.';
w=readmatrix(filename2);
gamma = 2;
Aeq = ones(1,68);
beq = 1;
lb = zeros(68,1);
ub = ones(68,1);
x0=0.0147*ones(1,68);
u = @(x) 1/(1-gamma)*x.^(1-gamma);
obj = @(x)-sum(u(x*w*R));
x = fmincon(obj,x0,[],[],Aeq,beq,lb,ub);
I recived the following error
Error using barrier
Objective function is undefined at initial point. Fmincon cannot continue.
Error in fmincon (line 824)
[X,FVAL,EXITFLAG,OUTPUT,LAMBDA,GRAD,HESSIAN] =
barrier(funfcn,X,A,B,Aeq,Beq,l,u,confcn,options.HessFcn, ...
I run the same code before but with a lees number of data and it works perfectly. Can you please help me what is wrong with my code ?
Thanks in advance
:::: UPDATE
after my discussion with Torsten : here
I reads my data carefully and found the problem with my data
  3 个评论
Az.Sa
Az.Sa 2023-4-15
Thanks Walter. I apprecaite the time everyone spend it here to help . I did not want to mislead the reader since my data cause the problem. I tried to accept Torsten answer but I could not
Rik
Rik 2023-4-17
Original question:
Error using barrier Objective function is undefined at initial point. Fmincon cannot continue.
Hi, after running my code
R=readmatrix(filename1);
R=R.';
w=readmatrix(filename2);
gamma = 2;
Aeq = ones(1,68);
beq = 1;
lb = zeros(68,1);
ub = ones(68,1);
x0=0.0147*ones(1,68);
u = @(x) 1/(1-gamma)*x.^(1-gamma);
obj = @(x)-sum(u(x*w*R));
x = fmincon(obj,x0,[],[],Aeq,beq,lb,ub);
I recived the following error
Error using barrier
Objective function is undefined at initial point. Fmincon cannot continue.
Error in fmincon (line 824)
[X,FVAL,EXITFLAG,OUTPUT,LAMBDA,GRAD,HESSIAN] =
barrier(funfcn,X,A,B,Aeq,Beq,l,u,confcn,options.HessFcn, ...
I run the same code before but with a lees number of data and it works perfectly. Can you please help me what is wrong with my code ?
Thanks in advance

回答(1 个)

Walter Roberson
Walter Roberson 2023-4-13
Your gamma is 2. 1-gamma is -1. x.^(1-gamma) is then 1./x
But you permit x to start at 0 (your lower bound is 0). That would get you infinity or nan, either of which is going to cause your objective to fail.
Your lb needs to be greater than 0.
  8 个评论

This question is locked.

类别

Help CenterFile Exchange 中查找有关 Surrogate Optimization 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by