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 日

0 投票

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

3 件のコメント

Sivani Remash T
Sivani Remash T 2022 年 9 月 4 日
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 2022 年 9 月 4 日
編集済み: Torsten 2022 年 9 月 4 日
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);
Sivani Remash T
Sivani Remash T 2022 年 9 月 4 日
Yes, got it. Thanks

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by