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

 채택된 답변

Walter Roberson
Walter Roberson 2022년 9월 4일
problem = createOptimProblem('fmincon', 'objective', @inclinedbckfill_inclwall, 'x0', x0, 'lb', lb, 'ub', ub, 'options', opts);

댓글 수: 3

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?
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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Surrogate Optimization에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by