Incorrect output of linear optimization problem

2 views (last 30 days)
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 Comments
bassant tolba
bassant tolba on 18 Nov 2022
Dear Torsten,
Thanks for your reply. s referese to the services.. 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..
Thus I think that zm_optimized should be differe from service to service..
Torsten
Torsten on 18 Nov 2022
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.

Sign in to comment.

Accepted Answer

Matt J
Matt J on 18 Nov 2022
Edited: Matt J on 18 Nov 2022
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);
Solving problem using linprog. Optimal solution found.
zm_optimized=sol.zm
zm_optimized = 10×1
0 0 0 0 0 0 0 0 1 1
  10 Comments
Matt J
Matt J on 19 Nov 2022
Edited: Matt J on 19 Nov 2022
No, sum(eq_36,1) means to sum over k because k is the first index of eq_36(k,s).
sum(eq_36,2) would be a summation over s. You can easily check these things with small examples.
bassant tolba
bassant tolba on 20 Nov 2022
Dear Matt J Thank you very much for your help. I appreciate that.

Sign in to comment.

More Answers (0)

Categories

Find more on Get Started with Optimization Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!