fmincon Error on undefined objective function at init. point.
조회 수: 1 (최근 30일)
이전 댓글 표시
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
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Surrogate Optimization에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!