Compare commits
36 Commits
2040ea639f
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8cdfbd727e | ||
|
|
d3650acfe3 | ||
|
|
a49579b6b0 | ||
|
|
c74d231d69 | ||
|
|
22c3e828b4 | ||
|
|
910a5c9233 | ||
|
|
d5d163f098 | ||
|
|
5be438e9a1 | ||
|
|
b166a9e64a | ||
|
|
ed08b8fef3 | ||
|
|
6da629f90e | ||
|
|
b7aaa31860 | ||
|
|
78345c9788 | ||
|
|
032251dd78 | ||
|
|
78e700a2cf | ||
|
|
7d194176f0 | ||
|
|
036789cc7c | ||
|
|
3787d004c1 | ||
|
|
0ea1fb5d07 | ||
|
|
272f722f23 | ||
|
|
799f7b78d4 | ||
|
|
4ea5505130 | ||
|
|
b2cc80bb09 | ||
|
|
f32588340d | ||
|
|
6672608721 | ||
|
|
ad4654dd0f | ||
|
|
3a9e3105f2 | ||
|
|
f9d48e6fe4 | ||
|
|
a484d49128 | ||
|
|
123129f3a9 | ||
|
|
43b84bf0bb | ||
|
|
09b943e41d | ||
|
|
dea6004160 | ||
|
|
b540aafc61 | ||
|
|
673302a6b2 | ||
|
|
62fc02b205 |
1
00_aoi_caching_simulation/.gitignore
vendored
Normal file
1
00_aoi_caching_simulation/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
.aoi_cache/
|
||||||
67500
00_aoi_caching_simulation/00-aoi_cache_simulation.ipynb
Normal file
67500
00_aoi_caching_simulation/00-aoi_cache_simulation.ipynb
Normal file
File diff suppressed because one or more lines are too long
441
00_aoi_caching_simulation/01-aoi_cache_experiment_eval.ipynb
Normal file
441
00_aoi_caching_simulation/01-aoi_cache_experiment_eval.ipynb
Normal file
File diff suppressed because one or more lines are too long
887
00_aoi_caching_simulation/02-multi_aoi_cache_simulation.ipynb
Normal file
887
00_aoi_caching_simulation/02-multi_aoi_cache_simulation.ipynb
Normal file
File diff suppressed because one or more lines are too long
1118
00_aoi_caching_simulation/04-aoi_simulation_from_file.ipynb
Normal file
1118
00_aoi_caching_simulation/04-aoi_simulation_from_file.ipynb
Normal file
File diff suppressed because one or more lines are too long
158871
00_aoi_caching_simulation/05-multi_aoi_simulation_from_file.ipynb
Normal file
158871
00_aoi_caching_simulation/05-multi_aoi_simulation_from_file.ipynb
Normal file
File diff suppressed because one or more lines are too long
903
00_aoi_caching_simulation/06-multi_aoi_simulation.ipynb
Normal file
903
00_aoi_caching_simulation/06-multi_aoi_simulation.ipynb
Normal file
@@ -0,0 +1,903 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 1,
|
||||||
|
"id": "71f85f2a-423f-44d2-b80d-da9ac8d3961a",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"import simpy\n",
|
||||||
|
"import random\n",
|
||||||
|
"import numpy as np\n",
|
||||||
|
"import matplotlib.pyplot as plt\n",
|
||||||
|
"import pandas as pd\n",
|
||||||
|
"from enum import Enum\n",
|
||||||
|
"import os\n",
|
||||||
|
"import shutil\n",
|
||||||
|
"from tqdm import tqdm\n",
|
||||||
|
"import math\n",
|
||||||
|
"from dataclasses import dataclass, field\n",
|
||||||
|
"from typing import List, Union, Dict\n",
|
||||||
|
"import math\n",
|
||||||
|
"\n",
|
||||||
|
"# Constants\n",
|
||||||
|
"SEED = 42\n",
|
||||||
|
"ACCESS_COUNT_LIMIT = 1000 # Total time to run the simulation\n",
|
||||||
|
"EXPERIMENT_BASE_DIR = \"./experiments/\"\n",
|
||||||
|
"TEMP_BASE_DIR = \"./.aoi_cache/\"\n",
|
||||||
|
"\n",
|
||||||
|
"ZIPF_CONSTANT = 2 # Shape parameter for the Zipf distribution (controls skewness) Needs to be: 1< \n",
|
||||||
|
"\n",
|
||||||
|
"# Set random seeds\n",
|
||||||
|
"random.seed(SEED)\n",
|
||||||
|
"np.random.seed(SEED)\n",
|
||||||
|
"\n",
|
||||||
|
"os.makedirs(TEMP_BASE_DIR, exist_ok=True)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 2,
|
||||||
|
"id": "d88effd8-d92b-47d1-9e15-527166073e81",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# Types of cache\n",
|
||||||
|
"class EvictionStrategy(Enum):\n",
|
||||||
|
" LRU = 1\n",
|
||||||
|
" RANDOM_EVICTION = 2\n",
|
||||||
|
" TTL = 3"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 3,
|
||||||
|
"id": "1d6a3c67-f9a5-4d9c-8ade-e1ca6944867c",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"@dataclass\n",
|
||||||
|
"class DatabaseObject:\n",
|
||||||
|
" id: int\n",
|
||||||
|
" data: str\n",
|
||||||
|
" lambda_value: int\n",
|
||||||
|
" mu_value: Union[float, None]\n",
|
||||||
|
" ttl: Union[float, None]"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 4,
|
||||||
|
"id": "f40af914-a6c3-4e44-b7de-b3b40a743fb2",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"@dataclass\n",
|
||||||
|
"class CacheObject:\n",
|
||||||
|
" id: int # id of object\n",
|
||||||
|
" data: DatabaseObject # body of object\n",
|
||||||
|
" initial_fetch_timer: float # time at which the object was initially pulled into the cache (object_start_time)\n",
|
||||||
|
" age_timer: float # time at which the object was last pulled into the cache (initial fetch)\n",
|
||||||
|
" last_access: float # time at which the object was last accesse\n",
|
||||||
|
" next_refresh: Union[float, None] # scheduled time for the object to be requested (for refresh cache)\n",
|
||||||
|
" next_expiry: Union[float, None] # scheduled time for the object to be evicted (for ttl cache) (ttl)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 5,
|
||||||
|
"id": "00a944e4-842b-49ba-bb36-587d9c12fdf4",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# Base class for all cache types\n",
|
||||||
|
"@dataclass\n",
|
||||||
|
"class SimulationConfig:\n",
|
||||||
|
" db_objects: Union[int, List[DatabaseObject]]\n",
|
||||||
|
" cache_size: int\n",
|
||||||
|
" eviction_strategy: EvictionStrategy\n",
|
||||||
|
"\n",
|
||||||
|
" def __post_init__(self):\n",
|
||||||
|
" if not hasattr(self, 'eviction_strategy') or self.eviction_strategy is None:\n",
|
||||||
|
" raise ValueError(\"Eviction strategy must be defined in subclasses.\")\n",
|
||||||
|
"\n",
|
||||||
|
" def __repr__(self):\n",
|
||||||
|
" db_object_count = self.db_objects if isinstance(self.db_objects, int) else len(self.db_objects)\n",
|
||||||
|
" return f\"[{self.__class__.__name__}] Database Object Count: {db_object_count}, Cache Size: {self.cache_size}, Eviction Strategy: {self.eviction_strategy}\"\n",
|
||||||
|
" \n",
|
||||||
|
" def generate_objects(self):\n",
|
||||||
|
" if isinstance(self.db_objects, int):\n",
|
||||||
|
" self.db_objects = [\n",
|
||||||
|
" DatabaseObject(id=i, data=f\"Generated Object {i}\", lambda_value=np.random.zipf(ZIPF_CONSTANT), mu_value=None, ttl=None) \n",
|
||||||
|
" for i in range(self.db_objects)\n",
|
||||||
|
" ]\n",
|
||||||
|
"\n",
|
||||||
|
" def from_file(self, path: str, lambda_column_name: str):\n",
|
||||||
|
" df = pd.read_csv(path)\n",
|
||||||
|
" lambdas = df[lambda_column_name]\n",
|
||||||
|
"\n",
|
||||||
|
" self.db_objects = [\n",
|
||||||
|
" DatabaseObject(id=i, data=f\"Generated Object {i}\", lambda_value=lambdas[i], mu_value=None, ttl=None) \n",
|
||||||
|
" for i in range(self.db_objects)\n",
|
||||||
|
" ]\n",
|
||||||
|
" \n",
|
||||||
|
"# Specific cache type variants\n",
|
||||||
|
"@dataclass\n",
|
||||||
|
"class TTLSimulation(SimulationConfig):\n",
|
||||||
|
" eviction_strategy: EvictionStrategy = field(default=EvictionStrategy.TTL, init=False)\n",
|
||||||
|
"\n",
|
||||||
|
" def __repr__(self):\n",
|
||||||
|
" return super().__repr__().replace(super().__class__.__name__, self.__class__.__name__)\n",
|
||||||
|
" \n",
|
||||||
|
" def generate_objects(self, fixed_ttl):\n",
|
||||||
|
" if isinstance(self.db_objects, int):\n",
|
||||||
|
" self.db_objects = [\n",
|
||||||
|
" DatabaseObject(id=i, data=f\"Generated Object {i}\", lambda_value=np.random.zipf(ZIPF_CONSTANT), mu_value=None, ttl=fixed_ttl) \n",
|
||||||
|
" for i in range(self.db_objects)\n",
|
||||||
|
" ]\n",
|
||||||
|
"\n",
|
||||||
|
" \n",
|
||||||
|
" def from_file(self, path: str, lambda_column_name: str, ttl_column_name: str):\n",
|
||||||
|
" df = pd.read_csv(path)\n",
|
||||||
|
" lambdas = df[lambda_column_name]\n",
|
||||||
|
" ttls = df[ttl_column_name]\n",
|
||||||
|
"\n",
|
||||||
|
" self.db_objects = [\n",
|
||||||
|
" DatabaseObject(id=i, data=f\"Generated Object {i}\", lambda_value=lambdas[i], mu_value=None, ttl=ttls[i]) \n",
|
||||||
|
" for i in range(self.db_objects)\n",
|
||||||
|
" ]\n",
|
||||||
|
" \n",
|
||||||
|
"@dataclass\n",
|
||||||
|
"class LRUSimulation(SimulationConfig):\n",
|
||||||
|
" eviction_strategy: EvictionStrategy = field(default=EvictionStrategy.LRU, init=False)\n",
|
||||||
|
" \n",
|
||||||
|
" def __repr__(self):\n",
|
||||||
|
" return super().__repr__().replace(super().__class__.__name__, self.__class__.__name__)\n",
|
||||||
|
" \n",
|
||||||
|
"\n",
|
||||||
|
"@dataclass\n",
|
||||||
|
"class RandomEvictionSimulation(SimulationConfig):\n",
|
||||||
|
" eviction_strategy: EvictionStrategy = field(default=EvictionStrategy.RANDOM_EVICTION, init=False)\n",
|
||||||
|
"\n",
|
||||||
|
" \n",
|
||||||
|
" def __repr__(self):\n",
|
||||||
|
" return super().__repr__().replace(super().__class__.__name__, self.__class__.__name__)\n",
|
||||||
|
"\n",
|
||||||
|
"@dataclass\n",
|
||||||
|
"class RefreshSimulation(TTLSimulation):\n",
|
||||||
|
"\n",
|
||||||
|
" \n",
|
||||||
|
" def __repr__(self):\n",
|
||||||
|
" return super().__repr__().replace(super().__class__.__name__, self.__class__.__name__)\n",
|
||||||
|
" \n",
|
||||||
|
" def generate_objects(self, fixed_ttl, max_refresh_rate):\n",
|
||||||
|
" if isinstance(self.db_objects, int):\n",
|
||||||
|
" self.db_objects = [\n",
|
||||||
|
" DatabaseObject(id=i, data=f\"Generated Object {i}\", lambda_value=np.random.zipf(ZIPF_CONSTANT), mu_value=np.random.uniform(1, max_refresh_rate), ttl=fixed_ttl) \n",
|
||||||
|
" for i in range(self.db_objects)\n",
|
||||||
|
" ]\n",
|
||||||
|
" \n",
|
||||||
|
" def from_file(self, path: str, lambda_column_name: str, ttl_column_name: str, mu_column_name: str):\n",
|
||||||
|
" df = pd.read_csv(path)\n",
|
||||||
|
" lambdas = df[lambda_column_name]\n",
|
||||||
|
" ttls = df[ttl_column_name]\n",
|
||||||
|
" mus = df[mu_column_name]\n",
|
||||||
|
"\n",
|
||||||
|
" self.db_objects = [\n",
|
||||||
|
" DatabaseObject(id=i, data=f\"Generated Object {i}\", lambda_value=lambdas[i], mu_value=mus[i], ttl=ttls[i]) \n",
|
||||||
|
" for i in range(self.db_objects)\n",
|
||||||
|
" ]"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 6,
|
||||||
|
"id": "5cea042f-e9fc-4a1e-9750-de212ca70601",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"class Database:\n",
|
||||||
|
" data: Dict[int, DatabaseObject]\n",
|
||||||
|
" \n",
|
||||||
|
" def __init__(self, data: List[DatabaseObject]):\n",
|
||||||
|
" self.data = {i: data[i] for i in range(len(data))}\n",
|
||||||
|
"\n",
|
||||||
|
" def get_object(self, obj_id):\n",
|
||||||
|
" # print(f\"[{env.now:.2f}] Database: Fetched {self.data.get(obj_id, 'Unknown')} for ID {obj_id}\")\n",
|
||||||
|
" return self.data.get(obj_id, None)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 7,
|
||||||
|
"id": "499bf543-b2c6-4e4d-afcc-0a6665ce3ae1",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"class Cache:\n",
|
||||||
|
" capacity: int\n",
|
||||||
|
" eviction_strategy: EvictionStrategy\n",
|
||||||
|
" cache_size_over_time: List[int] # To record cache state at each interval\n",
|
||||||
|
" storage: Dict[int, CacheObject]\n",
|
||||||
|
" hits: Dict[int, int] # hit counter for each object\n",
|
||||||
|
" misses: Dict[int, int] # miss counter for each object\n",
|
||||||
|
" access_count: Dict[int, int] # access counter for each object (should be hit+miss)\n",
|
||||||
|
" next_request: Dict[int, float] # scheduled time for each object to be requested\n",
|
||||||
|
" cumulative_age: Dict[int, List[float]] # list of ages of each object at the time it was requested (current time - age_timer)\n",
|
||||||
|
" cumulative_cache_time: Dict[int, List[float]] # list of total time of each object spent in cache when it was evicted (current time - initial fetch time)\n",
|
||||||
|
" request_log: Dict[int, List[float]] # list of timestamps when each object was requested\n",
|
||||||
|
" \n",
|
||||||
|
" def __init__(self, env, db, simulation_config):\n",
|
||||||
|
" self.env = env\n",
|
||||||
|
" self.db = db\n",
|
||||||
|
" self.capacity = simulation_config.cache_size\n",
|
||||||
|
" self.eviction_strategy = simulation_config.eviction_strategy\n",
|
||||||
|
" self.cache_size_over_time = []\n",
|
||||||
|
" self.storage = {}\n",
|
||||||
|
"\n",
|
||||||
|
" db_object_count = len(self.db.data)\n",
|
||||||
|
" \n",
|
||||||
|
" self.hits = {i: 0 for i in range(db_object_count)}\n",
|
||||||
|
" self.misses = {i: 0 for i in range(db_object_count)}\n",
|
||||||
|
" self.access_count = {i: 0 for i in range(db_object_count)}\n",
|
||||||
|
" self.next_request = {i: np.random.exponential(1/self.db.data[i].lambda_value) for i in range(len(self.db.data))}\n",
|
||||||
|
" self.cumulative_age = {i: [] for i in range(db_object_count)}\n",
|
||||||
|
" self.cumulative_cache_time = {i: [] for i in range(db_object_count)}\n",
|
||||||
|
" self.request_log = {i: [] for i in range(db_object_count)}\n",
|
||||||
|
"\n",
|
||||||
|
" \n",
|
||||||
|
" def get(self, obj_id):\n",
|
||||||
|
" assert len(self.storage) <= self.capacity, f\"Too many objects in cache ({len(self.storage)}).\"\n",
|
||||||
|
" # print(f\"[{self.env.now:.2f}] Requesting Object {obj_id}... (Cache Size: {len(self.storage)})\")\n",
|
||||||
|
"\n",
|
||||||
|
" # Schedule next request\n",
|
||||||
|
" next_request = self.env.now + np.random.exponential(1/self.db.data[obj_id].lambda_value)\n",
|
||||||
|
" self.request_log[obj_id].append(next_request)\n",
|
||||||
|
" self.next_request[obj_id] = next_request\n",
|
||||||
|
" self.access_count[obj_id] += 1\n",
|
||||||
|
" # print(f\"[{self.env.now:.2f}] Client: Schedule next request for {obj_id}@{next_request:.2f}\")\n",
|
||||||
|
" \n",
|
||||||
|
" if obj_id in self.storage:\n",
|
||||||
|
" # Cache hit: Refresh TTL if TTL-Cache\n",
|
||||||
|
" if self.storage[obj_id].next_expiry:\n",
|
||||||
|
" assert self.env.now <= self.storage[obj_id].next_expiry, f\"[{self.env.now:.2f}] Cache should never hit on an expired cache entry.\"\n",
|
||||||
|
" self.storage[obj_id].next_expiry = self.env.now + self.db.data[obj_id].ttl\n",
|
||||||
|
" \n",
|
||||||
|
" # Cache hit: increment hit count and update cumulative age\n",
|
||||||
|
" self.hits[obj_id] += 1\n",
|
||||||
|
" age = self.env.now - self.storage[obj_id].age_timer\n",
|
||||||
|
" self.cumulative_age[obj_id].append(age)\n",
|
||||||
|
" self.storage[obj_id].last_access = self.env.now\n",
|
||||||
|
"\n",
|
||||||
|
" assert len(self.cumulative_age[obj_id]) == self.access_count[obj_id], f\"[{self.env.now:.2f}] Age values collected and object access count do not match.\"\n",
|
||||||
|
" # print(f\"[{env.now:.2f}] {obj_id} Hit: Current Age {age:.2f} (Average: {sum(self.cumulative_age[obj_id])/len(self.cumulative_age[obj_id]):.2f}) \")\n",
|
||||||
|
" return self.storage[obj_id]\n",
|
||||||
|
" else:\n",
|
||||||
|
" # Cache miss: increment miss count\n",
|
||||||
|
" self.misses[obj_id] += 1\n",
|
||||||
|
" self.cumulative_age[obj_id].append(0)\n",
|
||||||
|
" \n",
|
||||||
|
" # Cache miss: Add TTL if TTL-Cache\n",
|
||||||
|
" # When full cache: If Non-TTL-Cache: Evict. If TTL-Cache: Don't add to Cache.\n",
|
||||||
|
" if len(self.storage) == self.capacity:\n",
|
||||||
|
" if self.eviction_strategy == EvictionStrategy.LRU:\n",
|
||||||
|
" self.evict_oldest()\n",
|
||||||
|
" elif self.eviction_strategy == EvictionStrategy.RANDOM_EVICTION:\n",
|
||||||
|
" self.evict_random()\n",
|
||||||
|
" elif self.eviction_strategy == EvictionStrategy.TTL:\n",
|
||||||
|
" # print(f\"[{self.env.now:.2f}] Cache: Capacity reached. Not accepting new request.\")\n",
|
||||||
|
" return\n",
|
||||||
|
"\n",
|
||||||
|
" # Cache miss: Construct CacheObject from Database Object\n",
|
||||||
|
" db_object = self.db.get_object(obj_id)\n",
|
||||||
|
" initial_fetch_timer=self.env.now\n",
|
||||||
|
" age_timer=self.env.now\n",
|
||||||
|
" last_access=self.env.now\n",
|
||||||
|
" next_refresh = (self.env.now + np.random.exponential(1/db_object.mu_value)) if db_object.mu_value is not None else None\n",
|
||||||
|
" next_expiry = (self.env.now + db_object.ttl) if db_object.ttl is not None else None\n",
|
||||||
|
" cache_object = CacheObject(id=obj_id, data=db_object, \n",
|
||||||
|
" initial_fetch_timer=initial_fetch_timer, age_timer=age_timer, \n",
|
||||||
|
" last_access=last_access,next_refresh=next_refresh, next_expiry=next_expiry\n",
|
||||||
|
" )\n",
|
||||||
|
" self.storage[obj_id] = cache_object\n",
|
||||||
|
" \n",
|
||||||
|
" assert len(self.cumulative_age[obj_id]) == self.access_count[obj_id], f\"[{self.env.now:.2f}] Age values collected and object access count do not match.\"\n",
|
||||||
|
" # print(f\"[{env.now:.2f}] {obj_id} Miss: Average Age {sum(self.cumulative_age[obj_id])/len(self.cumulative_age[obj_id]):.2f} \")\n",
|
||||||
|
" return self.storage[obj_id]\n",
|
||||||
|
"\n",
|
||||||
|
" def refresh_object(self, obj_id):\n",
|
||||||
|
" \"\"\"Refresh the object from the database to keep it up-to-date. TTL is increased on refresh.\"\"\"\n",
|
||||||
|
" assert obj_id in self.storage, f\"[{self.env.now:.2f}] Refreshed object has to be in cache\"\n",
|
||||||
|
" db_object = self.db.get_object(obj_id)\n",
|
||||||
|
" age_timer = self.env.now\n",
|
||||||
|
" next_refresh = self.env.now + np.random.exponential(1/db_object.mu_value)\n",
|
||||||
|
" # next_expiry = self.env.now + db_object.ttl if db_object.ttl is not None else None\n",
|
||||||
|
"\n",
|
||||||
|
" self.storage[obj_id].data = db_object\n",
|
||||||
|
" self.storage[obj_id].age_timer = age_timer\n",
|
||||||
|
" self.storage[obj_id].next_refresh = next_refresh\n",
|
||||||
|
"\n",
|
||||||
|
" # print(f\"[{self.env.now:.2f}] Cache: Refreshed object {obj_id}\")\n",
|
||||||
|
" \n",
|
||||||
|
" def evict_oldest(self):\n",
|
||||||
|
" \"\"\"Remove the oldest item from the cache to make space.\"\"\"\n",
|
||||||
|
" assert self.capacity == len(self.storage), f\"[{self.env.now:.2f}] Expecting cache to be at capacity\"\n",
|
||||||
|
" oldest_id = min(self.storage.items(), key=lambda item: item[1].last_access)[0]\n",
|
||||||
|
" \n",
|
||||||
|
" # print(f\"[{self.env.now:.2f}] Cache: Evicting oldest object {oldest_id}.\")\n",
|
||||||
|
" self.cumulative_cache_time[oldest_id].append(self.env.now - self.storage[oldest_id].initial_fetch_timer)\n",
|
||||||
|
" del self.storage[oldest_id]\n",
|
||||||
|
" \n",
|
||||||
|
" def evict_random(self):\n",
|
||||||
|
" \"\"\"Remove a random item from the cache to make space.\"\"\"\n",
|
||||||
|
" assert self.capacity == len(self.storage), f\"[{self.env.now:.2f}] Expecting cache to be at capacity\"\n",
|
||||||
|
" random_id = np.random.choice(list(self.storage.keys())) # Select a random key from the cache\n",
|
||||||
|
" \n",
|
||||||
|
" # print(f\"[{self.env.now:.2f}] Cache: Evicting random object {random_id}.\")\n",
|
||||||
|
" self.cumulative_cache_time[random_id].append(self.env.now - self.storage[random_id].initial_fetch_timer)\n",
|
||||||
|
" del self.storage[random_id]\n",
|
||||||
|
" \n",
|
||||||
|
" def check_expired(self, obj_id):\n",
|
||||||
|
" \"\"\"Remove object if its TTL expired.\"\"\"\n",
|
||||||
|
" assert self.storage, f\"[{self.env.now:.2f}] Expecting cache to be not empty\"\n",
|
||||||
|
" assert self.env.now >= self.storage[obj_id].next_expiry\n",
|
||||||
|
" \n",
|
||||||
|
" # print(f\"[{self.env.now:.2f}] Cache: Object {obj_id} expired\")\n",
|
||||||
|
" self.cumulative_cache_time[obj_id].append(self.env.now - self.storage[obj_id].initial_fetch_timer)\n",
|
||||||
|
" del self.storage[obj_id]\n",
|
||||||
|
"\n",
|
||||||
|
" \n",
|
||||||
|
" def record_cache_state(self):\n",
|
||||||
|
" \"\"\"Record the current cache state (number of objects in cache) over time.\"\"\"\n",
|
||||||
|
" self.cache_size_over_time.append((self.env.now, len(self.storage)))"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 8,
|
||||||
|
"id": "687f5634-8edf-4337-b42f-bbb292d47f0f",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"def client_request_process(env, cache, event):\n",
|
||||||
|
" \"\"\"Client process that makes requests for objects from the cache.\"\"\"\n",
|
||||||
|
" last_print = 0\n",
|
||||||
|
" with tqdm(total=ACCESS_COUNT_LIMIT, desc=\"Progress\", leave=True) as pbar:\n",
|
||||||
|
" while True:\n",
|
||||||
|
" request_id, next_request = min(cache.next_request.items(), key=lambda x: x[1])\n",
|
||||||
|
" expiry_id = -1\n",
|
||||||
|
" next_expiry = float('inf')\n",
|
||||||
|
" refresh_id = -1\n",
|
||||||
|
" next_refresh = float('inf')\n",
|
||||||
|
"\n",
|
||||||
|
" if cache.storage:\n",
|
||||||
|
" expiry_id, next_expiry = min(cache.storage.items(), key=lambda x: x[1].next_expiry if x[1].next_expiry is not None else float('inf'))\n",
|
||||||
|
" next_expiry = cache.storage[expiry_id].next_expiry\n",
|
||||||
|
" refresh_id, next_refresh = min(cache.storage.items(), key=lambda x: x[1].next_refresh if x[1].next_refresh is not None else float('inf'))\n",
|
||||||
|
" next_refresh = cache.storage[refresh_id].next_refresh\n",
|
||||||
|
"\n",
|
||||||
|
" events = [\n",
|
||||||
|
" (request_id, next_request),\n",
|
||||||
|
" (expiry_id, next_expiry),\n",
|
||||||
|
" (refresh_id, next_refresh)\n",
|
||||||
|
" ]\n",
|
||||||
|
"\n",
|
||||||
|
" event_id, event_timestamp = min(events, key=lambda x: x[1] if x[1] is not None else float('inf'))\n",
|
||||||
|
" \n",
|
||||||
|
" # if event_id == request_id and event_timestamp == next_request:\n",
|
||||||
|
" # print(f\"[{env.now:.2f}] Waiting for request...\")\n",
|
||||||
|
" # elif event_id == expiry_id and event_timestamp == next_expiry:\n",
|
||||||
|
" # print(f\"[{env.now:.2f}] Waiting for expiry until...\")\n",
|
||||||
|
" # elif event_id == refresh_id and event_timestamp == next_refresh:\n",
|
||||||
|
" # print(f\"[{env.now:.2f}] Waiting for refresh...\")\n",
|
||||||
|
"\n",
|
||||||
|
" wait_time = event_timestamp - env.now\n",
|
||||||
|
" wait_time += math.ulp(wait_time) # Round up\n",
|
||||||
|
"\n",
|
||||||
|
" yield(env.timeout(wait_time))\n",
|
||||||
|
" if event_id == request_id and event_timestamp == next_request:\n",
|
||||||
|
" assert env.now >= next_request, f\"[{env.now}] Time for request should've been reached for Object {request_id}\"\n",
|
||||||
|
" cache.get(request_id)\n",
|
||||||
|
" elif event_id == expiry_id and event_timestamp == next_expiry:\n",
|
||||||
|
" assert env.now >= next_expiry, f\"[{env.now}] Time for expiry should've been reached for Object {expiry_id}\"\n",
|
||||||
|
" cache.check_expired(expiry_id)\n",
|
||||||
|
" elif event_id == refresh_id and event_timestamp == next_refresh:\n",
|
||||||
|
" assert env.now >= next_refresh, f\"[{env.now}] Time for refresh should've been reached for Object {refresh_id}\"\n",
|
||||||
|
" cache.refresh_object(refresh_id)\n",
|
||||||
|
" else:\n",
|
||||||
|
" assert False, \"Unreachable\"\n",
|
||||||
|
"\n",
|
||||||
|
" # For progress bar\n",
|
||||||
|
" if (int(env.now) % 1) == 0 and int(env.now) != last_print:\n",
|
||||||
|
" last_print = int(env.now)\n",
|
||||||
|
" pbar.n = min(cache.access_count.values())\n",
|
||||||
|
" pbar.refresh()\n",
|
||||||
|
" \n",
|
||||||
|
" # Simulation stop condition\n",
|
||||||
|
" if all(access_count >= ACCESS_COUNT_LIMIT for access_count in cache.access_count.values()):\n",
|
||||||
|
" print(f\"Simulation ended after {env.now} seconds.\")\n",
|
||||||
|
" for obj_id in cache.storage.keys():\n",
|
||||||
|
" cache.cumulative_cache_time[obj_id].append(env.now - cache.storage[obj_id].initial_fetch_timer)\n",
|
||||||
|
" event.succeed()\n",
|
||||||
|
" \n",
|
||||||
|
" cache.record_cache_state()"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 9,
|
||||||
|
"id": "c8516830-9880-4d9e-a91b-000338baf9d6",
|
||||||
|
"metadata": {
|
||||||
|
"scrolled": true
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"class Simulation:\n",
|
||||||
|
" def __init__(self, simulation_config: Union[TTLSimulation, LRUSimulation, RandomEvictionSimulation, RefreshSimulation]):\n",
|
||||||
|
" # Initialize simulation environment\n",
|
||||||
|
" self.env = simpy.Environment()\n",
|
||||||
|
" \n",
|
||||||
|
" # Instantiate components\n",
|
||||||
|
" self.db = Database(simulation_config.db_objects)\n",
|
||||||
|
" self.cache = Cache(self.env, self.db, simulation_config)\n",
|
||||||
|
"\n",
|
||||||
|
" def run_simulation(self):\n",
|
||||||
|
" # Start processes\n",
|
||||||
|
" # env.process(age_cache_process(env, cache))\n",
|
||||||
|
" stop_event = self.env.event()\n",
|
||||||
|
" self.env.process(client_request_process(self.env, self.cache, stop_event))\n",
|
||||||
|
" \n",
|
||||||
|
" # Run the simulation\n",
|
||||||
|
" self.env.run(until=stop_event)\n",
|
||||||
|
" self.end_time = self.env.now"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 10,
|
||||||
|
"id": "e269b607-16b9-46d0-8a97-7324f2002c72",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# Simulate with a Cache that does random evictions, We'll have 100 Database Objects and a Cache Size of 10\n",
|
||||||
|
"# We'll generate lambdas from a zipf distribution\n",
|
||||||
|
"# config = RandomEvictionSimulation(100, 10)\n",
|
||||||
|
"# config.generate_objects()"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 11,
|
||||||
|
"id": "33fdc5fd-1f39-4b51-b2c7-6ea6acf2b753",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# Simulate with a Cache that does lru, We'll have 100 Database Objects and a Cache Size of 10\n",
|
||||||
|
"# We'll generate lambdas from a zipf distribution\n",
|
||||||
|
"config = LRUSimulation(100, 10)\n",
|
||||||
|
"config.from_file('./input/2024-12-14/results.csv', 'Lambda')"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 12,
|
||||||
|
"id": "6c391bfd-b294-4ff7-8b22-51777368a6b9",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# Simulate with a Cache that does Refreshes with TTL based eviction, We'll have 100 Database Objects and a Cache Size of 10\n",
|
||||||
|
"# We'll generate lambdas from a zipf distribution. Each object will have a fixed ttl of 1 when its pulled into the cache. Mu for the refresh rate is 10\n",
|
||||||
|
"# config = RefreshSimulation(100, 10)\n",
|
||||||
|
"# config.from_file(path='./input/2024-12-13/output.csv', lambda_column_name='Lambda', ttl_column_name='TTL_2', mu_column_name='u_opt_2')"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 13,
|
||||||
|
"id": "0a444c9d-53dd-4cab-b8f1-100ad3ab213a",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# Simulate with a Cache that does TTL based eviction, We'll have 100 Database Objects and a Cache Size of 10\n",
|
||||||
|
"# We'll take lambdas from the \"lambda\" column of the file \"../calculated.csv\" and the TTLs for each object from the \"optimal_TTL\" column of the same file.\n",
|
||||||
|
"# config = TTLSimulation(100, 10)\n",
|
||||||
|
"# config.from_file(\"../calculated.csv\", \"lambda\", \"optimal_TTL\")"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 14,
|
||||||
|
"id": "6ac338bd-2094-41d2-8e92-565d03422b87",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"with open(f\"{TEMP_BASE_DIR}/simulation_config.txt\", 'w') as f:\n",
|
||||||
|
" f.write(str(config))"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 15,
|
||||||
|
"id": "66f65699-a3c9-48c4-8f1f-b9d7834c026a",
|
||||||
|
"metadata": {
|
||||||
|
"scrolled": true
|
||||||
|
},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stderr",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"Progress: 0%| | 0/1000 [00:00<?, ?it/s]"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"0.04482947830142957\n"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "stderr",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"\n"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ename": "NameError",
|
||||||
|
"evalue": "name 'error_wait_time' is not defined",
|
||||||
|
"output_type": "error",
|
||||||
|
"traceback": [
|
||||||
|
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
||||||
|
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
|
||||||
|
"Cell \u001b[0;32mIn[8], line 39\u001b[0m, in \u001b[0;36mclient_request_process\u001b[0;34m(env, cache, event)\u001b[0m\n\u001b[1;32m 38\u001b[0m \u001b[38;5;28mprint\u001b[39m(wait_time)\n\u001b[0;32m---> 39\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[43merror_wait_time\u001b[49m)\n\u001b[1;32m 40\u001b[0m \u001b[38;5;28;01myield\u001b[39;00m(env\u001b[38;5;241m.\u001b[39mtimeout(wait_time))\n",
|
||||||
|
"\u001b[0;31mNameError\u001b[0m: name 'error_wait_time' is not defined",
|
||||||
|
"\nThe above exception was the direct cause of the following exception:\n",
|
||||||
|
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
|
||||||
|
"File \u001b[0;32m<timed exec>:2\u001b[0m\n",
|
||||||
|
"Cell \u001b[0;32mIn[9], line 17\u001b[0m, in \u001b[0;36mSimulation.run_simulation\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 14\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39menv\u001b[38;5;241m.\u001b[39mprocess(client_request_process(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39menv, \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mcache, stop_event))\n\u001b[1;32m 16\u001b[0m \u001b[38;5;66;03m# Run the simulation\u001b[39;00m\n\u001b[0;32m---> 17\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43menv\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mrun\u001b[49m\u001b[43m(\u001b[49m\u001b[43muntil\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mstop_event\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 18\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mend_time \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39menv\u001b[38;5;241m.\u001b[39mnow\n",
|
||||||
|
"File \u001b[0;32m~/.genesis/workspace/python-virtualenv/graphs/lib/python3.12/site-packages/simpy/core.py:246\u001b[0m, in \u001b[0;36mEnvironment.run\u001b[0;34m(self, until)\u001b[0m\n\u001b[1;32m 244\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m 245\u001b[0m \u001b[38;5;28;01mwhile\u001b[39;00m \u001b[38;5;28;01mTrue\u001b[39;00m:\n\u001b[0;32m--> 246\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mstep\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 247\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m StopSimulation \u001b[38;5;28;01mas\u001b[39;00m exc:\n\u001b[1;32m 248\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m exc\u001b[38;5;241m.\u001b[39margs[\u001b[38;5;241m0\u001b[39m] \u001b[38;5;66;03m# == until.value\u001b[39;00m\n",
|
||||||
|
"File \u001b[0;32m~/.genesis/workspace/python-virtualenv/graphs/lib/python3.12/site-packages/simpy/core.py:204\u001b[0m, in \u001b[0;36mEnvironment.step\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 202\u001b[0m exc \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mtype\u001b[39m(event\u001b[38;5;241m.\u001b[39m_value)(\u001b[38;5;241m*\u001b[39mevent\u001b[38;5;241m.\u001b[39m_value\u001b[38;5;241m.\u001b[39margs)\n\u001b[1;32m 203\u001b[0m exc\u001b[38;5;241m.\u001b[39m__cause__ \u001b[38;5;241m=\u001b[39m event\u001b[38;5;241m.\u001b[39m_value\n\u001b[0;32m--> 204\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m exc\n",
|
||||||
|
"\u001b[0;31mNameError\u001b[0m: name 'error_wait_time' is not defined"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"%%time\n",
|
||||||
|
"\n",
|
||||||
|
"simulation = Simulation(config)\n",
|
||||||
|
"simulation.run_simulation()"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 16,
|
||||||
|
"id": "6f900c68-1f34-48d1-b346-ef6ea6911fa5",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"ename": "AttributeError",
|
||||||
|
"evalue": "'Simulation' object has no attribute 'end_time'",
|
||||||
|
"output_type": "error",
|
||||||
|
"traceback": [
|
||||||
|
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
||||||
|
"\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)",
|
||||||
|
"Cell \u001b[0;32mIn[16], line 3\u001b[0m\n\u001b[1;32m 1\u001b[0m cache \u001b[38;5;241m=\u001b[39m simulation\u001b[38;5;241m.\u001b[39mcache\n\u001b[1;32m 2\u001b[0m db \u001b[38;5;241m=\u001b[39m simulation\u001b[38;5;241m.\u001b[39mdb\n\u001b[0;32m----> 3\u001b[0m simulation_end_time \u001b[38;5;241m=\u001b[39m \u001b[43msimulation\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mend_time\u001b[49m\n\u001b[1;32m 4\u001b[0m database_object_count \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mlen\u001b[39m(db\u001b[38;5;241m.\u001b[39mdata)\n",
|
||||||
|
"\u001b[0;31mAttributeError\u001b[0m: 'Simulation' object has no attribute 'end_time'"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"cache = simulation.cache\n",
|
||||||
|
"db = simulation.db\n",
|
||||||
|
"simulation_end_time = simulation.end_time\n",
|
||||||
|
"database_object_count = len(db.data)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "3b6f7c1f-ea54-4496-bb9a-370cee2d2751",
|
||||||
|
"metadata": {
|
||||||
|
"scrolled": true
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"statistics = []\n",
|
||||||
|
"# Calculate and print hit rate and average age for each object\n",
|
||||||
|
"for obj_id in range(database_object_count):\n",
|
||||||
|
" if cache.access_count[obj_id] != 0:\n",
|
||||||
|
" output = \"\"\n",
|
||||||
|
" expected_hit_rate = None\n",
|
||||||
|
" hit_rate = cache.hits[obj_id] / max(1, cache.access_count[obj_id])\n",
|
||||||
|
" output += f\"Object {obj_id}: Hit Rate = {hit_rate:.2f}, \"\n",
|
||||||
|
" if db.data[obj_id].ttl is not None:\n",
|
||||||
|
" expected_hit_rate = 1-math.exp(-db.data[obj_id].lambda_value*(db.data[obj_id].ttl))\n",
|
||||||
|
" output += f\"Expected Hit Rate = {expected_hit_rate:.2f}, \"\n",
|
||||||
|
" avg_cache_time = sum(cache.cumulative_cache_time[obj_id]) / max(1, simulation_end_time) \n",
|
||||||
|
" output += f\"Average Time spend in Cache: {avg_cache_time:.2f}, \"\n",
|
||||||
|
" avg_age = sum(cache.cumulative_age[obj_id]) / max(len(cache.cumulative_age[obj_id]), 1)\n",
|
||||||
|
" output += f\"Average Age = {avg_age:.2f}, \"\n",
|
||||||
|
" expected_age = hit_rate / (db.data[obj_id].lambda_value * (1 - pow(hit_rate,2)))\n",
|
||||||
|
" output += f\"Expected Age = {expected_age:.2f}\"\n",
|
||||||
|
" print(output)\n",
|
||||||
|
" if db.data[obj_id].ttl is not None:\n",
|
||||||
|
" statistics.append({\n",
|
||||||
|
" \"obj_id\": obj_id,\n",
|
||||||
|
" \"hit_rate\": hit_rate, \n",
|
||||||
|
" \"expected_hit_rate\": expected_hit_rate, \n",
|
||||||
|
" \"avg_cache_time\":avg_cache_time, \n",
|
||||||
|
" \"avg_age\": avg_age, \n",
|
||||||
|
" \"expected_age\": expected_age\n",
|
||||||
|
" })\n",
|
||||||
|
" else:\n",
|
||||||
|
" statistics.append({\n",
|
||||||
|
" \"obj_id\": obj_id,\n",
|
||||||
|
" \"hit_rate\": hit_rate, \n",
|
||||||
|
" \"avg_cache_time\":avg_cache_time, \n",
|
||||||
|
" \"avg_age\": avg_age, \n",
|
||||||
|
" \"expected_age\": expected_age\n",
|
||||||
|
" })"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "b2d18372-cdba-4151-ae32-5bf45466bf94",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"stats = pd.DataFrame(statistics)\n",
|
||||||
|
"stats.to_csv(f\"{TEMP_BASE_DIR}/hit_age.csv\",index=False)\n",
|
||||||
|
"stats.drop(\"obj_id\", axis=1).describe().to_csv(f\"{TEMP_BASE_DIR}/overall_hit_age.csv\")"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "be7e67e7-4533-438a-ab65-ca813f48052a",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"expected_hit_rate = None\n",
|
||||||
|
"expected_hit_rate_delta = None"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "80971714-44f1-47db-9e89-85be7c885bde",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"access_count = pd.DataFrame.from_dict(cache.access_count, orient='index', columns=['access_count'])\n",
|
||||||
|
"hits = pd.DataFrame.from_dict(cache.hits, orient='index', columns=['hits'])\n",
|
||||||
|
"misses = pd.DataFrame.from_dict(cache.misses, orient='index', columns=['misses'])\n",
|
||||||
|
"mu = pd.DataFrame.from_dict({l: db.data[l].mu_value for l in range(database_object_count)}, orient='index', columns=['mu'])\n",
|
||||||
|
"lmbda = pd.DataFrame.from_dict({l: db.data[l].lambda_value for l in range(database_object_count)}, orient='index', columns=['lambda'])\n",
|
||||||
|
"\n",
|
||||||
|
"hit_rate = pd.DataFrame(stats['hit_rate'])\n",
|
||||||
|
"hit_rate.index = range(database_object_count)\n",
|
||||||
|
"if 'expected_hit_rate' in stats:\n",
|
||||||
|
" expected_hit_rate = pd.DataFrame(stats['expected_hit_rate'])\n",
|
||||||
|
" expected_hit_rate.index = range(database_object_count)\n",
|
||||||
|
" expected_hit_rate_delta = pd.DataFrame((hit_rate.to_numpy()-expected_hit_rate.to_numpy()), columns=['expected_hit_rate_delta'])\n",
|
||||||
|
" expected_hit_rate_delta.index = range(database_object_count)\n",
|
||||||
|
"avg_cache_time = pd.DataFrame(stats['avg_cache_time'])\n",
|
||||||
|
"avg_cache_time.index = range(database_object_count)\n",
|
||||||
|
"cache_time_delta = pd.DataFrame((hit_rate.to_numpy()-avg_cache_time.to_numpy()), columns=['cache_time_delta'])\n",
|
||||||
|
"cache_time_delta.index = range(database_object_count)\n",
|
||||||
|
"\n",
|
||||||
|
"avg_age = pd.DataFrame(stats['avg_age'])\n",
|
||||||
|
"avg_age.index = range(database_object_count)\n",
|
||||||
|
"\n",
|
||||||
|
"ages = {k: str(v) for k,v in cache.cumulative_age.items()}\n",
|
||||||
|
"ages = pd.DataFrame.from_dict(ages, orient='index', columns=['ages'])\n",
|
||||||
|
"\n",
|
||||||
|
"merged = access_count.merge(hits, left_index=True, right_index=True).merge(misses, left_index=True, right_index=True) \\\n",
|
||||||
|
" .merge(mu, left_index=True, right_index=True).merge(lmbda, left_index=True, right_index=True) \\\n",
|
||||||
|
" .merge(hit_rate, left_index=True, right_index=True)\n",
|
||||||
|
"if 'expected_hit_rate' in stats:\n",
|
||||||
|
" merged = merged.merge(expected_hit_rate, left_index=True, right_index=True).merge(expected_hit_rate_delta, left_index=True, right_index=True)\n",
|
||||||
|
"merged = merged.merge(avg_cache_time, left_index=True, right_index=True).merge(cache_time_delta, left_index=True, right_index=True) \\\n",
|
||||||
|
" .merge(avg_age, left_index=True, right_index=True).merge(ages, left_index=True, right_index=True)\n",
|
||||||
|
"merged.to_csv(f\"{TEMP_BASE_DIR}/details.csv\", index_label=\"obj_id\")\n",
|
||||||
|
"merged"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "01f8f9ee-c278-4a22-8562-ba02e77f5ddd",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# Extract recorded data for plotting\n",
|
||||||
|
"times, cache_sizes = zip(*cache.cache_size_over_time)\n",
|
||||||
|
"\n",
|
||||||
|
"# Plot the cache size over time\n",
|
||||||
|
"plt.figure(figsize=(30, 5))\n",
|
||||||
|
"plt.plot(times, cache_sizes, label=\"Objects in Cache\")\n",
|
||||||
|
"plt.xlabel(\"Time (s)\")\n",
|
||||||
|
"plt.ylabel(\"Number of Cached Objects\")\n",
|
||||||
|
"plt.title(\"Number of Objects in Cache Over Time\")\n",
|
||||||
|
"plt.legend()\n",
|
||||||
|
"plt.grid(True)\n",
|
||||||
|
"plt.savefig(f\"{TEMP_BASE_DIR}/objects_in_cache_over_time.pdf\")\n",
|
||||||
|
"\n",
|
||||||
|
"plt.show()"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "f30a0497-9b2e-4ea9-8ebf-6687de19aaa9",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"from collections import Counter\n",
|
||||||
|
"# Count occurrences of each number\n",
|
||||||
|
"count = Counter([l.lambda_value for l in db.data.values()])\n",
|
||||||
|
"\n",
|
||||||
|
"# Separate the counts into two lists for plotting\n",
|
||||||
|
"x = list(count.keys()) # List of unique numbers\n",
|
||||||
|
"y = list(count.values()) # List of their respective counts\n",
|
||||||
|
"\n",
|
||||||
|
"# Plot the data\n",
|
||||||
|
"plt.figure(figsize=(8, 6))\n",
|
||||||
|
"plt.bar(x, y, color='skyblue')\n",
|
||||||
|
"\n",
|
||||||
|
"# Adding labels and title\n",
|
||||||
|
"plt.xlabel('Number')\n",
|
||||||
|
"plt.ylabel('Occurrences')\n",
|
||||||
|
"plt.title('Occurance of each lambda in db')\n",
|
||||||
|
"plt.savefig(f\"{TEMP_BASE_DIR}/lambda_distribution.pdf\")\n",
|
||||||
|
"\n",
|
||||||
|
"# Show the plot\n",
|
||||||
|
"plt.show()"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "c192564b-d3c6-40e1-a614-f7a5ee787c4e",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# Plotting lambda against access_count.\n",
|
||||||
|
"\n",
|
||||||
|
"plt.figure(figsize=(8, 6))\n",
|
||||||
|
"plt.scatter(merged['lambda'], merged['access_count'], alpha=0.7, edgecolor='k')\n",
|
||||||
|
"plt.title('Lambda vs Access Count', fontsize=14)\n",
|
||||||
|
"plt.xlabel('Lambda', fontsize=12)\n",
|
||||||
|
"plt.ylabel('Access Count', fontsize=12)\n",
|
||||||
|
"plt.grid(alpha=0.3)\n",
|
||||||
|
"\n",
|
||||||
|
"plt.savefig(f\"{TEMP_BASE_DIR}/lambda_vs_access_count.pdf\")\n",
|
||||||
|
"plt.show()"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "00a12eea-c805-4209-9143-48fa65619873",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"from collections import Counter\n",
|
||||||
|
"# Count occurrences of each number\n",
|
||||||
|
"count = Counter(np.array([l.mu_value if l.mu_value is not None else 0.0 for l in db.data.values() ]).round(0))\n",
|
||||||
|
"\n",
|
||||||
|
"# Separate the counts into two lists for plotting\n",
|
||||||
|
"x = list(count.keys()) # List of unique numbers\n",
|
||||||
|
"y = list(count.values()) # List of their respective counts\n",
|
||||||
|
"\n",
|
||||||
|
"# Plot the data\n",
|
||||||
|
"plt.figure(figsize=(8, 6))\n",
|
||||||
|
"plt.bar(x, y, color='skyblue')\n",
|
||||||
|
"\n",
|
||||||
|
"# Adding labels and title\n",
|
||||||
|
"plt.xlabel('Number')\n",
|
||||||
|
"plt.ylabel('Occurrences')\n",
|
||||||
|
"plt.title('Occurance of each mu in db (rounded)')\n",
|
||||||
|
"\n",
|
||||||
|
"# Show the plot\n",
|
||||||
|
"plt.show()"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "adbfeb40-76bd-4224-ac45-65c7b2b2cb7b",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"def plot_requests(object_id: int):\n",
|
||||||
|
" mu = db.mu_values[object_id]\n",
|
||||||
|
" lmb = db.lambda_values[object_id]\n",
|
||||||
|
" rq_log = np.array(cache.request_log[object_id])\n",
|
||||||
|
" df = rq_log[1:] - rq_log[:-1]\n",
|
||||||
|
" pd.DataFrame(df, columns=[f\"{object_id}, mu:{mu:.2f}, lambda: {lmb:.2f}\"]).plot()"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "1f550686-3463-4e50-be83-ceafb27512b0",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"def print_rate(object_id: int):\n",
|
||||||
|
" # Calculate time intervals between consecutive events\n",
|
||||||
|
" intervals = np.diff(np.array(cache.request_log[object_id])) # Differences between each event time\n",
|
||||||
|
" \n",
|
||||||
|
" # Calculate the rate per second for each interval\n",
|
||||||
|
" rates = 1 / intervals # Inverse of the time interval gives rate per second\n",
|
||||||
|
" \n",
|
||||||
|
" # Optional: Calculate the average event rate over all intervals\n",
|
||||||
|
" average_rate = np.mean(rates)\n",
|
||||||
|
" print(\"Average event rate per second:\", average_rate)\n",
|
||||||
|
" print(\"The mu is: \", db.lambda_values[object_id])"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "135f4a26-a666-4fd5-8f71-1f62abd4bb81",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"print(config)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "b47990b1-0231-43ac-8bc5-8340abe4a8b3",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# os.makedirs(EXPERIMENT_BASE_DIR, exist_ok=True)\n",
|
||||||
|
"# folder_name = experiment_name.replace(\" \", \"_\").replace(\"(\", \"\").replace(\")\", \"\").replace(\".\", \"_\")\n",
|
||||||
|
"# folder_path = os.path.join(EXPERIMENT_BASE_DIR, folder_name)\n",
|
||||||
|
"# os.makedirs(folder_path, exist_ok=True)\n"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "db83cad4-7cc6-4702-ae3a-d1af30a561d2",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# file_names = os.listdir(TEMP_BASE_DIR)\n",
|
||||||
|
" \n",
|
||||||
|
"# for file_name in file_names:\n",
|
||||||
|
"# shutil.move(os.path.join(TEMP_BASE_DIR, file_name), folder_path)"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "graphs",
|
||||||
|
"language": "python",
|
||||||
|
"name": "graphs"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.12.7"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
||||||
101
00_aoi_caching_simulation/input/2024-12-13/input.csv
Normal file
101
00_aoi_caching_simulation/input/2024-12-13/input.csv
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
Lambda,h_opt,u_opt,TTL,h_opt_2,u_opt_2,TTL_2
|
||||||
|
0.0251,0.0000,0.5864,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0253,0.0000,0.5949,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0255,0.0000,0.6040,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0257,0.0000,0.6125,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0260,0.0000,0.6213,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0262,0.0000,0.6308,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0264,0.0000,0.6405,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0266,0.0000,0.6494,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0269,0.0000,0.6594,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0271,0.0000,0.6687,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0273,0.0000,0.6791,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0276,-0.0000,0.6897,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0278,0.0000,0.7000,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0281,0.0000,0.7107,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0283,0.0000,0.7215,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0286,0.0000,0.7336,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0289,0.0000,0.7450,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0292,0.0000,0.7569,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0294,0.0000,0.7688,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0297,0.0000,0.7817,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0300,0.0000,0.7970,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0303,0.0000,0.8123,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0306,0.0000,0.8287,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0310,0.0000,0.8456,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0313,0.0000,0.8632,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0316,0.0000,0.8815,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0320,0.0000,0.8994,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0323,0.0000,0.9192,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0327,0.0000,0.9387,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0330,0.0000,0.9597,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0334,0.0000,0.9810,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0338,0.0000,1.0034,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0342,0.0000,1.0255,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0346,0.0000,1.0493,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0350,0.0000,1.0748,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0355,0.0000,1.0993,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0359,0.0000,1.1248,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0364,0.0000,1.1476,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0368,0.0000,1.1720,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0373,0.0000,1.1825,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0378,0.0000,1.1863,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0383,0.0000,1.1908,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0388,0.0000,1.1952,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0394,0.0000,1.1980,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0399,0.0000,1.2026,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0405,0.0000,1.2061,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0411,0.0000,1.2098,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0417,0.0000,1.2145,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0424,0.0000,1.2178,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0430,0.0000,1.2230,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0437,-0.0000,1.2303,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0444,0.0000,1.2395,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0452,-0.0000,1.2625,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0460,0.0000,1.2952,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0468,0.0000,1.3524,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0476,0.0000,1.4463,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0484,0.0000,1.5991,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0493,0.0000,1.5090,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0503,0.0000,1.3806,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0513,0.0000,1.2543,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0523,0.0000,1.2417,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0534,0.0000,1.2596,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0545,0.0000,1.2800,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0556,-0.0000,1.3013,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0569,0.0000,1.3297,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0582,0.0000,1.3607,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0595,0.0000,1.3963,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0610,0.0000,1.4368,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0625,0.0000,1.4821,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0641,0.0000,1.5593,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0658,0.0000,1.6248,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0676,-0.0000,1.6642,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0695,0.0000,1.7363,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0716,0.0000,1.8178,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0738,0.0000,1.9062,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0761,0.0000,2.0062,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0787,0.0000,2.9160,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0814,0.0000,3.0182,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0843,0.0000,1.2583,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0875,0.0000,2.5766,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0910,0.0000,2.8726,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0948,0.0000,2.9134,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.0990,0.0000,2.6963,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.1037,0.0000,2.2230,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.1088,0.0000,2.8233,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.1146,0.0000,4.0485,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.1211,0.0000,5.5240,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.1285,0.0000,5.6492,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.1370,0.0000,0.1399,-0.0000,0.0000,1.0000,-0.0000
|
||||||
|
0.1469,0.0000,0.5974,0.0000,0.0000,1.0000,0.0000
|
||||||
|
0.1585,1.0000,0.5637,Inf,1.0000,0.5628,Inf
|
||||||
|
0.1724,1.0000,0.5397,Inf,1.0000,0.5396,Inf
|
||||||
|
0.1895,1.0000,0.5156,Inf,1.0000,0.5148,Inf
|
||||||
|
0.2108,1.0000,0.4871,Inf,1.0000,0.4880,Inf
|
||||||
|
0.2385,1.0000,0.4584,Inf,1.0000,0.4588,Inf
|
||||||
|
0.2759,1.0000,0.4274,Inf,1.0000,0.4265,Inf
|
||||||
|
0.3299,1.0000,0.3913,Inf,1.0000,0.3901,Inf
|
||||||
|
0.4152,1.0000,0.3471,Inf,1.0000,0.3477,Inf
|
||||||
|
0.5743,1.0000,0.2950,Inf,1.0000,0.2957,Inf
|
||||||
|
1.0000,1.0000,0.2241,Inf,1.0000,0.2241,Inf
|
||||||
|
102
00_aoi_caching_simulation/input/2024-12-13/input.txt
Normal file
102
00_aoi_caching_simulation/input/2024-12-13/input.txt
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
Lambda h_opt u_opt TTL h_opt_2 u_opt_2 TTL_2
|
||||||
|
------ ------ ------ ------ ------ ------ ------
|
||||||
|
0.0251 0.0000 0.5864 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0253 0.0000 0.5949 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0255 0.0000 0.6040 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0257 0.0000 0.6125 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0260 0.0000 0.6213 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0262 0.0000 0.6308 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0264 0.0000 0.6405 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0266 0.0000 0.6494 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0269 0.0000 0.6594 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0271 0.0000 0.6687 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0273 0.0000 0.6791 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0276 -0.0000 0.6897 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0278 0.0000 0.7000 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0281 0.0000 0.7107 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0283 0.0000 0.7215 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0286 0.0000 0.7336 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0289 0.0000 0.7450 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0292 0.0000 0.7569 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0294 0.0000 0.7688 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0297 0.0000 0.7817 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0300 0.0000 0.7970 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0303 0.0000 0.8123 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0306 0.0000 0.8287 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0310 0.0000 0.8456 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0313 0.0000 0.8632 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0316 0.0000 0.8815 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0320 0.0000 0.8994 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0323 0.0000 0.9192 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0327 0.0000 0.9387 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0330 0.0000 0.9597 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0334 0.0000 0.9810 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0338 0.0000 1.0034 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0342 0.0000 1.0255 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0346 0.0000 1.0493 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0350 0.0000 1.0748 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0355 0.0000 1.0993 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0359 0.0000 1.1248 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0364 0.0000 1.1476 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0368 0.0000 1.1720 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0373 0.0000 1.1825 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0378 0.0000 1.1863 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0383 0.0000 1.1908 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0388 0.0000 1.1952 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0394 0.0000 1.1980 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0399 0.0000 1.2026 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0405 0.0000 1.2061 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0411 0.0000 1.2098 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0417 0.0000 1.2145 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0424 0.0000 1.2178 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0430 0.0000 1.2230 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0437 -0.0000 1.2303 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0444 0.0000 1.2395 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0452 -0.0000 1.2625 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0460 0.0000 1.2952 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0468 0.0000 1.3524 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0476 0.0000 1.4463 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0484 0.0000 1.5991 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0493 0.0000 1.5090 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0503 0.0000 1.3806 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0513 0.0000 1.2543 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0523 0.0000 1.2417 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0534 0.0000 1.2596 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0545 0.0000 1.2800 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0556 -0.0000 1.3013 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0569 0.0000 1.3297 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0582 0.0000 1.3607 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0595 0.0000 1.3963 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0610 0.0000 1.4368 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0625 0.0000 1.4821 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0641 0.0000 1.5593 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0658 0.0000 1.6248 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0676 -0.0000 1.6642 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0695 0.0000 1.7363 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0716 0.0000 1.8178 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0738 0.0000 1.9062 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0761 0.0000 2.0062 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0787 0.0000 2.9160 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0814 0.0000 3.0182 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0843 0.0000 1.2583 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0875 0.0000 2.5766 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0910 0.0000 2.8726 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0948 0.0000 2.9134 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.0990 0.0000 2.6963 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.1037 0.0000 2.2230 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.1088 0.0000 2.8233 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.1146 0.0000 4.0485 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.1211 0.0000 5.5240 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.1285 0.0000 5.6492 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.1370 0.0000 0.1399 -0.0000 0.0000 1.0000 -0.0000
|
||||||
|
0.1469 0.0000 0.5974 0.0000 0.0000 1.0000 0.0000
|
||||||
|
0.1585 1.0000 0.5637 Inf 1.0000 0.5628 Inf
|
||||||
|
0.1724 1.0000 0.5397 Inf 1.0000 0.5396 Inf
|
||||||
|
0.1895 1.0000 0.5156 Inf 1.0000 0.5148 Inf
|
||||||
|
0.2108 1.0000 0.4871 Inf 1.0000 0.4880 Inf
|
||||||
|
0.2385 1.0000 0.4584 Inf 1.0000 0.4588 Inf
|
||||||
|
0.2759 1.0000 0.4274 Inf 1.0000 0.4265 Inf
|
||||||
|
0.3299 1.0000 0.3913 Inf 1.0000 0.3901 Inf
|
||||||
|
0.4152 1.0000 0.3471 Inf 1.0000 0.3477 Inf
|
||||||
|
0.5743 1.0000 0.2950 Inf 1.0000 0.2957 Inf
|
||||||
|
1.0000 1.0000 0.2241 Inf 1.0000 0.2241 Inf
|
||||||
101
00_aoi_caching_simulation/input/2024-12-13/output.csv
Normal file
101
00_aoi_caching_simulation/input/2024-12-13/output.csv
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
,Lambda,h_opt,u_opt,TTL,h_opt_2,u_opt_2,TTL_2
|
||||||
|
0,0.0251,0.0,0.5864,-0.0,0.0,1.0,-0.0
|
||||||
|
1,0.0253,0.0,0.5949,-0.0,0.0,1.0,-0.0
|
||||||
|
2,0.0255,0.0,0.604,-0.0,0.0,1.0,-0.0
|
||||||
|
3,0.0257,0.0,0.6125,-0.0,0.0,1.0,-0.0
|
||||||
|
4,0.026,0.0,0.6213,-0.0,0.0,1.0,-0.0
|
||||||
|
5,0.0262,0.0,0.6308,-0.0,0.0,1.0,-0.0
|
||||||
|
6,0.0264,0.0,0.6405,-0.0,0.0,1.0,-0.0
|
||||||
|
7,0.0266,0.0,0.6494,-0.0,0.0,1.0,-0.0
|
||||||
|
8,0.0269,0.0,0.6594,-0.0,0.0,1.0,-0.0
|
||||||
|
9,0.0271,0.0,0.6687,-0.0,0.0,1.0,-0.0
|
||||||
|
10,0.0273,0.0,0.6791,-0.0,0.0,1.0,-0.0
|
||||||
|
11,0.0276,-0.0,0.6897,-0.0,0.0,1.0,-0.0
|
||||||
|
12,0.0278,0.0,0.7,-0.0,0.0,1.0,-0.0
|
||||||
|
13,0.0281,0.0,0.7107,-0.0,0.0,1.0,-0.0
|
||||||
|
14,0.0283,0.0,0.7215,-0.0,0.0,1.0,-0.0
|
||||||
|
15,0.0286,0.0,0.7336,-0.0,0.0,1.0,-0.0
|
||||||
|
16,0.0289,0.0,0.745,-0.0,0.0,1.0,-0.0
|
||||||
|
17,0.0292,0.0,0.7569,-0.0,0.0,1.0,-0.0
|
||||||
|
18,0.0294,0.0,0.7688,-0.0,0.0,1.0,-0.0
|
||||||
|
19,0.0297,0.0,0.7817,-0.0,0.0,1.0,-0.0
|
||||||
|
20,0.03,rsa diagram0.0,0.797,-0.0,0.0,1.0,-0.0
|
||||||
|
21,0.0303,0.0,0.8123,-0.0,0.0,1.0,-0.0
|
||||||
|
22,0.0306,0.0,0.8287,-0.0,0.0,1.0,-0.0
|
||||||
|
23,0.031,0.0,0.8456,-0.0,0.0,1.0,-0.0
|
||||||
|
24,0.0313,0.0,0.8632,-0.0,0.0,1.0,-0.0
|
||||||
|
25,0.0316,0.0,0.8815,-0.0,0.0,1.0,-0.0
|
||||||
|
26,0.032,0.0,0.8994,-0.0,0.0,1.0,-0.0
|
||||||
|
27,0.0323,0.0,0.9192,-0.0,0.0,1.0,-0.0
|
||||||
|
28,0.0327,0.0,0.9387,-0.0,0.0,1.0,-0.0
|
||||||
|
29,0.033,0.0,0.9597,-0.0,0.0,1.0,-0.0
|
||||||
|
30,0.0334,0.0,0.981,-0.0,0.0,1.0,-0.0
|
||||||
|
31,0.0338,0.0,1.0034,-0.0,0.0,1.0,-0.0
|
||||||
|
32,0.0342,0.0,1.0255,-0.0,0.0,1.0,-0.0
|
||||||
|
33,0.0346,0.0,1.0493,-0.0,0.0,1.0,-0.0
|
||||||
|
34,0.035,0.0,1.0748,-0.0,0.0,1.0,-0.0
|
||||||
|
35,0.0355,0.0,1.0993,-0.0,0.0,1.0,-0.0
|
||||||
|
36,0.0359,0.0,1.1248,-0.0,0.0,1.0,-0.0
|
||||||
|
37,0.0364,0.0,1.1476,-0.0,0.0,1.0,-0.0
|
||||||
|
38,0.0368,0.0,1.172,-0.0,0.0,1.0,-0.0
|
||||||
|
39,0.0373,0.0,1.1825,-0.0,0.0,1.0,-0.0
|
||||||
|
40,0.0378,0.0,1.1863,-0.0,0.0,1.0,-0.0
|
||||||
|
41,0.0383,0.0,1.1908,-0.0,0.0,1.0,-0.0
|
||||||
|
42,0.0388,0.0,1.1952,-0.0,0.0,1.0,-0.0
|
||||||
|
43,0.0394,0.0,1.198,-0.0,0.0,1.0,-0.0
|
||||||
|
44,0.0399,0.0,1.2026,-0.0,0.0,1.0,-0.0
|
||||||
|
45,0.0405,0.0,1.2061,-0.0,0.0,1.0,-0.0
|
||||||
|
46,0.0411,0.0,1.2098,-0.0,0.0,1.0,-0.0
|
||||||
|
47,0.0417,0.0,1.2145,-0.0,0.0,1.0,-0.0
|
||||||
|
48,0.0424,0.0,1.2178,-0.0,0.0,1.0,-0.0
|
||||||
|
49,0.043,0.0,1.223,-0.0,0.0,1.0,-0.0
|
||||||
|
50,0.0437,-0.0,1.2303,-0.0,0.0,1.0,-0.0
|
||||||
|
51,0.0444,0.0,1.2395,-0.0,0.0,1.0,-0.0
|
||||||
|
52,0.0452,-0.0,1.2625,-0.0,0.0,1.0,-0.0
|
||||||
|
53,0.046,0.0,1.2952,-0.0,0.0,1.0,-0.0
|
||||||
|
54,0.0468,0.0,1.3524,-0.0,0.0,1.0,-0.0
|
||||||
|
55,0.0476,0.0,1.4463,-0.0,0.0,1.0,-0.0
|
||||||
|
56,0.0484,0.0,1.5991,-0.0,0.0,1.0,-0.0
|
||||||
|
57,0.0493,0.0,1.509,-0.0,0.0,1.0,-0.0
|
||||||
|
58,0.0503,0.0,1.3806,-0.0,0.0,1.0,-0.0
|
||||||
|
59,0.0513,0.0,1.2543,-0.0,0.0,1.0,-0.0
|
||||||
|
60,0.0523,0.0,1.2417,-0.0,0.0,1.0,-0.0
|
||||||
|
61,0.0534,0.0,1.2596,-0.0,0.0,1.0,-0.0
|
||||||
|
62,0.0545,0.0,1.28,-0.0,0.0,1.0,-0.0
|
||||||
|
63,0.0556,-0.0,1.3013,-0.0,0.0,1.0,-0.0
|
||||||
|
64,0.0569,0.0,1.3297,-0.0,0.0,1.0,-0.0
|
||||||
|
65,0.0582,0.0,1.3607,-0.0,0.0,1.0,-0.0
|
||||||
|
66,0.0595,0.0,1.3963,-0.0,0.0,1.0,-0.0
|
||||||
|
67,0.061,0.0,1.4368,-0.0,0.0,1.0,-0.0
|
||||||
|
68,0.0625,0.0,1.4821,-0.0,0.0,1.0,-0.0
|
||||||
|
69,0.0641,0.0,1.5593,-0.0,0.0,1.0,-0.0
|
||||||
|
70,0.0658,0.0,1.6248,-0.0,0.0,1.0,-0.0
|
||||||
|
71,0.0676,-0.0,1.6642,-0.0,0.0,1.0,-0.0
|
||||||
|
72,0.0695,0.0,1.7363,-0.0,0.0,1.0,-0.0
|
||||||
|
73,0.0716,0.0,1.8178,-0.0,0.0,1.0,-0.0
|
||||||
|
74,0.0738,0.0,1.9062,-0.0,0.0,1.0,-0.0
|
||||||
|
75,0.0761,0.0,2.0062,-0.0,0.0,1.0,-0.0
|
||||||
|
76,0.0787,0.0,2.916,-0.0,0.0,1.0,-0.0
|
||||||
|
77,0.0814,0.0,3.0182,-0.0,0.0,1.0,-0.0
|
||||||
|
78,0.0843,0.0,1.2583,-0.0,0.0,1.0,-0.0
|
||||||
|
79,0.0875,0.0,2.5766,-0.0,0.0,1.0,-0.0
|
||||||
|
80,0.091,0.0,2.8726,-0.0,0.0,1.0,-0.0
|
||||||
|
81,0.0948,0.0,2.9134,-0.0,0.0,1.0,-0.0
|
||||||
|
82,0.099,0.0,2.6963,-0.0,0.0,1.0,-0.0
|
||||||
|
83,0.1037,0.0,2.223,-0.0,0.0,1.0,-0.0
|
||||||
|
84,0.1088,0.0,2.8233,-0.0,0.0,1.0,-0.0
|
||||||
|
85,0.1146,0.0,4.0485,-0.0,0.0,1.0,-0.0
|
||||||
|
86,0.1211,0.0,5.524,-0.0,0.0,1.0,-0.0
|
||||||
|
87,0.1285,0.0,5.6492,-0.0,0.0,1.0,-0.0
|
||||||
|
88,0.137,0.0,0.1399,-0.0,0.0,1.0,-0.0
|
||||||
|
89,0.1469,0.0,0.5974,0.0,0.0,1.0,0.0
|
||||||
|
90,0.1585,1.0,0.5637,inf,1.0,1.7768301350390903,inf
|
||||||
|
91,0.1724,1.0,0.5397,inf,1.0,1.8532246108228319,inf
|
||||||
|
92,0.1895,1.0,0.5156,inf,1.0,1.9425019425019423,inf
|
||||||
|
93,0.2108,1.0,0.4871,inf,1.0,2.0491803278688523,inf
|
||||||
|
94,0.2385,1.0,0.4584,inf,1.0,2.1795989537925022,inf
|
||||||
|
95,0.2759,1.0,0.4274,inf,1.0,2.3446658851113718,inf
|
||||||
|
96,0.3299,1.0,0.3913,inf,1.0,2.563445270443476,inf
|
||||||
|
97,0.4152,1.0,0.3471,inf,1.0,2.876042565429968,inf
|
||||||
|
98,0.5743,1.0,0.295,inf,1.0,3.3818058843422385,inf
|
||||||
|
99,1.0,1.0,0.2241,inf,1.0,4.462293618920125,inf
|
||||||
|
18
00_aoi_caching_simulation/input/2024-12-13/preprocessor.py
Normal file
18
00_aoi_caching_simulation/input/2024-12-13/preprocessor.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import pandas as pd
|
||||||
|
import sys
|
||||||
|
import pathlib
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
input_file = sys.argv[1]
|
||||||
|
assert pathlib.Path(input_file).suffix == ".csv", "Input needs to be a .csv file"
|
||||||
|
|
||||||
|
input_df = pd.read_csv(input_file)
|
||||||
|
output_df = input_df.copy()
|
||||||
|
output_df["u_opt_2"] = 1 / input_df["u_opt_2"]
|
||||||
|
output_df.to_csv("./output.csv")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
assert len(sys.argv) > 1, "Need filename of the file to preprocess."
|
||||||
|
main()
|
||||||
101
00_aoi_caching_simulation/input/2024-12-14/results.csv
Normal file
101
00_aoi_caching_simulation/input/2024-12-14/results.csv
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
Lambda,h_opt,u_opt,TTL,h_opt_2,u_opt_2,TTL_2,mu
|
||||||
|
0.0251188643150958,4.03358160426645e-23,0.123919681693936,-0,0,1.00000000000001,-0,0.999999999999992
|
||||||
|
0.0253216408296374,0,0.0505875350219564,-0,0,1,-0,1
|
||||||
|
0.0255281380320494,5.4065081445305e-22,0.522377809343488,-0,1.71377672395083e-33,1,-0,1
|
||||||
|
0.0257384632137329,0,0.101572737772223,-0,0,1,-0,1
|
||||||
|
0.0259527279086566,0,0.188581376480437,-0,3.85185988877447e-34,1,-0,1
|
||||||
|
0.0261710481074958,0,0.280797173850802,-0,0,1,-0,1
|
||||||
|
0.0263935444849688,5.75256527097375e-24,0.37728128813874,-0,0,1,-0,1
|
||||||
|
0.0266203426413373,0,0.489008862499741,-0,9.14816723583937e-34,1,-0,1
|
||||||
|
0.0268515733591148,0,0.622960563894529,-0,0,1,-0,1
|
||||||
|
0.0270873728761194,0,0.759865479128741,-0,0,1,-0,1
|
||||||
|
0.027327883176104,0,0.916528176230392,-0,4.81482486096809e-34,1,-0,1
|
||||||
|
0.0275732522983048,1.20856395403221e-24,1.08896600002116,-0,1.43341539499996e-34,1,-0,1
|
||||||
|
0.0278236346673699,2.65947043580255e-25,1.1751152950236,-0,0,1,-0,1
|
||||||
|
0.0280791914452574,0,1.25230270856483,-0,1.3951960033517e-33,1,-0,1
|
||||||
|
0.0283400909068398,1.39139236999703e-25,1.28918083237236,-0,0,1,-0,1
|
||||||
|
0.0286065088411073,0,1.2370089333978,-0,2.40741243048404e-34,1,-0,1
|
||||||
|
0.0288786289800412,5.10261429443745e-25,1.19306642390838,-0,7.69268771425848e-34,1,-0,1
|
||||||
|
0.0291566434574212,0,1.13936111462937,-0,0,1,-0,1
|
||||||
|
0.0294407533000456,9.18354961579912e-41,1.09629009883254,-0,3.85185988877447e-34,1,-0,1
|
||||||
|
0.0297311689540826,0,1.18553402270292,-0,8.6556526864521e-34,1,-0,1
|
||||||
|
0.0300281108495358,0,1.51494316047234,-0,0,1,-0,1
|
||||||
|
0.0303318100060983,0,1.46331126129221,-0,0,1,-0,1
|
||||||
|
0.0306425086840024,0,1.32169129905484,-0,0,1,-0,1
|
||||||
|
0.0309604610838299,6.91351165946676e-24,1.27558698733639,-0,4.14074938043256e-33,1,-0,1
|
||||||
|
0.0312859340996612,0,1.26526214238641,-0,1.2518544638517e-33,1,-0,1
|
||||||
|
0.0316192081303908,9.44225368671881e-25,1.31925763007173,-0,0,1,-0,1
|
||||||
|
0.0319605779545482,5.57247603462848e-23,1.35972890340586,-0,0,1,-0,1
|
||||||
|
0.0323103536745306,1.10034096826695e-21,1.27235577587924,-0,1.5155666248759e-33,1,-0,1
|
||||||
|
0.0326688617367965,2.95427555542052e-23,1.12021301384138,-0,0,1,-0,1
|
||||||
|
0.0330364460352817,8.01195015945139e-23,0.911058734193402,-0,9.51932908903155e-35,1,-0,1
|
||||||
|
0.0334134691061146,4.98867373582614e-25,0.641349069487049,-0,3.85185988877447e-34,1,-0,1
|
||||||
|
0.0338003134226122,0,0.610262082112085,-0,0,1,-0,1
|
||||||
|
0.0341973828005735,2.31090881333029e-24,0.105305111854949,-0,1.17852888460814e-33,1,-0,1
|
||||||
|
0.0346051039250455,5.03453621818642e-25,1.25013121869741,-0,4.80379279767763e-34,1,-0,1
|
||||||
|
0.035023928011061,3.33960780095097e-25,1.49218371547879,-0,1.34815096107107e-33,1,-0,1
|
||||||
|
0.0354543326123406,9.99034216856973e-24,1.35281370510585,-0,0,1,-0,1
|
||||||
|
0.0358968235936573,3.33866902170142e-25,1.81796954060273,-0,0,1,-0,1
|
||||||
|
0.0363519372845013,0,1.40710438332905,-0,9.85935890169412e-34,1,-0,1
|
||||||
|
0.0368202428338972,0,1.352465637171,-0,1.13038063599845e-33,1,-0,1
|
||||||
|
0.0373023447887628,6.69962103284551e-24,1.39858426118217,-0,0,1,-0,1
|
||||||
|
0.0377988859211009,4.0846333452986e-23,1.45715305639586,-0,1.03518734510814e-33,1,-0,1
|
||||||
|
0.0383105503326579,0,1.50137206328652,-0,0,1,-0,1
|
||||||
|
0.0388380668695228,4.49260743012737e-24,1.5462289972504,-0,0,1,-0,1
|
||||||
|
0.0393822128835806,4.15915531402447e-25,1.61124408866454,-0,0,1,-0,1
|
||||||
|
0.0399438183828623,0,1.6729781712164,-0,2.87786285329039e-34,1,-0,1
|
||||||
|
0.0405237706187912,0,1.73193720782327,-0,1.2518544638517e-33,1,-0,1
|
||||||
|
0.0411230191652392,1.6427546668366e-24,1.79618350060273,-0,0,1,-0,1
|
||||||
|
0.0417425815523796,0,1.87102077605761,-0,0,1,-0,1
|
||||||
|
0.0423835495277492,0,1.92444311907521,-0,9.62964972193618e-34,1,-0,1
|
||||||
|
0.04304709602799,3.74151459827752e-25,1.9274285762318,-0,0,1,-0,1
|
||||||
|
0.0437344829577311,0,1.87091171476828,-0,7.70371977754894e-34,1,-0,1
|
||||||
|
0.0444470698874037,0,1.82783571255705,-0,3.85185988877447e-34,1,-0,1
|
||||||
|
0.0451863237999041,7.87345144860759e-26,1.78940619114241,-0,0,1,-0,1
|
||||||
|
0.0459538300375418,2.32996154417604e-23,1.76550767613088,-0,0,1,-0,1
|
||||||
|
0.0467513046263291,0,1.74029557632777,-0,6.24824025596805e-34,1,-0,1
|
||||||
|
0.0475806081852961,0,1.72049124869484,-0,0,1,-0,1
|
||||||
|
0.0484437616652488,4.2210087088433e-24,1.72079999863276,-0,8.6556526864521e-34,1,-0,1
|
||||||
|
0.0493429642056255,0,1.71987171573499,-0,0,1,-0,1
|
||||||
|
0.0502806134515894,1.91765411319283e-25,1.77874623854687,-0,0,1,-0,1
|
||||||
|
0.0512593287384338,8.55437539706488e-23,1.830189551316,-0,3.17668120190989e-33,1,-0,1
|
||||||
|
0.0522819776295637,7.24686412660482e-23,1.77903997481112,-0,0,1,-0,1
|
||||||
|
0.0533517063913293,1.55294990295315e-23,2.01898224290866,-0,3.08148791101958e-33,1,-0,1
|
||||||
|
0.0544719751074109,0,2.08911267346387,-0,0,1,-0,1
|
||||||
|
0.0556465982832032,3.73962432453909e-25,2.21185660671955,-0,2.87786285329039e-34,1,-0,1
|
||||||
|
0.0568797919744227,0,2.360572574116,-0,0,1,-0,1
|
||||||
|
0.0581762287040114,0,2.55964431937068,-0,0,1,-0,1
|
||||||
|
0.0595411017205848,2.93551201655547e-25,2.75459242800534,-0,9.51932908903155e-35,1,-0,1
|
||||||
|
0.0609802005177442,4.01647119864077e-25,2.60934232910097,-0,0,1,-0,1
|
||||||
|
0.0625,0,2.35328599453927,-0,3.08148791101958e-33,1,-0,1
|
||||||
|
0.0641077662794986,2.89674266939654e-24,2.36156292059577,-0,0,1,-0,1
|
||||||
|
0.0658116828611607,0,2.61869995204192,-0,4.80379279767763e-34,1,-0,1
|
||||||
|
0.0676210019811913,-5.73971850987445e-42,2.80752649237365,-0,0,1,-0,1
|
||||||
|
0.0695462271867977,3.86578716687983e-25,2.63211155214017,-0,0,1,-0,1
|
||||||
|
0.0715993349974727,5.30308644266468e-25,2.59559867307993,-0,0,1,-0,1
|
||||||
|
0.0737940458317425,1.40340239106185e-25,2.54452097489368,-0,0,1,-0,1
|
||||||
|
0.0761461575486351,-4.70197740328915e-38,2.35650504068759,-0,9.51932908903155e-35,1,-0,1
|
||||||
|
0.0786739592745751,3.02014719099634e-26,3.25399541488032,-0,0,1,-0,1
|
||||||
|
0.081398749154559,2.65111561983658e-22,2.9940185116118,-0,0,1,-0,1
|
||||||
|
0.0843454880117311,0,1.31622832582448,-0,0,1,-0,1
|
||||||
|
0.0875436327263116,9.38056775099631e-26,5.11909215266465,-0,0,1,-0,1
|
||||||
|
0.091028210151304,6.57019351361687e-26,4.4185690430038,-0,0,1,-0,1
|
||||||
|
0.094841217227218,0,3.62209564563645,-0,0,1,-0,1
|
||||||
|
0.0990334698870002,2.02896730262414e-25,3.82616147388578,-0,0,1,-0,1
|
||||||
|
0.103667079284254,0,7.57861951778736,-0,0,1,-0,1
|
||||||
|
0.108818820412016,7.33776507639146e-26,6.80213057031659,-0,0,1,-0,1
|
||||||
|
0.114584795172499,2.79203477636773e-26,4.26187784535936,-0,0,1,-0,1
|
||||||
|
0.121087014505174,0,2.4762937822956,-0,0,1,-0,1
|
||||||
|
0.128482896333447,1.24513980064047e-25,2.58161016754972,-0,8.6556526864521e-34,1,-0,1
|
||||||
|
0.136979319126435,1.05792179042261e-24,1.72592209402389,-0,0,1,-0,1
|
||||||
|
0.146854024200198,0,0.656952793779639,-0,7.99547730340752e-16,1,5.29203146778025e-15,1
|
||||||
|
0.158489319246111,1.58764379585932e-23,0.232450668079407,-0,1,0.562818109287691,Inf,1.77677296358785
|
||||||
|
0.172427285990596,4.9810656459993e-24,0.469979676007235,-0,1,0.539591774926815,Inf,1.85325285978577
|
||||||
|
0.1894645708138,2.69428681958203e-23,0.308780856367804,-0,1,0.514759239575152,Inf,1.94265575655395
|
||||||
|
0.21082473737065,0,0.353973053967676,-0,1,0.487986156964493,Inf,2.04923845836217
|
||||||
|
0.238494846850876,0.847288140963468,0.325103579318314,7.87942562392709,1,0.458805588756474,Inf,2.17957240388103
|
||||||
|
0.275945932292243,1,0.302238130362979,Inf,1,0.42653654477372,Inf,2.34446499896159
|
||||||
|
0.329876977693224,1,0.276430043457921,Inf,1,0.390114627795856,Inf,2.56334915112
|
||||||
|
0.415243646538506,1,0.246382432787601,Inf,1,0.347709583112921,Inf,2.87596329973812
|
||||||
|
0.574349177498518,1,0.209494804596015,Inf,1,0.295651470574403,Inf,3.38236098760869
|
||||||
|
1,1,0.158767376280701,Inf,1,0.224062061198399,Inf,4.46304918669179
|
||||||
|
@@ -83,4 +83,15 @@ CPU times: user 3min 46s, sys: 43 s, total: 4min 29s
|
|||||||
Wall time: 4min 29s
|
Wall time: 4min 29s
|
||||||
for ACCESS_COUNT_LIMIT = 10_000 # Total time to run the simulation
|
for ACCESS_COUNT_LIMIT = 10_000 # Total time to run the simulation
|
||||||
|
|
||||||
## Notes 11/27/2024
|
## Notes 11/29/2024
|
||||||
|
|
||||||
|
C_m = cost for cache miss
|
||||||
|
C_delta = cost for refresh
|
||||||
|
C = Cm + C_delta over all objects summarized
|
||||||
|
|
||||||
|
We wanna minimize cost function
|
||||||
|
|
||||||
|
N = number of objects
|
||||||
|
B is cache size
|
||||||
|
|
||||||
|
C_f roughly equals C_m
|
||||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,101 @@
|
|||||||
|
obj_id,hit_rate,avg_cache_time,avg_age,expected_age
|
||||||
|
0,0.028,0.03325329929630683,0.023204482858348002,1.116413116488905
|
||||||
|
1,0.04498594189315839,0.035665625087609024,0.043221330226160294,1.7817061711666293
|
||||||
|
2,0.026363636363636363,0.036409396070116534,0.020288542949824868,1.0345871735287608
|
||||||
|
3,0.04607046070460705,0.0363978343831401,0.03872773209062088,1.7964378467442923
|
||||||
|
4,0.04419889502762431,0.03615228672799074,0.03642763114777527,1.70328494027916
|
||||||
|
5,0.03985507246376811,0.03676950351217687,0.034461547202715846,1.5236061086768762
|
||||||
|
6,0.036815068493150686,0.03849721981680691,0.030530991605135907,1.3964027836860209
|
||||||
|
7,0.023963133640552997,0.03529988040670102,0.018856436349120938,0.9013872909581104
|
||||||
|
8,0.03531438415159346,0.038165386953784596,0.027027811402170435,1.3144416325066297
|
||||||
|
9,0.03423423423423423,0.036955897527025466,0.029226502049341182,1.2647381271254077
|
||||||
|
10,0.042588042588042586,0.04077450946596414,0.03836042094973442,1.5628361405665512
|
||||||
|
11,0.04233700254022015,0.03919033374216662,0.029710294871190753,1.5367037887459236
|
||||||
|
12,0.038704581358609796,0.04168673435894385,0.02829352195557324,1.3943399114076962
|
||||||
|
13,0.036815068493150686,0.03893738067545655,0.037075705361456344,1.3119228999754786
|
||||||
|
14,0.04746317512274959,0.04020338894092804,0.03817945715447017,1.680930718978058
|
||||||
|
15,0.032852564102564104,0.04052105977774059,0.029212184002895596,1.149932163935685
|
||||||
|
16,0.04897314375987362,0.0417690649209027,0.04070364257566264,1.6986464290527248
|
||||||
|
17,0.03205128205128205,0.041212391391329616,0.021840635126575185,1.0987754007290234
|
||||||
|
18,0.04471195184866724,0.038361622106490766,0.03615410997564333,1.5238611288692487
|
||||||
|
19,0.036891679748822605,0.04227676920087244,0.031227142707488744,1.2438369564524887
|
||||||
|
20,0.0420032310177706,0.04114585402640357,0.03300695509799385,1.402582236340423
|
||||||
|
21,0.0422102839600921,0.04261347030412948,0.03419423692027347,1.3955651682762023
|
||||||
|
22,0.04108527131782946,0.042504951780664976,0.03133117742953732,1.3449261601310043
|
||||||
|
23,0.05171102661596958,0.043582426310604404,0.04125464781377853,1.6725701359515956
|
||||||
|
24,0.04636785162287481,0.042780927890087986,0.043351346646960734,1.484592851787145
|
||||||
|
25,0.04412811387900356,0.04620155503491008,0.035673892882568274,1.3991839174270044
|
||||||
|
26,0.04454022988505747,0.046001826950597555,0.03462578048970189,1.394648933199574
|
||||||
|
27,0.04145818441744103,0.046087690512175,0.033982183048274446,1.2857450354918125
|
||||||
|
28,0.04169611307420495,0.04703290821891488,0.037431919242893484,1.2773312159914103
|
||||||
|
29,0.055596196049743966,0.044798320876109944,0.054645889622558126,1.6899567635431305
|
||||||
|
30,0.05647382920110193,0.047396086748614084,0.04338332152007283,1.6962430262762667
|
||||||
|
31,0.05331510594668489,0.04755902759104284,0.0505542494697692,1.5818664546458632
|
||||||
|
32,0.043048694424841216,0.04705587894818888,0.0310445085643039,1.26107075894771
|
||||||
|
33,0.04435483870967742,0.049180614490502754,0.031594859282328816,1.284458736715999
|
||||||
|
34,0.053475935828877004,0.0487246197775325,0.04126428851528732,1.532265663729141
|
||||||
|
35,0.05584756898817345,0.04988657777917233,0.04621468657782067,1.5780929519437517
|
||||||
|
36,0.050293925538863485,0.05009659125832776,0.03988543871600336,1.4044976483138174
|
||||||
|
37,0.04498714652956298,0.05186652444765034,0.040584154011748995,1.2384169809189551
|
||||||
|
38,0.046975546975546977,0.05107916655928901,0.03882109844967486,1.279332534363051
|
||||||
|
39,0.05689548546691404,0.051500198252406294,0.04919610991510581,1.5303018703132325
|
||||||
|
40,0.050625,0.0527687465014302,0.04053463295590003,1.3427269766661467
|
||||||
|
41,0.0489060489060489,0.05059791686930254,0.0388947629997362,1.2799817995136926
|
||||||
|
42,0.0664576802507837,0.051742792892207234,0.05910233858832176,1.7204252809073808
|
||||||
|
43,0.05677114133648729,0.05627758036561266,0.05036094771733182,1.4455508683176053
|
||||||
|
44,0.05781710914454277,0.05480447224286348,0.04356510101506421,1.4539105128923906
|
||||||
|
45,0.05714285714285714,0.055032778619670195,0.048828257729445435,1.4155569711125267
|
||||||
|
46,0.05719044975013881,0.05880768138896037,0.04566534428450409,1.3960612917800446
|
||||||
|
47,0.0502540937323546,0.05789635500635094,0.0469978219825162,1.208185382958257
|
||||||
|
48,0.06463878326996197,0.06001984017140374,0.054397286637291695,1.5308959524905221
|
||||||
|
49,0.04722222222222222,0.059959207280027016,0.04135763986974341,1.1006455861863944
|
||||||
|
50,0.05758055995773904,0.06217897689346915,0.051425257121582295,1.3220161230443321
|
||||||
|
51,0.05855397148676171,0.06372387431741706,0.04288946277382657,1.3233202344433639
|
||||||
|
52,0.06338397066526978,0.06251060769777299,0.053172383598969995,1.4079567412180523
|
||||||
|
53,0.05650596163815448,0.06225873927308857,0.04605184435602171,1.2323251907029695
|
||||||
|
54,0.05893719806763285,0.06806119347852706,0.051176398153009214,1.2637315284424802
|
||||||
|
55,0.06386138613861386,0.06578269526004205,0.052302741788977154,1.347119685960501
|
||||||
|
56,0.06184586108468126,0.0689300622730106,0.05875521351532089,1.2827133108580708
|
||||||
|
57,0.07298930729893073,0.06944527982603416,0.05860294589284284,1.4884429214748491
|
||||||
|
58,0.057498802108289414,0.06918681861278915,0.04758334762313444,1.146909148515501
|
||||||
|
59,0.07136322049405307,0.07049866444461284,0.06741990025531656,1.3982166267972218
|
||||||
|
60,0.07049486461251167,0.0692845950378321,0.059860222974755,1.3546260099420684
|
||||||
|
61,0.06554392353208921,0.07222780825003801,0.057728863913871276,1.2327100279214385
|
||||||
|
62,0.0741067490074989,0.07293822252911843,0.06468799395550129,1.3672656258995988
|
||||||
|
63,0.07695652173913044,0.07396759857412441,0.0661893826796155,1.3923560622148003
|
||||||
|
64,0.08162393162393163,0.07570404805666296,0.07337991748729436,1.444137008295239
|
||||||
|
65,0.08501208702659147,0.07995308515750973,0.07127990732129247,1.4713221062226414
|
||||||
|
66,0.08711217183770883,0.08122977649849832,0.07081143513060936,1.4752652099345152
|
||||||
|
67,0.08323609490470633,0.08298995293908036,0.06641194226573623,1.3740458758763274
|
||||||
|
68,0.0888086642599278,0.0894385733295043,0.07529217251107581,1.4322346324095052
|
||||||
|
69,0.09126984126984126,0.0885461312911583,0.0757960745758491,1.4358271829880735
|
||||||
|
70,0.09289031797070382,0.09000225912910918,0.08094604178480055,1.4239940510195752
|
||||||
|
71,0.0900490539593553,0.0908843947970821,0.07268544918405634,1.3429765685661026
|
||||||
|
72,0.09943276609943276,0.09595773117180394,0.08248885195539596,1.4449735548843714
|
||||||
|
73,0.09152872444011685,0.09914825541313035,0.07451441081115397,1.289133868747066
|
||||||
|
74,0.097624471200781,0.09781067144338312,0.08372685227042513,1.3355533541800129
|
||||||
|
75,0.10081992104464015,0.10572304373727383,0.08772900337196457,1.338439482480946
|
||||||
|
76,0.09993979530403371,0.1063810916691862,0.08883676103054818,1.2826945459739607
|
||||||
|
77,0.11166325635779012,0.10861895682059657,0.09272970848940887,1.389104783084545
|
||||||
|
78,0.12379875635952516,0.11277126476129097,0.11422922957949964,1.4914074043618848
|
||||||
|
79,0.12454116413214474,0.11912671105426215,0.11227619772896971,1.4457519276152038
|
||||||
|
80,0.11502590673575129,0.12241137699598297,0.10229909745371212,1.2809694071283966
|
||||||
|
81,0.13426952451342694,0.12868486291774633,0.12040308233893292,1.4423482904938751
|
||||||
|
82,0.11747919143876338,0.1335434979514995,0.11005897672688875,1.203265196034087
|
||||||
|
83,0.14910491728982553,0.13725059251118138,0.12971746636499665,1.4705422706246458
|
||||||
|
84,0.15522325189553496,0.1477667621549505,0.1447179069738615,1.4619078861887382
|
||||||
|
85,0.15825262724088193,0.1513357562138355,0.1389545257968508,1.416384767695064
|
||||||
|
86,0.16326530612244897,0.16375498247303472,0.14956255130898283,1.3851066408443213
|
||||||
|
87,0.17315068493150684,0.16807131373471096,0.16124952105802978,1.3891236864011822
|
||||||
|
88,0.17099982551038212,0.1774593888934748,0.16266742252110025,1.2857710637820294
|
||||||
|
89,0.19326241134751773,0.1884746874081035,0.18340741145076409,1.3666501244854066
|
||||||
|
90,0.21402483564645727,0.20629605175358057,0.20783639047132194,1.415137081563887
|
||||||
|
91,0.21857776582874042,0.22423730151722707,0.21640299371981916,1.3314648540427159
|
||||||
|
92,0.2426193658121735,0.24617312789123882,0.2504080155994952,1.3603915790940857
|
||||||
|
93,0.27040261153427636,0.2680858260848082,0.2752509554276252,1.3839347884902697
|
||||||
|
94,0.2846100485581211,0.29348037564302487,0.2973373684411991,1.2985171668373057
|
||||||
|
95,0.3312862504264756,0.32911832057660734,0.36998392171012784,1.3487765649223409
|
||||||
|
96,0.37973874769274457,0.38247618330526634,0.44005423622449896,1.3450272579735552
|
||||||
|
97,0.4484845025400993,0.45205298056156323,0.5760415629309096,1.3521302287110968
|
||||||
|
98,0.5721407149225906,0.571997861558314,0.919749655577073,1.4810566203198905
|
||||||
|
99,0.7681812899477048,0.7683946264444863,1.9660540242903553,1.87408139626671
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,9 @@
|
|||||||
|
,hit_rate,avg_cache_time,avg_age,expected_age
|
||||||
|
count,100.0,100.0,100.0,100.0
|
||||||
|
mean,0.09995752379349948,0.09999849133785652,0.10917612001045782,1.3953153806298055
|
||||||
|
std,0.11190861822425655,0.11193809346072345,0.22322689014838046,0.16253739044526075
|
||||||
|
min,0.023963133640552997,0.03325329929630683,0.018856436349120938,0.9013872909581104
|
||||||
|
25%,0.0449174443820356,0.044494347234733556,0.03831518000091836,1.288293167505807
|
||||||
|
50%,0.0576988345511409,0.06109940853243645,0.05086532381138921,1.3907398743079913
|
||||||
|
75%,0.099559523400583,0.10079195249416623,0.08472739004581,1.4707372295241448
|
||||||
|
max,0.7681812899477048,0.7683946264444863,1.9660540242903553,1.87408139626671
|
||||||
|
@@ -0,0 +1 @@
|
|||||||
|
[LRUSimulation] Database Object Count: 100, Cache Size: 10, Eviction Strategy: EvictionStrategy.LRU
|
||||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,101 @@
|
|||||||
|
obj_id,hit_rate,expected_hit_rate,avg_cache_time,avg_age,expected_age
|
||||||
|
0,0.0,0.0,0.0,0.0,0.0
|
||||||
|
1,0.0,0.0,0.0,0.0,0.0
|
||||||
|
2,0.0,0.0,0.0,0.0,0.0
|
||||||
|
3,0.0,0.0,0.0,0.0,0.0
|
||||||
|
4,0.0,0.0,0.0,0.0,0.0
|
||||||
|
5,0.0,0.0,0.0,0.0,0.0
|
||||||
|
6,0.0,0.0,0.0,0.0,0.0
|
||||||
|
7,0.0,0.0,0.0,0.0,0.0
|
||||||
|
8,0.0,0.0,0.0,0.0,0.0
|
||||||
|
9,0.0,0.0,0.0,0.0,0.0
|
||||||
|
10,0.0,0.0,0.0,0.0,0.0
|
||||||
|
11,0.0,0.0,0.0,0.0,0.0
|
||||||
|
12,0.0,0.0,0.0,0.0,0.0
|
||||||
|
13,0.0,0.0,0.0,0.0,0.0
|
||||||
|
14,0.0,0.0,0.0,0.0,0.0
|
||||||
|
15,0.0,0.0,0.0,0.0,0.0
|
||||||
|
16,0.0,0.0,0.0,0.0,0.0
|
||||||
|
17,0.0,0.0,0.0,0.0,0.0
|
||||||
|
18,0.0,0.0,0.0,0.0,0.0
|
||||||
|
19,0.0,0.0,0.0,0.0,0.0
|
||||||
|
20,0.0,0.0,0.0,0.0,0.0
|
||||||
|
21,0.0,0.0,0.0,0.0,0.0
|
||||||
|
22,0.0,0.0,0.0,0.0,0.0
|
||||||
|
23,0.0,0.0,0.0,0.0,0.0
|
||||||
|
24,0.0,0.0,0.0,0.0,0.0
|
||||||
|
25,0.0,0.0,0.0,0.0,0.0
|
||||||
|
26,0.0,0.0,0.0,0.0,0.0
|
||||||
|
27,0.0,0.0,0.0,0.0,0.0
|
||||||
|
28,0.0,0.0,0.0,0.0,0.0
|
||||||
|
29,0.0,0.0,0.0,0.0,0.0
|
||||||
|
30,0.0,0.0,0.0,0.0,0.0
|
||||||
|
31,0.0,0.0,0.0,0.0,0.0
|
||||||
|
32,0.0,0.0,0.0,0.0,0.0
|
||||||
|
33,0.0,0.0,0.0,0.0,0.0
|
||||||
|
34,0.0,0.0,0.0,0.0,0.0
|
||||||
|
35,0.0,0.0,0.0,0.0,0.0
|
||||||
|
36,0.0,0.0,0.0,0.0,0.0
|
||||||
|
37,0.0,0.0,0.0,0.0,0.0
|
||||||
|
38,0.0,0.0,0.0,0.0,0.0
|
||||||
|
39,0.0,0.0,0.0,0.0,0.0
|
||||||
|
40,0.0,0.0,0.0,0.0,0.0
|
||||||
|
41,0.0,0.0,0.0,0.0,0.0
|
||||||
|
42,0.0,0.0,0.0,0.0,0.0
|
||||||
|
43,0.0,0.0,0.0,0.0,0.0
|
||||||
|
44,0.0,0.0,0.0,0.0,0.0
|
||||||
|
45,0.0,0.0,0.0,0.0,0.0
|
||||||
|
46,0.0,0.0,0.0,0.0,0.0
|
||||||
|
47,0.0,0.0,0.0,0.0,0.0
|
||||||
|
48,0.0,0.0,0.0,0.0,0.0
|
||||||
|
49,0.0,0.0,0.0,0.0,0.0
|
||||||
|
50,0.0,0.0,0.0,0.0,0.0
|
||||||
|
51,0.0,0.0,0.0,0.0,0.0
|
||||||
|
52,0.0,0.0,0.0,0.0,0.0
|
||||||
|
53,0.0,0.0,0.0,0.0,0.0
|
||||||
|
54,0.0,0.0,0.0,0.0,0.0
|
||||||
|
55,0.0,0.0,0.0,0.0,0.0
|
||||||
|
56,0.0,0.0,0.0,0.0,0.0
|
||||||
|
57,0.0,0.0,0.0,0.0,0.0
|
||||||
|
58,0.0,0.0,0.0,0.0,0.0
|
||||||
|
59,0.0,0.0,0.0,0.0,0.0
|
||||||
|
60,0.0,0.0,0.0,0.0,0.0
|
||||||
|
61,0.0,0.0,0.0,0.0,0.0
|
||||||
|
62,0.0,0.0,0.0,0.0,0.0
|
||||||
|
63,0.0,0.0,0.0,0.0,0.0
|
||||||
|
64,0.0,0.0,0.0,0.0,0.0
|
||||||
|
65,0.0,0.0,0.0,0.0,0.0
|
||||||
|
66,0.0,0.0,0.0,0.0,0.0
|
||||||
|
67,0.0,0.0,0.0,0.0,0.0
|
||||||
|
68,0.0,0.0,0.0,0.0,0.0
|
||||||
|
69,0.0,0.0,0.0,0.0,0.0
|
||||||
|
70,0.0,0.0,0.0,0.0,0.0
|
||||||
|
71,0.0,0.0,0.0,0.0,0.0
|
||||||
|
72,0.0,0.0,0.0,0.0,0.0
|
||||||
|
73,0.0,0.0,0.0,0.0,0.0
|
||||||
|
74,0.0,0.0,0.0,0.0,0.0
|
||||||
|
75,0.0,0.0,0.0,0.0,0.0
|
||||||
|
76,0.0,0.0,0.0,0.0,0.0
|
||||||
|
77,0.0,0.0,0.0,0.0,0.0
|
||||||
|
78,0.0,0.0,0.0,0.0,0.0
|
||||||
|
79,0.0,0.0,0.0,0.0,0.0
|
||||||
|
80,0.0,0.0,0.0,0.0,0.0
|
||||||
|
81,0.0,0.0,0.0,0.0,0.0
|
||||||
|
82,0.0,0.0,0.0,0.0,0.0
|
||||||
|
83,0.0,0.0,0.0,0.0,0.0
|
||||||
|
84,0.0,0.0,0.0,0.0,0.0
|
||||||
|
85,0.0,0.0,0.0,0.0,0.0
|
||||||
|
86,0.0,0.0,0.0,0.0,0.0
|
||||||
|
87,0.0,0.0,0.0,0.0,0.0
|
||||||
|
88,0.0,0.0,0.0,0.0,0.0
|
||||||
|
89,0.0,0.0,0.0,0.0,0.0
|
||||||
|
90,0.9998451293170203,1.0,0.9999806574518315,0.554997000606214,20367.507764292128
|
||||||
|
91,0.9998614190687362,1.0,0.999825603907617,0.5392195314133789,20926.624029447044
|
||||||
|
92,0.9998713164328915,1.0,0.9998183172352216,0.5060456649820166,20502.63843753892
|
||||||
|
93,0.9998838829540176,1.0,0.9999059270099743,0.4876205066988089,20425.75894442207
|
||||||
|
94,0.999899709156554,1.0,0.999851254333356,0.46247837628351507,20902.515670701632
|
||||||
|
95,0.9999123114696598,1.0,0.9999406056837161,0.42832186536432143,20666.002134964023
|
||||||
|
96,0.999927039252882,1.0,0.9999460329694837,0.38643223504496843,20772.203670443334
|
||||||
|
97,0.9999418503227308,1.0,0.9999676629901119,0.3493398533098376,20708.694587514987
|
||||||
|
98,0.9999582602888388,1.0,0.9999989208830471,0.2978637772010669,20858.0010356803
|
||||||
|
99,0.9999756649551018,1.0,0.9999972520432827,0.22374460354561168,20546.24999693472
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,9 @@
|
|||||||
|
,hit_rate,expected_hit_rate,avg_cache_time,avg_age,expected_age
|
||||||
|
count,100.0,100.0,100.0,100.0,100.0
|
||||||
|
mean,0.09999076583218432,0.1,0.0999923223450764,0.042360634144497394,2066.7619627193917
|
||||||
|
std,0.30148350279480357,0.3015113445777637,0.3014881963028628,0.1318359696508086,6231.814881241828
|
||||||
|
min,0.0,0.0,0.0,0.0,0.0
|
||||||
|
25%,0.0,0.0,0.0,0.0,0.0
|
||||||
|
50%,0.0,0.0,0.0,0.0,0.0
|
||||||
|
75%,0.0,0.0,0.0,0.0,0.0
|
||||||
|
max,0.9999756649551018,1.0,0.9999989208830471,0.554997000606214,20926.624029447044
|
||||||
|
@@ -0,0 +1 @@
|
|||||||
|
[RefreshSimulation] Database Object Count: 100, Cache Size: 10, Eviction Strategy: EvictionStrategy.TTL
|
||||||
566
01_nb_cncf_optimization/00-hitrate_optimization.ipynb
Normal file
566
01_nb_cncf_optimization/00-hitrate_optimization.ipynb
Normal file
@@ -0,0 +1,566 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 1,
|
||||||
|
"id": "ab5cd7d1-1a57-46fc-8282-dae0a6cc2944",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"import matplotlib.pyplot as plt\n",
|
||||||
|
"import numpy as np\n",
|
||||||
|
"import random\n",
|
||||||
|
"import pandas as pd"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 2,
|
||||||
|
"id": "3d1ad0b9-f6a8-4e98-84aa-6e02e4279954",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"DATABASE_OBJECT_COUNT = 100\n",
|
||||||
|
"CACHE_SIZE = DATABASE_OBJECT_COUNT/2\n",
|
||||||
|
"ZIPF_CONSTANT = 2\n",
|
||||||
|
"\n",
|
||||||
|
"CACHE_MISS_COST = 2\n",
|
||||||
|
"CACHE_REFRESH_COST = 1\n",
|
||||||
|
"\n",
|
||||||
|
"SEED = 42\n",
|
||||||
|
"np.random.seed(SEED)\n",
|
||||||
|
"random.seed(SEED)\n",
|
||||||
|
"\n",
|
||||||
|
"LAMBDA_VALUES = np.array([np.random.zipf(ZIPF_CONSTANT) for i in np.arange(1, DATABASE_OBJECT_COUNT + 1,1)])"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 3,
|
||||||
|
"id": "9cc83cf6-5c78-4f0d-b7cb-08cdb80c362e",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# LAMBDA_VALUES = np.array([0.03, 0.04,0.05,0.06,0.07,1,1.1,1.2,1.3,1.4,1.5])\n",
|
||||||
|
"# DATABASE_OBJECT_COUNT = len(LAMBDA_VALUES)\n",
|
||||||
|
"# CACHE_SIZE = 4.4\n",
|
||||||
|
"# CACHE_MISS_COST = 7\n",
|
||||||
|
"# CACHE_REFRESH_COST = 1"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 4,
|
||||||
|
"id": "3dc07233-0b56-4fee-a93b-212836c18b42",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"db_object_count = DATABASE_OBJECT_COUNT\n",
|
||||||
|
"cache_sz = CACHE_SIZE\n",
|
||||||
|
"\n",
|
||||||
|
"lambda_vals = LAMBDA_VALUES\n",
|
||||||
|
"c_f = CACHE_MISS_COST\n",
|
||||||
|
"c_delta = CACHE_REFRESH_COST"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 5,
|
||||||
|
"id": "5a27d416-8f98-4814-af9e-6c6bef95f4ef",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"def eta_star(db_object_count, c_f, cache_sz, c_delta, lambda_vals):\n",
|
||||||
|
" num = (db_object_count * c_f - cache_sz * c_delta)\n",
|
||||||
|
" denom = np.sum(1.0/lambda_vals)\n",
|
||||||
|
" return max(0, num/denom)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 6,
|
||||||
|
"id": "6276a9ce-f839-4fe6-90f2-2195cf065fc8",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"def h_i_star(c_f, eta, lambda_vals, c_delta):\n",
|
||||||
|
" optimized_hitrate = (c_f - (eta/lambda_vals)) / c_delta\n",
|
||||||
|
" return optimized_hitrate"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 7,
|
||||||
|
"id": "dcd31a8c-6864-4b9a-8bb3-998f0c32baf6",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"def get_index_of_furthest_hitrate_from_boundary(hitrates):\n",
|
||||||
|
" lower_bound_violation = hitrates[(hitrates < 0)]\n",
|
||||||
|
" upper_bound_violation = hitrates[(hitrates > 1)]\n",
|
||||||
|
" smallest_delta = np.abs(np.min(lower_bound_violation))\n",
|
||||||
|
" biggest_delta = np.max(upper_bound_violation) - 1\n",
|
||||||
|
" if smallest_delta > biggest_delta:\n",
|
||||||
|
" print(smallest_delta)\n",
|
||||||
|
" index = np.where(hitrates == np.min(local_hitrates))[0][0]\n",
|
||||||
|
" return index\n",
|
||||||
|
" else:\n",
|
||||||
|
" \n",
|
||||||
|
" index = np.where(hitrates == np.max(local_hitrates))[0][0]\n",
|
||||||
|
" return index"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 8,
|
||||||
|
"id": "9d774304-ae68-43b3-a76a-e970c06c5236",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"def get_index_of_furthest_hitrate_from_boundary(hitrates):\n",
|
||||||
|
" outside_bounds = (hitrates < 0) | (hitrates > 1)\n",
|
||||||
|
" distances = np.where(outside_bounds, np.maximum(np.abs(hitrates - 0), np.abs(hitrates - 1)), -np.inf)\n",
|
||||||
|
" index = np.argmax(distances)\n",
|
||||||
|
" return index"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 9,
|
||||||
|
"id": "19678083-15e1-439b-be8c-42033d501644",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"text/plain": [
|
||||||
|
"array([ 1, 3, 1, 1, 2, 1, 5, 1, 1, 1, 2, 1, 1, 1, 2, 2, 1,\n",
|
||||||
|
" 1, 3, 1, 1, 1, 1, 2, 1, 1, 1, 5, 1, 1, 1, 4, 1, 4,\n",
|
||||||
|
" 1, 1, 1, 3, 8, 1, 4, 4, 2, 1, 1, 1, 10, 1, 1, 1, 5,\n",
|
||||||
|
" 9, 1, 1, 1, 1, 1, 17, 2, 1, 26, 1, 1, 2, 1, 10, 1, 69,\n",
|
||||||
|
" 1, 1, 2, 1, 1, 1, 3, 2, 2, 3, 15, 1, 1, 5, 2, 1, 1,\n",
|
||||||
|
" 2, 1, 2, 1, 1, 2, 2, 3, 1, 2, 1, 1, 37, 4, 2])"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"execution_count": 9,
|
||||||
|
"metadata": {},
|
||||||
|
"output_type": "execute_result"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"lambda_vals"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 10,
|
||||||
|
"id": "ccd4b95d-1cdd-4c99-a22e-4b31338993cf",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"2.1159070575516945\n"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"text/plain": [
|
||||||
|
"array([-0.11590706, 1.29469765, -0.11590706, -0.11590706, 0.94204647,\n",
|
||||||
|
" -0.11590706, -0.11590706, -0.11590706, -0.11590706, 0.94204647,\n",
|
||||||
|
" -0.11590706, -0.11590706, -0.11590706, 0.94204647, 0.94204647,\n",
|
||||||
|
" -0.11590706, -0.11590706, 1.29469765, -0.11590706, -0.11590706,\n",
|
||||||
|
" -0.11590706, -0.11590706, 0.94204647, -0.11590706, -0.11590706,\n",
|
||||||
|
" -0.11590706, -0.11590706, -0.11590706, -0.11590706, 1.47102324,\n",
|
||||||
|
" -0.11590706, 1.47102324, -0.11590706, -0.11590706, -0.11590706,\n",
|
||||||
|
" 1.29469765, 1.73551162, -0.11590706, 1.47102324, 1.47102324,\n",
|
||||||
|
" 0.94204647, -0.11590706, -0.11590706, -0.11590706, 1.78840929,\n",
|
||||||
|
" -0.11590706, -0.11590706, -0.11590706, 1.76489922, -0.11590706,\n",
|
||||||
|
" -0.11590706, -0.11590706, -0.11590706, -0.11590706, 1.87553488,\n",
|
||||||
|
" 0.94204647, -0.11590706, 1.91861896, -0.11590706, -0.11590706,\n",
|
||||||
|
" 0.94204647, -0.11590706, 1.78840929, -0.11590706, 1.96933468,\n",
|
||||||
|
" -0.11590706, -0.11590706, 0.94204647, -0.11590706, -0.11590706,\n",
|
||||||
|
" -0.11590706, 1.29469765, 0.94204647, 0.94204647, 1.29469765,\n",
|
||||||
|
" 1.85893953, -0.11590706, -0.11590706, 0.94204647, -0.11590706,\n",
|
||||||
|
" -0.11590706, 0.94204647, -0.11590706, 0.94204647, -0.11590706,\n",
|
||||||
|
" -0.11590706, 0.94204647, 0.94204647, 1.29469765, -0.11590706,\n",
|
||||||
|
" 0.94204647, -0.11590706, -0.11590706, 1.94281332, 1.47102324,\n",
|
||||||
|
" 0.94204647])"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"execution_count": 10,
|
||||||
|
"metadata": {},
|
||||||
|
"output_type": "execute_result"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"eta = eta_star(db_object_count, c_f, cache_sz, c_delta, lambda_vals[lambda_vals != lambda_vals[6]])\n",
|
||||||
|
"print(eta)\n",
|
||||||
|
"optimized_hitrates = (c_f - eta / lambda_vals[lambda_vals != lambda_vals[6]]) / c_delta\n",
|
||||||
|
"optimized_hitrates"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 11,
|
||||||
|
"id": "05b17074-719f-4bca-8434-2aaee26094d0",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"text/html": [
|
||||||
|
"<div>\n",
|
||||||
|
"<style scoped>\n",
|
||||||
|
" .dataframe tbody tr th:only-of-type {\n",
|
||||||
|
" vertical-align: middle;\n",
|
||||||
|
" }\n",
|
||||||
|
"\n",
|
||||||
|
" .dataframe tbody tr th {\n",
|
||||||
|
" vertical-align: top;\n",
|
||||||
|
" }\n",
|
||||||
|
"\n",
|
||||||
|
" .dataframe thead th {\n",
|
||||||
|
" text-align: right;\n",
|
||||||
|
" }\n",
|
||||||
|
"</style>\n",
|
||||||
|
"<table border=\"1\" class=\"dataframe\">\n",
|
||||||
|
" <thead>\n",
|
||||||
|
" <tr style=\"text-align: right;\">\n",
|
||||||
|
" <th></th>\n",
|
||||||
|
" <th>0</th>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" </thead>\n",
|
||||||
|
" <tbody>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>count</th>\n",
|
||||||
|
" <td>96.000000</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>mean</th>\n",
|
||||||
|
" <td>0.437500</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>std</th>\n",
|
||||||
|
" <td>0.726101</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>min</th>\n",
|
||||||
|
" <td>-0.115907</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>25%</th>\n",
|
||||||
|
" <td>-0.115907</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>50%</th>\n",
|
||||||
|
" <td>-0.115907</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>75%</th>\n",
|
||||||
|
" <td>0.942046</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>max</th>\n",
|
||||||
|
" <td>1.969335</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" </tbody>\n",
|
||||||
|
"</table>\n",
|
||||||
|
"</div>"
|
||||||
|
],
|
||||||
|
"text/plain": [
|
||||||
|
" 0\n",
|
||||||
|
"count 96.000000\n",
|
||||||
|
"mean 0.437500\n",
|
||||||
|
"std 0.726101\n",
|
||||||
|
"min -0.115907\n",
|
||||||
|
"25% -0.115907\n",
|
||||||
|
"50% -0.115907\n",
|
||||||
|
"75% 0.942046\n",
|
||||||
|
"max 1.969335"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"execution_count": 11,
|
||||||
|
"metadata": {},
|
||||||
|
"output_type": "execute_result"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"pd.DataFrame(optimized_hitrates).describe()"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 12,
|
||||||
|
"id": "0e21c26f-058a-4e56-a5ad-1c47bf28656c",
|
||||||
|
"metadata": {
|
||||||
|
"scrolled": true
|
||||||
|
},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"Optimized: 67 1.97 // [ 1.79077042 -0.09229584 1. -0.09229584 -0.09229584]\n",
|
||||||
|
"Optimized: 97 1.94 // [-0.07876743 -0.07876743 1. 1.48030814 0.96061628]\n",
|
||||||
|
"Optimized: 60 1.92 // [ 0.96720258 -0.06559484 1. -0.06559484 -0.06559484]\n",
|
||||||
|
"Optimized: 57 1.88 // [-0.05274002 -0.05274002 1. 0.97362999 -0.05274002]\n",
|
||||||
|
"Optimized: 78 1.86 // [ 0.97977406 1.31984937 1. -0.04045188 -0.04045188]\n",
|
||||||
|
"Optimized: 46 1.80 // [-0.02836604 -0.02836604 1. -0.02836604 -0.02836604]\n",
|
||||||
|
"Optimized: 65 1.80 // [ 0.99140044 -0.01719911 1. -0.01719911 1. ]\n",
|
||||||
|
"Optimized: 51 1.78 // [-0.00600086 1.59879983 1. -0.00600086 -0.00600086]\n",
|
||||||
|
"Optimized: 38 1.75 // [0.00491746 1.33497249 1. 0.00491746 1.50122936]\n",
|
||||||
|
"Optimized: 6 1.60 // [1.00774103 0.01548205 1. 0.01548205 0.01548205]\n",
|
||||||
|
"Optimized: 27 1.60 // [0.02399435 0.02399435 1. 0.02399435 0.02399435]\n",
|
||||||
|
"Optimized: 50 1.61 // [0.03255485 0.03255485 1. 1. 0.03255485]\n",
|
||||||
|
"Optimized: 81 1.61 // [0.04116395 0.04116395 1. 1.02058197 0.04116395]\n",
|
||||||
|
"Optimized: 31 1.51 // [0.04982206 0.04982206 1. 0.04982206 1.51245552]\n",
|
||||||
|
"Optimized: 33 1.51 // [1. 0.05714286 1. 0.05714286 0.05714286]\n",
|
||||||
|
"Optimized: 40 1.52 // [1. 0.06451613 1. 1.51612903 1.03225806]\n",
|
||||||
|
"Optimized: 41 1.52 // [0.07194245 1. 1. 1.03597122 0.07194245]\n",
|
||||||
|
"Optimized: 98 1.52 // [0.07942238 1. 1. 1.03971119]\n",
|
||||||
|
"Optimized: 1 1.36 // []\n",
|
||||||
|
"Optimized: 18 1.36 // [0.09223301 0.09223301 1. 0.09223301 0.09223301]\n",
|
||||||
|
"Optimized: 37 1.37 // [0.09756098 0.09756098 1. 1. 0.09756098]\n",
|
||||||
|
"Optimized: 74 1.37 // [0.10294118 0.10294118 1. 1.05147059 1.05147059]\n",
|
||||||
|
"Optimized: 77 1.37 // [1.05418719 1.05418719 1. 1. 0.10837438]\n",
|
||||||
|
"Optimized: 92 1.37 // [1.05693069 1.05693069 1. 0.11386139 1.05693069]\n",
|
||||||
|
"Optimized: 4 1.06 // [0.11940299 0.11940299 1. 0.11940299 1. ]\n",
|
||||||
|
"Optimized: 10 1.06 // [0.12030075 0.12030075 1. 0.12030075 0.12030075]\n",
|
||||||
|
"Optimized: 14 1.06 // [0.12121212 0.12121212 1. 1.06060606 0.12121212]\n",
|
||||||
|
"Optimized: 15 1.06 // [0.1221374 1. 1. 0.1221374 0.1221374]\n",
|
||||||
|
"Optimized: 23 1.06 // [0.12307692 0.12307692 1. 0.12307692 0.12307692]\n",
|
||||||
|
"Optimized: 42 1.06 // [1. 1. 1. 0.12403101 0.12403101]\n",
|
||||||
|
"Optimized: 58 1.06 // [0.125 1. 1. 0.125 1. ]\n",
|
||||||
|
"Optimized: 63 1.06 // [0.12598425 0.12598425 1. 0.12598425 1. ]\n",
|
||||||
|
"Optimized: 70 1.06 // [0.12698413 0.12698413 1. 0.12698413 0.12698413]\n",
|
||||||
|
"Optimized: 75 1.06 // [0.128 1. 1. 1.064 1. ]\n",
|
||||||
|
"Optimized: 76 1.06 // [1. 1. 1. 1. 1.]\n",
|
||||||
|
"Optimized: 82 1.07 // [0.1300813 1. 1. 0.1300813 0.1300813]\n",
|
||||||
|
"Optimized: 85 1.07 // [0.13114754 0.13114754 1. 0.13114754 1.06557377]\n",
|
||||||
|
"Optimized: 87 1.07 // [1. 0.1322314 1. 0.1322314 0.1322314]\n",
|
||||||
|
"Optimized: 90 1.07 // [0.13333333 0.13333333 1. 1.06666667 1. ]\n",
|
||||||
|
"Optimized: 91 1.07 // [0.13445378 1. 1. 1. 0.13445378]\n",
|
||||||
|
"Optimized: 94 1.07 // [1. 0.13559322 1. 0.13559322 0.13559322]\n",
|
||||||
|
"Optimized: 99 1.07 // [1. 1. 1.]\n",
|
||||||
|
"All values optimized.\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"\"\"\"\n",
|
||||||
|
"Perform theoretical optimization to compute optimal hit probabilities.\n",
|
||||||
|
"\n",
|
||||||
|
"Parameters:\n",
|
||||||
|
"- lambda_vals (numpy array): Request rates for each item.\n",
|
||||||
|
"- B (float): Total cache size.\n",
|
||||||
|
"- c_f (float): Fetching linear cost (cache miss cost).\n",
|
||||||
|
"- c_delta (float): Age linear cost.\n",
|
||||||
|
"\n",
|
||||||
|
"Returns:\n",
|
||||||
|
"- h_opt (numpy array): Optimal hit probabilities for each item.\n",
|
||||||
|
"\"\"\"\n",
|
||||||
|
"optimized_hitrates = np.zeros(DATABASE_OBJECT_COUNT)\n",
|
||||||
|
"current_db_object_count = DATABASE_OBJECT_COUNT\n",
|
||||||
|
"current_cache_size = CACHE_SIZE\n",
|
||||||
|
"\n",
|
||||||
|
"differenc_set = np.arange(DATABASE_OBJECT_COUNT)\n",
|
||||||
|
"fix_i = []\n",
|
||||||
|
"\n",
|
||||||
|
"while True:\n",
|
||||||
|
" if current_db_object_count == 0:\n",
|
||||||
|
" print(\"No objects left to optimize.\")\n",
|
||||||
|
" if current_cache_size > 0:\n",
|
||||||
|
" print(\"Add obj with optimized hitrate 0 and add them to optimization pool for re-optimization.\")\n",
|
||||||
|
" # Redistribute unused cache size among items with zero hit probability\n",
|
||||||
|
" differenc_set = np.where(optimized_hitrates == 0)[0]\n",
|
||||||
|
" fix_i = np.setdiff1d(np.arange(DATABASE_OBJECT_COUNT), differenc_set).tolist()\n",
|
||||||
|
" current_db_object_count = len(differenc_set)\n",
|
||||||
|
" continue\n",
|
||||||
|
" else:\n",
|
||||||
|
" \"Reset\"\n",
|
||||||
|
" optimized_hitrates[differenc_set] = 0\n",
|
||||||
|
" break\n",
|
||||||
|
" # Compute Lagrangian multiplier and optimal hit probabilities\n",
|
||||||
|
" eta = eta_star(current_db_object_count, c_f, current_cache_size, c_delta, lambda_vals[differenc_set])\n",
|
||||||
|
" optimized_hitrates[differenc_set] = (c_f - eta / lambda_vals[differenc_set]) / c_delta\n",
|
||||||
|
" if eta < 0:\n",
|
||||||
|
" print(\"eta was negative.\")\n",
|
||||||
|
" current_cache_size = current_db_object_count * c_f / c_delta # Adjust cache size for next iteration\n",
|
||||||
|
" continue\n",
|
||||||
|
" \n",
|
||||||
|
" if len((optimized_hitrates[differenc_set])[((optimized_hitrates[differenc_set]) < 0) | ((optimized_hitrates[differenc_set])> 1)]) == 0:\n",
|
||||||
|
" print(\"All values optimized.\")\n",
|
||||||
|
" break\n",
|
||||||
|
" \n",
|
||||||
|
" max_outbound_index = get_index_of_furthest_hitrate_from_boundary(optimized_hitrates)\n",
|
||||||
|
" fix_i.append(max_outbound_index)\n",
|
||||||
|
" differenc_set = np.setdiff1d(np.arange(DATABASE_OBJECT_COUNT), fix_i)\n",
|
||||||
|
"\n",
|
||||||
|
" old_hitrate = optimized_hitrates[max_outbound_index]\n",
|
||||||
|
" optimized_hitrates[max_outbound_index] = (1 if optimized_hitrates[max_outbound_index] > 1 else 0)\n",
|
||||||
|
" \n",
|
||||||
|
" print(f\"Optimized: {max_outbound_index} {old_hitrate:.2f} // {optimized_hitrates[max_outbound_index-2:max_outbound_index+3]}\")\n",
|
||||||
|
" \n",
|
||||||
|
" current_db_object_count -= 1\n",
|
||||||
|
" current_cache_size -= optimized_hitrates[max_outbound_index]"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 13,
|
||||||
|
"id": "f559ee7a-be2f-4076-b01c-f08950ad5a88",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"text/plain": [
|
||||||
|
"array([0.13793103, 1. , 0.13793103, 0.13793103, 1. ,\n",
|
||||||
|
" 0.13793103, 1. , 0.13793103, 0.13793103, 0.13793103,\n",
|
||||||
|
" 1. , 0.13793103, 0.13793103, 0.13793103, 1. ,\n",
|
||||||
|
" 1. , 0.13793103, 0.13793103, 1. , 0.13793103,\n",
|
||||||
|
" 0.13793103, 0.13793103, 0.13793103, 1. , 0.13793103,\n",
|
||||||
|
" 0.13793103, 0.13793103, 1. , 0.13793103, 0.13793103,\n",
|
||||||
|
" 0.13793103, 1. , 0.13793103, 1. , 0.13793103,\n",
|
||||||
|
" 0.13793103, 0.13793103, 1. , 1. , 0.13793103,\n",
|
||||||
|
" 1. , 1. , 1. , 0.13793103, 0.13793103,\n",
|
||||||
|
" 0.13793103, 1. , 0.13793103, 0.13793103, 0.13793103,\n",
|
||||||
|
" 1. , 1. , 0.13793103, 0.13793103, 0.13793103,\n",
|
||||||
|
" 0.13793103, 0.13793103, 1. , 1. , 0.13793103,\n",
|
||||||
|
" 1. , 0.13793103, 0.13793103, 1. , 0.13793103,\n",
|
||||||
|
" 1. , 0.13793103, 1. , 0.13793103, 0.13793103,\n",
|
||||||
|
" 1. , 0.13793103, 0.13793103, 0.13793103, 1. ,\n",
|
||||||
|
" 1. , 1. , 1. , 1. , 0.13793103,\n",
|
||||||
|
" 0.13793103, 1. , 1. , 0.13793103, 0.13793103,\n",
|
||||||
|
" 1. , 0.13793103, 1. , 0.13793103, 0.13793103,\n",
|
||||||
|
" 1. , 1. , 1. , 0.13793103, 1. ,\n",
|
||||||
|
" 0.13793103, 0.13793103, 1. , 1. , 1. ])"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"execution_count": 13,
|
||||||
|
"metadata": {},
|
||||||
|
"output_type": "execute_result"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"optimized_hitrates"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 14,
|
||||||
|
"id": "8b2d3cea-1cc0-476e-92bf-2ac4344a9b1b",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"text/html": [
|
||||||
|
"<div>\n",
|
||||||
|
"<style scoped>\n",
|
||||||
|
" .dataframe tbody tr th:only-of-type {\n",
|
||||||
|
" vertical-align: middle;\n",
|
||||||
|
" }\n",
|
||||||
|
"\n",
|
||||||
|
" .dataframe tbody tr th {\n",
|
||||||
|
" vertical-align: top;\n",
|
||||||
|
" }\n",
|
||||||
|
"\n",
|
||||||
|
" .dataframe thead th {\n",
|
||||||
|
" text-align: right;\n",
|
||||||
|
" }\n",
|
||||||
|
"</style>\n",
|
||||||
|
"<table border=\"1\" class=\"dataframe\">\n",
|
||||||
|
" <thead>\n",
|
||||||
|
" <tr style=\"text-align: right;\">\n",
|
||||||
|
" <th></th>\n",
|
||||||
|
" <th>0</th>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" </thead>\n",
|
||||||
|
" <tbody>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>count</th>\n",
|
||||||
|
" <td>100.000000</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>mean</th>\n",
|
||||||
|
" <td>0.500000</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>std</th>\n",
|
||||||
|
" <td>0.427625</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>min</th>\n",
|
||||||
|
" <td>0.137931</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>25%</th>\n",
|
||||||
|
" <td>0.137931</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>50%</th>\n",
|
||||||
|
" <td>0.137931</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>75%</th>\n",
|
||||||
|
" <td>1.000000</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>max</th>\n",
|
||||||
|
" <td>1.000000</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" </tbody>\n",
|
||||||
|
"</table>\n",
|
||||||
|
"</div>"
|
||||||
|
],
|
||||||
|
"text/plain": [
|
||||||
|
" 0\n",
|
||||||
|
"count 100.000000\n",
|
||||||
|
"mean 0.500000\n",
|
||||||
|
"std 0.427625\n",
|
||||||
|
"min 0.137931\n",
|
||||||
|
"25% 0.137931\n",
|
||||||
|
"50% 0.137931\n",
|
||||||
|
"75% 1.000000\n",
|
||||||
|
"max 1.000000"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"execution_count": 14,
|
||||||
|
"metadata": {},
|
||||||
|
"output_type": "execute_result"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"pd.DataFrame(optimized_hitrates).describe()"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "7a998837-72b8-4039-95a5-ca8d9c8e65ab",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "graphs",
|
||||||
|
"language": "python",
|
||||||
|
"name": "graphs"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.12.7"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
||||||
287
01_nb_cncf_optimization/01-objective_gridsearch.ipynb
Normal file
287
01_nb_cncf_optimization/01-objective_gridsearch.ipynb
Normal file
@@ -0,0 +1,287 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 1,
|
||||||
|
"id": "ab5cd7d1-1a57-46fc-8282-dae0a6cc2944",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"import matplotlib.pyplot as plt\n",
|
||||||
|
"import numpy as np\n",
|
||||||
|
"import random\n",
|
||||||
|
"import pandas as pd\n",
|
||||||
|
"import itertools\n",
|
||||||
|
"from tqdm import tqdm"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 2,
|
||||||
|
"id": "3d1ad0b9-f6a8-4e98-84aa-6e02e4279954",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"SEED = 42\n",
|
||||||
|
"np.random.seed(SEED)\n",
|
||||||
|
"random.seed(SEED)\n",
|
||||||
|
"\n",
|
||||||
|
"ZIPF_CONSTANT = 2"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 3,
|
||||||
|
"id": "5a27d416-8f98-4814-af9e-6c6bef95f4ef",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"def eta_star(db_object_count, c_f, cache_sz, c_delta, lambda_vals):\n",
|
||||||
|
" num = (db_object_count * c_f - cache_sz * c_delta)\n",
|
||||||
|
" denom = np.sum(1.0/lambda_vals)\n",
|
||||||
|
" if denom == 0:\n",
|
||||||
|
" print(\"sum(1.0/lambda_vals) == 0\")\n",
|
||||||
|
" print(db_object_count, c_f, cache_sz, c_delta, lambda_vals)\n",
|
||||||
|
" return max(0, num/denom)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 4,
|
||||||
|
"id": "6276a9ce-f839-4fe6-90f2-2195cf065fc8",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"def h_i_star(c_f, eta, lambda_vals, c_delta):\n",
|
||||||
|
" optimized_hitrate = (c_f - (eta/lambda_vals)) / c_delta\n",
|
||||||
|
" return optimized_hitrate"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 5,
|
||||||
|
"id": "dcd31a8c-6864-4b9a-8bb3-998f0c32baf6",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"def get_index_of_furthest_hitrate_from_boundary(hitrates):\n",
|
||||||
|
" lower_bound_violation = hitrates[(hitrates < 0)]\n",
|
||||||
|
" upper_bound_violation = hitrates[(hitrates > 1)]\n",
|
||||||
|
" smallest_delta = np.abs(np.min(lower_bound_violation))\n",
|
||||||
|
" biggest_delta = np.max(upper_bound_violation) - 1\n",
|
||||||
|
" if smallest_delta > biggest_delta:\n",
|
||||||
|
" print(smallest_delta)\n",
|
||||||
|
" index = np.where(hitrates == np.min(local_hitrates))[0][0]\n",
|
||||||
|
" return index\n",
|
||||||
|
" else:\n",
|
||||||
|
" \n",
|
||||||
|
" index = np.where(hitrates == np.max(local_hitrates))[0][0]\n",
|
||||||
|
" return index"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 6,
|
||||||
|
"id": "9d774304-ae68-43b3-a76a-e970c06c5236",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"def get_index_of_furthest_hitrate_from_boundary(hitrates):\n",
|
||||||
|
" outside_bounds = (hitrates < 0) | (hitrates > 1)\n",
|
||||||
|
" distances = np.where(outside_bounds, np.maximum(np.abs(hitrates - 0), np.abs(hitrates - 1)), -np.inf)\n",
|
||||||
|
" index = np.argmax(distances)\n",
|
||||||
|
" return index"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 7,
|
||||||
|
"id": "0e21c26f-058a-4e56-a5ad-1c47bf28656c",
|
||||||
|
"metadata": {
|
||||||
|
"scrolled": true
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"def optimize_hitrates(db_object_count, cache_size, c_f, c_delta, lambda_vals):\n",
|
||||||
|
" optimized_hitrates = np.zeros(db_object_count)\n",
|
||||||
|
" current_db_object_count = db_object_count\n",
|
||||||
|
" current_cache_size = cache_size\n",
|
||||||
|
" \n",
|
||||||
|
" differenc_set = np.arange(db_object_count)\n",
|
||||||
|
" fix_i = []\n",
|
||||||
|
" while True:\n",
|
||||||
|
" if current_db_object_count == 0:\n",
|
||||||
|
" if current_cache_size > 0:\n",
|
||||||
|
" # print(\"Re-optimize objects with optimal hitrate of 0.\")\n",
|
||||||
|
" differenc_set = np.where(optimized_hitrates == 0)[0]\n",
|
||||||
|
" fix_i = np.setdiff1d(np.arange(db_object_count), differenc_set).tolist()\n",
|
||||||
|
" current_db_object_count = len(differenc_set)\n",
|
||||||
|
" continue\n",
|
||||||
|
" else:\n",
|
||||||
|
" # print(\"Stop optimization.\")\n",
|
||||||
|
" optimized_hitrates[differenc_set] = 0\n",
|
||||||
|
" break\n",
|
||||||
|
" \n",
|
||||||
|
" eta = eta_star(current_db_object_count, c_f, current_cache_size, c_delta, lambda_vals[differenc_set])\n",
|
||||||
|
" optimized_hitrates[differenc_set] = h_i_star(c_f, eta, lambda_vals[differenc_set], c_delta)\n",
|
||||||
|
"\n",
|
||||||
|
" if eta < 0:\n",
|
||||||
|
" # print(\"eta was negative.\")\n",
|
||||||
|
" current_cache_size = current_db_object_count * c_f / c_delta # Adjust cache size for next iteration\n",
|
||||||
|
" continue\n",
|
||||||
|
" \n",
|
||||||
|
" if len((optimized_hitrates[differenc_set])[((optimized_hitrates[differenc_set]) < 0) | ((optimized_hitrates[differenc_set])> 1)]) == 0:\n",
|
||||||
|
" # print(\"All values optimized.\")\n",
|
||||||
|
" break\n",
|
||||||
|
" \n",
|
||||||
|
" max_outbound_index = get_index_of_furthest_hitrate_from_boundary(optimized_hitrates)\n",
|
||||||
|
" fix_i.append(max_outbound_index)\n",
|
||||||
|
" differenc_set = np.setdiff1d(np.arange(db_object_count), fix_i)\n",
|
||||||
|
" \n",
|
||||||
|
" old_hitrate = optimized_hitrates[max_outbound_index]\n",
|
||||||
|
" optimized_hitrates[max_outbound_index] = (1 if optimized_hitrates[max_outbound_index] > 1 else 0)\n",
|
||||||
|
" \n",
|
||||||
|
" current_db_object_count -= 1\n",
|
||||||
|
" current_cache_size -= optimized_hitrates[max_outbound_index]\n",
|
||||||
|
" return optimized_hitrates"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 8,
|
||||||
|
"id": "b6bf3329-3a63-4807-ab8b-8a54f824f47e",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"def objective_function(optimized_hitrates, c_f, c_delta, lambda_vals):\n",
|
||||||
|
" return np.sum(lambda_vals*(1-optimized_hitrates)*c_f+0.5*np.power(optimized_hitrates,2)*c_delta)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 9,
|
||||||
|
"id": "7a998837-72b8-4039-95a5-ca8d9c8e65ab",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# Perform grid search\n",
|
||||||
|
"def grid_search(db_object_counts, cache_sizes, c_f_values, c_delta_values):\n",
|
||||||
|
" best_objective = float('inf')\n",
|
||||||
|
" best_params = None\n",
|
||||||
|
"\n",
|
||||||
|
" # Iterate through all combinations of parameters\n",
|
||||||
|
" for db_object_count, cache_size, c_f, c_delta in tqdm(itertools.product(db_object_counts, cache_sizes, c_f_values, c_delta_values), total=len(db_object_counts) * len(cache_sizes) * len(c_f_values) * len(c_delta_values), desc=\"Grid Search Progress\"):\n",
|
||||||
|
" if db_object_count < cache_size:\n",
|
||||||
|
" continue\n",
|
||||||
|
" lambda_vals = np.array([np.random.zipf(ZIPF_CONSTANT) for i in np.arange(1, db_object_count + 1,1)])\n",
|
||||||
|
" # print(db_object_count, cache_size, c_f, c_delta)\n",
|
||||||
|
" # Call the optimization function\n",
|
||||||
|
" optimized_hitrates = optimize_hitrates(db_object_count, cache_size, c_f, c_delta, lambda_vals)\n",
|
||||||
|
"\n",
|
||||||
|
" # Compute the objective function\n",
|
||||||
|
" objective = objective_function(optimized_hitrates, c_f, c_delta, lambda_vals)\n",
|
||||||
|
" \n",
|
||||||
|
" # Track the best (minimum) objective and corresponding parameters\n",
|
||||||
|
" if objective < best_objective:\n",
|
||||||
|
" best_objective = objective\n",
|
||||||
|
" best_params = (db_object_count, cache_size, c_f, c_delta)\n",
|
||||||
|
"\n",
|
||||||
|
" return best_objective, best_params"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 10,
|
||||||
|
"id": "a271b52d-1f24-4670-ae3f-af5dd9096a2f",
|
||||||
|
"metadata": {
|
||||||
|
"scrolled": true
|
||||||
|
},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stderr",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"Grid Search Progress: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 64152/64152 [12:27<00:00, 85.87it/s]"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"CPU times: user 12min 16s, sys: 11.5 s, total: 12min 28s\n",
|
||||||
|
"Wall time: 12min 27s\n"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "stderr",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"%%time\n",
|
||||||
|
"\n",
|
||||||
|
"# Define the grid search space\n",
|
||||||
|
"test_ratios = np.array([0.1, 0.2, 0.5, 0.7, 1, 1.5, 2, 5, 10])\n",
|
||||||
|
"db_object_count_values = np.round(np.array([10, 15, 30, 100, 200, 500]))\n",
|
||||||
|
"cache_size_values = np.unique(np.round(np.array([db_object_count_values * i for i in test_ratios]).flatten()))\n",
|
||||||
|
"c_f_values = np.array([0.1, 0.2, 0.5, 0.7, 1, 1.5, 2, 5, 10])\n",
|
||||||
|
"c_delta_values = np.unique(np.array([c_f_values * i for i in test_ratios]).flatten())\n",
|
||||||
|
"\n",
|
||||||
|
"best_objective, best_params = grid_search(db_object_count_values, cache_size_values, c_f_values, c_delta_values)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 11,
|
||||||
|
"id": "b2f625d0-ebe0-4a5d-92ff-7de03942ef51",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"text/plain": [
|
||||||
|
"(0.05000000000000002, (10, 10.0, 1.5, 0.010000000000000002))"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"execution_count": 11,
|
||||||
|
"metadata": {},
|
||||||
|
"output_type": "execute_result"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"best_objective, best_params "
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "86a23d02-6f14-4d4d-ad8a-39084ea69151",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "graphs",
|
||||||
|
"language": "python",
|
||||||
|
"name": "graphs"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.12.7"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
||||||
360
01_nb_cncf_optimization/02-objective_multi-core_gridsearch.ipynb
Normal file
360
01_nb_cncf_optimization/02-objective_multi-core_gridsearch.ipynb
Normal file
@@ -0,0 +1,360 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 1,
|
||||||
|
"id": "ab5cd7d1-1a57-46fc-8282-dae0a6cc2944",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"import matplotlib.pyplot as plt\n",
|
||||||
|
"import numpy as np\n",
|
||||||
|
"import random\n",
|
||||||
|
"import pandas as pd\n",
|
||||||
|
"import itertools\n",
|
||||||
|
"from joblib import Parallel, delayed\n",
|
||||||
|
"import os.path"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 2,
|
||||||
|
"id": "3d1ad0b9-f6a8-4e98-84aa-6e02e4279954",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"SEED = 42\n",
|
||||||
|
"np.random.seed(SEED)\n",
|
||||||
|
"random.seed(SEED)\n",
|
||||||
|
"\n",
|
||||||
|
"ZIPF_CONSTANT = 2"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 3,
|
||||||
|
"id": "5a27d416-8f98-4814-af9e-6c6bef95f4ef",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"def eta_star(db_object_count, c_f, cache_sz, c_delta, lambda_vals):\n",
|
||||||
|
" num = (db_object_count * c_f - cache_sz * c_delta)\n",
|
||||||
|
" denom = np.sum(1.0/lambda_vals)\n",
|
||||||
|
" return max(0, num/denom)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 4,
|
||||||
|
"id": "6276a9ce-f839-4fe6-90f2-2195cf065fc8",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"def h_i_star(c_f, eta, lambda_vals, c_delta):\n",
|
||||||
|
" optimized_hitrate = (c_f - (eta/lambda_vals)) / c_delta\n",
|
||||||
|
" return optimized_hitrate"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 5,
|
||||||
|
"id": "dcd31a8c-6864-4b9a-8bb3-998f0c32baf6",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"def get_index_of_furthest_hitrate_from_boundary(hitrates):\n",
|
||||||
|
" lower_bound_violation = hitrates[(hitrates < 0)]\n",
|
||||||
|
" upper_bound_violation = hitrates[(hitrates > 1)]\n",
|
||||||
|
" smallest_delta = np.abs(np.min(lower_bound_violation))\n",
|
||||||
|
" biggest_delta = np.max(upper_bound_violation) - 1\n",
|
||||||
|
" if smallest_delta > biggest_delta:\n",
|
||||||
|
" index = np.where(hitrates == np.min(local_hitrates))[0][0]\n",
|
||||||
|
" return index\n",
|
||||||
|
" else:\n",
|
||||||
|
" \n",
|
||||||
|
" index = np.where(hitrates == np.max(local_hitrates))[0][0]\n",
|
||||||
|
" return index"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 6,
|
||||||
|
"id": "9d774304-ae68-43b3-a76a-e970c06c5236",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"def get_index_of_furthest_hitrate_from_boundary(hitrates):\n",
|
||||||
|
" outside_bounds = (hitrates < 0) | (hitrates > 1)\n",
|
||||||
|
" distances = np.where(outside_bounds, np.maximum(np.abs(hitrates - 0), np.abs(hitrates - 1)), -np.inf)\n",
|
||||||
|
" index = np.argmax(distances)\n",
|
||||||
|
" return index"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 7,
|
||||||
|
"id": "0e21c26f-058a-4e56-a5ad-1c47bf28656c",
|
||||||
|
"metadata": {
|
||||||
|
"scrolled": true
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"def optimize_hitrates(db_object_count, cache_size, c_f, c_delta, lambda_vals):\n",
|
||||||
|
" optimized_hitrates = np.zeros(db_object_count)\n",
|
||||||
|
" current_db_object_count = db_object_count\n",
|
||||||
|
" current_cache_size = cache_size\n",
|
||||||
|
" \n",
|
||||||
|
" differenc_set = np.arange(db_object_count)\n",
|
||||||
|
" fix_i = []\n",
|
||||||
|
" while True:\n",
|
||||||
|
" if current_db_object_count == 0:\n",
|
||||||
|
" if current_cache_size > 0:\n",
|
||||||
|
" # print(\"Re-optimize objects with optimal hitrate of 0.\")\n",
|
||||||
|
" differenc_set = np.where(optimized_hitrates == 0)[0]\n",
|
||||||
|
" fix_i = np.setdiff1d(np.arange(db_object_count), differenc_set).tolist()\n",
|
||||||
|
" current_db_object_count = len(differenc_set)\n",
|
||||||
|
" continue\n",
|
||||||
|
" else:\n",
|
||||||
|
" # print(\"Stop optimization.\")\n",
|
||||||
|
" optimized_hitrates[differenc_set] = 0\n",
|
||||||
|
" break\n",
|
||||||
|
" \n",
|
||||||
|
" eta = eta_star(current_db_object_count, c_f, current_cache_size, c_delta, lambda_vals[differenc_set])\n",
|
||||||
|
" optimized_hitrates[differenc_set] = h_i_star(c_f, eta, lambda_vals[differenc_set], c_delta)\n",
|
||||||
|
"\n",
|
||||||
|
" if eta < 0:\n",
|
||||||
|
" # print(\"eta was negative.\")\n",
|
||||||
|
" current_cache_size = current_db_object_count * c_f / c_delta # Adjust cache size for next iteration\n",
|
||||||
|
" continue\n",
|
||||||
|
" \n",
|
||||||
|
" if len((optimized_hitrates[differenc_set])[((optimized_hitrates[differenc_set]) < 0) | ((optimized_hitrates[differenc_set])> 1)]) == 0:\n",
|
||||||
|
" # print(\"All values optimized.\")\n",
|
||||||
|
" break\n",
|
||||||
|
" \n",
|
||||||
|
" max_outbound_index = get_index_of_furthest_hitrate_from_boundary(optimized_hitrates)\n",
|
||||||
|
" fix_i.append(max_outbound_index)\n",
|
||||||
|
" differenc_set = np.setdiff1d(np.arange(db_object_count), fix_i)\n",
|
||||||
|
" \n",
|
||||||
|
" old_hitrate = optimized_hitrates[max_outbound_index]\n",
|
||||||
|
" optimized_hitrates[max_outbound_index] = (1 if optimized_hitrates[max_outbound_index] > 1 else 0)\n",
|
||||||
|
" \n",
|
||||||
|
" current_db_object_count -= 1\n",
|
||||||
|
" current_cache_size -= optimized_hitrates[max_outbound_index]\n",
|
||||||
|
" return optimized_hitrates"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 8,
|
||||||
|
"id": "b6bf3329-3a63-4807-ab8b-8a54f824f47e",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"def objective_function(optimized_hitrates, c_f, c_delta, lambda_vals):\n",
|
||||||
|
" return np.sum(lambda_vals*(1-optimized_hitrates)*c_f+0.5*np.power(optimized_hitrates,2)*c_delta)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 9,
|
||||||
|
"id": "a289bb1a-0385-4835-bc92-88304c1834df",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"def optimize_ttl(optimized_hitrates, lambda_vals):\n",
|
||||||
|
" result = []\n",
|
||||||
|
" for i in range(len(lambda_vals)):\n",
|
||||||
|
" if optimized_hitrates[i] < 1:\n",
|
||||||
|
" result.append(-1 / lambda_vals[i] * np.log(1 - optimized_hitrates[i]))\n",
|
||||||
|
" else:\n",
|
||||||
|
" result.append(np.inf)\n",
|
||||||
|
" # ti_values = np.where(\n",
|
||||||
|
" # optimized_hitrates < 1,\n",
|
||||||
|
" # -1 / lambda_vals * np.log(1 - optimized_hitrates),\n",
|
||||||
|
" # np.inf\n",
|
||||||
|
" # )\n",
|
||||||
|
" \n",
|
||||||
|
" return np.array(result)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 13,
|
||||||
|
"id": "bd4536e9-273b-4f49-b06c-2f00605e0f7d",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# Define the task to be parallelized\n",
|
||||||
|
"def grid_search_task(db_object_count, cache_size, c_f, c_delta):\n",
|
||||||
|
" if db_object_count < cache_size:\n",
|
||||||
|
" return None # Skip this combination if db_object_count < cache_size\n",
|
||||||
|
" \n",
|
||||||
|
" # Generate lambda_vals\n",
|
||||||
|
" lambda_vals = np.array([np.random.zipf(ZIPF_CONSTANT) for _ in np.arange(1, db_object_count + 1, 1)])\n",
|
||||||
|
" \n",
|
||||||
|
" # Call the optimization function\n",
|
||||||
|
" optimized_hitrates = optimize_hitrates(db_object_count, cache_size, c_f, c_delta, lambda_vals)\n",
|
||||||
|
"\n",
|
||||||
|
" optimized_ttl = optimize_ttl(optimized_hitrates, lambda_vals)\n",
|
||||||
|
" \n",
|
||||||
|
" # Compute the objective function\n",
|
||||||
|
" objective = objective_function(optimized_hitrates, c_f, c_delta, lambda_vals)\n",
|
||||||
|
"\n",
|
||||||
|
" return (objective, optimized_ttl, db_object_count, cache_size, c_f, c_delta, optimized_hitrates)\n",
|
||||||
|
"\n",
|
||||||
|
"# Perform grid search with parallelization and tqdm progress bar\n",
|
||||||
|
"def grid_search(db_object_counts, cache_sizes, c_f_values, c_delta_values):\n",
|
||||||
|
" results = [] # List to collect the results (objective, parameters)\n",
|
||||||
|
" total_combinations = len(db_object_counts) * len(cache_sizes) * len(c_f_values) * len(c_delta_values)\n",
|
||||||
|
" \n",
|
||||||
|
" # Use Parallel from joblib to parallelize the grid search\n",
|
||||||
|
" task_results = Parallel(n_jobs=-1, verbose=1)(\n",
|
||||||
|
" delayed(grid_search_task)(db_object_count, cache_size, c_f, c_delta)\n",
|
||||||
|
" for db_object_count, cache_size, c_f, c_delta in itertools.product(db_object_counts, cache_sizes, c_f_values, c_delta_values)\n",
|
||||||
|
" )\n",
|
||||||
|
"\n",
|
||||||
|
" # Collect valid results\n",
|
||||||
|
" for result in task_results:\n",
|
||||||
|
" if result is not None:\n",
|
||||||
|
" results.append(result)\n",
|
||||||
|
" \n",
|
||||||
|
" # Convert the results into a pandas DataFrame\n",
|
||||||
|
" df = pd.DataFrame(results, columns=[\"Objective\", \"Optimal TTL\", \"db_object_count\", \"cache_size\", \"c_f (Miss Cost)\", \"c_delta (Refresh Cost)\", \"optimized_hitrates\"])\n",
|
||||||
|
" \n",
|
||||||
|
" return df\n"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 14,
|
||||||
|
"id": "a92c6772-6609-41a8-a3d1-4d640b69a864",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stderr",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"[Parallel(n_jobs=-1)]: Using backend LokyBackend with 12 concurrent workers.\n",
|
||||||
|
"[Parallel(n_jobs=-1)]: Done 26 tasks | elapsed: 0.4s\n",
|
||||||
|
"[Parallel(n_jobs=-1)]: Done 1420 tasks | elapsed: 0.7s\n",
|
||||||
|
"[Parallel(n_jobs=-1)]: Done 64152 out of 64152 | elapsed: 1.4min finished\n"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"CPU times: user 42 s, sys: 731 ms, total: 42.7 s\n",
|
||||||
|
"Wall time: 2min 5s\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"%%time\n",
|
||||||
|
"# Define the grid search space\n",
|
||||||
|
"test_ratios = np.array([0.1, 0.2, 0.5, 0.7, 1, 1.5, 2, 5, 10])\n",
|
||||||
|
"db_object_count_values = np.round(np.array([10, 15, 30, 100, 200, 500]))\n",
|
||||||
|
"cache_size_values = np.unique(np.round(np.array([db_object_count_values * i for i in test_ratios]).flatten()))\n",
|
||||||
|
"c_f_values = np.array([0.1, 0.2, 0.5, 0.7, 1, 1.5, 2, 5, 10])\n",
|
||||||
|
"c_delta_values = np.unique(np.array([c_f_values * i for i in test_ratios]).flatten())\n",
|
||||||
|
"\n",
|
||||||
|
"objective_result_file = \"./objective_grid-search_multi-core.csv\"\n",
|
||||||
|
"\n",
|
||||||
|
"results_df = None\n",
|
||||||
|
"if not os.path.isfile(objective_result_file):\n",
|
||||||
|
" # Call the grid search function\n",
|
||||||
|
" results_df = grid_search(db_object_count_values, cache_size_values, c_f_values, c_delta_values)\n",
|
||||||
|
" results_df.to_csv(objective_result_file,index=False)\n",
|
||||||
|
"else:\n",
|
||||||
|
" results_df = pd.read_csv(objective_result_file)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 15,
|
||||||
|
"id": "e79e6ed1-d6a5-4b04-a2b2-b3f0984e0fbe",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"Best Result:\n",
|
||||||
|
"Objective 0.05\n",
|
||||||
|
"Optimal TTL [inf, inf, inf, inf, inf, inf, inf, inf, inf, ...\n",
|
||||||
|
"db_object_count 10\n",
|
||||||
|
"cache_size 10.0\n",
|
||||||
|
"c_f (Miss Cost) 0.7\n",
|
||||||
|
"c_delta (Refresh Cost) 0.01\n",
|
||||||
|
"optimized_hitrates [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, ...\n",
|
||||||
|
"Name: 2376, dtype: object\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"# After performing the grid search and obtaining the DataFrame 'results_df'\n",
|
||||||
|
"best_row = results_df.loc[results_df['Objective'].idxmin()]\n",
|
||||||
|
"\n",
|
||||||
|
"# Display the best row\n",
|
||||||
|
"print(\"Best Result:\")\n",
|
||||||
|
"print(best_row)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 16,
|
||||||
|
"id": "95af94b4-05c0-488c-9561-50fc4e7cc3d4",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"text/plain": [
|
||||||
|
"(0.049999999999999996,\n",
|
||||||
|
" array([inf, inf, inf, inf, inf, inf, inf, inf, inf, inf]),\n",
|
||||||
|
" 10,\n",
|
||||||
|
" 10,\n",
|
||||||
|
" 1.5,\n",
|
||||||
|
" 0.01,\n",
|
||||||
|
" array([1., 1., 1., 1., 1., 1., 1., 1., 1., 1.]))"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"execution_count": 16,
|
||||||
|
"metadata": {},
|
||||||
|
"output_type": "execute_result"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"grid_search_task(10, 10, 1.5, 0.01)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "20c943b4-b32b-4294-949b-0f3abe2fb97a",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "graphs",
|
||||||
|
"language": "python",
|
||||||
|
"name": "graphs"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.12.7"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
||||||
319
01_nb_cncf_optimization/03-plot_objective_optimization.ipynb
Normal file
319
01_nb_cncf_optimization/03-plot_objective_optimization.ipynb
Normal file
File diff suppressed because one or more lines are too long
BIN
01_nb_cncf_optimization/NB_Tuan.pdf
Normal file
BIN
01_nb_cncf_optimization/NB_Tuan.pdf
Normal file
Binary file not shown.
@@ -0,0 +1,258 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 1,
|
||||||
|
"id": "d0996120-bb17-4476-b912-ce155100b2cb",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"Hit probabilities (numerical and theoretical):\n",
|
||||||
|
" [[0.4 0. ]\n",
|
||||||
|
" [0.4 0.08]\n",
|
||||||
|
" [0.4 0.16]\n",
|
||||||
|
" [0.4 0.24]\n",
|
||||||
|
" [0.4 0.32]\n",
|
||||||
|
" [0.4 0.4 ]\n",
|
||||||
|
" [0.4 0.48]\n",
|
||||||
|
" [0.4 0.56]\n",
|
||||||
|
" [0.4 0.64]\n",
|
||||||
|
" [0.4 0.72]\n",
|
||||||
|
" [0.4 0.8 ]]\n",
|
||||||
|
"Objective function values (numerical, theoretical): [33.17, 22.944080000000007]\n",
|
||||||
|
"Constraint violations (numerical, theoretical): [0.0, 0.0]\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"import numpy as np\n",
|
||||||
|
"from scipy.optimize import minimize\n",
|
||||||
|
"import numpy as np\n",
|
||||||
|
"\n",
|
||||||
|
"# Define Parameters\n",
|
||||||
|
"lambda_vals = np.array([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",
|
||||||
|
"N = len(lambda_vals)\n",
|
||||||
|
"B = 4.4 # Cache size\n",
|
||||||
|
"c_delta = 1 # Age linear cost\n",
|
||||||
|
"c_f = 7 # Fetching linear cost (cache miss cost)\n",
|
||||||
|
"\n"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "fcf0c13c-5b2c-457e-9aa6-8d349fcf13fa",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"import numpy as np\n",
|
||||||
|
"\n",
|
||||||
|
"def theoretical_opt(lambda_vals, B, c_f, c_delta):\n",
|
||||||
|
" \"\"\"\n",
|
||||||
|
" Perform theoretical optimization to compute optimal hit probabilities.\n",
|
||||||
|
" \n",
|
||||||
|
" Parameters:\n",
|
||||||
|
" - lambda_vals: Array of request rates.\n",
|
||||||
|
" - B: Cache size (constraint on total hit probabilities).\n",
|
||||||
|
" - c_f: Cost of fetching (cache miss cost).\n",
|
||||||
|
" - c_delta: Cost of caching (hit cost).\n",
|
||||||
|
"\n",
|
||||||
|
" Returns:\n",
|
||||||
|
" - h_optt: Optimal hit probabilities.\n",
|
||||||
|
" \"\"\"\n",
|
||||||
|
" N = len(lambda_vals)\n",
|
||||||
|
" h_optt = np.zeros(N) # Initialize optimal hit probabilities\n",
|
||||||
|
" differenc_set = np.arange(N) # Set of variables to optimize\n",
|
||||||
|
" fix_i = [] # Set of fixed variables (those already optimized)\n",
|
||||||
|
" n = N\n",
|
||||||
|
" b = B\n",
|
||||||
|
" flag = True\n",
|
||||||
|
"\n",
|
||||||
|
" while flag:\n",
|
||||||
|
" if n == 0: # If no variables left to optimize\n",
|
||||||
|
" if b > 0: # If there is leftover cache size, redistribute it\n",
|
||||||
|
" differenc_set = np.where(h_optt == 0)[0] # Find zero hit probability variables\n",
|
||||||
|
" fix_i = np.setdiff1d(np.arange(N), differenc_set)\n",
|
||||||
|
" n = len(differenc_set)\n",
|
||||||
|
" continue\n",
|
||||||
|
" else: # No variables to optimize, finalize\n",
|
||||||
|
" h_optt[differenc_set] = 0\n",
|
||||||
|
" break\n",
|
||||||
|
" \n",
|
||||||
|
" # Calculate the optimal Lagrange multiplier (mu) and hit probabilities for the set of variables\n",
|
||||||
|
" mu = max(0, (n * c_f - b * c_delta) / np.sum(1 / lambda_vals[differenc_set]))\n",
|
||||||
|
" h_optt[differenc_set] = (c_f - mu / lambda_vals[differenc_set]) / c_delta\n",
|
||||||
|
" \n",
|
||||||
|
" # If mu < 0, adjust the cache size to set mu to zero in the next iteration\n",
|
||||||
|
" if mu < 0:\n",
|
||||||
|
" b = (n * c_f / c_delta)\n",
|
||||||
|
" continue\n",
|
||||||
|
" \n",
|
||||||
|
" # Identify violations of the hit probability constraints (h > 1 or h < 0)\n",
|
||||||
|
" larger_i = np.where(h_optt > 1)[0]\n",
|
||||||
|
" smaller_i = np.where(h_optt < 0)[0]\n",
|
||||||
|
"\n",
|
||||||
|
" # If no violations, the optimal solution is reached\n",
|
||||||
|
" if len(smaller_i) == 0 and len(larger_i) == 0:\n",
|
||||||
|
" break\n",
|
||||||
|
" \n",
|
||||||
|
" # Find the furthest object from the boundary (either 0 or 1)\n",
|
||||||
|
" min_viol = 0\n",
|
||||||
|
" min_viol_i = -1\n",
|
||||||
|
" if len(smaller_i) > 0:\n",
|
||||||
|
" min_viol, min_viol_i = np.min(h_optt[smaller_i]), np.argmin(h_optt[smaller_i])\n",
|
||||||
|
"\n",
|
||||||
|
" max_viol = 0\n",
|
||||||
|
" max_viol_i = -1\n",
|
||||||
|
" if len(larger_i) > 0:\n",
|
||||||
|
" max_viol, max_viol_i = np.max(h_optt[larger_i] - 1), np.argmax(h_optt[larger_i] - 1)\n",
|
||||||
|
" \n",
|
||||||
|
" # Choose the variable with the largest violation to adjust\n",
|
||||||
|
" if max_viol > abs(min_viol):\n",
|
||||||
|
" viol_i = max_viol_i\n",
|
||||||
|
" min_viol_flag = 0\n",
|
||||||
|
" else:\n",
|
||||||
|
" viol_i = min_viol_i\n",
|
||||||
|
" min_viol_flag = 1\n",
|
||||||
|
" \n",
|
||||||
|
" # Set the furthest object to the nearest boundary (0 or 1)\n",
|
||||||
|
" if min_viol_flag:\n",
|
||||||
|
" h_optt[viol_i] = 0\n",
|
||||||
|
" else:\n",
|
||||||
|
" h_optt[viol_i] = min(1, b)\n",
|
||||||
|
" \n",
|
||||||
|
" # Update cache size and fix the selected variable\n",
|
||||||
|
" b -= h_optt[viol_i]\n",
|
||||||
|
" fix_i.append(viol_i)\n",
|
||||||
|
" differenc_set = np.setdiff1d(np.arange(N), fix_i)\n",
|
||||||
|
" n = N - len(fix_i)\n",
|
||||||
|
" \n",
|
||||||
|
" return h_optt\n",
|
||||||
|
"\n",
|
||||||
|
"\n",
|
||||||
|
"# Example usage\n",
|
||||||
|
"lambda_vals = np.array(\n"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "5d223324-d193-416a-b2c3-1e143e981a37",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"\n",
|
||||||
|
"def numerical_opt(lambda_vals, B, c_f, c_delta):\n",
|
||||||
|
" \"\"\"\n",
|
||||||
|
" Perform numerical optimization to compute optimal hit probabilities.\n",
|
||||||
|
"\n",
|
||||||
|
" Parameters:\n",
|
||||||
|
" - lambda_vals: Array of request rates.\n",
|
||||||
|
" - B: Cache size (constraint on total hit probabilities).\n",
|
||||||
|
" - c_f: Cost of fetching (cache miss cost).\n",
|
||||||
|
" - c_delta: Cost of caching (hit cost).\n",
|
||||||
|
"\n",
|
||||||
|
" Returns:\n",
|
||||||
|
" - x_opt: Optimal hit probabilities.\n",
|
||||||
|
" \"\"\"\n",
|
||||||
|
" N = len(lambda_vals) # Number of items\n",
|
||||||
|
"\n",
|
||||||
|
" # Initial guess: Even distribution of cache capacity\n",
|
||||||
|
" x_init = np.full(N, B / N)\n",
|
||||||
|
"\n",
|
||||||
|
" # Objective function\n",
|
||||||
|
" def objective(x):\n",
|
||||||
|
" return np.sum(lambda_vals * ((1 - x) * c_f + x**2 * c_delta / 2))\n",
|
||||||
|
"\n",
|
||||||
|
" # Constraint: Sum of hit probabilities <= cache size (B)\n",
|
||||||
|
" def constraint_total_hit(x):\n",
|
||||||
|
" return B - np.sum(x) # Non-negative means constraint satisfied\n",
|
||||||
|
"\n",
|
||||||
|
" # Bounds for hit probabilities: 0 <= h_i <= 1\n",
|
||||||
|
" bounds = [(0, 1) for _ in range(N)]\n",
|
||||||
|
"\n",
|
||||||
|
" # Optimization\n",
|
||||||
|
" constraints = [{'type': 'ineq', 'fun': constraint_total_hit}] # Inequality constraint\n",
|
||||||
|
" result = minimize(\n",
|
||||||
|
" objective, \n",
|
||||||
|
" x_init, \n",
|
||||||
|
" method='SLSQP', # Sequential Least Squares Quadratic Programming\n",
|
||||||
|
" bounds=bounds, \n",
|
||||||
|
" constraints=constraints, \n",
|
||||||
|
" options={'disp': True} # Set to True for optimization output\n",
|
||||||
|
" )\n",
|
||||||
|
"\n",
|
||||||
|
" # Optimal solution\n",
|
||||||
|
" if result.success:\n",
|
||||||
|
" return result.x # Optimal hit probabilities\n",
|
||||||
|
" else:\n",
|
||||||
|
" raise ValueError(\"Optimization failed: \" + result.message)\n"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "073be740-dc97-454b-87e7-2f8f93c8f137",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"\n",
|
||||||
|
"# Example usage\n",
|
||||||
|
"lambda_vals = np.array([0.03, 0.04, 0.05, 0.06, 0.07, 1, 1.1, 1.2, 1.3, 1.4, 1.5])\n",
|
||||||
|
"B = 4.4\n",
|
||||||
|
"c_f = 7\n",
|
||||||
|
"c_delta = 1\n",
|
||||||
|
"\n",
|
||||||
|
"optimal_hit_probs = numerical_opt(lambda_vals, B, c_f, c_delta)\n",
|
||||||
|
"print(\"Optimal Hit Probabilities:\", optimal_hit_probs)\n",
|
||||||
|
"\n",
|
||||||
|
"\n",
|
||||||
|
"# Optimization\n",
|
||||||
|
"h_numerical = numerical_opt(lambda_vals, B, c_f, c_delta)\n",
|
||||||
|
"h_theoretical = theoretical_opt(lambda_vals, B, c_f, c_delta)\n",
|
||||||
|
"\n",
|
||||||
|
"# Comparison\n",
|
||||||
|
"hit_opt = np.vstack((h_numerical, h_theoretical)).T # Combine for comparison\n",
|
||||||
|
"\n",
|
||||||
|
"# Objective Function Calculation\n",
|
||||||
|
"obj_1 = np.sum(lambda_vals * ((1 - h_numerical) * c_f + h_numerical**2 * c_delta / 2))\n",
|
||||||
|
"obj_2 = np.sum(lambda_vals * ((1 - h_theoretical) * c_f + h_theoretical**2 * c_delta / 2))\n",
|
||||||
|
"obj = [obj_1, obj_2]\n",
|
||||||
|
"\n",
|
||||||
|
"# Constraints\n",
|
||||||
|
"const_1 = np.sum(h_numerical) - B\n",
|
||||||
|
"const_2 = np.sum(h_theoretical) - B\n",
|
||||||
|
"constraint = [const_1, const_2]\n",
|
||||||
|
"\n",
|
||||||
|
"# Outputs\n",
|
||||||
|
"print(\"Hit probabilities (numerical and theoretical):\\n\", hit_opt)\n",
|
||||||
|
"print(\"Objective function values (numerical, theoretical):\", obj)\n",
|
||||||
|
"print(\"Constraint violations (numerical, theoretical):\", constraint)\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "graphs",
|
||||||
|
"language": "python",
|
||||||
|
"name": "graphs"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.12.7"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
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]
|
||||||
|
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
function [x_opt] = Numerical_opt(lambda,B,c_f,c_delta)
|
||||||
|
% Numerical optimization
|
||||||
|
% x_opt are the optimal hit probabilities
|
||||||
|
|
||||||
|
N = length(lambda); % Number of variables
|
||||||
|
h_init = ones(N, 1) * B / N; % Initial guess for h_i, evenly distributed
|
||||||
|
x_init=h_init;
|
||||||
|
objective1 = @(x) sum(lambda .*( (1-x)*c_f+x.^2*c_delta/2)); % Objective function
|
||||||
|
constraint1 = @(x) sum(x) - B; % cache size constraint
|
||||||
|
% constraint on hit prob. 0<=h_i<=1
|
||||||
|
nonlcon1 = @(x) deal(constraint1(x), []); %
|
||||||
|
lb = zeros(N, 1); % Lower bounds
|
||||||
|
ub = ones(N, 1); % Upper bounds
|
||||||
|
options = optimoptions('fmincon', 'Display', 'iter', 'Algorithm', 'sqp');
|
||||||
|
[x_opt, fval_h] = fmincon(objective1, x_init, [], [], [], [], lb, ub, nonlcon1, options);
|
||||||
|
end
|
||||||
|
|
||||||
@@ -0,0 +1,171 @@
|
|||||||
|
function [h_optt] = Theoritical_opt(lambda,B,c_f,c_delta)
|
||||||
|
%% Theoritical optimization
|
||||||
|
|
||||||
|
|
||||||
|
%% Iterative identification of active constraints
|
||||||
|
N=length(lambda)
|
||||||
|
flag=1;
|
||||||
|
h_optt=zeros(N,1); %optimal hit prob
|
||||||
|
differenc_set=1:N; % the set of variables to optimize
|
||||||
|
fix_i=[]; % set of variables that reached optimality and are excluded from the optimization
|
||||||
|
n=N;
|
||||||
|
b=B;
|
||||||
|
|
||||||
|
%%
|
||||||
|
while flag
|
||||||
|
if(n==0)
|
||||||
|
if(b>0) % if there is left over cache size and mu is not zero (the loop would break), redistribute it among the zero hit probability
|
||||||
|
differenc_set=find(h_optt==0)';
|
||||||
|
fix_i=setdiff(1:N,differenc_set)';
|
||||||
|
n=length(differenc_set);
|
||||||
|
continue;
|
||||||
|
else
|
||||||
|
h_optt(differenc_set)=0;
|
||||||
|
break;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
% Optimal Lagrangian mult. and hit prob. calculated theoritically for the set of variables in differenc_set
|
||||||
|
mu=max(0,(n*c_f-b*c_delta)/ sum(1./lambda(differenc_set))); %optimal lagrangian mult.
|
||||||
|
h_optt(differenc_set)=(c_f-mu./lambda(differenc_set))/c_delta %optimal hit prob
|
||||||
|
|
||||||
|
% mu has to be >=0
|
||||||
|
if(mu<0)
|
||||||
|
b=(n*c_f/c_delta); % this sets mu to zero in the next iteration
|
||||||
|
continue;
|
||||||
|
end
|
||||||
|
|
||||||
|
% check the violation of the hit_prob const
|
||||||
|
larger_i=find(h_optt>1); % h>1
|
||||||
|
smaller_i=find(h_optt<0); % h<0
|
||||||
|
|
||||||
|
% smaller=h(find(differenc_set<0))-0;
|
||||||
|
% no violation means optimal solution is reached for all objects
|
||||||
|
if(length(smaller_i)==0 && length(larger_i)==0)
|
||||||
|
% flag=0;
|
||||||
|
|
||||||
|
break;
|
||||||
|
end
|
||||||
|
|
||||||
|
% find the furthest object from the 0 boundary
|
||||||
|
min_viol=0;
|
||||||
|
min_viol_i=-1;
|
||||||
|
if(length(smaller_i)>0)
|
||||||
|
[min_viol, min_viol_i]=min(h_optt);
|
||||||
|
end
|
||||||
|
% find the furthest object from the 1 boundary
|
||||||
|
max_viol=0;
|
||||||
|
max_viol_i=-1;
|
||||||
|
if(length(larger_i)>0)
|
||||||
|
larger=h_optt-1;
|
||||||
|
[max_viol ,max_viol_i]=max(h_optt-1);
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
% compare both furthest objects from both boundaries
|
||||||
|
viol_i=min_viol_i;
|
||||||
|
min_viol_flag=1; % True if the furthest one is from the left
|
||||||
|
if(max_viol>abs(min_viol))
|
||||||
|
viol_i= max_viol_i;
|
||||||
|
min_viol_flag=0;
|
||||||
|
|
||||||
|
end
|
||||||
|
% set the furthest object to the nearest boundary
|
||||||
|
if(min_viol_flag)
|
||||||
|
h_optt(viol_i)=0;
|
||||||
|
else
|
||||||
|
h_optt(viol_i)=min(1,b);
|
||||||
|
end
|
||||||
|
|
||||||
|
%calculate the new parameters after removing the furthest object from
|
||||||
|
%the decision variables
|
||||||
|
B_new=b-(h_optt(viol_i));
|
||||||
|
b=B_new;
|
||||||
|
fix_i=[fix_i' viol_i']';
|
||||||
|
differenc_set=setdiff(1:N,fix_i) ;
|
||||||
|
n=N-length(fix_i);
|
||||||
|
|
||||||
|
|
||||||
|
% % Identify the most violating object from the right side h>1
|
||||||
|
% if(length(larger_i)>0)
|
||||||
|
% larger=h_optt-1;
|
||||||
|
% [max_viol ,max_viol_i]=max(h_optt-1); % maximum violating object
|
||||||
|
% h_optt(max_viol_i)=min(1,b); %project to the feasible range
|
||||||
|
% b=max(b-1,0); % update the cache size
|
||||||
|
% fix_i=[fix_i' max_viol_i']'; %exclude i from the set of decision variables
|
||||||
|
% differenc_set=setdiff(1:N,fix_i); % obtain the set of decision variables
|
||||||
|
% n=N-length(fix_i); % update the number of decision variables
|
||||||
|
% continue;
|
||||||
|
% end
|
||||||
|
%
|
||||||
|
% if(length(smaller_i)>0)
|
||||||
|
% [min_viol, min_viol_i]=min(h_optt);
|
||||||
|
% h_optt(min_viol_i)=0;
|
||||||
|
% fix_i=[fix_i' min_viol_i']';
|
||||||
|
% differenc_set=setdiff(1:N,fix_i) ;
|
||||||
|
% n=N-length(fix_i);
|
||||||
|
% end
|
||||||
|
%
|
||||||
|
% end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
%% Identfying the active constraints collectively
|
||||||
|
% flag=1;
|
||||||
|
% h_optt=zeros(N,1);
|
||||||
|
% differenc_set=1:N;
|
||||||
|
% fix_i=[];
|
||||||
|
% n=N;
|
||||||
|
% b=B;
|
||||||
|
% while flag
|
||||||
|
% mu=(n*c_f-b*c_delta)/ sum(1./lambda(differenc_set));
|
||||||
|
% h_optt(differenc_set)=(c_f-mu./lambda(differenc_set))/c_delta
|
||||||
|
%
|
||||||
|
% larger_i=find(h_optt>1);
|
||||||
|
% % larger=h_optt(larger_i)-1;
|
||||||
|
% smaller_i=find(h_optt<0);
|
||||||
|
% % smaller=h(find(differenc_set<0))-0;
|
||||||
|
% mult=solve_multipliers(lambda,B,c_f,c_delta,larger_i)
|
||||||
|
%
|
||||||
|
% if(length(larger_i)+length(smaller_i)==0)
|
||||||
|
% flag=0;
|
||||||
|
% break;
|
||||||
|
% end
|
||||||
|
% if(length(smaller_i)>0)
|
||||||
|
% h_optt(smaller_i)=0;
|
||||||
|
% fix_i=[fix_i' smaller_i' ]';
|
||||||
|
% differenc_set=setdiff(1:N,fix_i)
|
||||||
|
% n=N-length(fix_i);
|
||||||
|
% continue
|
||||||
|
% end
|
||||||
|
% % h_optt(smaller_i)=0;
|
||||||
|
% if(length(larger_i)>b)
|
||||||
|
% [~,index]=maxk(h_optt,b)
|
||||||
|
% h_optt(index)=1;
|
||||||
|
% B_new=b-sum(h_optt(index));
|
||||||
|
% fix_i=[fix_i' smaller_i' index']';
|
||||||
|
% else
|
||||||
|
% h_optt(larger_i)=1;
|
||||||
|
% B_new=b-sum(h_optt(larger_i));
|
||||||
|
% fix_i=[fix_i' smaller_i' larger_i']';
|
||||||
|
% end
|
||||||
|
% % mult=solve_multipliers(lambda,B,c_f,c_delta,larger_i)
|
||||||
|
%
|
||||||
|
% b=B_new;
|
||||||
|
%
|
||||||
|
% differenc_set=setdiff(1:N,fix_i)
|
||||||
|
% n=N-length(fix_i);
|
||||||
|
% end
|
||||||
|
% % h_optt=zeros(N,1);
|
||||||
|
% % h_optt(end-B+1:end)=1;
|
||||||
|
% optimal=[h_opt h_optt]
|
||||||
|
% obj_1=sum(lambda .* ((1-h_opt)*c_f+h_opt.^2*c_delta/2));
|
||||||
|
% obj_2=sum(lambda .* ((1-h_optt)*c_f+h_optt.^2*c_delta/2));
|
||||||
|
% objective=[obj_1 obj_2]
|
||||||
|
% const_1=sum(h_opt)-B;
|
||||||
|
% const_2=sum(h_optt)-B;
|
||||||
|
% constraint=[const_1 const_2]
|
||||||
|
%
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
@@ -0,0 +1,171 @@
|
|||||||
|
function [h_optt] = Theoritical_opt(lambda,B,c_f,c_delta)
|
||||||
|
%% Theoritical optimization
|
||||||
|
|
||||||
|
|
||||||
|
%% Iterative identification of active constraints
|
||||||
|
N=length(lambda)
|
||||||
|
flag=1;
|
||||||
|
h_optt=zeros(N,1); %optimal hit prob
|
||||||
|
differenc_set=1:N; % the set of variables to optimize
|
||||||
|
fix_i=[]; % set of variables that reached optimality and are excluded from the optimization
|
||||||
|
n=N;
|
||||||
|
b=B;
|
||||||
|
|
||||||
|
%%
|
||||||
|
while flag
|
||||||
|
if(n==0)
|
||||||
|
if(b>0) % if there is left over cache size and mu is not zero (the loop would break), redistribute it among the zero hit probability
|
||||||
|
differenc_set=find(h_optt==0)';
|
||||||
|
fix_i=setdiff(1:N,differenc_set)';
|
||||||
|
n=length(differenc_set);
|
||||||
|
continue;
|
||||||
|
else
|
||||||
|
h_optt(differenc_set)=0;
|
||||||
|
break;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
% Optimal Lagrangian mult. and hit prob. calculated theoritically for the set of variables in differenc_set
|
||||||
|
mu=max(0,(n*c_f-b*c_delta)/ sum(1./lambda(differenc_set))); %optimal lagrangian mult.
|
||||||
|
h_optt(differenc_set)=(c_f-mu./lambda(differenc_set))/c_delta %optimal hit prob
|
||||||
|
|
||||||
|
% mu has to be >=0
|
||||||
|
if(mu<0)
|
||||||
|
b=(n*c_f/c_delta); % this sets mu to zero in the next iteration
|
||||||
|
continue;
|
||||||
|
end
|
||||||
|
|
||||||
|
% check the violation of the hit_prob const
|
||||||
|
larger_i=find(h_optt>1); % h>1
|
||||||
|
smaller_i=find(h_optt<0); % h<0
|
||||||
|
|
||||||
|
% smaller=h(find(differenc_set<0))-0;
|
||||||
|
% no violation means optimal solution is reached for all objects
|
||||||
|
if(length(smaller_i)==0 && length(larger_i)==0)
|
||||||
|
% flag=0;
|
||||||
|
|
||||||
|
break;
|
||||||
|
end
|
||||||
|
|
||||||
|
% find the furthest object from the 0 boundary
|
||||||
|
min_viol=0;
|
||||||
|
min_viol_i=-1;
|
||||||
|
if(length(smaller_i)>0)
|
||||||
|
[min_viol, min_viol_i]=min(h_optt);
|
||||||
|
end
|
||||||
|
% find the furthest object from the 1 boundary
|
||||||
|
max_viol=0;
|
||||||
|
max_viol_i=-1;
|
||||||
|
if(length(larger_i)>0)
|
||||||
|
larger=h_optt-1;
|
||||||
|
[max_viol ,max_viol_i]=max(h_optt-1);
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
% compare both furthest objects from both boundaries
|
||||||
|
viol_i=min_viol_i;
|
||||||
|
min_viol_flag=1; % True if the furthest one is from the left
|
||||||
|
if(max_viol>abs(min_viol))
|
||||||
|
viol_i= max_viol_i;
|
||||||
|
min_viol_flag=0;
|
||||||
|
|
||||||
|
end
|
||||||
|
% set the furthest object to the nearest boundary
|
||||||
|
if(min_viol_flag)
|
||||||
|
h_optt(viol_i)=0;
|
||||||
|
else
|
||||||
|
h_optt(viol_i)=min(1,b);
|
||||||
|
end
|
||||||
|
|
||||||
|
%calculate the new parameters after removing the furthest object from
|
||||||
|
%the decision variables
|
||||||
|
B_new=b-(h_optt(viol_i));
|
||||||
|
b=B_new;
|
||||||
|
fix_i=[fix_i' viol_i']';
|
||||||
|
differenc_set=setdiff(1:N,fix_i) ;
|
||||||
|
n=N-length(fix_i);
|
||||||
|
|
||||||
|
|
||||||
|
% % Identify the most violating object from the right side h>1
|
||||||
|
% if(length(larger_i)>0)
|
||||||
|
% larger=h_optt-1;
|
||||||
|
% [max_viol ,max_viol_i]=max(h_optt-1); % maximum violating object
|
||||||
|
% h_optt(max_viol_i)=min(1,b); %project to the feasible range
|
||||||
|
% b=max(b-1,0); % update the cache size
|
||||||
|
% fix_i=[fix_i' max_viol_i']'; %exclude i from the set of decision variables
|
||||||
|
% differenc_set=setdiff(1:N,fix_i); % obtain the set of decision variables
|
||||||
|
% n=N-length(fix_i); % update the number of decision variables
|
||||||
|
% continue;
|
||||||
|
% end
|
||||||
|
%
|
||||||
|
% if(length(smaller_i)>0)
|
||||||
|
% [min_viol, min_viol_i]=min(h_optt);
|
||||||
|
% h_optt(min_viol_i)=0;
|
||||||
|
% fix_i=[fix_i' min_viol_i']';
|
||||||
|
% differenc_set=setdiff(1:N,fix_i) ;
|
||||||
|
% n=N-length(fix_i);
|
||||||
|
% end
|
||||||
|
%
|
||||||
|
% end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
%% Identfying the active constraints collectively
|
||||||
|
% flag=1;
|
||||||
|
% h_optt=zeros(N,1);
|
||||||
|
% differenc_set=1:N;
|
||||||
|
% fix_i=[];
|
||||||
|
% n=N;
|
||||||
|
% b=B;
|
||||||
|
% while flag
|
||||||
|
% mu=(n*c_f-b*c_delta)/ sum(1./lambda(differenc_set));
|
||||||
|
% h_optt(differenc_set)=(c_f-mu./lambda(differenc_set))/c_delta
|
||||||
|
%
|
||||||
|
% larger_i=find(h_optt>1);
|
||||||
|
% % larger=h_optt(larger_i)-1;
|
||||||
|
% smaller_i=find(h_optt<0);
|
||||||
|
% % smaller=h(find(differenc_set<0))-0;
|
||||||
|
% mult=solve_multipliers(lambda,B,c_f,c_delta,larger_i)
|
||||||
|
%
|
||||||
|
% if(length(larger_i)+length(smaller_i)==0)
|
||||||
|
% flag=0;
|
||||||
|
% break;
|
||||||
|
% end
|
||||||
|
% if(length(smaller_i)>0)
|
||||||
|
% h_optt(smaller_i)=0;
|
||||||
|
% fix_i=[fix_i' smaller_i' ]';
|
||||||
|
% differenc_set=setdiff(1:N,fix_i)
|
||||||
|
% n=N-length(fix_i);
|
||||||
|
% continue
|
||||||
|
% end
|
||||||
|
% % h_optt(smaller_i)=0;
|
||||||
|
% if(length(larger_i)>b)
|
||||||
|
% [~,index]=maxk(h_optt,b)
|
||||||
|
% h_optt(index)=1;
|
||||||
|
% B_new=b-sum(h_optt(index));
|
||||||
|
% fix_i=[fix_i' smaller_i' index']';
|
||||||
|
% else
|
||||||
|
% h_optt(larger_i)=1;
|
||||||
|
% B_new=b-sum(h_optt(larger_i));
|
||||||
|
% fix_i=[fix_i' smaller_i' larger_i']';
|
||||||
|
% end
|
||||||
|
% % mult=solve_multipliers(lambda,B,c_f,c_delta,larger_i)
|
||||||
|
%
|
||||||
|
% b=B_new;
|
||||||
|
%
|
||||||
|
% differenc_set=setdiff(1:N,fix_i)
|
||||||
|
% n=N-length(fix_i);
|
||||||
|
% end
|
||||||
|
% % h_optt=zeros(N,1);
|
||||||
|
% % h_optt(end-B+1:end)=1;
|
||||||
|
% optimal=[h_opt h_optt]
|
||||||
|
% obj_1=sum(lambda .* ((1-h_opt)*c_f+h_opt.^2*c_delta/2));
|
||||||
|
% obj_2=sum(lambda .* ((1-h_optt)*c_f+h_optt.^2*c_delta/2));
|
||||||
|
% objective=[obj_1 obj_2]
|
||||||
|
% const_1=sum(h_opt)-B;
|
||||||
|
% const_2=sum(h_optt)-B;
|
||||||
|
% constraint=[const_1 const_2]
|
||||||
|
%
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
248
01_nb_cncf_optimization/matlab/Main.ipynb
Normal file
248
01_nb_cncf_optimization/matlab/Main.ipynb
Normal file
@@ -0,0 +1,248 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 1,
|
||||||
|
"id": "d0996120-bb17-4476-b912-ce155100b2cb",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"import numpy as np\n",
|
||||||
|
"from scipy.optimize import minimize\n",
|
||||||
|
"import numpy as np\n",
|
||||||
|
"\n",
|
||||||
|
"# Define Parameters\n",
|
||||||
|
"lambda_vals = np.array([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",
|
||||||
|
"N = len(lambda_vals)\n",
|
||||||
|
"B = 4.4 # Cache size\n",
|
||||||
|
"c_delta = 1 # Age linear cost\n",
|
||||||
|
"c_f = 7 # Fetching linear cost (caching miss cost)\n"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 2,
|
||||||
|
"id": "fcf0c13c-5b2c-457e-9aa6-8d349fcf13fa",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"import numpy as np\n",
|
||||||
|
"\n",
|
||||||
|
"def theoretical_opt(lambda_vals, B, c_f, c_delta):\n",
|
||||||
|
" \"\"\"\n",
|
||||||
|
" Perform theoretical optimization to compute optimal hit probabilities.\n",
|
||||||
|
" \n",
|
||||||
|
" Parameters:\n",
|
||||||
|
" - lambda_vals: Array of request rates.\n",
|
||||||
|
" - B: Cache size (constraint on total hit probabilities).\n",
|
||||||
|
" - c_f: Cost of fetching (cache miss cost).\n",
|
||||||
|
" - c_delta: Cost of caching (hit cost).\n",
|
||||||
|
"\n",
|
||||||
|
" Returns:\n",
|
||||||
|
" - h_optt: Optimal hit probabilities.\n",
|
||||||
|
" \"\"\"\n",
|
||||||
|
" N = len(lambda_vals)\n",
|
||||||
|
" h_optt = np.zeros(N) # Initialize optimal hit probabilities\n",
|
||||||
|
" differenc_set = np.arange(N) # Set of variables to optimize\n",
|
||||||
|
" fix_i = [] # Set of fixed variables (those already optimized)\n",
|
||||||
|
" n = N\n",
|
||||||
|
" b = B\n",
|
||||||
|
" flag = True\n",
|
||||||
|
"\n",
|
||||||
|
" while flag:\n",
|
||||||
|
" if n == 0: # If no variables left to optimize\n",
|
||||||
|
" if b > 0: # If there is leftover cache size, redistribute it\n",
|
||||||
|
" differenc_set = np.where(h_optt == 0)[0] # Find zero hit probability variables\n",
|
||||||
|
" fix_i = np.setdiff1d(np.arange(N), differenc_set)\n",
|
||||||
|
" n = len(differenc_set)\n",
|
||||||
|
" continue\n",
|
||||||
|
" else: # No variables to optimize, finalize\n",
|
||||||
|
" h_optt[differenc_set] = 0\n",
|
||||||
|
" break\n",
|
||||||
|
" \n",
|
||||||
|
" # Calculate the optimal Lagrange multiplier (mu) and hit probabilities for the set of variables\n",
|
||||||
|
" mu = max(0, (n * c_f - b * c_delta) / np.sum(1 / lambda_vals[differenc_set]))\n",
|
||||||
|
" h_optt[differenc_set] = (c_f - mu / lambda_vals[differenc_set]) / c_delta\n",
|
||||||
|
" \n",
|
||||||
|
" # If mu < 0, adjust the cache size to set mu to zero in the next iteration\n",
|
||||||
|
" if mu < 0:\n",
|
||||||
|
" b = (n * c_f / c_delta)\n",
|
||||||
|
" continue\n",
|
||||||
|
" \n",
|
||||||
|
" # Identify violations of the hit probability constraints (h > 1 or h < 0)\n",
|
||||||
|
" larger_i = np.where(h_optt > 1)[0]\n",
|
||||||
|
" smaller_i = np.where(h_optt < 0)[0]\n",
|
||||||
|
"\n",
|
||||||
|
" # If no violations, the optimal solution is reached\n",
|
||||||
|
" if len(smaller_i) == 0 and len(larger_i) == 0:\n",
|
||||||
|
" break\n",
|
||||||
|
" \n",
|
||||||
|
" # Find the furthest object from the boundary (either 0 or 1)\n",
|
||||||
|
" min_viol = 0\n",
|
||||||
|
" min_viol_i = -1\n",
|
||||||
|
" if len(smaller_i) > 0:\n",
|
||||||
|
" min_viol, min_viol_i = np.min(h_optt[smaller_i]), np.argmin(h_optt[smaller_i])\n",
|
||||||
|
"\n",
|
||||||
|
" max_viol = 0\n",
|
||||||
|
" max_viol_i = -1\n",
|
||||||
|
" if len(larger_i) > 0:\n",
|
||||||
|
" max_viol, max_viol_i = np.max(h_optt[larger_i] - 1), np.argmax(h_optt[larger_i] - 1)\n",
|
||||||
|
" \n",
|
||||||
|
" # Choose the variable with the largest violation to adjust\n",
|
||||||
|
" if max_viol > abs(min_viol):\n",
|
||||||
|
" viol_i = max_viol_i\n",
|
||||||
|
" min_viol_flag = 0\n",
|
||||||
|
" else:\n",
|
||||||
|
" viol_i = min_viol_i\n",
|
||||||
|
" min_viol_flag = 1\n",
|
||||||
|
" \n",
|
||||||
|
" # Set the furthest object to the nearest boundary (0 or 1)\n",
|
||||||
|
" if min_viol_flag:\n",
|
||||||
|
" h_optt[viol_i] = 0\n",
|
||||||
|
" else:\n",
|
||||||
|
" h_optt[viol_i] = min(1, b)\n",
|
||||||
|
" \n",
|
||||||
|
" # Update cache size and fix the selected variable\n",
|
||||||
|
" b -= h_optt[viol_i]\n",
|
||||||
|
" fix_i.append(viol_i)\n",
|
||||||
|
" differenc_set = np.setdiff1d(np.arange(N), fix_i)\n",
|
||||||
|
" n = N - len(fix_i)\n",
|
||||||
|
" \n",
|
||||||
|
" return h_optt"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 3,
|
||||||
|
"id": "5d223324-d193-416a-b2c3-1e143e981a37",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"\n",
|
||||||
|
"def numerical_opt(lambda_vals, B, c_f, c_delta):\n",
|
||||||
|
" \"\"\"\n",
|
||||||
|
" Perform numerical optimization to compute optimal hit probabilities.\n",
|
||||||
|
"\n",
|
||||||
|
" Parameters:\n",
|
||||||
|
" - lambda_vals: Array of request rates.\n",
|
||||||
|
" - B: Cache size (constraint on total hit probabilities).\n",
|
||||||
|
" - c_f: Cost of fetching (cache miss cost).\n",
|
||||||
|
" - c_delta: Cost of caching (hit cost).\n",
|
||||||
|
"\n",
|
||||||
|
" Returns:\n",
|
||||||
|
" - x_opt: Optimal hit probabilities.\n",
|
||||||
|
" \"\"\"\n",
|
||||||
|
" N = len(lambda_vals) # Number of items\n",
|
||||||
|
"\n",
|
||||||
|
" # Initial guess: Even distribution of cache capacity\n",
|
||||||
|
" x_init = np.full(N, B / N)\n",
|
||||||
|
"\n",
|
||||||
|
" # Objective function\n",
|
||||||
|
" def objective(x):\n",
|
||||||
|
" return np.sum(lambda_vals * ((1 - x) * c_f + x**2 * c_delta / 2))\n",
|
||||||
|
"\n",
|
||||||
|
" # Constraint: Sum of hit probabilities <= cache size (B)\n",
|
||||||
|
" def constraint_total_hit(x):\n",
|
||||||
|
" return B - np.sum(x) # Non-negative means constraint satisfied\n",
|
||||||
|
"\n",
|
||||||
|
" # Bounds for hit probabilities: 0 <= h_i <= 1\n",
|
||||||
|
" bounds = [(0, 1) for _ in range(N)]\n",
|
||||||
|
"\n",
|
||||||
|
" # Optimization\n",
|
||||||
|
" constraints = [{'type': 'ineq', 'fun': constraint_total_hit}] # Inequality constraint\n",
|
||||||
|
" result = minimize(\n",
|
||||||
|
" objective, \n",
|
||||||
|
" x_init, \n",
|
||||||
|
" method='SLSQP', # Sequential Least Squares Quadratic Programming\n",
|
||||||
|
" bounds=bounds, \n",
|
||||||
|
" constraints=constraints, \n",
|
||||||
|
" options={'disp': True} # Set to True for optimization output\n",
|
||||||
|
" )\n",
|
||||||
|
"\n",
|
||||||
|
" # Optimal solution\n",
|
||||||
|
" if result.success:\n",
|
||||||
|
" return result.x # Optimal hit probabilities\n",
|
||||||
|
" else:\n",
|
||||||
|
" raise ValueError(\"Optimization failed: \" + result.message)\n"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 4,
|
||||||
|
"id": "073be740-dc97-454b-87e7-2f8f93c8f137",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"Optimization terminated successfully (Exit mode 0)\n",
|
||||||
|
" Current function value: 16.15721739129548\n",
|
||||||
|
" Iterations: 4\n",
|
||||||
|
" Function evaluations: 48\n",
|
||||||
|
" Gradient evaluations: 4\n",
|
||||||
|
"Hit probabilities (numerical and theoretical):\n",
|
||||||
|
" [[0.00000000e+00 0.00000000e+00]\n",
|
||||||
|
" [0.00000000e+00 0.00000000e+00]\n",
|
||||||
|
" [0.00000000e+00 0.00000000e+00]\n",
|
||||||
|
" [0.00000000e+00 0.00000000e+00]\n",
|
||||||
|
" [0.00000000e+00 0.00000000e+00]\n",
|
||||||
|
" [4.58923826e-13 1.00000000e+00]\n",
|
||||||
|
" [4.26087031e-01 0.00000000e+00]\n",
|
||||||
|
" [9.73912969e-01 4.00000000e-01]\n",
|
||||||
|
" [1.00000000e+00 0.00000000e+00]\n",
|
||||||
|
" [1.00000000e+00 0.00000000e+00]\n",
|
||||||
|
" [1.00000000e+00 0.00000000e+00]]\n",
|
||||||
|
"Objective function values (numerical, theoretical): [16.15721739129548, 44.486]\n",
|
||||||
|
"Constraint violations (numerical, theoretical): [1.241673430740775e-12, -3.0]\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"\n",
|
||||||
|
"# Optimization\n",
|
||||||
|
"h_numerical = numerical_opt(lambda_vals, B, c_f, c_delta)\n",
|
||||||
|
"h_theoretical = theoretical_opt(lambda_vals, B, c_f, c_delta)\n",
|
||||||
|
"\n",
|
||||||
|
"# Comparison of Hit Probabilities\n",
|
||||||
|
"hit_opt = np.vstack((h_numerical, h_theoretical)).T # Combine numerical and theoretical hit probabilities\n",
|
||||||
|
"\n",
|
||||||
|
"# Objective Function Calculation\n",
|
||||||
|
"obj_1 = np.sum(lambda_vals * ((1 - h_numerical) * c_f + h_numerical**2 * c_delta / 2))\n",
|
||||||
|
"obj_2 = np.sum(lambda_vals * ((1 - h_theoretical) * c_f + h_theoretical**2 * c_delta / 2))\n",
|
||||||
|
"obj = [obj_1, obj_2] # Store objective function values for both methods\n",
|
||||||
|
"\n",
|
||||||
|
"# Constraints\n",
|
||||||
|
"const_1 = np.sum(h_numerical) - B\n",
|
||||||
|
"const_2 = np.sum(h_theoretical) - B\n",
|
||||||
|
"constraint = [const_1, const_2] # Check if the cache size constraint is satisfied\n",
|
||||||
|
"\n",
|
||||||
|
"# Outputs\n",
|
||||||
|
"print(\"Hit probabilities (numerical and theoretical):\\n\", hit_opt)\n",
|
||||||
|
"print(\"Objective function values (numerical, theoretical):\", obj)\n",
|
||||||
|
"print(\"Constraint violations (numerical, theoretical):\", constraint)"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "graphs",
|
||||||
|
"language": "python",
|
||||||
|
"name": "graphs"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.12.7"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
||||||
27
01_nb_cncf_optimization/matlab/Main.m
Normal file
27
01_nb_cncf_optimization/matlab/Main.m
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
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]
|
||||||
|
|
||||||
17
01_nb_cncf_optimization/matlab/Numerical_opt.m
Normal file
17
01_nb_cncf_optimization/matlab/Numerical_opt.m
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
function [x_opt] = Numerical_opt(lambda,B,c_f,c_delta)
|
||||||
|
% Numerical optimization
|
||||||
|
% x_opt are the optimal hit probabilities
|
||||||
|
|
||||||
|
N = length(lambda); % Number of variables
|
||||||
|
h_init = ones(N, 1) * B / N; % Initial guess for h_i, evenly distributed
|
||||||
|
x_init=h_init;
|
||||||
|
objective1 = @(x) sum(lambda .*( (1-x)*c_f+x.^2*c_delta/2)); % Objective function
|
||||||
|
constraint1 = @(x) sum(x) - B; % cache size constraint
|
||||||
|
% constraint on hit prob. 0<=h_i<=1
|
||||||
|
nonlcon1 = @(x) deal(constraint1(x), []); %
|
||||||
|
lb = zeros(N, 1); % Lower bounds
|
||||||
|
ub = ones(N, 1); % Upper bounds
|
||||||
|
options = optimoptions('fmincon', 'Display', 'iter', 'Algorithm', 'sqp');
|
||||||
|
[x_opt, fval_h] = fmincon(objective1, x_init, [], [], [], [], lb, ub, nonlcon1, options);
|
||||||
|
end
|
||||||
|
|
||||||
87
01_nb_cncf_optimization/matlab/Theoritical_opt-Copy1.m
Normal file
87
01_nb_cncf_optimization/matlab/Theoritical_opt-Copy1.m
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
function [h_optt] = Theoritical_opt(lambda,B,c_f,c_delta)
|
||||||
|
%% Theoritical optimization
|
||||||
|
|
||||||
|
|
||||||
|
%% Iterative identification of active constraints
|
||||||
|
N=length(lambda)
|
||||||
|
flag=1;
|
||||||
|
h_optt=zeros(N,1); %optimal hit prob
|
||||||
|
differenc_set=1:N; % the set of variables to optimize
|
||||||
|
fix_i=[]; % set of variables that reached optimality and are excluded from the optimization
|
||||||
|
n=N;
|
||||||
|
b=B;
|
||||||
|
|
||||||
|
%%
|
||||||
|
while flag
|
||||||
|
if(n==0)
|
||||||
|
if(b>0) % if there is left over cache size and mu is not zero (the loop would break), redistribute it among the zero hit probability
|
||||||
|
differenc_set=find(h_optt==0)';
|
||||||
|
fix_i=setdiff(1:N,differenc_set)';
|
||||||
|
n=length(differenc_set);
|
||||||
|
continue;
|
||||||
|
else
|
||||||
|
h_optt(differenc_set)=0;
|
||||||
|
break;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
% Optimal Lagrangian mult. and hit prob. calculated theoritically for the set of variables in differenc_set
|
||||||
|
mu=max(0,(n*c_f-b*c_delta)/ sum(1./lambda(differenc_set))); %optimal lagrangian mult.
|
||||||
|
h_optt(differenc_set)=(c_f-mu./lambda(differenc_set))/c_delta %optimal hit prob
|
||||||
|
|
||||||
|
% mu has to be >=0
|
||||||
|
if(mu<0)
|
||||||
|
b=(n*c_f/c_delta); % this sets mu to zero in the next iteration
|
||||||
|
continue;
|
||||||
|
end
|
||||||
|
|
||||||
|
% check the violation of the hit_prob const
|
||||||
|
larger_i=find(h_optt>1); % h>1
|
||||||
|
smaller_i=find(h_optt<0); % h<0
|
||||||
|
|
||||||
|
if(length(smaller_i)==0 && length(larger_i)==0)
|
||||||
|
|
||||||
|
|
||||||
|
break;
|
||||||
|
end
|
||||||
|
|
||||||
|
% find the furthest object from the 0 boundary
|
||||||
|
min_viol=0;
|
||||||
|
min_viol_i=-1;
|
||||||
|
if(length(smaller_i)>0)
|
||||||
|
[min_viol, min_viol_i]=min(h_optt);
|
||||||
|
end
|
||||||
|
% find the furthest object from the 1 boundary
|
||||||
|
max_viol=0;
|
||||||
|
max_viol_i=-1;
|
||||||
|
if(length(larger_i)>0)
|
||||||
|
larger=h_optt-1;
|
||||||
|
[max_viol ,max_viol_i]=max(h_optt-1);
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
% compare both furthest objects from both boundaries
|
||||||
|
viol_i=min_viol_i;
|
||||||
|
min_viol_flag=1; % True if the furthest one is from the left
|
||||||
|
if(max_viol>abs(min_viol))
|
||||||
|
viol_i= max_viol_i;
|
||||||
|
min_viol_flag=0;
|
||||||
|
|
||||||
|
end
|
||||||
|
% set the furthest object to the nearest boundary
|
||||||
|
if(min_viol_flag)
|
||||||
|
h_optt(viol_i)=0;
|
||||||
|
else
|
||||||
|
h_optt(viol_i)=min(1,b);
|
||||||
|
end
|
||||||
|
|
||||||
|
%calculate the new parameters after removing the furthest object from
|
||||||
|
%the decision variables
|
||||||
|
B_new=b-(h_optt(viol_i));
|
||||||
|
b=B_new;
|
||||||
|
fix_i=[fix_i' viol_i']';
|
||||||
|
differenc_set=setdiff(1:N,fix_i) ;
|
||||||
|
n=N-length(fix_i);
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
171
01_nb_cncf_optimization/matlab/Theoritical_opt.m
Normal file
171
01_nb_cncf_optimization/matlab/Theoritical_opt.m
Normal file
@@ -0,0 +1,171 @@
|
|||||||
|
function [h_optt] = Theoritical_opt(lambda,B,c_f,c_delta)
|
||||||
|
%% Theoritical optimization
|
||||||
|
|
||||||
|
|
||||||
|
%% Iterative identification of active constraints
|
||||||
|
N=length(lambda)
|
||||||
|
flag=1;
|
||||||
|
h_optt=zeros(N,1); %optimal hit prob
|
||||||
|
differenc_set=1:N; % the set of variables to optimize
|
||||||
|
fix_i=[]; % set of variables that reached optimality and are excluded from the optimization
|
||||||
|
n=N;
|
||||||
|
b=B;
|
||||||
|
|
||||||
|
%%
|
||||||
|
while flag
|
||||||
|
if(n==0)
|
||||||
|
if(b>0) % if there is left over cache size and mu is not zero (the loop would break), redistribute it among the zero hit probability
|
||||||
|
differenc_set=find(h_optt==0)';
|
||||||
|
fix_i=setdiff(1:N,differenc_set)';
|
||||||
|
n=length(differenc_set);
|
||||||
|
continue;
|
||||||
|
else
|
||||||
|
h_optt(differenc_set)=0;
|
||||||
|
break;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
% Optimal Lagrangian mult. and hit prob. calculated theoritically for the set of variables in differenc_set
|
||||||
|
mu=max(0,(n*c_f-b*c_delta)/ sum(1./lambda(differenc_set))); %optimal lagrangian mult.
|
||||||
|
h_optt(differenc_set)=(c_f-mu./lambda(differenc_set))/c_delta %optimal hit prob
|
||||||
|
|
||||||
|
% mu has to be >=0
|
||||||
|
if(mu<0)
|
||||||
|
b=(n*c_f/c_delta); % this sets mu to zero in the next iteration
|
||||||
|
continue;
|
||||||
|
end
|
||||||
|
|
||||||
|
% check the violation of the hit_prob const
|
||||||
|
larger_i=find(h_optt>1); % h>1
|
||||||
|
smaller_i=find(h_optt<0); % h<0
|
||||||
|
|
||||||
|
% smaller=h(find(differenc_set<0))-0;
|
||||||
|
% no violation means optimal solution is reached for all objects
|
||||||
|
if(length(smaller_i)==0 && length(larger_i)==0)
|
||||||
|
% flag=0;
|
||||||
|
|
||||||
|
break;
|
||||||
|
end
|
||||||
|
|
||||||
|
% find the furthest object from the 0 boundary
|
||||||
|
min_viol=0;
|
||||||
|
min_viol_i=-1;
|
||||||
|
if(length(smaller_i)>0)
|
||||||
|
[min_viol, min_viol_i]=min(h_optt);
|
||||||
|
end
|
||||||
|
% find the furthest object from the 1 boundary
|
||||||
|
max_viol=0;
|
||||||
|
max_viol_i=-1;
|
||||||
|
if(length(larger_i)>0)
|
||||||
|
larger=h_optt-1;
|
||||||
|
[max_viol ,max_viol_i]=max(h_optt-1);
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
% compare both furthest objects from both boundaries
|
||||||
|
viol_i=min_viol_i;
|
||||||
|
min_viol_flag=1; % True if the furthest one is from the left
|
||||||
|
if(max_viol>abs(min_viol))
|
||||||
|
viol_i= max_viol_i;
|
||||||
|
min_viol_flag=0;
|
||||||
|
|
||||||
|
end
|
||||||
|
% set the furthest object to the nearest boundary
|
||||||
|
if(min_viol_flag)
|
||||||
|
h_optt(viol_i)=0;
|
||||||
|
else
|
||||||
|
h_optt(viol_i)=min(1,b);
|
||||||
|
end
|
||||||
|
|
||||||
|
%calculate the new parameters after removing the furthest object from
|
||||||
|
%the decision variables
|
||||||
|
B_new=b-(h_optt(viol_i));
|
||||||
|
b=B_new;
|
||||||
|
fix_i=[fix_i' viol_i']';
|
||||||
|
differenc_set=setdiff(1:N,fix_i) ;
|
||||||
|
n=N-length(fix_i);
|
||||||
|
|
||||||
|
|
||||||
|
% % Identify the most violating object from the right side h>1
|
||||||
|
% if(length(larger_i)>0)
|
||||||
|
% larger=h_optt-1;
|
||||||
|
% [max_viol ,max_viol_i]=max(h_optt-1); % maximum violating object
|
||||||
|
% h_optt(max_viol_i)=min(1,b); %project to the feasible range
|
||||||
|
% b=max(b-1,0); % update the cache size
|
||||||
|
% fix_i=[fix_i' max_viol_i']'; %exclude i from the set of decision variables
|
||||||
|
% differenc_set=setdiff(1:N,fix_i); % obtain the set of decision variables
|
||||||
|
% n=N-length(fix_i); % update the number of decision variables
|
||||||
|
% continue;
|
||||||
|
% end
|
||||||
|
%
|
||||||
|
% if(length(smaller_i)>0)
|
||||||
|
% [min_viol, min_viol_i]=min(h_optt);
|
||||||
|
% h_optt(min_viol_i)=0;
|
||||||
|
% fix_i=[fix_i' min_viol_i']';
|
||||||
|
% differenc_set=setdiff(1:N,fix_i) ;
|
||||||
|
% n=N-length(fix_i);
|
||||||
|
% end
|
||||||
|
%
|
||||||
|
% end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
%% Identfying the active constraints collectively
|
||||||
|
% flag=1;
|
||||||
|
% h_optt=zeros(N,1);
|
||||||
|
% differenc_set=1:N;
|
||||||
|
% fix_i=[];
|
||||||
|
% n=N;
|
||||||
|
% b=B;
|
||||||
|
% while flag
|
||||||
|
% mu=(n*c_f-b*c_delta)/ sum(1./lambda(differenc_set));
|
||||||
|
% h_optt(differenc_set)=(c_f-mu./lambda(differenc_set))/c_delta
|
||||||
|
%
|
||||||
|
% larger_i=find(h_optt>1);
|
||||||
|
% % larger=h_optt(larger_i)-1;
|
||||||
|
% smaller_i=find(h_optt<0);
|
||||||
|
% % smaller=h(find(differenc_set<0))-0;
|
||||||
|
% mult=solve_multipliers(lambda,B,c_f,c_delta,larger_i)
|
||||||
|
%
|
||||||
|
% if(length(larger_i)+length(smaller_i)==0)
|
||||||
|
% flag=0;
|
||||||
|
% break;
|
||||||
|
% end
|
||||||
|
% if(length(smaller_i)>0)
|
||||||
|
% h_optt(smaller_i)=0;
|
||||||
|
% fix_i=[fix_i' smaller_i' ]';
|
||||||
|
% differenc_set=setdiff(1:N,fix_i)
|
||||||
|
% n=N-length(fix_i);
|
||||||
|
% continue
|
||||||
|
% end
|
||||||
|
% % h_optt(smaller_i)=0;
|
||||||
|
% if(length(larger_i)>b)
|
||||||
|
% [~,index]=maxk(h_optt,b)
|
||||||
|
% h_optt(index)=1;
|
||||||
|
% B_new=b-sum(h_optt(index));
|
||||||
|
% fix_i=[fix_i' smaller_i' index']';
|
||||||
|
% else
|
||||||
|
% h_optt(larger_i)=1;
|
||||||
|
% B_new=b-sum(h_optt(larger_i));
|
||||||
|
% fix_i=[fix_i' smaller_i' larger_i']';
|
||||||
|
% end
|
||||||
|
% % mult=solve_multipliers(lambda,B,c_f,c_delta,larger_i)
|
||||||
|
%
|
||||||
|
% b=B_new;
|
||||||
|
%
|
||||||
|
% differenc_set=setdiff(1:N,fix_i)
|
||||||
|
% n=N-length(fix_i);
|
||||||
|
% end
|
||||||
|
% % h_optt=zeros(N,1);
|
||||||
|
% % h_optt(end-B+1:end)=1;
|
||||||
|
% optimal=[h_opt h_optt]
|
||||||
|
% obj_1=sum(lambda .* ((1-h_opt)*c_f+h_opt.^2*c_delta/2));
|
||||||
|
% obj_2=sum(lambda .* ((1-h_optt)*c_f+h_optt.^2*c_delta/2));
|
||||||
|
% objective=[obj_1 obj_2]
|
||||||
|
% const_1=sum(h_opt)-B;
|
||||||
|
% const_2=sum(h_optt)-B;
|
||||||
|
% constraint=[const_1 const_2]
|
||||||
|
%
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
45757
01_nb_cncf_optimization/notes_code.excalidraw
Normal file
45757
01_nb_cncf_optimization/notes_code.excalidraw
Normal file
File diff suppressed because one or more lines are too long
101998
01_nb_cncf_optimization/notes_paper.excalidraw
Normal file
101998
01_nb_cncf_optimization/notes_paper.excalidraw
Normal file
File diff suppressed because one or more lines are too long
1721291
01_nb_cncf_optimization/objective_grid-search_multi-core.csv
Normal file
1721291
01_nb_cncf_optimization/objective_grid-search_multi-core.csv
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
101
calculated.csv
Normal file
101
calculated.csv
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
lambda,optimal_hitrates,optimal_TTL
|
||||||
|
2.0000,0.0513,0.0263
|
||||||
|
2.0000,0.0513,0.0263
|
||||||
|
5.0000,0.4000,0.1022
|
||||||
|
3.0000,0.2254,0.0851
|
||||||
|
1.0000,0,0
|
||||||
|
1.0000,0,0
|
||||||
|
39.0000,0.7852,0.0394
|
||||||
|
1.0000,0,0
|
||||||
|
3.0000,0.2254,0.0851
|
||||||
|
1.0000,0,0
|
||||||
|
1.0000,0,0
|
||||||
|
1.0000,0,0
|
||||||
|
3.0000,0.2254,0.0851
|
||||||
|
1.0000,0,0
|
||||||
|
1.0000,0,0
|
||||||
|
1.0000,0,0
|
||||||
|
1.0000,0,0
|
||||||
|
1.0000,0,0
|
||||||
|
15.0000,0.6536,0.0707
|
||||||
|
1.0000,0,0
|
||||||
|
1.0000,0,0
|
||||||
|
1.0000,0,0
|
||||||
|
17.0000,0.6746,0.0660
|
||||||
|
1.0000,0,0
|
||||||
|
1.0000,0,0
|
||||||
|
1.0000,0,0
|
||||||
|
1.0000,0,0
|
||||||
|
4.0000,0.3292,0.0998
|
||||||
|
2.0000,0.0513,0.0263
|
||||||
|
1.0000,0,0
|
||||||
|
1.0000,0,0
|
||||||
|
1.0000,0,0
|
||||||
|
1.0000,0,0
|
||||||
|
1.0000,0,0
|
||||||
|
5.0000,0.4000,0.1022
|
||||||
|
1.0000,0,0
|
||||||
|
2.0000,0.0513,0.0263
|
||||||
|
1.0000,0,0
|
||||||
|
1.0000,0,0
|
||||||
|
1.0000,0,0
|
||||||
|
4.0000,0.3292,0.0998
|
||||||
|
6.0000,0.4523,0.1003
|
||||||
|
5.0000,0.4000,0.1022
|
||||||
|
1.0000,0,0
|
||||||
|
1.0000,0,0
|
||||||
|
19.0000,0.6922,0.0620
|
||||||
|
1.0000,0,0
|
||||||
|
1.0000,0,0
|
||||||
|
1.0000,0,0
|
||||||
|
1.0000,0,0
|
||||||
|
2.0000,0.0513,0.0263
|
||||||
|
1.0000,0,0
|
||||||
|
3.0000,0.2254,0.0851
|
||||||
|
2.0000,0.0513,0.0263
|
||||||
|
1.0000,0,0
|
||||||
|
1.0000,0,0
|
||||||
|
10.0000,0.5757,0.0857
|
||||||
|
1.0000,0,0
|
||||||
|
2.0000,0.0513,0.0263
|
||||||
|
1.0000,0,0
|
||||||
|
1.0000,0,0
|
||||||
|
1.0000,0,0
|
||||||
|
1.0000,0,0
|
||||||
|
1.0000,0,0
|
||||||
|
1.0000,0,0
|
||||||
|
1.0000,0,0
|
||||||
|
1.0000,0,0
|
||||||
|
3.0000,0.2254,0.0851
|
||||||
|
1.0000,0,0
|
||||||
|
1.0000,0,0
|
||||||
|
1.0000,0,0
|
||||||
|
1.0000,0,0
|
||||||
|
1.0000,0,0
|
||||||
|
1.0000,0,0
|
||||||
|
1.0000,0,0
|
||||||
|
1.0000,0,0
|
||||||
|
1.0000,0,0
|
||||||
|
1.0000,0,0
|
||||||
|
1.0000,0,0
|
||||||
|
1.0000,0,0
|
||||||
|
1.0000,0,0
|
||||||
|
1.0000,0,0
|
||||||
|
1.0000,0,0
|
||||||
|
1.0000,0,0
|
||||||
|
1.0000,0,0
|
||||||
|
9.0000,0.5528,0.0894
|
||||||
|
1.0000,0,0
|
||||||
|
3.0000,0.2254,0.0851
|
||||||
|
1.0000,0,0
|
||||||
|
5.0000,0.4000,0.1022
|
||||||
|
1.0000,0,0
|
||||||
|
1.0000,0,0
|
||||||
|
5.0000,0.4000,0.1022
|
||||||
|
1.0000,0,0
|
||||||
|
1.0000,0,0
|
||||||
|
1.0000,0,0
|
||||||
|
1.0000,0,0
|
||||||
|
1.0000,0,0
|
||||||
|
9.0000,0.5528,0.0894
|
||||||
|
1.0000,0,0
|
||||||
|
@@ -1,100 +0,0 @@
|
|||||||
,access_count,hits,misses,mu,lambda,hit_rate
|
|
||||||
1,664,224,440,0,1,10.38
|
|
||||||
2,212,22,190,0,3,32.39
|
|
||||||
3,673,218,455,0,1,34.6
|
|
||||||
4,711,246,465,0,1,19.13
|
|
||||||
5,345,66,279,0,2,31.74
|
|
||||||
6,649,206,443,0,1,10.22
|
|
||||||
7,137,14,123,0,5,32.45
|
|
||||||
8,681,221,460,0,1,34.4
|
|
||||||
9,689,237,452,0,1,34.18
|
|
||||||
10,667,228,439,0,1,21.95
|
|
||||||
11,328,72,256,0,2,34.97
|
|
||||||
12,692,242,450,0,1,32.21
|
|
||||||
13,683,220,463,0,1,33.62
|
|
||||||
14,696,234,462,0,1,20.35
|
|
||||||
15,344,70,274,0,2,18.4
|
|
||||||
16,326,60,266,0,2,29.9
|
|
||||||
17,689,206,483,0,1,32.85
|
|
||||||
18,691,227,464,0,1,11.87
|
|
||||||
19,219,26,193,0,3,34.84
|
|
||||||
20,732,255,477,0,1,35.05
|
|
||||||
21,739,259,480,0,1,34.55
|
|
||||||
22,683,236,447,0,1,35.22
|
|
||||||
23,670,236,434,0,1,19.94
|
|
||||||
24,331,66,265,0,2,34.67
|
|
||||||
25,724,251,473,0,1,32.08
|
|
||||||
26,692,222,470,0,1,34.18
|
|
||||||
27,705,241,464,0,1,8.76
|
|
||||||
28,137,12,125,0,5,34.23
|
|
||||||
29,672,230,442,0,1,31.7
|
|
||||||
30,694,220,474,0,1,33.09
|
|
||||||
31,674,223,451,0,1,9.03
|
|
||||||
32,144,13,131,0,4,34.63
|
|
||||||
33,670,232,438,0,1,7.09
|
|
||||||
34,141,10,131,0,4,32.78
|
|
||||||
35,659,216,443,0,1,32.27
|
|
||||||
36,691,223,468,0,1,36.91
|
|
||||||
37,737,272,465,0,1,14.16
|
|
||||||
38,219,31,188,0,3,5.0
|
|
||||||
39,100,5,95,0,8,32.77
|
|
||||||
40,714,234,480,0,1,12.5
|
|
||||||
41,184,23,161,0,4,7.45
|
|
||||||
42,161,12,149,0,4,21.55
|
|
||||||
43,362,78,284,0,2,32.61
|
|
||||||
44,696,227,469,0,1,29.98
|
|
||||||
45,627,188,439,0,1,32.56
|
|
||||||
46,648,211,437,0,1,1.89
|
|
||||||
47,53,1,52,0,10,31.51
|
|
||||||
48,676,213,463,0,1,31.35
|
|
||||||
49,638,200,438,0,1,32.69
|
|
||||||
50,673,220,453,0,1,12.5
|
|
||||||
51,128,16,112,0,5,3.53
|
|
||||||
52,85,3,82,0,9,33.33
|
|
||||||
53,747,249,498,0,1,33.0
|
|
||||||
54,700,231,469,0,1,35.08
|
|
||||||
55,687,241,446,0,1,37.5
|
|
||||||
56,720,270,450,0,1,31.3
|
|
||||||
57,690,216,474,0,1,0.0
|
|
||||||
58,40,0,40,0,17,19.18
|
|
||||||
59,318,61,257,0,2,31.31
|
|
||||||
60,674,211,463,0,1,13.04
|
|
||||||
61,23,3,20,0,26,35.22
|
|
||||||
62,724,255,469,0,1,32.32
|
|
||||||
63,628,203,425,0,1,24.93
|
|
||||||
64,345,86,259,0,2,35.1
|
|
||||||
65,681,239,442,0,1,4.11
|
|
||||||
66,73,3,70,0,10,33.79
|
|
||||||
67,651,220,431,0,1,0.0
|
|
||||||
68,10,0,10,0,69,33.02
|
|
||||||
69,636,210,426,0,1,32.77
|
|
||||||
70,656,215,441,0,1,22.58
|
|
||||||
71,372,84,288,0,2,33.48
|
|
||||||
72,678,227,451,0,1,33.7
|
|
||||||
73,638,215,423,0,1,33.28
|
|
||||||
74,685,228,457,0,1,10.45
|
|
||||||
75,201,21,180,0,3,20.35
|
|
||||||
76,344,70,274,0,2,21.16
|
|
||||||
77,345,73,272,0,2,17.24
|
|
||||||
78,261,45,216,0,3,4.26
|
|
||||||
79,47,2,45,0,15,33.79
|
|
||||||
80,660,223,437,0,1,30.28
|
|
||||||
81,634,192,442,0,1,5.84
|
|
||||||
82,137,8,129,0,5,18.45
|
|
||||||
83,309,57,252,0,2,34.11
|
|
||||||
84,686,234,452,0,1,32.99
|
|
||||||
85,682,225,457,0,1,19.25
|
|
||||||
86,322,62,260,0,2,32.99
|
|
||||||
87,676,223,453,0,1,20.92
|
|
||||||
88,325,68,257,0,2,35.27
|
|
||||||
89,689,243,446,0,1,32.95
|
|
||||||
90,695,229,466,0,1,21.91
|
|
||||||
91,324,71,253,0,2,20.47
|
|
||||||
92,337,69,268,0,2,13.96
|
|
||||||
93,222,31,191,0,3,31.78
|
|
||||||
94,686,218,468,0,1,19.94
|
|
||||||
95,351,70,281,0,2,33.89
|
|
||||||
96,717,243,474,0,1,32.53
|
|
||||||
97,664,216,448,0,1,0.0
|
|
||||||
98,23,0,23,0,37,11.6
|
|
||||||
99,181,21,160,0,4,22.85
|
|
||||||
|
@@ -1,101 +0,0 @@
|
|||||||
obj_id,hit_rate,avg_age
|
|
||||||
1,0.3373493975903614,0.25892857142857145
|
|
||||||
2,0.10377358490566038,0.36363636363636365
|
|
||||||
3,0.32392273402674593,0.24311926605504589
|
|
||||||
4,0.3459915611814346,0.25609756097560976
|
|
||||||
5,0.19130434782608696,0.24242424242424243
|
|
||||||
6,0.31741140215716485,0.24757281553398058
|
|
||||||
7,0.10218978102189781,0.21428571428571427
|
|
||||||
8,0.3245227606461087,0.2579185520361991
|
|
||||||
9,0.3439767779390421,0.23628691983122363
|
|
||||||
10,0.34182908545727136,0.2236842105263158
|
|
||||||
11,0.21951219512195122,0.2361111111111111
|
|
||||||
12,0.34971098265895956,0.30578512396694213
|
|
||||||
13,0.32210834553440704,0.22727272727272727
|
|
||||||
14,0.33620689655172414,0.2692307692307692
|
|
||||||
15,0.20348837209302326,0.2
|
|
||||||
16,0.18404907975460122,0.2
|
|
||||||
17,0.29898403483309144,0.2524271844660194
|
|
||||||
18,0.32850940665701883,0.24669603524229075
|
|
||||||
19,0.1187214611872146,0.2692307692307692
|
|
||||||
20,0.3483606557377049,0.25882352941176473
|
|
||||||
21,0.35047361299052776,0.21235521235521235
|
|
||||||
22,0.34553440702781846,0.288135593220339
|
|
||||||
23,0.3522388059701492,0.19915254237288135
|
|
||||||
24,0.19939577039274925,0.18181818181818182
|
|
||||||
25,0.34668508287292815,0.2589641434262948
|
|
||||||
26,0.3208092485549133,0.2072072072072072
|
|
||||||
27,0.34184397163120567,0.23651452282157676
|
|
||||||
28,0.08759124087591241,0.16666666666666666
|
|
||||||
29,0.34226190476190477,0.24782608695652175
|
|
||||||
30,0.3170028818443804,0.2818181818181818
|
|
||||||
31,0.33086053412462907,0.2600896860986547
|
|
||||||
32,0.09027777777777778,0.3076923076923077
|
|
||||||
33,0.34626865671641793,0.24568965517241378
|
|
||||||
34,0.07092198581560284,0.3
|
|
||||||
35,0.3277693474962064,0.2638888888888889
|
|
||||||
36,0.3227206946454414,0.29596412556053814
|
|
||||||
37,0.36906377204884666,0.22058823529411764
|
|
||||||
38,0.1415525114155251,0.3870967741935484
|
|
||||||
39,0.05,0.2
|
|
||||||
40,0.3277310924369748,0.27350427350427353
|
|
||||||
41,0.125,0.30434782608695654
|
|
||||||
42,0.07453416149068323,0.25
|
|
||||||
43,0.2154696132596685,0.32051282051282054
|
|
||||||
44,0.3261494252873563,0.24669603524229075
|
|
||||||
45,0.29984051036682613,0.3404255319148936
|
|
||||||
46,0.3256172839506173,0.27014218009478674
|
|
||||||
47,0.018867924528301886,0.0
|
|
||||||
48,0.3150887573964497,0.23943661971830985
|
|
||||||
49,0.31347962382445144,0.27
|
|
||||||
50,0.32689450222882616,0.22727272727272727
|
|
||||||
51,0.125,0.25
|
|
||||||
52,0.03529411764705882,0.3333333333333333
|
|
||||||
53,0.3333333333333333,0.26506024096385544
|
|
||||||
54,0.33,0.24675324675324675
|
|
||||||
55,0.3508005822416303,0.24481327800829875
|
|
||||||
56,0.375,0.25925925925925924
|
|
||||||
57,0.3130434782608696,0.2638888888888889
|
|
||||||
58,0.0,0.0
|
|
||||||
59,0.1918238993710692,0.14754098360655737
|
|
||||||
60,0.31305637982195844,0.1990521327014218
|
|
||||||
61,0.13043478260869565,0.0
|
|
||||||
62,0.35220994475138123,0.2549019607843137
|
|
||||||
63,0.3232484076433121,0.2315270935960591
|
|
||||||
64,0.2492753623188406,0.3372093023255814
|
|
||||||
65,0.3509544787077827,0.2803347280334728
|
|
||||||
66,0.0410958904109589,0.3333333333333333
|
|
||||||
67,0.3379416282642089,0.20909090909090908
|
|
||||||
68,0.0,0.0
|
|
||||||
69,0.330188679245283,0.32857142857142857
|
|
||||||
70,0.3277439024390244,0.26046511627906976
|
|
||||||
71,0.22580645161290322,0.2261904761904762
|
|
||||||
72,0.33480825958702065,0.2422907488986784
|
|
||||||
73,0.33699059561128525,0.2930232558139535
|
|
||||||
74,0.33284671532846716,0.19736842105263158
|
|
||||||
75,0.1044776119402985,0.2857142857142857
|
|
||||||
76,0.20348837209302326,0.3
|
|
||||||
77,0.21159420289855072,0.2054794520547945
|
|
||||||
78,0.1724137931034483,0.2
|
|
||||||
79,0.0425531914893617,0.0
|
|
||||||
80,0.3378787878787879,0.27802690582959644
|
|
||||||
81,0.3028391167192429,0.2604166666666667
|
|
||||||
82,0.058394160583941604,0.125
|
|
||||||
83,0.18446601941747573,0.24561403508771928
|
|
||||||
84,0.34110787172011664,0.2905982905982906
|
|
||||||
85,0.32991202346041054,0.26222222222222225
|
|
||||||
86,0.19254658385093168,0.3064516129032258
|
|
||||||
87,0.32988165680473375,0.20179372197309417
|
|
||||||
88,0.20923076923076922,0.25
|
|
||||||
89,0.35268505079825835,0.22633744855967078
|
|
||||||
90,0.3294964028776978,0.2794759825327511
|
|
||||||
91,0.2191358024691358,0.30985915492957744
|
|
||||||
92,0.20474777448071216,0.21739130434782608
|
|
||||||
93,0.13963963963963963,0.25806451612903225
|
|
||||||
94,0.3177842565597668,0.2889908256880734
|
|
||||||
95,0.19943019943019943,0.3142857142857143
|
|
||||||
96,0.3389121338912134,0.2139917695473251
|
|
||||||
97,0.3253012048192771,0.26851851851851855
|
|
||||||
98,0.0,0.0
|
|
||||||
99,0.11602209944751381,0.3333333333333333
|
|
||||||
100,0.228486646884273,0.24675324675324675
|
|
||||||
|
Binary file not shown.
@@ -1,9 +0,0 @@
|
|||||||
,hit_rate,avg_age
|
|
||||||
count,100.0,100.0
|
|
||||||
mean,0.24997190226308422,0.24085664637735987
|
|
||||||
std,0.10967384888958667,0.07537398148292249
|
|
||||||
min,0.0,0.0
|
|
||||||
25%,0.1843617845017571,0.21978900255754474
|
|
||||||
50%,0.3172071420007726,0.25
|
|
||||||
75%,0.3351579188281965,0.2796906689079315
|
|
||||||
max,0.375,0.3870967741935484
|
|
||||||
|
@@ -1,100 +0,0 @@
|
|||||||
,access_count,hits,misses,mu,lambda,hit_rate
|
|
||||||
1,664,328,336,0,1,22.17
|
|
||||||
2,212,47,165,0,3,50.07
|
|
||||||
3,673,337,336,0,1,50.63
|
|
||||||
4,711,360,351,0,1,32.75
|
|
||||||
5,345,113,232,0,2,49.46
|
|
||||||
6,649,321,328,0,1,18.98
|
|
||||||
7,137,26,111,0,5,49.63
|
|
||||||
8,681,338,343,0,1,50.22
|
|
||||||
9,689,346,343,0,1,49.33
|
|
||||||
10,667,329,338,0,1,37.8
|
|
||||||
11,328,124,204,0,2,52.31
|
|
||||||
12,692,362,330,0,1,48.46
|
|
||||||
13,683,331,352,0,1,49.86
|
|
||||||
14,696,347,349,0,1,31.98
|
|
||||||
15,344,110,234,0,2,29.14
|
|
||||||
16,326,95,231,0,2,48.48
|
|
||||||
17,689,334,355,0,1,49.93
|
|
||||||
18,691,345,346,0,1,22.83
|
|
||||||
19,219,50,169,0,3,51.09
|
|
||||||
20,732,374,358,0,1,52.77
|
|
||||||
21,739,390,349,0,1,51.1
|
|
||||||
22,683,349,334,0,1,49.55
|
|
||||||
23,670,332,338,0,1,32.02
|
|
||||||
24,331,106,225,0,2,50.97
|
|
||||||
25,724,369,355,0,1,50.58
|
|
||||||
26,692,350,342,0,1,51.49
|
|
||||||
27,705,363,342,0,1,15.33
|
|
||||||
28,137,21,116,0,5,49.55
|
|
||||||
29,672,333,339,0,1,48.56
|
|
||||||
30,694,337,357,0,1,50.3
|
|
||||||
31,674,339,335,0,1,17.36
|
|
||||||
32,144,25,119,0,4,51.19
|
|
||||||
33,670,343,327,0,1,12.77
|
|
||||||
34,141,18,123,0,4,50.99
|
|
||||||
35,659,336,323,0,1,50.36
|
|
||||||
36,691,348,343,0,1,53.05
|
|
||||||
37,737,391,346,0,1,24.66
|
|
||||||
38,219,54,165,0,3,9.0
|
|
||||||
39,100,9,91,0,8,49.72
|
|
||||||
40,714,355,359,0,1,22.28
|
|
||||||
41,184,41,143,0,4,18.63
|
|
||||||
42,161,30,131,0,4,37.57
|
|
||||||
43,362,136,226,0,2,49.57
|
|
||||||
44,696,345,351,0,1,47.05
|
|
||||||
45,627,295,332,0,1,48.77
|
|
||||||
46,648,316,332,0,1,5.66
|
|
||||||
47,53,3,50,0,10,48.22
|
|
||||||
48,676,326,350,0,1,48.12
|
|
||||||
49,638,307,331,0,1,49.93
|
|
||||||
50,673,336,337,0,1,18.75
|
|
||||||
51,128,24,104,0,5,9.41
|
|
||||||
52,85,8,77,0,9,51.54
|
|
||||||
53,747,385,362,0,1,49.86
|
|
||||||
54,700,349,351,0,1,51.24
|
|
||||||
55,687,352,335,0,1,53.75
|
|
||||||
56,720,387,333,0,1,50.43
|
|
||||||
57,690,348,342,0,1,2.5
|
|
||||||
58,40,1,39,0,17,32.08
|
|
||||||
59,318,102,216,0,2,47.92
|
|
||||||
60,674,323,351,0,1,17.39
|
|
||||||
61,23,4,19,0,26,50.97
|
|
||||||
62,724,369,355,0,1,49.2
|
|
||||||
63,628,309,319,0,1,36.52
|
|
||||||
64,345,126,219,0,2,50.66
|
|
||||||
65,681,345,336,0,1,6.85
|
|
||||||
66,73,5,68,0,10,50.23
|
|
||||||
67,651,327,324,0,1,0.0
|
|
||||||
68,10,0,10,0,69,49.06
|
|
||||||
69,636,312,324,0,1,48.17
|
|
||||||
70,656,316,340,0,1,34.95
|
|
||||||
71,372,130,242,0,2,51.33
|
|
||||||
72,678,348,330,0,1,49.69
|
|
||||||
73,638,317,321,0,1,50.95
|
|
||||||
74,685,349,336,0,1,20.9
|
|
||||||
75,201,42,159,0,3,35.76
|
|
||||||
76,344,123,221,0,2,36.23
|
|
||||||
77,345,125,220,0,2,27.2
|
|
||||||
78,261,71,190,0,3,8.51
|
|
||||||
79,47,4,43,0,15,50.3
|
|
||||||
80,660,332,328,0,1,49.53
|
|
||||||
81,634,314,320,0,1,13.87
|
|
||||||
82,137,19,118,0,5,30.74
|
|
||||||
83,309,95,214,0,2,50.44
|
|
||||||
84,686,346,340,0,1,49.41
|
|
||||||
85,682,337,345,0,1,32.61
|
|
||||||
86,322,105,217,0,2,50.0
|
|
||||||
87,676,338,338,0,1,31.69
|
|
||||||
88,325,103,222,0,2,49.93
|
|
||||||
89,689,344,345,0,1,49.06
|
|
||||||
90,695,341,354,0,1,36.73
|
|
||||||
91,324,119,205,0,2,33.53
|
|
||||||
92,337,113,224,0,2,26.13
|
|
||||||
93,222,58,164,0,3,49.85
|
|
||||||
94,686,342,344,0,1,35.61
|
|
||||||
95,351,125,226,0,2,52.44
|
|
||||||
96,717,376,341,0,1,49.25
|
|
||||||
97,664,327,337,0,1,0.0
|
|
||||||
98,23,0,23,0,37,21.55
|
|
||||||
99,181,39,142,0,4,35.31
|
|
||||||
|
@@ -1,101 +0,0 @@
|
|||||||
obj_id,hit_rate,avg_age
|
|
||||||
1,0.4939759036144578,0.45426829268292684
|
|
||||||
2,0.22169811320754718,0.5106382978723404
|
|
||||||
3,0.5007429420505201,0.5133531157270029
|
|
||||||
4,0.5063291139240507,0.5166666666666667
|
|
||||||
5,0.32753623188405795,0.4247787610619469
|
|
||||||
6,0.4946070878274268,0.5171339563862928
|
|
||||||
7,0.1897810218978102,0.46153846153846156
|
|
||||||
8,0.49632892804698975,0.4556213017751479
|
|
||||||
9,0.502177068214804,0.476878612716763
|
|
||||||
10,0.49325337331334335,0.44376899696048633
|
|
||||||
11,0.3780487804878049,0.5483870967741935
|
|
||||||
12,0.523121387283237,0.5
|
|
||||||
13,0.48462664714494874,0.4743202416918429
|
|
||||||
14,0.4985632183908046,0.49279538904899134
|
|
||||||
15,0.31976744186046513,0.4727272727272727
|
|
||||||
16,0.29141104294478526,0.4421052631578947
|
|
||||||
17,0.4847605224963715,0.5988023952095808
|
|
||||||
18,0.4992764109985528,0.4927536231884058
|
|
||||||
19,0.228310502283105,0.52
|
|
||||||
20,0.5109289617486339,0.5053475935828877
|
|
||||||
21,0.5277401894451962,0.4897435897435897
|
|
||||||
22,0.5109809663250366,0.49283667621776506
|
|
||||||
23,0.4955223880597015,0.43373493975903615
|
|
||||||
24,0.3202416918429003,0.3867924528301887
|
|
||||||
25,0.5096685082872928,0.5013550135501355
|
|
||||||
26,0.5057803468208093,0.5057142857142857
|
|
||||||
27,0.5148936170212766,0.49586776859504134
|
|
||||||
28,0.15328467153284672,0.42857142857142855
|
|
||||||
29,0.4955357142857143,0.45645645645645644
|
|
||||||
30,0.48559077809798273,0.5608308605341247
|
|
||||||
31,0.5029673590504451,0.49557522123893805
|
|
||||||
32,0.1736111111111111,0.6
|
|
||||||
33,0.5119402985074627,0.44314868804664725
|
|
||||||
34,0.1276595744680851,0.5
|
|
||||||
35,0.5098634294385432,0.5297619047619048
|
|
||||||
36,0.5036179450072359,0.5
|
|
||||||
37,0.5305291723202171,0.4961636828644501
|
|
||||||
38,0.2465753424657534,0.6296296296296297
|
|
||||||
39,0.09,0.4444444444444444
|
|
||||||
40,0.49719887955182074,0.5014084507042254
|
|
||||||
41,0.22282608695652173,0.5853658536585366
|
|
||||||
42,0.18633540372670807,0.6666666666666666
|
|
||||||
43,0.3756906077348066,0.47794117647058826
|
|
||||||
44,0.4956896551724138,0.4956521739130435
|
|
||||||
45,0.4704944178628389,0.535593220338983
|
|
||||||
46,0.4876543209876543,0.4810126582278481
|
|
||||||
47,0.05660377358490566,0.3333333333333333
|
|
||||||
48,0.4822485207100592,0.4263803680981595
|
|
||||||
49,0.48119122257053293,0.50814332247557
|
|
||||||
50,0.49925705794947994,0.4523809523809524
|
|
||||||
51,0.1875,0.5
|
|
||||||
52,0.09411764705882353,0.5
|
|
||||||
53,0.5153949129852744,0.535064935064935
|
|
||||||
54,0.49857142857142855,0.5358166189111748
|
|
||||||
55,0.512372634643377,0.4943181818181818
|
|
||||||
56,0.5375,0.4728682170542636
|
|
||||||
57,0.5043478260869565,0.5431034482758621
|
|
||||||
58,0.025,1.0
|
|
||||||
59,0.32075471698113206,0.5196078431372549
|
|
||||||
60,0.4792284866468843,0.47678018575851394
|
|
||||||
61,0.17391304347826086,0.25
|
|
||||||
62,0.5096685082872928,0.46883468834688347
|
|
||||||
63,0.49203821656050956,0.47896440129449835
|
|
||||||
64,0.3652173913043478,0.5476190476190477
|
|
||||||
65,0.5066079295154186,0.5594202898550724
|
|
||||||
66,0.0684931506849315,0.6
|
|
||||||
67,0.5023041474654378,0.40978593272171254
|
|
||||||
68,0.0,0.0
|
|
||||||
69,0.49056603773584906,0.5416666666666666
|
|
||||||
70,0.4817073170731707,0.5
|
|
||||||
71,0.34946236559139787,0.5615384615384615
|
|
||||||
72,0.5132743362831859,0.49137931034482757
|
|
||||||
73,0.49686520376175547,0.5362776025236593
|
|
||||||
74,0.5094890510948905,0.4813753581661891
|
|
||||||
75,0.208955223880597,0.5238095238095238
|
|
||||||
76,0.35755813953488375,0.5853658536585366
|
|
||||||
77,0.36231884057971014,0.488
|
|
||||||
78,0.2720306513409962,0.4647887323943662
|
|
||||||
79,0.0851063829787234,0.5
|
|
||||||
80,0.503030303030303,0.5180722891566265
|
|
||||||
81,0.4952681388012618,0.49044585987261147
|
|
||||||
82,0.1386861313868613,0.47368421052631576
|
|
||||||
83,0.3074433656957929,0.5368421052631579
|
|
||||||
84,0.5043731778425656,0.5028901734104047
|
|
||||||
85,0.4941348973607038,0.5014836795252225
|
|
||||||
86,0.32608695652173914,0.5428571428571428
|
|
||||||
87,0.5,0.5029585798816568
|
|
||||||
88,0.3169230769230769,0.4368932038834951
|
|
||||||
89,0.49927431059506533,0.45058139534883723
|
|
||||||
90,0.4906474820143885,0.49266862170087977
|
|
||||||
91,0.36728395061728397,0.5630252100840336
|
|
||||||
92,0.3353115727002967,0.415929203539823
|
|
||||||
93,0.26126126126126126,0.4827586206896552
|
|
||||||
94,0.49854227405247814,0.52046783625731
|
|
||||||
95,0.3561253561253561,0.536
|
|
||||||
96,0.5244072524407253,0.4627659574468085
|
|
||||||
97,0.4924698795180723,0.5015290519877675
|
|
||||||
98,0.0,0.0
|
|
||||||
99,0.2154696132596685,0.5384615384615384
|
|
||||||
100,0.35311572700296734,0.4957983193277311
|
|
||||||
|
Binary file not shown.
@@ -1,9 +0,0 @@
|
|||||||
,hit_rate,avg_age
|
|
||||||
count,100.0,100.0
|
|
||||||
mean,0.3881665606779017,0.4920888885617573
|
|
||||||
std,0.15249831056210744,0.10293321749563328
|
|
||||||
min,0.0,0.0
|
|
||||||
25%,0.30343528500804096,0.4717541266321754
|
|
||||||
50%,0.4866225495428185,0.49808184143222506
|
|
||||||
75%,0.5022088380274625,0.5252976190476191
|
|
||||||
max,0.5375,1.0
|
|
||||||
|
@@ -1,100 +0,0 @@
|
|||||||
,access_count,hits,misses,mu,lambda,hit_rate
|
|
||||||
1,664,445,219,0,1,37.74
|
|
||||||
2,212,80,132,0,3,66.42
|
|
||||||
3,673,447,226,0,1,67.37
|
|
||||||
4,711,479,232,0,1,51.01
|
|
||||||
5,345,176,169,0,2,64.56
|
|
||||||
6,649,419,230,0,1,29.2
|
|
||||||
7,137,40,97,0,5,66.37
|
|
||||||
8,681,452,229,0,1,66.76
|
|
||||||
9,689,460,229,0,1,66.57
|
|
||||||
10,667,444,223,0,1,52.13
|
|
||||||
11,328,171,157,0,2,67.92
|
|
||||||
12,692,470,222,0,1,66.03
|
|
||||||
13,683,451,232,0,1,66.67
|
|
||||||
14,696,464,232,0,1,48.55
|
|
||||||
15,344,167,177,0,2,48.47
|
|
||||||
16,326,158,168,0,2,66.33
|
|
||||||
17,689,457,232,0,1,65.99
|
|
||||||
18,691,456,235,0,1,41.1
|
|
||||||
19,219,90,129,0,3,68.58
|
|
||||||
20,732,502,230,0,1,68.88
|
|
||||||
21,739,509,230,0,1,66.76
|
|
||||||
22,683,456,227,0,1,66.57
|
|
||||||
23,670,446,224,0,1,49.85
|
|
||||||
24,331,165,166,0,2,68.09
|
|
||||||
25,724,493,231,0,1,66.91
|
|
||||||
26,692,463,229,0,1,68.09
|
|
||||||
27,705,480,225,0,1,28.47
|
|
||||||
28,137,39,98,0,5,65.92
|
|
||||||
29,672,443,229,0,1,66.28
|
|
||||||
30,694,460,234,0,1,66.62
|
|
||||||
31,674,449,225,0,1,29.17
|
|
||||||
32,144,42,102,0,4,66.72
|
|
||||||
33,670,447,223,0,1,26.95
|
|
||||||
34,141,38,103,0,4,66.77
|
|
||||||
35,659,440,219,0,1,67.15
|
|
||||||
36,691,464,227,0,1,69.06
|
|
||||||
37,737,509,228,0,1,39.27
|
|
||||||
38,219,86,133,0,3,21.0
|
|
||||||
39,100,21,79,0,8,66.81
|
|
||||||
40,714,477,237,0,1,32.07
|
|
||||||
41,184,59,125,0,4,34.78
|
|
||||||
42,161,56,105,0,4,53.87
|
|
||||||
43,362,195,167,0,2,66.52
|
|
||||||
44,696,463,233,0,1,64.59
|
|
||||||
45,627,405,222,0,1,64.97
|
|
||||||
46,648,421,227,0,1,9.43
|
|
||||||
47,53,5,48,0,10,64.79
|
|
||||||
48,676,438,238,0,1,65.52
|
|
||||||
49,638,418,220,0,1,66.12
|
|
||||||
50,673,445,228,0,1,29.69
|
|
||||||
51,128,38,90,0,5,16.47
|
|
||||||
52,85,14,71,0,9,68.14
|
|
||||||
53,747,509,238,0,1,67.71
|
|
||||||
54,700,474,226,0,1,66.67
|
|
||||||
55,687,458,229,0,1,68.89
|
|
||||||
56,720,496,224,0,1,67.25
|
|
||||||
57,690,464,226,0,1,5.0
|
|
||||||
58,40,2,38,0,17,48.11
|
|
||||||
59,318,153,165,0,2,66.32
|
|
||||||
60,674,447,227,0,1,17.39
|
|
||||||
61,23,4,19,0,26,68.09
|
|
||||||
62,724,493,231,0,1,64.49
|
|
||||||
63,628,405,223,0,1,52.46
|
|
||||||
64,345,181,164,0,2,67.11
|
|
||||||
65,681,457,224,0,1,16.44
|
|
||||||
66,73,12,61,0,10,66.36
|
|
||||||
67,651,432,219,0,1,0.0
|
|
||||||
68,10,0,10,0,69,65.41
|
|
||||||
69,636,416,220,0,1,65.7
|
|
||||||
70,656,431,225,0,1,50.81
|
|
||||||
71,372,189,183,0,2,67.7
|
|
||||||
72,678,459,219,0,1,66.14
|
|
||||||
73,638,422,216,0,1,65.69
|
|
||||||
74,685,450,235,0,1,32.84
|
|
||||||
75,201,66,135,0,3,52.33
|
|
||||||
76,344,180,164,0,2,51.88
|
|
||||||
77,345,179,166,0,2,41.76
|
|
||||||
78,261,109,152,0,3,10.64
|
|
||||||
79,47,5,42,0,15,66.52
|
|
||||||
80,660,439,221,0,1,65.3
|
|
||||||
81,634,414,220,0,1,29.2
|
|
||||||
82,137,40,97,0,5,46.93
|
|
||||||
83,309,145,164,0,2,67.49
|
|
||||||
84,686,463,223,0,1,66.72
|
|
||||||
85,682,455,227,0,1,49.07
|
|
||||||
86,322,158,164,0,2,64.94
|
|
||||||
87,676,439,237,0,1,48.92
|
|
||||||
88,325,159,166,0,2,66.62
|
|
||||||
89,689,459,230,0,1,67.05
|
|
||||||
90,695,466,229,0,1,51.23
|
|
||||||
91,324,166,158,0,2,51.63
|
|
||||||
92,337,174,163,0,2,39.64
|
|
||||||
93,222,88,134,0,3,66.18
|
|
||||||
94,686,454,232,0,1,50.71
|
|
||||||
95,351,178,173,0,2,67.78
|
|
||||||
96,717,486,231,0,1,66.72
|
|
||||||
97,664,443,221,0,1,0.0
|
|
||||||
98,23,0,23,0,37,38.12
|
|
||||||
99,181,69,112,0,4,50.15
|
|
||||||
|
@@ -1,101 +0,0 @@
|
|||||||
obj_id,hit_rate,avg_age
|
|
||||||
1,0.6701807228915663,1.0269662921348315
|
|
||||||
2,0.37735849056603776,1.2375
|
|
||||||
3,0.6641901931649331,0.9574944071588367
|
|
||||||
4,0.6736990154711674,1.0041753653444676
|
|
||||||
5,0.5101449275362319,0.9829545454545454
|
|
||||||
6,0.6456086286594761,0.9260143198090692
|
|
||||||
7,0.291970802919708,1.125
|
|
||||||
8,0.6637298091042585,0.9867256637168141
|
|
||||||
9,0.6676342525399129,0.9760869565217392
|
|
||||||
10,0.6656671664167916,0.9954954954954955
|
|
||||||
11,0.5213414634146342,0.9883040935672515
|
|
||||||
12,0.6791907514450867,0.9702127659574468
|
|
||||||
13,0.6603221083455344,1.0532150776053215
|
|
||||||
14,0.6666666666666666,1.0668103448275863
|
|
||||||
15,0.48546511627906974,1.0658682634730539
|
|
||||||
16,0.48466257668711654,1.0253164556962024
|
|
||||||
17,0.6632801161103048,1.0284463894967177
|
|
||||||
18,0.6599131693198264,0.9912280701754386
|
|
||||||
19,0.410958904109589,1.0
|
|
||||||
20,0.6857923497267759,1.00199203187251
|
|
||||||
21,0.6887686062246279,0.9194499017681729
|
|
||||||
22,0.6676427525622255,0.9780701754385965
|
|
||||||
23,0.6656716417910448,0.9618834080717489
|
|
||||||
24,0.4984894259818731,0.9939393939393939
|
|
||||||
25,0.680939226519337,1.028397565922921
|
|
||||||
26,0.6690751445086706,1.0172786177105833
|
|
||||||
27,0.6808510638297872,0.9458333333333333
|
|
||||||
28,0.2846715328467153,1.1538461538461537
|
|
||||||
29,0.6592261904761905,0.9616252821670429
|
|
||||||
30,0.6628242074927954,1.0456521739130435
|
|
||||||
31,0.6661721068249258,1.0311804008908685
|
|
||||||
32,0.2916666666666667,0.9523809523809523
|
|
||||||
33,0.6671641791044776,1.0067114093959733
|
|
||||||
34,0.2695035460992908,1.105263157894737
|
|
||||||
35,0.6676783004552352,1.0
|
|
||||||
36,0.6714905933429812,1.0581896551724137
|
|
||||||
37,0.6906377204884667,0.9823182711198428
|
|
||||||
38,0.3926940639269406,1.1162790697674418
|
|
||||||
39,0.21,1.1904761904761905
|
|
||||||
40,0.6680672268907563,1.0377358490566038
|
|
||||||
41,0.32065217391304346,0.8983050847457628
|
|
||||||
42,0.34782608695652173,1.0892857142857142
|
|
||||||
43,0.5386740331491713,0.958974358974359
|
|
||||||
44,0.6652298850574713,0.9395248380129589
|
|
||||||
45,0.645933014354067,1.0148148148148148
|
|
||||||
46,0.6496913580246914,1.0332541567695963
|
|
||||||
47,0.09433962264150944,0.6
|
|
||||||
48,0.6479289940828402,0.8972602739726028
|
|
||||||
49,0.6551724137931034,0.9497607655502392
|
|
||||||
50,0.6612184249628529,0.9775280898876404
|
|
||||||
51,0.296875,0.8947368421052632
|
|
||||||
52,0.16470588235294117,0.7857142857142857
|
|
||||||
53,0.6813922356091031,0.9960707269155207
|
|
||||||
54,0.6771428571428572,1.0168776371308017
|
|
||||||
55,0.6666666666666666,0.9541484716157205
|
|
||||||
56,0.6888888888888889,1.002016129032258
|
|
||||||
57,0.672463768115942,0.9612068965517241
|
|
||||||
58,0.05,1.0
|
|
||||||
59,0.4811320754716981,1.0065359477124183
|
|
||||||
60,0.6632047477744807,0.9798657718120806
|
|
||||||
61,0.17391304347826086,0.25
|
|
||||||
62,0.680939226519337,1.026369168356998
|
|
||||||
63,0.6449044585987261,0.945679012345679
|
|
||||||
64,0.5246376811594203,1.0165745856353592
|
|
||||||
65,0.671071953010279,1.0087527352297594
|
|
||||||
66,0.1643835616438356,1.0833333333333333
|
|
||||||
67,0.663594470046083,0.9652777777777778
|
|
||||||
68,0.0,0.0
|
|
||||||
69,0.6540880503144654,0.9447115384615384
|
|
||||||
70,0.6570121951219512,1.0092807424593968
|
|
||||||
71,0.5080645161290323,1.0052910052910053
|
|
||||||
72,0.6769911504424779,0.9368191721132898
|
|
||||||
73,0.6614420062695925,0.9881516587677726
|
|
||||||
74,0.656934306569343,0.94
|
|
||||||
75,0.3283582089552239,0.9393939393939394
|
|
||||||
76,0.5232558139534884,1.0055555555555555
|
|
||||||
77,0.518840579710145,0.994413407821229
|
|
||||||
78,0.41762452107279696,0.9724770642201835
|
|
||||||
79,0.10638297872340426,0.8
|
|
||||||
80,0.6651515151515152,1.0227790432801822
|
|
||||||
81,0.6529968454258676,0.9154589371980676
|
|
||||||
82,0.291970802919708,1.1
|
|
||||||
83,0.4692556634304207,1.0689655172413792
|
|
||||||
84,0.6749271137026239,0.9848812095032398
|
|
||||||
85,0.6671554252199413,0.9956043956043956
|
|
||||||
86,0.4906832298136646,1.0949367088607596
|
|
||||||
87,0.6494082840236687,1.0501138952164009
|
|
||||||
88,0.48923076923076925,0.9748427672955975
|
|
||||||
89,0.6661828737300436,0.9564270152505446
|
|
||||||
90,0.6705035971223021,0.9463519313304721
|
|
||||||
91,0.5123456790123457,1.0602409638554218
|
|
||||||
92,0.516320474777448,1.0
|
|
||||||
93,0.3963963963963964,0.9204545454545454
|
|
||||||
94,0.6618075801749271,1.002202643171806
|
|
||||||
95,0.5071225071225072,0.9157303370786517
|
|
||||||
96,0.6778242677824268,0.9732510288065843
|
|
||||||
97,0.6671686746987951,0.9977426636568849
|
|
||||||
98,0.0,0.0
|
|
||||||
99,0.3812154696132597,1.0289855072463767
|
|
||||||
100,0.5014836795252225,0.9467455621301775
|
|
||||||
|
Binary file not shown.
@@ -1,9 +0,0 @@
|
|||||||
,hit_rate,avg_age
|
|
||||||
count,100.0,100.0
|
|
||||||
mean,0.5381173912695726,0.966399936751214
|
|
||||||
std,0.18361763609229173,0.17530494397945118
|
|
||||||
min,0.0,0.0
|
|
||||||
25%,0.47816297246137873,0.9537065918070284
|
|
||||||
50%,0.6546302320537845,0.9949544516583623
|
|
||||||
75%,0.667165303003057,1.0265184493014563
|
|
||||||
max,0.6906377204884667,1.2375
|
|
||||||
|
@@ -1,100 +0,0 @@
|
|||||||
,access_count,hits,misses,mu,lambda,hit_rate
|
|
||||||
1,664,494,170,0,1,45.28
|
|
||||||
2,212,96,116,0,3,74.15
|
|
||||||
3,673,499,174,0,1,76.65
|
|
||||||
4,711,545,166,0,1,60.0
|
|
||||||
5,345,207,138,0,2,73.96
|
|
||||||
6,649,480,169,0,1,38.69
|
|
||||||
7,137,53,84,0,5,74.3
|
|
||||||
8,681,506,175,0,1,74.6
|
|
||||||
9,689,514,175,0,1,74.66
|
|
||||||
10,667,498,169,0,1,60.37
|
|
||||||
11,328,198,130,0,2,75.29
|
|
||||||
12,692,521,171,0,1,74.96
|
|
||||||
13,683,512,171,0,1,74.71
|
|
||||||
14,696,520,176,0,1,60.76
|
|
||||||
15,344,209,135,0,2,59.2
|
|
||||||
16,326,193,133,0,2,75.47
|
|
||||||
17,689,520,169,0,1,75.11
|
|
||||||
18,691,519,172,0,1,51.6
|
|
||||||
19,219,113,106,0,3,75.96
|
|
||||||
20,732,556,176,0,1,76.32
|
|
||||||
21,739,564,175,0,1,75.26
|
|
||||||
22,683,514,169,0,1,74.78
|
|
||||||
23,670,501,169,0,1,57.4
|
|
||||||
24,331,190,141,0,2,75.83
|
|
||||||
25,724,549,175,0,1,74.86
|
|
||||||
26,692,518,174,0,1,75.74
|
|
||||||
27,705,534,171,0,1,37.23
|
|
||||||
28,137,51,86,0,5,75.15
|
|
||||||
29,672,505,167,0,1,74.64
|
|
||||||
30,694,518,176,0,1,74.78
|
|
||||||
31,674,504,170,0,1,38.89
|
|
||||||
32,144,56,88,0,4,74.93
|
|
||||||
33,670,502,168,0,1,31.91
|
|
||||||
34,141,45,96,0,4,74.66
|
|
||||||
35,659,492,167,0,1,75.4
|
|
||||||
36,691,521,170,0,1,76.12
|
|
||||||
37,737,561,176,0,1,48.86
|
|
||||||
38,219,107,112,0,3,28.0
|
|
||||||
39,100,28,72,0,8,75.91
|
|
||||||
40,714,542,172,0,1,42.39
|
|
||||||
41,184,78,106,0,4,43.48
|
|
||||||
42,161,70,91,0,4,61.88
|
|
||||||
43,362,224,138,0,2,75.43
|
|
||||||
44,696,525,171,0,1,73.21
|
|
||||||
45,627,459,168,0,1,75.15
|
|
||||||
46,648,487,161,0,1,22.64
|
|
||||||
47,53,12,41,0,10,74.85
|
|
||||||
48,676,506,170,0,1,73.98
|
|
||||||
49,638,472,166,0,1,74.59
|
|
||||||
50,673,502,171,0,1,39.06
|
|
||||||
51,128,50,78,0,5,21.18
|
|
||||||
52,85,18,67,0,9,76.57
|
|
||||||
53,747,572,175,0,1,76.0
|
|
||||||
54,700,532,168,0,1,75.25
|
|
||||||
55,687,517,170,0,1,75.42
|
|
||||||
56,720,543,177,0,1,75.36
|
|
||||||
57,690,520,170,0,1,10.0
|
|
||||||
58,40,4,36,0,17,60.69
|
|
||||||
59,318,193,125,0,2,74.93
|
|
||||||
60,674,505,169,0,1,21.74
|
|
||||||
61,23,5,18,0,26,75.55
|
|
||||||
62,724,547,177,0,1,74.2
|
|
||||||
63,628,466,162,0,1,60.29
|
|
||||||
64,345,208,137,0,2,74.89
|
|
||||||
65,681,510,171,0,1,23.29
|
|
||||||
66,73,17,56,0,10,74.35
|
|
||||||
67,651,484,167,0,1,0.0
|
|
||||||
68,10,0,10,0,69,73.9
|
|
||||||
69,636,470,166,0,1,74.7
|
|
||||||
70,656,490,166,0,1,61.56
|
|
||||||
71,372,229,143,0,2,75.52
|
|
||||||
72,678,512,166,0,1,73.51
|
|
||||||
73,638,469,169,0,1,74.89
|
|
||||||
74,685,513,172,0,1,44.28
|
|
||||||
75,201,89,112,0,3,59.88
|
|
||||||
76,344,206,138,0,2,61.45
|
|
||||||
77,345,212,133,0,2,50.19
|
|
||||||
78,261,131,130,0,3,10.64
|
|
||||||
79,47,5,42,0,15,75.3
|
|
||||||
80,660,497,163,0,1,74.29
|
|
||||||
81,634,471,163,0,1,37.96
|
|
||||||
82,137,52,85,0,5,57.28
|
|
||||||
83,309,177,132,0,2,75.51
|
|
||||||
84,686,518,168,0,1,74.63
|
|
||||||
85,682,509,173,0,1,58.39
|
|
||||||
86,322,188,134,0,2,74.7
|
|
||||||
87,676,505,171,0,1,58.15
|
|
||||||
88,325,189,136,0,2,75.62
|
|
||||||
89,689,521,168,0,1,75.11
|
|
||||||
90,695,522,173,0,1,62.35
|
|
||||||
91,324,202,122,0,2,60.53
|
|
||||||
92,337,204,133,0,2,47.75
|
|
||||||
93,222,106,116,0,3,75.07
|
|
||||||
94,686,515,171,0,1,62.39
|
|
||||||
95,351,219,132,0,2,76.29
|
|
||||||
96,717,547,170,0,1,74.4
|
|
||||||
97,664,494,170,0,1,8.7
|
|
||||||
98,23,2,21,0,37,46.96
|
|
||||||
99,181,85,96,0,4,59.64
|
|
||||||
|
@@ -1,101 +0,0 @@
|
|||||||
obj_id,hit_rate,avg_age
|
|
||||||
1,0.7439759036144579,1.45748987854251
|
|
||||||
2,0.4528301886792453,1.5416666666666667
|
|
||||||
3,0.7414561664190193,1.4909819639278556
|
|
||||||
4,0.7665260196905767,1.6018348623853211
|
|
||||||
5,0.6,1.5507246376811594
|
|
||||||
6,0.7395993836671803,1.5833333333333333
|
|
||||||
7,0.38686131386861317,1.6603773584905661
|
|
||||||
8,0.7430249632892805,1.4703557312252964
|
|
||||||
9,0.7460087082728593,1.461089494163424
|
|
||||||
10,0.7466266866566716,1.4759036144578312
|
|
||||||
11,0.6036585365853658,1.4444444444444444
|
|
||||||
12,0.7528901734104047,1.4491362763915547
|
|
||||||
13,0.7496339677891655,1.537109375
|
|
||||||
14,0.7471264367816092,1.5596153846153846
|
|
||||||
15,0.6075581395348837,1.5023923444976077
|
|
||||||
16,0.5920245398773006,1.5803108808290156
|
|
||||||
17,0.7547169811320755,1.6423076923076922
|
|
||||||
18,0.7510853835021708,1.5260115606936415
|
|
||||||
19,0.5159817351598174,1.6106194690265487
|
|
||||||
20,0.7595628415300546,1.4460431654676258
|
|
||||||
21,0.7631935047361299,1.5088652482269505
|
|
||||||
22,0.7525622254758418,1.5291828793774318
|
|
||||||
23,0.7477611940298508,1.403193612774451
|
|
||||||
24,0.5740181268882175,1.563157894736842
|
|
||||||
25,0.7582872928176796,1.5136612021857923
|
|
||||||
26,0.7485549132947977,1.5347490347490347
|
|
||||||
27,0.7574468085106383,1.4138576779026217
|
|
||||||
28,0.3722627737226277,1.5098039215686274
|
|
||||||
29,0.7514880952380952,1.506930693069307
|
|
||||||
30,0.7463976945244957,1.555984555984556
|
|
||||||
31,0.7477744807121661,1.5297619047619047
|
|
||||||
32,0.3888888888888889,1.5
|
|
||||||
33,0.7492537313432835,1.4302788844621515
|
|
||||||
34,0.3191489361702128,1.3777777777777778
|
|
||||||
35,0.7465857359635811,1.5142276422764227
|
|
||||||
36,0.7539797395079595,1.5009596928982725
|
|
||||||
37,0.7611940298507462,1.5080213903743316
|
|
||||||
38,0.4885844748858447,1.5794392523364487
|
|
||||||
39,0.28,1.6785714285714286
|
|
||||||
40,0.7591036414565826,1.6199261992619927
|
|
||||||
41,0.42391304347826086,1.7179487179487178
|
|
||||||
42,0.43478260869565216,1.6857142857142857
|
|
||||||
43,0.6187845303867403,1.3392857142857142
|
|
||||||
44,0.7543103448275862,1.5447619047619048
|
|
||||||
45,0.7320574162679426,1.5359477124183007
|
|
||||||
46,0.7515432098765432,1.5010266940451746
|
|
||||||
47,0.22641509433962265,1.9166666666666667
|
|
||||||
48,0.7485207100591716,1.5118577075098814
|
|
||||||
49,0.7398119122257053,1.4406779661016949
|
|
||||||
50,0.7459138187221397,1.4760956175298805
|
|
||||||
51,0.390625,1.44
|
|
||||||
52,0.21176470588235294,1.2777777777777777
|
|
||||||
53,0.7657295850066934,1.4912587412587412
|
|
||||||
54,0.76,1.5432330827067668
|
|
||||||
55,0.75254730713246,1.4700193423597678
|
|
||||||
56,0.7541666666666667,1.3922651933701657
|
|
||||||
57,0.7536231884057971,1.5288461538461537
|
|
||||||
58,0.1,1.5
|
|
||||||
59,0.6069182389937107,1.5025906735751295
|
|
||||||
60,0.7492581602373887,1.508910891089109
|
|
||||||
61,0.21739130434782608,0.6
|
|
||||||
62,0.755524861878453,1.5045703839122486
|
|
||||||
63,0.7420382165605095,1.4785407725321889
|
|
||||||
64,0.6028985507246377,1.4519230769230769
|
|
||||||
65,0.748898678414097,1.4843137254901961
|
|
||||||
66,0.2328767123287671,1.588235294117647
|
|
||||||
67,0.7434715821812596,1.493801652892562
|
|
||||||
68,0.0,0.0
|
|
||||||
69,0.7389937106918238,1.553191489361702
|
|
||||||
70,0.7469512195121951,1.530612244897959
|
|
||||||
71,0.6155913978494624,1.5327510917030567
|
|
||||||
72,0.7551622418879056,1.484375
|
|
||||||
73,0.7351097178683386,1.4179104477611941
|
|
||||||
74,0.7489051094890511,1.557504873294347
|
|
||||||
75,0.4427860696517413,1.5056179775280898
|
|
||||||
76,0.5988372093023255,1.441747572815534
|
|
||||||
77,0.6144927536231884,1.4433962264150944
|
|
||||||
78,0.5019157088122606,1.4885496183206106
|
|
||||||
79,0.10638297872340426,0.8
|
|
||||||
80,0.753030303030303,1.5070422535211268
|
|
||||||
81,0.7429022082018928,1.4692144373673035
|
|
||||||
82,0.3795620437956204,1.5192307692307692
|
|
||||||
83,0.5728155339805825,1.5197740112994351
|
|
||||||
84,0.7551020408163265,1.494208494208494
|
|
||||||
85,0.7463343108504399,1.3889980353634577
|
|
||||||
86,0.5838509316770186,1.5106382978723405
|
|
||||||
87,0.7470414201183432,1.4792079207920792
|
|
||||||
88,0.5815384615384616,1.3915343915343916
|
|
||||||
89,0.7561683599419449,1.5335892514395393
|
|
||||||
90,0.7510791366906475,1.496168582375479
|
|
||||||
91,0.6234567901234568,1.5792079207920793
|
|
||||||
92,0.6053412462908012,1.392156862745098
|
|
||||||
93,0.4774774774774775,1.4622641509433962
|
|
||||||
94,0.750728862973761,1.5728155339805825
|
|
||||||
95,0.6239316239316239,1.5342465753424657
|
|
||||||
96,0.7629009762900977,1.4204753199268738
|
|
||||||
97,0.7439759036144579,1.4412955465587045
|
|
||||||
98,0.08695652173913043,3.0
|
|
||||||
99,0.4696132596685083,1.411764705882353
|
|
||||||
100,0.5964391691394659,1.328358208955224
|
|
||||||
|
Binary file not shown.
@@ -1,9 +0,0 @@
|
|||||||
,hit_rate,avg_age
|
|
||||||
count,100.0,100.0
|
|
||||||
mean,0.6224679450442043,1.4900421658850633
|
|
||||||
std,0.18900729549961315,0.2559552015594171
|
|
||||||
min,0.0,0.0
|
|
||||||
25%,0.5737174786613087,1.4512263767901963
|
|
||||||
50%,0.7429635857455866,1.5035805287436892
|
|
||||||
75%,0.7511860614361519,1.5382486979166667
|
|
||||||
max,0.7665260196905767,3.0
|
|
||||||
|
@@ -1,100 +0,0 @@
|
|||||||
,access_count,hits,misses,mu,lambda,hit_rate
|
|
||||||
1,664,527,137,0,1,52.83
|
|
||||||
2,212,112,100,0,3,79.79
|
|
||||||
3,673,537,136,0,1,80.87
|
|
||||||
4,711,575,136,0,1,68.99
|
|
||||||
5,345,238,107,0,2,79.35
|
|
||||||
6,649,515,134,0,1,43.8
|
|
||||||
7,137,60,77,0,5,80.32
|
|
||||||
8,681,547,134,0,1,79.97
|
|
||||||
9,689,551,138,0,1,79.31
|
|
||||||
10,667,529,138,0,1,68.29
|
|
||||||
11,328,224,104,0,2,80.2
|
|
||||||
12,692,555,137,0,1,80.09
|
|
||||||
13,683,547,136,0,1,80.6
|
|
||||||
14,696,561,135,0,1,67.15
|
|
||||||
15,344,231,113,0,2,65.64
|
|
||||||
16,326,214,112,0,2,80.12
|
|
||||||
17,689,552,137,0,1,80.32
|
|
||||||
18,691,555,136,0,1,55.71
|
|
||||||
19,219,122,97,0,3,80.87
|
|
||||||
20,732,592,140,0,1,81.33
|
|
||||||
21,739,601,138,0,1,79.8
|
|
||||||
22,683,545,138,0,1,79.85
|
|
||||||
23,670,535,135,0,1,67.07
|
|
||||||
24,331,222,109,0,2,80.66
|
|
||||||
25,724,584,140,0,1,80.35
|
|
||||||
26,692,556,136,0,1,80.85
|
|
||||||
27,705,570,135,0,1,43.8
|
|
||||||
28,137,60,77,0,5,79.76
|
|
||||||
29,672,536,136,0,1,79.83
|
|
||||||
30,694,554,140,0,1,79.82
|
|
||||||
31,674,538,136,0,1,47.92
|
|
||||||
32,144,69,75,0,4,79.55
|
|
||||||
33,670,533,137,0,1,43.26
|
|
||||||
34,141,61,80,0,4,79.51
|
|
||||||
35,659,524,135,0,1,80.03
|
|
||||||
36,691,553,138,0,1,80.73
|
|
||||||
37,737,595,142,0,1,57.08
|
|
||||||
38,219,125,94,0,3,37.0
|
|
||||||
39,100,37,63,0,8,80.39
|
|
||||||
40,714,574,140,0,1,50.54
|
|
||||||
41,184,93,91,0,4,47.83
|
|
||||||
42,161,77,84,0,4,68.51
|
|
||||||
43,362,248,114,0,2,80.6
|
|
||||||
44,696,561,135,0,1,78.63
|
|
||||||
45,627,493,134,0,1,79.63
|
|
||||||
46,648,516,132,0,1,24.53
|
|
||||||
47,53,13,40,0,10,79.73
|
|
||||||
48,676,539,137,0,1,78.68
|
|
||||||
49,638,502,136,0,1,79.35
|
|
||||||
50,673,534,139,0,1,42.97
|
|
||||||
51,128,55,73,0,5,30.59
|
|
||||||
52,85,26,59,0,9,81.12
|
|
||||||
53,747,606,141,0,1,81.0
|
|
||||||
54,700,567,133,0,1,80.2
|
|
||||||
55,687,551,136,0,1,81.25
|
|
||||||
56,720,585,135,0,1,79.57
|
|
||||||
57,690,549,141,0,1,12.5
|
|
||||||
58,40,5,35,0,17,65.72
|
|
||||||
59,318,209,109,0,2,79.82
|
|
||||||
60,674,538,136,0,1,21.74
|
|
||||||
61,23,5,18,0,26,80.94
|
|
||||||
62,724,586,138,0,1,78.34
|
|
||||||
63,628,492,136,0,1,66.96
|
|
||||||
64,345,231,114,0,2,80.62
|
|
||||||
65,681,549,132,0,1,28.77
|
|
||||||
66,73,21,52,0,10,79.57
|
|
||||||
67,651,518,133,0,1,0.0
|
|
||||||
68,10,0,10,0,69,78.46
|
|
||||||
69,636,499,137,0,1,79.73
|
|
||||||
70,656,523,133,0,1,67.74
|
|
||||||
71,372,252,120,0,2,80.38
|
|
||||||
72,678,545,133,0,1,79.31
|
|
||||||
73,638,506,132,0,1,79.85
|
|
||||||
74,685,547,138,0,1,52.24
|
|
||||||
75,201,105,96,0,3,65.99
|
|
||||||
76,344,227,117,0,2,68.41
|
|
||||||
77,345,236,109,0,2,59.0
|
|
||||||
78,261,154,107,0,3,14.89
|
|
||||||
79,47,7,40,0,15,79.7
|
|
||||||
80,660,526,134,0,1,79.02
|
|
||||||
81,634,501,133,0,1,43.07
|
|
||||||
82,137,59,78,0,5,65.05
|
|
||||||
83,309,201,108,0,2,80.47
|
|
||||||
84,686,552,134,0,1,79.47
|
|
||||||
85,682,542,140,0,1,64.91
|
|
||||||
86,322,209,113,0,2,79.14
|
|
||||||
87,676,535,141,0,1,65.23
|
|
||||||
88,325,212,113,0,2,80.41
|
|
||||||
89,689,554,135,0,1,80.43
|
|
||||||
90,695,559,136,0,1,67.59
|
|
||||||
91,324,219,105,0,2,67.36
|
|
||||||
92,337,227,110,0,2,56.76
|
|
||||||
93,222,126,96,0,3,79.74
|
|
||||||
94,686,547,139,0,1,68.38
|
|
||||||
95,351,240,111,0,2,80.61
|
|
||||||
96,717,578,139,0,1,79.52
|
|
||||||
97,664,528,136,0,1,17.39
|
|
||||||
98,23,4,19,0,37,53.04
|
|
||||||
99,181,96,85,0,4,68.25
|
|
||||||
|
@@ -1,101 +0,0 @@
|
|||||||
obj_id,hit_rate,avg_age
|
|
||||||
1,0.7936746987951807,1.9316888045540797
|
|
||||||
2,0.5283018867924528,2.080357142857143
|
|
||||||
3,0.7979197622585439,2.0242085661080074
|
|
||||||
4,0.8087201125175809,2.1339130434782607
|
|
||||||
5,0.6898550724637681,2.168067226890756
|
|
||||||
6,0.7935285053929122,1.9300970873786407
|
|
||||||
7,0.43795620437956206,1.9333333333333333
|
|
||||||
8,0.8032305433186491,2.03290676416819
|
|
||||||
9,0.7997097242380261,1.9945553539019965
|
|
||||||
10,0.7931034482758621,2.007561436672968
|
|
||||||
11,0.6829268292682927,1.9866071428571428
|
|
||||||
12,0.8020231213872833,1.936936936936937
|
|
||||||
13,0.8008784773060029,2.113345521023766
|
|
||||||
14,0.8060344827586207,1.9946524064171123
|
|
||||||
15,0.6715116279069767,1.8874458874458875
|
|
||||||
16,0.656441717791411,2.046728971962617
|
|
||||||
17,0.8011611030478955,1.9728260869565217
|
|
||||||
18,0.8031837916063675,2.045045045045045
|
|
||||||
19,0.5570776255707762,1.9344262295081966
|
|
||||||
20,0.8087431693989071,2.0591216216216215
|
|
||||||
21,0.8132611637347767,2.043261231281198
|
|
||||||
22,0.7979502196193266,1.9064220183486238
|
|
||||||
23,0.7985074626865671,1.97196261682243
|
|
||||||
24,0.6706948640483383,2.1036036036036037
|
|
||||||
25,0.8066298342541437,1.9777397260273972
|
|
||||||
26,0.8034682080924855,2.1097122302158273
|
|
||||||
27,0.8085106382978723,2.1070175438596492
|
|
||||||
28,0.43795620437956206,2.1666666666666665
|
|
||||||
29,0.7976190476190477,1.9011194029850746
|
|
||||||
30,0.7982708933717579,1.96028880866426
|
|
||||||
31,0.798219584569733,2.0780669144981414
|
|
||||||
32,0.4791666666666667,2.1594202898550723
|
|
||||||
33,0.7955223880597015,1.8818011257035647
|
|
||||||
34,0.4326241134751773,2.2131147540983607
|
|
||||||
35,0.795144157814871,2.068702290076336
|
|
||||||
36,0.8002894356005789,1.9620253164556962
|
|
||||||
37,0.8073270013568521,1.946218487394958
|
|
||||||
38,0.5707762557077626,2.096
|
|
||||||
39,0.37,2.27027027027027
|
|
||||||
40,0.803921568627451,2.06794425087108
|
|
||||||
41,0.5054347826086957,2.204301075268817
|
|
||||||
42,0.4782608695652174,2.1948051948051948
|
|
||||||
43,0.6850828729281768,1.8830645161290323
|
|
||||||
44,0.8060344827586207,2.0089126559714794
|
|
||||||
45,0.7862838915470495,1.997971602434077
|
|
||||||
46,0.7962962962962963,2.0174418604651163
|
|
||||||
47,0.24528301886792453,2.1538461538461537
|
|
||||||
48,0.7973372781065089,1.9851576994434137
|
|
||||||
49,0.786833855799373,2.0358565737051793
|
|
||||||
50,0.7934621099554234,1.9194756554307115
|
|
||||||
51,0.4296875,1.6363636363636365
|
|
||||||
52,0.3058823529411765,1.8846153846153846
|
|
||||||
53,0.8112449799196787,2.0132013201320134
|
|
||||||
54,0.81,2.0
|
|
||||||
55,0.8020378457059679,1.9310344827586208
|
|
||||||
56,0.8125,1.982905982905983
|
|
||||||
57,0.7956521739130434,2.0491803278688523
|
|
||||||
58,0.125,2.2
|
|
||||||
59,0.6572327044025157,1.9569377990430623
|
|
||||||
60,0.798219584569733,2.029739776951673
|
|
||||||
61,0.21739130434782608,0.6
|
|
||||||
62,0.8093922651933702,1.9112627986348123
|
|
||||||
63,0.7834394904458599,1.8333333333333333
|
|
||||||
64,0.6695652173913044,1.948051948051948
|
|
||||||
65,0.8061674008810573,2.034608378870674
|
|
||||||
66,0.2876712328767123,2.0952380952380953
|
|
||||||
67,0.7956989247311828,2.0656370656370657
|
|
||||||
68,0.0,0.0
|
|
||||||
69,0.7845911949685535,1.9799599198396793
|
|
||||||
70,0.7972560975609756,2.0095602294455066
|
|
||||||
71,0.6774193548387096,1.9722222222222223
|
|
||||||
72,0.803834808259587,1.891743119266055
|
|
||||||
73,0.7931034482758621,1.8893280632411067
|
|
||||||
74,0.7985401459854015,2.043875685557587
|
|
||||||
75,0.5223880597014925,2.2095238095238097
|
|
||||||
76,0.6598837209302325,1.9955947136563876
|
|
||||||
77,0.6840579710144927,2.0254237288135593
|
|
||||||
78,0.5900383141762452,2.0064935064935066
|
|
||||||
79,0.14893617021276595,1.5714285714285714
|
|
||||||
80,0.796969696969697,2.0
|
|
||||||
81,0.7902208201892744,2.0339321357285427
|
|
||||||
82,0.4306569343065693,1.8644067796610169
|
|
||||||
83,0.6504854368932039,2.2487562189054726
|
|
||||||
84,0.8046647230320699,1.9909420289855073
|
|
||||||
85,0.7947214076246334,1.985239852398524
|
|
||||||
86,0.6490683229813664,1.8229665071770336
|
|
||||||
87,0.7914201183431953,2.0261682242990653
|
|
||||||
88,0.6523076923076923,1.9575471698113207
|
|
||||||
89,0.8040638606676342,1.94043321299639
|
|
||||||
90,0.8043165467625899,2.0697674418604652
|
|
||||||
91,0.6759259259259259,1.9680365296803652
|
|
||||||
92,0.6735905044510386,1.9162995594713657
|
|
||||||
93,0.5675675675675675,1.9523809523809523
|
|
||||||
94,0.7973760932944607,2.1316270566727606
|
|
||||||
95,0.6837606837606838,2.0208333333333335
|
|
||||||
96,0.806136680613668,2.0328719723183393
|
|
||||||
97,0.7951807228915663,1.9109848484848484
|
|
||||||
98,0.17391304347826086,3.0
|
|
||||||
99,0.5303867403314917,1.8854166666666667
|
|
||||||
100,0.6824925816023739,1.8956521739130434
|
|
||||||
|
Binary file not shown.
Binary file not shown.
@@ -1,9 +0,0 @@
|
|||||||
,hit_rate,avg_age
|
|
||||||
count,100.0,100.0
|
|
||||||
mean,0.6783420943812974,1.9802754170895376
|
|
||||||
std,0.18732473237217517,0.28636988978093675
|
|
||||||
min,0.0,0.0
|
|
||||||
25%,0.6501311584152445,1.9341530054644809
|
|
||||||
50%,0.7932827791156427,1.9989858012170385
|
|
||||||
75%,0.800949133741476,2.0662138619455694
|
|
||||||
max,0.8132611637347767,3.0
|
|
||||||
|
@@ -1,100 +0,0 @@
|
|||||||
,access_count,hits,misses,mu,lambda,hit_rate
|
|
||||||
1,664,550,114,0,1,58.49
|
|
||||||
2,212,124,88,0,3,83.21
|
|
||||||
3,673,560,113,0,1,84.11
|
|
||||||
4,711,598,113,0,1,72.17
|
|
||||||
5,345,249,96,0,2,82.43
|
|
||||||
6,649,535,114,0,1,50.36
|
|
||||||
7,137,69,68,0,5,83.41
|
|
||||||
8,681,568,113,0,1,83.74
|
|
||||||
9,689,577,112,0,1,82.91
|
|
||||||
10,667,553,114,0,1,71.34
|
|
||||||
11,328,234,94,0,2,83.67
|
|
||||||
12,692,579,113,0,1,83.46
|
|
||||||
13,683,570,113,0,1,83.48
|
|
||||||
14,696,581,115,0,1,70.64
|
|
||||||
15,344,243,101,0,2,71.78
|
|
||||||
16,326,234,92,0,2,83.45
|
|
||||||
17,689,575,114,0,1,83.65
|
|
||||||
18,691,578,113,0,1,62.56
|
|
||||||
19,219,137,82,0,3,84.29
|
|
||||||
20,732,617,115,0,1,84.44
|
|
||||||
21,739,624,115,0,1,83.31
|
|
||||||
22,683,569,114,0,1,83.13
|
|
||||||
23,670,557,113,0,1,71.3
|
|
||||||
24,331,236,95,0,2,83.84
|
|
||||||
25,724,607,117,0,1,83.38
|
|
||||||
26,692,577,115,0,1,83.69
|
|
||||||
27,705,590,115,0,1,48.18
|
|
||||||
28,137,66,71,0,5,83.04
|
|
||||||
29,672,558,114,0,1,83.43
|
|
||||||
30,694,579,115,0,1,83.23
|
|
||||||
31,674,561,113,0,1,51.39
|
|
||||||
32,144,74,70,0,4,83.13
|
|
||||||
33,670,557,113,0,1,48.94
|
|
||||||
34,141,69,72,0,4,83.0
|
|
||||||
35,659,547,112,0,1,83.36
|
|
||||||
36,691,576,115,0,1,84.67
|
|
||||||
37,737,624,113,0,1,62.56
|
|
||||||
38,219,137,82,0,3,41.0
|
|
||||||
39,100,41,59,0,8,83.61
|
|
||||||
40,714,597,117,0,1,55.98
|
|
||||||
41,184,103,81,0,4,57.14
|
|
||||||
42,161,92,69,0,4,73.76
|
|
||||||
43,362,267,95,0,2,83.91
|
|
||||||
44,696,584,112,0,1,82.46
|
|
||||||
45,627,517,110,0,1,82.72
|
|
||||||
46,648,536,112,0,1,30.19
|
|
||||||
47,53,16,37,0,10,83.14
|
|
||||||
48,676,562,114,0,1,82.29
|
|
||||||
49,638,525,113,0,1,83.06
|
|
||||||
50,673,559,114,0,1,49.22
|
|
||||||
51,128,63,65,0,5,34.12
|
|
||||||
52,85,29,56,0,9,84.34
|
|
||||||
53,747,630,117,0,1,83.86
|
|
||||||
54,700,587,113,0,1,83.41
|
|
||||||
55,687,573,114,0,1,83.75
|
|
||||||
56,720,603,117,0,1,83.33
|
|
||||||
57,690,575,115,0,1,17.5
|
|
||||||
58,40,7,33,0,17,70.13
|
|
||||||
59,318,223,95,0,2,82.94
|
|
||||||
60,674,559,115,0,1,21.74
|
|
||||||
61,23,5,18,0,26,83.84
|
|
||||||
62,724,607,117,0,1,82.17
|
|
||||||
63,628,516,112,0,1,71.59
|
|
||||||
64,345,247,98,0,2,83.11
|
|
||||||
65,681,566,115,0,1,31.51
|
|
||||||
66,73,23,50,0,10,83.1
|
|
||||||
67,651,541,110,0,1,0.0
|
|
||||||
68,10,0,10,0,69,82.55
|
|
||||||
69,636,525,111,0,1,82.62
|
|
||||||
70,656,542,114,0,1,73.12
|
|
||||||
71,372,272,100,0,2,83.48
|
|
||||||
72,678,566,112,0,1,82.13
|
|
||||||
73,638,524,114,0,1,82.92
|
|
||||||
74,685,568,117,0,1,57.71
|
|
||||||
75,201,116,85,0,3,72.67
|
|
||||||
76,344,250,94,0,2,72.17
|
|
||||||
77,345,249,96,0,2,64.75
|
|
||||||
78,261,169,92,0,3,19.15
|
|
||||||
79,47,9,38,0,15,83.48
|
|
||||||
80,660,551,109,0,1,82.18
|
|
||||||
81,634,521,113,0,1,51.09
|
|
||||||
82,137,70,67,0,5,69.58
|
|
||||||
83,309,215,94,0,2,83.53
|
|
||||||
84,686,573,113,0,1,82.84
|
|
||||||
85,682,565,117,0,1,71.12
|
|
||||||
86,322,229,93,0,2,83.28
|
|
||||||
87,676,563,113,0,1,68.62
|
|
||||||
88,325,223,102,0,2,83.16
|
|
||||||
89,689,573,116,0,1,83.31
|
|
||||||
90,695,579,116,0,1,73.15
|
|
||||||
91,324,237,87,0,2,72.11
|
|
||||||
92,337,243,94,0,2,63.51
|
|
||||||
93,222,141,81,0,3,83.09
|
|
||||||
94,686,570,116,0,1,71.79
|
|
||||||
95,351,252,99,0,2,84.66
|
|
||||||
96,717,607,110,0,1,83.28
|
|
||||||
97,664,553,111,0,1,21.74
|
|
||||||
98,23,5,18,0,37,56.91
|
|
||||||
99,181,103,78,0,4,70.62
|
|
||||||
|
@@ -1,101 +0,0 @@
|
|||||||
obj_id,hit_rate,avg_age
|
|
||||||
1,0.8283132530120482,2.596363636363636
|
|
||||||
2,0.5849056603773585,2.524193548387097
|
|
||||||
3,0.8320950965824666,2.405357142857143
|
|
||||||
4,0.8410689170182841,2.4013377926421406
|
|
||||||
5,0.7217391304347827,2.4698795180722892
|
|
||||||
6,0.8243451463790447,2.3906542056074764
|
|
||||||
7,0.5036496350364964,2.739130434782609
|
|
||||||
8,0.8340675477239354,2.433098591549296
|
|
||||||
9,0.8374455732946299,2.5095320623916813
|
|
||||||
10,0.8290854572713643,2.5750452079566
|
|
||||||
11,0.7134146341463414,2.4188034188034186
|
|
||||||
12,0.8367052023121387,2.5250431778929188
|
|
||||||
13,0.8345534407027818,2.5526315789473686
|
|
||||||
14,0.8347701149425287,2.495697074010327
|
|
||||||
15,0.7063953488372093,2.522633744855967
|
|
||||||
16,0.7177914110429447,2.7777777777777777
|
|
||||||
17,0.8345428156748912,2.4991304347826087
|
|
||||||
18,0.8364688856729378,2.48961937716263
|
|
||||||
19,0.6255707762557078,2.562043795620438
|
|
||||||
20,0.842896174863388,2.521880064829822
|
|
||||||
21,0.8443843031123139,2.4759615384615383
|
|
||||||
22,0.8330893118594437,2.4938488576449913
|
|
||||||
23,0.8313432835820895,2.466786355475763
|
|
||||||
24,0.7129909365558912,2.5466101694915255
|
|
||||||
25,0.8383977900552486,2.3789126853377267
|
|
||||||
26,0.8338150289017341,2.5753899480069324
|
|
||||||
27,0.8368794326241135,2.422033898305085
|
|
||||||
28,0.48175182481751827,2.5757575757575757
|
|
||||||
29,0.8303571428571429,2.4408602150537635
|
|
||||||
30,0.8342939481268011,2.597582037996546
|
|
||||||
31,0.8323442136498517,2.443850267379679
|
|
||||||
32,0.5138888888888888,2.554054054054054
|
|
||||||
33,0.8313432835820895,2.443447037701975
|
|
||||||
34,0.48936170212765956,2.6231884057971016
|
|
||||||
35,0.8300455235204856,2.409506398537477
|
|
||||||
36,0.8335745296671491,2.4444444444444446
|
|
||||||
37,0.8466757123473542,2.3846153846153846
|
|
||||||
38,0.6255707762557078,2.81021897810219
|
|
||||||
39,0.41,2.5121951219512195
|
|
||||||
40,0.8361344537815126,2.5008375209380236
|
|
||||||
41,0.5597826086956522,2.5728155339805827
|
|
||||||
42,0.5714285714285714,2.6847826086956523
|
|
||||||
43,0.7375690607734806,2.397003745318352
|
|
||||||
44,0.8390804597701149,2.4914383561643834
|
|
||||||
45,0.8245614035087719,2.4545454545454546
|
|
||||||
46,0.8271604938271605,2.5167910447761193
|
|
||||||
47,0.3018867924528302,2.9375
|
|
||||||
48,0.8313609467455622,2.597864768683274
|
|
||||||
49,0.822884012539185,2.5238095238095237
|
|
||||||
50,0.8306092124814265,2.4991055456171734
|
|
||||||
51,0.4921875,2.3492063492063493
|
|
||||||
52,0.3411764705882353,2.1724137931034484
|
|
||||||
53,0.8433734939759037,2.5365079365079364
|
|
||||||
54,0.8385714285714285,2.5792163543441227
|
|
||||||
55,0.834061135371179,2.4223385689354275
|
|
||||||
56,0.8375,2.527363184079602
|
|
||||||
57,0.8333333333333334,2.3756521739130436
|
|
||||||
58,0.175,3.0
|
|
||||||
59,0.7012578616352201,2.506726457399103
|
|
||||||
60,0.8293768545994066,2.4686940966010735
|
|
||||||
61,0.21739130434782608,0.6
|
|
||||||
62,0.8383977900552486,2.6227347611202636
|
|
||||||
63,0.821656050955414,2.4108527131782944
|
|
||||||
64,0.7159420289855073,2.42914979757085
|
|
||||||
65,0.8311306901615272,2.57773851590106
|
|
||||||
66,0.3150684931506849,2.782608695652174
|
|
||||||
67,0.8310291858678955,2.478743068391867
|
|
||||||
68,0.0,0.0
|
|
||||||
69,0.8254716981132075,2.459047619047619
|
|
||||||
70,0.8262195121951219,2.559040590405904
|
|
||||||
71,0.7311827956989247,2.6544117647058822
|
|
||||||
72,0.8348082595870207,2.487632508833922
|
|
||||||
73,0.8213166144200627,2.427480916030534
|
|
||||||
74,0.8291970802919708,2.482394366197183
|
|
||||||
75,0.5771144278606966,2.7327586206896552
|
|
||||||
76,0.7267441860465116,2.576
|
|
||||||
77,0.7217391304347827,2.4859437751004014
|
|
||||||
78,0.6475095785440613,2.5562130177514795
|
|
||||||
79,0.19148936170212766,2.5555555555555554
|
|
||||||
80,0.8348484848484848,2.6515426497277677
|
|
||||||
81,0.8217665615141956,2.44721689059501
|
|
||||||
82,0.5109489051094891,2.557142857142857
|
|
||||||
83,0.6957928802588996,2.7209302325581395
|
|
||||||
84,0.8352769679300291,2.4694589877835953
|
|
||||||
85,0.8284457478005866,2.320353982300885
|
|
||||||
86,0.7111801242236024,2.6026200873362444
|
|
||||||
87,0.8328402366863905,2.644760213143872
|
|
||||||
88,0.6861538461538461,2.4260089686098656
|
|
||||||
89,0.8316400580551524,2.5095986038394416
|
|
||||||
90,0.8330935251798561,2.542314335060449
|
|
||||||
91,0.7314814814814815,2.261603375527426
|
|
||||||
92,0.7210682492581603,2.316872427983539
|
|
||||||
93,0.6351351351351351,2.5106382978723403
|
|
||||||
94,0.8309037900874635,2.507017543859649
|
|
||||||
95,0.717948717948718,2.373015873015873
|
|
||||||
96,0.8465829846582985,2.4365733113673804
|
|
||||||
97,0.8328313253012049,2.54249547920434
|
|
||||||
98,0.21739130434782608,3.4
|
|
||||||
99,0.569060773480663,2.320388349514563
|
|
||||||
100,0.7062314540059347,2.3529411764705883
|
|
||||||
|
Binary file not shown.
Binary file not shown.
@@ -1,9 +0,0 @@
|
|||||||
,hit_rate,avg_age
|
|
||||||
count,100.0,100.0
|
|
||||||
mean,0.7175225869007572,2.4791552890507336
|
|
||||||
std,0.1841955218651161,0.35131346514105605
|
|
||||||
min,0.0,0.0
|
|
||||||
25%,0.6933831217326363,2.4321113930546847
|
|
||||||
50%,0.8266900030111413,2.503781989168563
|
|
||||||
75%,0.8338765555190953,2.573372952474587
|
|
||||||
max,0.8466757123473542,3.4
|
|
||||||
|
@@ -1,15 +0,0 @@
|
|||||||
# Experiments: No Refresh with variable TTL
|
|
||||||
|
|
||||||
Explanation for files in each experiment:
|
|
||||||
|
|
||||||
- `details.csv`: Access Count, Hit, Miss, Mu, Lambda and Hit Rate for each object
|
|
||||||
- `hit_age.csv`: Shows hit rate/average age at time of request for each object.
|
|
||||||
- `lambda_distribution.pdf`: Lambda Distribution across all objects/discrete
|
|
||||||
values of the Zipf distribution
|
|
||||||
- `objects_in_cache_over_time.pdf`: Amount of cache entries at given time.
|
|
||||||
- `overall_hit_age.csv`: Cumulative description of `hit_age.csv`
|
|
||||||
|
|
||||||
Length of simulation doesn't change much since we're not touching the request
|
|
||||||
rate across the simulations.
|
|
||||||
Break condition for the simulation is when the each database object has been
|
|
||||||
requested at least `ACCESS_COUNT_LIMIT` (i.e. 10) times.
|
|
||||||
100
export.csv
100
export.csv
@@ -1,100 +0,0 @@
|
|||||||
,access_count,hits,misses,mu,lambda,hit_rate
|
|
||||||
1,664,550,114,0,1,58.49
|
|
||||||
2,212,124,88,0,3,83.21
|
|
||||||
3,673,560,113,0,1,84.11
|
|
||||||
4,711,598,113,0,1,72.17
|
|
||||||
5,345,249,96,0,2,82.43
|
|
||||||
6,649,535,114,0,1,50.36
|
|
||||||
7,137,69,68,0,5,83.41
|
|
||||||
8,681,568,113,0,1,83.74
|
|
||||||
9,689,577,112,0,1,82.91
|
|
||||||
10,667,553,114,0,1,71.34
|
|
||||||
11,328,234,94,0,2,83.67
|
|
||||||
12,692,579,113,0,1,83.46
|
|
||||||
13,683,570,113,0,1,83.48
|
|
||||||
14,696,581,115,0,1,70.64
|
|
||||||
15,344,243,101,0,2,71.78
|
|
||||||
16,326,234,92,0,2,83.45
|
|
||||||
17,689,575,114,0,1,83.65
|
|
||||||
18,691,578,113,0,1,62.56
|
|
||||||
19,219,137,82,0,3,84.29
|
|
||||||
20,732,617,115,0,1,84.44
|
|
||||||
21,739,624,115,0,1,83.31
|
|
||||||
22,683,569,114,0,1,83.13
|
|
||||||
23,670,557,113,0,1,71.3
|
|
||||||
24,331,236,95,0,2,83.84
|
|
||||||
25,724,607,117,0,1,83.38
|
|
||||||
26,692,577,115,0,1,83.69
|
|
||||||
27,705,590,115,0,1,48.18
|
|
||||||
28,137,66,71,0,5,83.04
|
|
||||||
29,672,558,114,0,1,83.43
|
|
||||||
30,694,579,115,0,1,83.23
|
|
||||||
31,674,561,113,0,1,51.39
|
|
||||||
32,144,74,70,0,4,83.13
|
|
||||||
33,670,557,113,0,1,48.94
|
|
||||||
34,141,69,72,0,4,83.0
|
|
||||||
35,659,547,112,0,1,83.36
|
|
||||||
36,691,576,115,0,1,84.67
|
|
||||||
37,737,624,113,0,1,62.56
|
|
||||||
38,219,137,82,0,3,41.0
|
|
||||||
39,100,41,59,0,8,83.61
|
|
||||||
40,714,597,117,0,1,55.98
|
|
||||||
41,184,103,81,0,4,57.14
|
|
||||||
42,161,92,69,0,4,73.76
|
|
||||||
43,362,267,95,0,2,83.91
|
|
||||||
44,696,584,112,0,1,82.46
|
|
||||||
45,627,517,110,0,1,82.72
|
|
||||||
46,648,536,112,0,1,30.19
|
|
||||||
47,53,16,37,0,10,83.14
|
|
||||||
48,676,562,114,0,1,82.29
|
|
||||||
49,638,525,113,0,1,83.06
|
|
||||||
50,673,559,114,0,1,49.22
|
|
||||||
51,128,63,65,0,5,34.12
|
|
||||||
52,85,29,56,0,9,84.34
|
|
||||||
53,747,630,117,0,1,83.86
|
|
||||||
54,700,587,113,0,1,83.41
|
|
||||||
55,687,573,114,0,1,83.75
|
|
||||||
56,720,603,117,0,1,83.33
|
|
||||||
57,690,575,115,0,1,17.5
|
|
||||||
58,40,7,33,0,17,70.13
|
|
||||||
59,318,223,95,0,2,82.94
|
|
||||||
60,674,559,115,0,1,21.74
|
|
||||||
61,23,5,18,0,26,83.84
|
|
||||||
62,724,607,117,0,1,82.17
|
|
||||||
63,628,516,112,0,1,71.59
|
|
||||||
64,345,247,98,0,2,83.11
|
|
||||||
65,681,566,115,0,1,31.51
|
|
||||||
66,73,23,50,0,10,83.1
|
|
||||||
67,651,541,110,0,1,0.0
|
|
||||||
68,10,0,10,0,69,82.55
|
|
||||||
69,636,525,111,0,1,82.62
|
|
||||||
70,656,542,114,0,1,73.12
|
|
||||||
71,372,272,100,0,2,83.48
|
|
||||||
72,678,566,112,0,1,82.13
|
|
||||||
73,638,524,114,0,1,82.92
|
|
||||||
74,685,568,117,0,1,57.71
|
|
||||||
75,201,116,85,0,3,72.67
|
|
||||||
76,344,250,94,0,2,72.17
|
|
||||||
77,345,249,96,0,2,64.75
|
|
||||||
78,261,169,92,0,3,19.15
|
|
||||||
79,47,9,38,0,15,83.48
|
|
||||||
80,660,551,109,0,1,82.18
|
|
||||||
81,634,521,113,0,1,51.09
|
|
||||||
82,137,70,67,0,5,69.58
|
|
||||||
83,309,215,94,0,2,83.53
|
|
||||||
84,686,573,113,0,1,82.84
|
|
||||||
85,682,565,117,0,1,71.12
|
|
||||||
86,322,229,93,0,2,83.28
|
|
||||||
87,676,563,113,0,1,68.62
|
|
||||||
88,325,223,102,0,2,83.16
|
|
||||||
89,689,573,116,0,1,83.31
|
|
||||||
90,695,579,116,0,1,73.15
|
|
||||||
91,324,237,87,0,2,72.11
|
|
||||||
92,337,243,94,0,2,63.51
|
|
||||||
93,222,141,81,0,3,83.09
|
|
||||||
94,686,570,116,0,1,71.79
|
|
||||||
95,351,252,99,0,2,84.66
|
|
||||||
96,717,607,110,0,1,83.28
|
|
||||||
97,664,553,111,0,1,21.74
|
|
||||||
98,23,5,18,0,37,56.91
|
|
||||||
99,181,103,78,0,4,70.62
|
|
||||||
|
Binary file not shown.
101
test.csv
Normal file
101
test.csv
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
Lambda,h_opt,u_opt,h_opt_2,u_opt_2
|
||||||
|
0.0502,0.0000,0.9873,0.0000,1.0000
|
||||||
|
0.0506,-0.0000,0.9872,0.0000,1.0000
|
||||||
|
0.0511,-0.0000,0.9871,0.0000,1.0000
|
||||||
|
0.0515,0.0000,0.9870,0.0000,1.0000
|
||||||
|
0.0519,-0.0000,0.9869,0.0000,1.0000
|
||||||
|
0.0523,0.0000,0.9868,0.0000,1.0000
|
||||||
|
0.0528,0.0000,0.9867,0.0000,1.0000
|
||||||
|
0.0532,-0.0000,0.9866,0.0000,1.0000
|
||||||
|
0.0537,0.0000,0.9865,0.0000,1.0000
|
||||||
|
0.0542,0.0000,0.9864,0.0000,1.0000
|
||||||
|
0.0547,-0.0000,0.9863,0.0000,1.0000
|
||||||
|
0.0551,0.0000,0.9861,0.0000,1.0000
|
||||||
|
0.0556,-0.0000,0.9860,0.0000,1.0000
|
||||||
|
0.0562,-0.0000,0.9859,0.0000,1.0000
|
||||||
|
0.0567,0.0000,0.9858,0.0000,1.0000
|
||||||
|
0.0572,-0.0000,0.9857,0.0000,1.0000
|
||||||
|
0.0578,-0.0000,0.9855,0.0000,1.0000
|
||||||
|
0.0583,-0.0000,0.9854,0.0000,1.0000
|
||||||
|
0.0589,0.0000,0.9853,0.0000,1.0000
|
||||||
|
0.0595,0.0000,0.9851,0.0000,1.0000
|
||||||
|
0.0601,0.0000,0.9850,0.0000,1.0000
|
||||||
|
0.0607,0.0000,0.9848,0.0000,1.0000
|
||||||
|
0.0613,0.0000,0.9847,0.0000,1.0000
|
||||||
|
0.0619,0.0000,0.9845,0.0000,1.0000
|
||||||
|
0.0626,0.0000,0.9843,0.0000,1.0000
|
||||||
|
0.0632,0.0000,0.9842,0.0000,1.0000
|
||||||
|
0.0639,-0.0000,0.9840,0.0000,1.0000
|
||||||
|
0.0646,-0.0000,0.9838,0.0000,1.0000
|
||||||
|
0.0653,-0.0000,0.9836,0.0000,1.0000
|
||||||
|
0.0661,0.0000,0.9834,0.0000,1.0000
|
||||||
|
0.0668,0.0000,0.9832,0.0000,1.0000
|
||||||
|
0.0676,-0.0000,0.9830,0.0000,1.0000
|
||||||
|
0.0684,-0.0000,0.9828,0.0000,1.0000
|
||||||
|
0.0692,0.0000,0.9826,0.0000,1.0000
|
||||||
|
0.0700,0.0000,0.9824,0.0000,1.0000
|
||||||
|
0.0709,-0.0000,0.9822,0.0000,1.0000
|
||||||
|
0.0718,0.0000,0.9819,0.0000,1.0000
|
||||||
|
0.0727,-0.0000,0.9817,0.0000,1.0000
|
||||||
|
0.0736,0.0000,0.9814,0.0000,1.0000
|
||||||
|
0.0746,0.0000,0.9812,0.0000,1.0000
|
||||||
|
0.0756,0.0000,0.9809,0.0000,1.0000
|
||||||
|
0.0766,-0.0000,0.9806,0.0000,1.0000
|
||||||
|
0.0777,0.0000,0.9803,0.0000,1.0000
|
||||||
|
0.0788,0.0000,0.9800,0.0000,1.0000
|
||||||
|
0.0799,-0.0000,0.9797,0.0000,1.0000
|
||||||
|
0.0810,0.0000,0.9793,0.0000,1.0000
|
||||||
|
0.0822,0.0000,0.9790,0.0000,1.0000
|
||||||
|
0.0835,-0.0000,0.9786,0.0000,1.0000
|
||||||
|
0.0848,-0.0000,0.9783,0.0000,1.0000
|
||||||
|
0.0861,-0.0000,0.9779,0.0000,1.0000
|
||||||
|
0.0875,-0.0000,0.9774,0.0000,1.0000
|
||||||
|
0.0889,0.0000,0.9770,0.0000,1.0000
|
||||||
|
0.0904,0.0000,0.9766,0.0000,1.0000
|
||||||
|
0.0919,-0.0000,0.9761,0.0000,1.0000
|
||||||
|
0.0935,-0.0000,0.9756,0.0000,1.0000
|
||||||
|
0.0952,-0.0000,0.9751,0.0000,1.0000
|
||||||
|
0.0969,-0.0000,0.9745,0.0000,1.0000
|
||||||
|
0.0987,0.0000,0.9739,0.0000,1.0000
|
||||||
|
0.1006,-0.0000,0.9733,0.0000,1.0000
|
||||||
|
0.1025,-0.0000,0.9727,0.0000,1.0000
|
||||||
|
0.1046,-0.0000,0.9720,0.0000,1.0000
|
||||||
|
0.1067,-0.0000,0.9713,0.0000,1.0000
|
||||||
|
0.1089,0.0000,0.9705,0.0000,1.0000
|
||||||
|
0.1113,0.0000,0.9697,0.0000,1.0000
|
||||||
|
0.1138,-0.0000,0.9688,0.0000,1.0000
|
||||||
|
0.1164,-0.0000,0.9679,0.0000,1.0000
|
||||||
|
0.1191,0.0000,0.9669,0.0000,1.0000
|
||||||
|
0.1220,-0.0000,0.9658,0.0000,1.0000
|
||||||
|
0.1250,0.0000,0.9647,0.0000,1.0000
|
||||||
|
0.1282,0.0000,0.9634,0.0000,1.0000
|
||||||
|
0.1316,-0.0000,0.9621,0.0000,1.0000
|
||||||
|
0.1352,-0.0000,0.9607,0.0000,1.0000
|
||||||
|
0.1391,-0.0000,0.9591,0.0000,1.0000
|
||||||
|
0.1432,0.0000,0.9574,0.0000,1.0000
|
||||||
|
0.1476,0.0000,0.9556,0.0000,1.0000
|
||||||
|
0.1523,0.0000,0.9536,0.0000,1.0000
|
||||||
|
0.1573,-0.0000,0.9514,0.0000,1.0000
|
||||||
|
0.1628,0.0000,0.9489,0.0000,1.0000
|
||||||
|
0.1687,-0.0000,0.9462,0.0000,1.0000
|
||||||
|
0.1751,0.0000,0.9425,0.0000,1.0000
|
||||||
|
0.1821,-0.0000,0.9381,0.0000,1.0000
|
||||||
|
0.1897,0.0000,0.9328,0.0000,1.0000
|
||||||
|
0.1981,-0.0000,0.9264,0.0000,1.0000
|
||||||
|
0.2073,-0.0000,0.9187,0.0000,1.0000
|
||||||
|
0.2176,0.0000,0.9089,0.0000,1.0000
|
||||||
|
0.2292,0.0000,0.8961,0.0000,1.0000
|
||||||
|
0.2422,0.0000,0.8754,0.0000,1.0000
|
||||||
|
0.2570,0.0000,0.8390,0.0000,1.0000
|
||||||
|
0.2740,-0.0000,0.7661,0.0000,1.0000
|
||||||
|
0.2937,0.0000,0.6928,0.0000,1.0000
|
||||||
|
0.3170,1.0000,0.6861,1.0000,0.6861
|
||||||
|
0.3449,1.0000,0.6578,1.0000,0.6578
|
||||||
|
0.3789,1.0000,0.6275,1.0000,0.6275
|
||||||
|
0.4216,1.0000,0.5949,1.0000,0.5949
|
||||||
|
0.4770,1.0000,0.5593,1.0000,0.5593
|
||||||
|
0.5519,1.0000,0.5200,1.0000,0.5200
|
||||||
|
0.6598,1.0000,0.4756,1.0000,0.4756
|
||||||
|
0.8305,1.0000,0.4239,1.0000,0.4239
|
||||||
|
1.1487,1.0000,0.3604,1.0000,0.3604
|
||||||
|
2.0000,1.0000,0.2731,1.0000,0.2731
|
||||||
|
Reference in New Issue
Block a user