FMINCON - Failure in initial objective function evaluation. FMINCON cannot continue

2 ビュー (過去 30 日間)
AXL
AXL 2017 年 10 月 6 日
コメント済み: AXL 2017 年 11 月 11 日
I am trying to solve a bar optimization problem, passing the initial conditions (the area of each bar) and all variables as a struct but I am facing the following problem:
"Failure in initial objective function evaluation. FMINCON cannot continue."
fem = struct(...
'x',x0,... % Initial set of points
'NODE',NODE,... % [NNode x 2] array of nodes
'ELEM',ELEM,... % [NElem x 2] array of elements
'v',{v},... % Cell defining the variables
'NNode',size(NODE,1),... % Number of nodes
'NElem',size(ELEM,1),... % Number of elements
'NVar',size(v,1)... % Number of variables
);
Plot10bar(fem);
mass = GetMass10bar(fem);
fprintf('Initial Mass = %f\n',mass);
[x,fval,exitflag,output,lambda,grad,hessian] = ...
fmincon(@GetMass10bar,x0,[],[],[],[],lb,ub,@GetConstraints10bar,options);
mass = GetMass10bar(fem);
fprintf('Final Mass = %f\n',mass);
Plot10bar(fem);
Thank you,
André Leitão
  2 件のコメント
Matt J
Matt J 2017 年 10 月 6 日
編集済み: Matt J 2017 年 10 月 6 日
If you evaluate the objective function at the initial point from the command line
>> GetMass10bar(x0)
you should see it fail.
AXL
AXL 2017 年 11 月 11 日
GetMass10bar evaluates the mass of 10-bar-truss! If I want to evaluate the initial mass, before the optimization process happens, I have to use, as argument of this function, the struct fem, which contains cross-section areas and nodal coordinates (used in to optimized the truss).

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

採用された回答

AXL
AXL 2017 年 11 月 11 日
I solved it using this:
[x,fval,exitflag,output,lambda,grad,hessian] = ...
fmincon(@GetMass18bar,x0,[],[],[],[],lb,ub,...
@GetConstraints18bar,options,fem);

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2017 年 10 月 6 日
You assign a struct to fem and then you call
mass = GetMass10bar(fem);
this suggests that the function GetMass10bar normally expects to be passed a single parameter that is a struct.
You then have
[x,fval,exitflag,output,lambda,grad,hessian] = ...
fmincon(@GetMass10bar,x0,[],[],[],[],lb,ub,@GetConstraints10bar,options);
fmincon passes a numeric vector with the same number of elements as x0; it does not pass a struct.
If your code for GetMass10bar cannot handle either a struct or a numeric vector, then the fmincon call to GetMass10bar is going to fail.
GetMass10bar appears to be your own code; I do not find any reference to it anywhere on the Internet.
  3 件のコメント
AXL
AXL 2017 年 11 月 11 日
I will take a look at this carefully.

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

カテゴリ

Help Center および File ExchangeStructural Analysis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by