b2cc80bb09
Signed-off-by: Tuan-Dat Tran <tuan-dat.tran@tudattr.dev>
28 lines
648 B
Matlab
28 lines
648 B
Matlab
clc
|
|
close all
|
|
clear all
|
|
|
|
|
|
%% Define parameters
|
|
lambda = [0.03, 0.04,0.05,0.06,0.07,1,1.1,1.2,1.3,1.4,1.5]'; % Request rates ascendingly
|
|
N=length(lambda);
|
|
B = 4.4; % Cache size
|
|
c_delta=1; % age linear cost
|
|
c_f=7; % fetching linear cost (caching miss cost)
|
|
|
|
|
|
%% Optimization
|
|
[h_numerical ]=Numerical_opt(lambda,B,c_f,c_delta)
|
|
[h_theo] = Theoritical_opt(lambda,B,c_f,c_delta)
|
|
|
|
|
|
%% Comparison
|
|
hit_opt=[h_numerical h_theo]
|
|
obj_1=sum(lambda .* ((1-h_numerical)*c_f+h_numerical.^2*c_delta/2));
|
|
obj_2=sum(lambda .* ((1-h_theo)*c_f+h_theo.^2*c_delta/2));
|
|
obj=[obj_1 obj_2]
|
|
const_1=sum(h_numerical)-B;
|
|
const_2=sum(h_theo)-B;
|
|
constraint=[const_1 const_2]
|
|
|