Incorrect output of linear optimization problem

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 comentarios

Torsten
Torsten el 18 de Nov. de 2022
Editada: Torsten el 18 de Nov. de 2022
What makes you think you can decouple the problem and solve it for each value of s separately ?
Because of constraint (11f), this does not seem possible.
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 el 18 de Nov. de 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.

Iniciar sesión para comentar.

 Respuesta aceptada

Matt J
Matt J el 18 de Nov. de 2022
Editada: Matt J el 18 de Nov. de 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 comentarios

ooh what the difference did you do to get different values ??
Please why did you make the summation over columns only ? why did not you make another summation over the rows ??
Matt J
Matt J el 18 de Nov. de 2022
Editada: Matt J el 18 de Nov. de 2022
Please why did you make the summation over columns only ? why did not you make another summation over the rows ??
Because in your problem defintiion (36a), the unknown variables z_M,s depend on s but not k.
Torsten
Torsten el 18 de Nov. de 2022
Editada: Torsten el 18 de Nov. de 2022
Because z_M,s is multiplied by the s-th element of sum(eq36,1) in your objective function.
Interchange the summation over k and s in your above mathematical formula of your objective and see what happens.
bassant tolba
bassant tolba el 18 de Nov. de 2022
Editada: bassant tolba el 18 de Nov. de 2022
Thanks alot for both replies.. but I see that I should make two summation to implement the objective function .. because there is one summation over s and another one over k.. if I write the above code, that's mean I will do only one summation over s not as the eq 36 right ?
Torsten
Torsten el 18 de Nov. de 2022
Then your image above is wrong and must read z_M,k,s instead of z_M,s and (11e) must read z_M,k,s in [0 1] for all s in S, k in K and (11f) must be valid for all k in K.
Matt J
Matt J el 18 de Nov. de 2022
Editada: Matt J el 18 de Nov. de 2022
but I see that I should make two summation to implement the objective function
We are doing so, but in two separate lines. In the line,
objfun_36=sum(eq_36,1);
we are summing over k, while in this line,
ProCach.Objective=objfun_36*zm
we are summing over s.
The first summation is independent of zm, so it is more computationally efficient to pre-compute it.
bassant tolba
bassant tolba el 19 de Nov. de 2022
Editada: Matt J el 19 de Nov. de 2022
Dear Matt, Really thank you very much for your clarification. The last thing, if this line
objfun_36=sum(eq_36,1);
means to sum over k, so in my code, k represents the rows.. so, should I modify it to be
objfun_36=sum(eq_36,2);
to be summation over rows??
Matt J
Matt J el 19 de Nov. de 2022
Editada: Matt J el 19 de Nov. de 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.
Dear Matt J Thank you very much for your help. I appreciate that.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Preguntada:

el 18 de Nov. de 2022

Comentada:

el 20 de Nov. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by