'Not enough input arguments' error in GlobalSearch function

I am trying to obtain global minima for a function using fmincon and globalsearch functions. But, there seems to be some error in function definition when I use CreateOptimProblem command. The error is
Not enough input arguments.
Error in inclndbackfill_inclinedwall>inclinedbckfill_inclwall (line 37)
alps(1:M)=X(1:M);
Code is given below. ( the function code is really big, so i m not including the entire one)
N=4; M=3;
A=[]; b=[];
Aeq=[]; Beq=[];
x0=[0*ones(1,M) 0*ones(1,N)]; lb=[0*ones(1,M) 0*ones(1,N)]; ub=[1.57*ones(1,M) 1.57*ones(1,N)];
opts=optimoptions(@fmincon,'Algorithm','sqp');
problem=createOptimProblem('fmincon','objective',inclinedbckfill_inclwall,'x0',x0,'lb',lb,'ub',ub,'options',opts);
gs=GlobalSearch;
[x,fval]=run(gs,problem);
function f=inclinedbckfill_inclwall(X)
N=4;
M=3;
alps(1:M)=X(1:M);
alp(1:N)=X(M+1:M+N);
...................................
end

 Respuesta aceptada

problem = createOptimProblem('fmincon', 'objective', @inclinedbckfill_inclwall, 'x0', x0, 'lb', lb, 'ub', ub, 'options', opts);

3 comentarios

I tried this way, but then it shows another error;
Error using sqpInterface
Objective function is undefined at initial point. Fmincon cannot continue.
Error in fmincon (line 871)
[X,FVAL,EXITFLAG,OUTPUT,LAMBDA,GRAD,HESSIAN] = sqpInterface(funfcn,X,full(A),full(B),full(Aeq),full(Beq), ...
Error in globaloptim.globalsearch.globalsearchnlp
Error in GlobalSearch/run (line 340)
globaloptim.globalsearch.globalsearchnlp(FUN,X0,A,B,Aeq,Beq,LB,UB,NONLCON,options,localOptions);
Error in inclndbackfill_inclinedwall (line 30)
[x,fval]=run(gs,problem);
Caused by:
Failure in initial call to fmincon with user-supplied problem structure.
So,what could be the reason here?
Torsten
Torsten el 4 de Sept. de 2022
Editada: Torsten el 4 de Sept. de 2022
The reason is that your objective function is undefined at the initial point as clearly stated by the error message.
Try what you get back when you call
inclinedbckfill_inclwall(x0)
before the line
[x,fval]=run(gs,problem);
Yes, got it. Thanks

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Productos

Preguntada:

el 4 de Sept. de 2022

Editada:

el 4 de Sept. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by