fmincon Error on undefined objective function at init. point.
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi everyone,
I've been trying to create an optimization problem for fmincon using the following code:
function [ prob ] = CreateOptProb( H,M,V,q0,P_max )
% Optimize the problem: q = arg min_q tr[J^-1]
% Subject to q_kj >= 0 AND norm(q,1) = P_max
% A*X <= B, therefore A = -1 and B = 0
% C(X) <= 0, Ceq(X) = 0, therefore C = [] and Ceq = norm(q,1)-P_max
objective=@(q) obj(q);
constraint=@con;
function f = obj(q)
f = trace(inv(H*V*diag(reshape(q, [1, numel(q)]))*V'*H' + eye(M)));
end
function [C,Ceq] = con(q)
C = [];
Ceq = norm(q,1) - P_max;
end
prob.x0 = q0;
prob.objective = objective;
prob.Aineq = -eye(numel(q0));
prob.bineq = zeros([numel(q0) 1]);
prob.nonlcon = constraint;
prob.solver = 'fmincon';
prob.options = optimset('Algorithm', 'interior-point');
end
But when I try to run the problem:
>> tempvar = CreateOptProb(H,M,V,q,P_max);
>> [q,tji] = fmincon(tempvar);
??? Error using ==> sqpLineSearch at 20
Objective function is undefined at initial point. Fmincon cannot continue.
Where:
q0 =
0.0548 0.0548 0.0548 0.0548
0.0548 0.0548 0.0548 0.0548
0.0548 0.0548 0.0548 0.0548
0.0548 0.0548 0.0548 0.0548
0.0548 0.0548 0.0548 0.0548
The confusing part is that the objective function is actually defined at q0:
>> trace(inv(H*V*diag(reshape(q0, [1, numel(q0)]))*V'*H' + eye(M)))
ans =
1.5438 + 0.0000i
Can anyone shed some light on this??
Thanks a lot, Yenson
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Surrogate Optimization dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!