[問題] 最佳化中結果與限制式不符?已回收
欲極大化一個目標函數 f=xR' (其中x=[x1 x2 x3 x4] R為已知1*4向量)
限制條件為
1. x1 x2 x3 x4 皆大於0
2. xP'=1 (P亦為已知1*4向量)
3. xQx'<0.01 (Q為已知4*4矩陣)
利用fmincon函數
x0=[0.5 0.5 0.5 0.5];
Aeq=[(P1(t)-15106.14714)/4486.253582 (P2(t)-13249.23672)/3288.483779
(P3(t)-2004.141868)/1007.715708 (P4(t)-6467.395469)/1480.414767] % Px'=1
Beq=[1];
lb=[0 0 0 0];
[x,
fval,lambda,output]=fmincon(@myfun,x0,[],[],Aeq,Beq,lb,[],@confuneq,options)
function f = myfun(x)
f=-[x(1) x(2) x(3) x(4)]*[R1(t) R2(t) R3(t) R4(t)]';
function [c, ceq] = confuneq(x)
% Nonlinear inequality constraints
c =[x(1) x(2) x(3) x(4)]*Q*[x(1) x(2) x(3) x(4)]'-0.1;
% Nonlinear equality constraints
ceq=[];
以上是程式部分
但雖然設x皆大於0 但出來的仍有負值
並且似乎沒有極大化 不知道問題出在哪裡 >""<
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.134.115.75
MATLAB 近期熱門文章
PTT數位生活區 即時熱門文章