def __init__(self, env, cache, amount, z, rate): self.env = env self.cache = cache self.rate = rate self.content = [i for i in range(1, amount + 1)] self.popularity = [ Zipf(amount, z).popularity()[i] for i in range(1, amount) ]
} font2 = { 'family': 'Arial', 'size': 15, } amount = 5000 z = 0.8 cachesize = 100 total_rate = 20 expected_value = 20 N=20 simulation_time = 50000 # random.seed(42) zipf = Zipf(amount, z) # pattern = "reactive" # pattern = "proactive_remove" # pattern = "proactive_renew" pattern = "proactive_optional_renew" # distribution = "constant" # distribution = "uniform" distribution = "exponential" popularity_dict = zipf.popularity() content = [i for i in range(1, amount + 1)] popularity = [popularity_dict[i] for i in range(1, amount)] index = []
miss_merge = {} for i in range(1, amount + 1): temp = 0.0 for j in range(len(misses)): temp = temp + misses[j][i] miss_merge[i] = temp return miss_merge if __name__ == "__main__": content_amount = 1000 cache_size = 100 request_rate = 10.0 staleness_time = 120 z = 0.8 # zipf parameter zipf = Zipf(content_amount, z) p_dict = zipf.popularity() # popularity of the contents nodes = 11 simulation_data = [[] for i in range(nodes)] model_data = [[] for i in range(nodes)] f = open("./src/abilene/hitratio-staleness-simulation.txt", "r") lines = f.readlines() i = 0 for line in lines: items = line.split('\t') for item in items: simulation_data[i].append(float(item)) i = i + 1
def F1(self, t): return (1 - exp(-self._rate * t)) / self._Ts def F2(self, t): return (1 - exp(-self._rate * t)) / self._Tc if __name__ == "__main__": amount = 100 z = 0.8 cachesize = 10 total_rate = 5 expeted_value = 2 zipf = Zipf(amount, z) popularity = zipf.popularity() # che = Che(amount, cachesize, popularity, total_rate) # print(total_rate*popularity[1], total_rate*popularity[2]) # Tc = che.T # print("Tc: ", Tc) reactive = ReactiveUniform(amount, cachesize, total_rate, expeted_value, popularity) hit_ratio = reactive.hitRatio() total_hit_ratio = reactive.totalHitRatio() print("Tc: ", reactive.Che().T) print("total hit ratio: ", total_hit_ratio)
import matplotlib.pyplot as plt import math import random from mcav.zipf import Zipf from che import Che if __name__ == "__main__": amount = 50 z = 0.8 cachesize = 60 total_rate = 20 Ts = 4 simulation_time = 10000 # random.seed(42) zipf = Zipf(amount, z) popularity_dict = zipf.popularity() content = [i for i in range(1, amount + 1)] popularity = [popularity_dict[i] for i in range(1, amount)] che = Che(amount, cachesize, zipf.popularity(), total_rate) result = [] index = [] for i in range(1, 50+1): result.append(che.hitRatio()[i]) index.append(i) plt.plot(index,result) plt.show()