"Failure in initial objective function evaluation"
Afficher commentaires plus anciens
Hello everybody,
I'm trying to set up a optimization. As a function for the optimization I want to use a Class I wrote with a bunch of calculations. The class itself is working as it should. But when I try to run the fmincon solver I get an error warning: "Failure in initial objective function evaluation. FMINCON cannot continue"
I think I'm calling the method from the Class in the wrong way, wherever my attempts to change the way I call it didn't work either. Has anybody some advice?
%Instanz erstellen
myHoltropObject = Holtrop_R_T(12.86, 900);
x0 = [50 12 3.2 -4.5];
lb = [40 10 3 -5];
ub = [60 15 5 5];
gs = GlobalSearch;
options = optimoptions('fmincon','Algorithm', 'interior-point',...
'UseParallel',true, 'Display','off','MaxFunctionEvaluations',6000, 'TolCon', 1e-4, 'TolFun', 1e-4);
objectiveA = @(in) calcRT(in);
constraintA = @(in) RT_equal84(in, calcRT);
problem = createOptimProblem('fmincon', ...
'objective',objectiveA, ...
'x0',x0, ...
'lb',lb, ...
'ub',ub, ...
'nonlcon',constraintA, ...
'options',options)
% Run optim search
%[resultVector,~,exitFlag,~,~] = run(gs,problem); % this is for global optimization
[resultVector,~,exitFlag,~,~,~,~] = fmincon(problem) % this is for local search of optimum
% ERROR:
problem =
objective: @(in)calcRT(in)
x0: [50 12 3.2000 -4.5000]
Aineq: []
bineq: []
Aeq: []
beq: []
lb: [40 10 3 -5]
ub: [60 15 5 5]
nonlcon: @(in)RT_equal84(in,calcRT)
solver: 'fmincon'
options: [1×1 optim.options.Fmincon]
Unable to resolve the name myHoltropObject.getR_T.
Error in User>calcRT (line 31)
RT = myHoltropObject.getR_T([Lwl B T lcb]);
Error in User (line 10)
objectiveA = @(in) calcRT(in);
Error in fmincon (line 552)
initVals.f = feval(funfcn{3},X,varargin{:});
Caused by:
Failure in initial objective function evaluation. FMINCON cannot continue.
%
%Ergebnisausgabe
fprintf('Optimale Abmessungen: \nLänge: %5.3f \nBreite: %5.3f \nTiefgang: %5.3f \nlcb: %5.3f \n',resultVector(1), resultVector(2), resultVector(3), resultVector(4));
%Objective function
function RT = calcRT(in)
Lwl = in(1);
B = in(2);
T = in(3);
lcb = in(4);
RT = myHoltropObject.getR_T([Lwl B T lcb]);
end
%Constraint function
function [c, ceq] = RT_equal84(in)
RT = calcRT(in);
ceq = RT-616;
c = [];
end
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Surrogate Optimization dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!