Incorrect output of linear optimization problem
2 ビュー (過去 30 日間)
古いコメントを表示
Hello Everyone,
I'm trying to make a linear optimization problem over an objective function as follows which is called (objfun_36) to get the optimized value of the decision variable " zm " for each "s" which is called (zm_optimized(s)). However, I defined the decision varaible "zm" as a continous decsion varaible with llower bound zero and upper bound 1. I'm expecting the optimzed value of zm for each "s" to be a different value from 0 up to 1. However, I got zm_optimezed(s) equals 1 for all "s".. and this does not make sense.
Please can anyone help me ?
Subject to
Here is my code
ls=[20000,20000,20000,20000,20000,20000,20000,20000,20000,20000];
CK=[500,600,700,800,900,1000,1100,1200,1300,1400];
TN=10;
N_S=length(TN);
zm = optimvar('zm',N_S,'Type','continuous','LowerBound',0,'UpperBound',1);
CMRN=0.4*(10^5);
Rk=[2.7684,4.7962,6.0404,5.5868,5.2827,5.7736,6.1362,6.1943,5.9630,6.1183]*1.0e+08;
expo=1;
pL=zeros(1,TN);
for l=1:TN
pL(l)=l^-expo;
end
beta=pL./sum(pL);
veta_s=pL./sum(pL);
a = 500;
b = 2000;
Lks = ((b-a).*rand(10) + a);
aa = 0.1;
bb = 1;
Fkf= ((bb-aa).*rand(10,1) + aa)*(10^9);
k_=[1,1,1,1,1,1,1,1,1,1];
for k=1:1:TN
for s=1:1:TN
DRK_hat(k)=Lks(k,s)/Rk(k)
tks_hat(k,s)=(CK(k)*Lks(k,s))/Fkf(k)
eq_36(k,s)=zm*(-beta(k)*((DRK_hat(k)*veta_s(s)+(tks_hat(k,s)*veta_s(s))))-k_(k));
end
sumcol_36=sum(eq_36,1);
end
sumrows_36=sum(sumcol_36,2);
objfun_36=sumrows_36;
for s=1:TN
cache_location_constraint_36=(zm*ls(s))<=CMRN;
ProCach=optimproblem; % create an optimization problem
ProCach.Objective=objfun_36 %minimization equation 36
ProCach.Constraints.Constr1=cache_location_constraint_36;
%% optimal solver
opts=optimoptions('linprog');
[zm_optimized(s),fval,exitflag,output]=solve(ProCach,'Options',opts);
end
3 件のコメント
Torsten
2022 年 11 月 18 日
so the constraint (11f) ensures that the sum of all services multipled by the length of each on should be less than the memory cach size..
Yes, but you only constrain one service at a time, not the sum of them.
採用された回答
Matt J
2022 年 11 月 18 日
編集済み: Matt J
2022 年 11 月 18 日
ls=[20000,20000,20000,20000,20000,20000,20000,20000,20000,20000];
CK=[500,600,700,800,900,1000,1100,1200,1300,1400];
TN=10;
N_S=TN;
zm = optimvar('zm',N_S,'Type','continuous','LowerBound',0,'UpperBound',1);
CMRN=0.4*(10^5);
Rk=[2.7684,4.7962,6.0404,5.5868,5.2827,5.7736,6.1362,6.1943,5.9630,6.1183]*1.0e+08;
expo=1;
pL=zeros(1,TN);
for l=1:TN
pL(l)=l^-expo;
end
beta=pL./sum(pL);
veta_s=pL./sum(pL);
a = 500;
b = 2000;
Lks = ((b-a).*rand(10) + a);
aa = 0.1;
bb = 1;
Fkf= ((bb-aa).*rand(10,1) + aa)*(10^9);
k_=[1,1,1,1,1,1,1,1,1,1];
for k=1:1:TN
for s=1:1:TN
DRK_hat(k)=Lks(k,s)/Rk(k);
tks_hat(k,s)=(CK(k)*Lks(k,s))/Fkf(k);
eq_36(k,s)=(-beta(k)*((DRK_hat(k)*veta_s(s)+(tks_hat(k,s)*veta_s(s))))-k_(k));
end
end
objfun_36=sum(eq_36,1);
ProCach=optimproblem; % create an optimization problem
ProCach.Objective=objfun_36*zm; %minimization equation 36
ProCach.Constraints.Constr1=ls*zm<=CMRN;
%% optimal solver
opts=optimoptions('linprog');
[sol,fval,exitflag,output]=solve(ProCach,'Options',opts);
zm_optimized=sol.zm
10 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Get Started with Optimization Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!