Compare commits
3 Commits
master
...
convergenc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9347ece041 | ||
|
|
6a4c2f26a8 | ||
|
|
5785827899 |
1
00_aoi_caching_simulation/.gitignore
vendored
1
00_aoi_caching_simulation/.gitignore
vendored
@@ -1 +0,0 @@
|
||||
.aoi_cache/
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,903 +0,0 @@
|
||||
{
|
||||
"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
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
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
|
||||
|
@@ -1,102 +0,0 @@
|
||||
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
|
||||
@@ -1,101 +0,0 @@
|
||||
,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
|
||||
|
@@ -1,18 +0,0 @@
|
||||
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()
|
||||
@@ -1,101 +0,0 @@
|
||||
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
|
||||
|
File diff suppressed because one or more lines are too long
@@ -1,101 +0,0 @@
|
||||
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
|
||||
|
@@ -1,9 +0,0 @@
|
||||
,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
|
||||
|
@@ -1 +0,0 @@
|
||||
[LRUSimulation] Database Object Count: 100, Cache Size: 10, Eviction Strategy: EvictionStrategy.LRU
|
||||
File diff suppressed because one or more lines are too long
@@ -1,101 +0,0 @@
|
||||
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
|
||||
|
@@ -1,9 +0,0 @@
|
||||
,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
|
||||
|
@@ -1 +0,0 @@
|
||||
[RefreshSimulation] Database Object Count: 100, Cache Size: 10, Eviction Strategy: EvictionStrategy.TTL
|
||||
@@ -1,566 +0,0 @@
|
||||
{
|
||||
"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
|
||||
}
|
||||
@@ -1,287 +0,0 @@
|
||||
{
|
||||
"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
|
||||
}
|
||||
@@ -1,360 +0,0 @@
|
||||
{
|
||||
"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
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
Binary file not shown.
@@ -1,258 +0,0 @@
|
||||
{
|
||||
"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
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
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]
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
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
|
||||
|
||||
@@ -1,171 +0,0 @@
|
||||
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
|
||||
|
||||
@@ -1,171 +0,0 @@
|
||||
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
|
||||
|
||||
@@ -1,248 +0,0 @@
|
||||
{
|
||||
"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
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
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]
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
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
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
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
|
||||
|
||||
@@ -1,171 +0,0 @@
|
||||
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
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
441
aoi_cache_experiment_eval.ipynb
Normal file
441
aoi_cache_experiment_eval.ipynb
Normal file
File diff suppressed because one or more lines are too long
957
aoi_cache_simulation.ipynb
Normal file
957
aoi_cache_simulation.ipynb
Normal file
File diff suppressed because one or more lines are too long
101
calculated.csv
101
calculated.csv
@@ -1,101 +0,0 @@
|
||||
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
|
||||
|
101
experiments/No_Refresh_0_5s_ttl/details.csv
Normal file
101
experiments/No_Refresh_0_5s_ttl/details.csv
Normal file
@@ -0,0 +1,101 @@
|
||||
obj_id,access_count,hits,misses,mu,lambda,hit_rate,avg_age
|
||||
1,10164,3264,6900,0,1,32.11,0.08333333333333333
|
||||
2,30898,18578,12320,0,3,60.13,0.14978315748592141
|
||||
3,10319,3473,6846,0,1,33.66,0.08460122104855122
|
||||
4,10227,3369,6858,0,1,32.94,0.08585117825364232
|
||||
5,20692,10422,10270,0,2,50.37,0.12700560603131644
|
||||
6,10238,3426,6812,0,1,33.46,0.08038679429576089
|
||||
7,50801,36152,14649,0,5,71.16,0.17375642211767484
|
||||
8,10299,3441,6858,0,1,33.41,0.08505680163122634
|
||||
9,10045,3335,6710,0,1,33.2,0.08541562966650075
|
||||
10,10202,3384,6818,0,1,33.17,0.08488531660458734
|
||||
11,20511,10282,10229,0,2,50.13,0.12403100775193798
|
||||
12,10254,3475,6779,0,1,33.89,0.08611273649307587
|
||||
13,10221,3350,6871,0,1,32.78,0.07983563252127972
|
||||
14,10269,3482,6787,0,1,33.91,0.07878079657220761
|
||||
15,20454,10203,10251,0,2,49.88,0.12770118314266157
|
||||
16,20508,10231,10277,0,2,49.89,0.1244392432221572
|
||||
17,10279,3521,6758,0,1,34.25,0.08249829749975679
|
||||
18,10194,3376,6818,0,1,33.12,0.08406906023150873
|
||||
19,30646,18385,12261,0,3,59.99,0.14820857534425375
|
||||
20,10194,3409,6785,0,1,33.44,0.0799489896017265
|
||||
21,10342,3436,6906,0,1,33.22,0.0834461419454651
|
||||
22,10296,3490,6806,0,1,33.9,0.08585858585858586
|
||||
23,10327,3456,6871,0,1,33.47,0.07950033891740099
|
||||
24,20516,10278,10238,0,2,50.1,0.12760772080327548
|
||||
25,10143,3379,6764,0,1,33.31,0.08301291531105195
|
||||
26,10291,3539,6752,0,1,34.39,0.08288796035370712
|
||||
27,10308,3419,6889,0,1,33.17,0.08187815289095848
|
||||
28,50863,36244,14619,0,5,71.26,0.17623812987830054
|
||||
29,10398,3502,6896,0,1,33.68,0.08001538757453357
|
||||
30,10260,3445,6815,0,1,33.58,0.08206627680311891
|
||||
31,10202,3387,6815,0,1,33.2,0.08508135659674573
|
||||
32,41023,27361,13662,0,4,66.7,0.16866148258294128
|
||||
33,10322,3435,6887,0,1,33.28,0.08157333850029064
|
||||
34,41011,27379,13632,0,4,66.76,0.16644314939894175
|
||||
35,10326,3416,6910,0,1,33.08,0.08270385434824715
|
||||
36,10118,3314,6804,0,1,32.75,0.08183435461553666
|
||||
37,10319,3481,6838,0,1,33.73,0.08527958135478245
|
||||
38,30664,18354,12310,0,3,59.86,0.14929559092094966
|
||||
39,81431,65050,16381,0,8,79.88,0.199015117092999
|
||||
40,10255,3385,6870,0,1,33.01,0.07791321306679669
|
||||
41,40971,27337,13634,0,4,66.72,0.1654340875253228
|
||||
42,40942,27312,13630,0,4,66.71,0.16748082653509844
|
||||
43,20292,10170,10122,0,2,50.12,0.12487679873841909
|
||||
44,10156,3350,6806,0,1,32.99,0.08733753446238676
|
||||
45,10135,3350,6785,0,1,33.05,0.08080907745436605
|
||||
46,10343,3451,6892,0,1,33.37,0.08382480904959876
|
||||
47,102500,85382,17118,0,10,83.3,0.21223414634146343
|
||||
48,10067,3307,6760,0,1,32.85,0.0819509287771928
|
||||
49,10166,3358,6808,0,1,33.03,0.08193979933110368
|
||||
50,10056,3326,6730,0,1,33.07,0.08164280031821798
|
||||
51,51319,36667,14652,0,5,71.45,0.17588027825951402
|
||||
52,91635,74849,16786,0,9,81.68,0.20417962568887435
|
||||
53,10173,3368,6805,0,1,33.11,0.08424260296864249
|
||||
54,10262,3467,6795,0,1,33.78,0.07883453517832781
|
||||
55,10337,3449,6888,0,1,33.37,0.08397020412111832
|
||||
56,10101,3353,6748,0,1,33.19,0.08335808335808335
|
||||
57,10262,3421,6841,0,1,33.34,0.08536347690508672
|
||||
58,174175,155832,18343,0,17,89.47,0.22248313477824028
|
||||
59,20618,10352,10266,0,2,50.21,0.1257638956251819
|
||||
60,10328,3494,6834,0,1,33.83,0.08278466305189776
|
||||
61,266787,247758,19029,0,26,92.87,0.23090330488367125
|
||||
62,10000,3279,6721,0,1,32.79,0.0788
|
||||
63,10189,3377,6812,0,1,33.14,0.08420846010403377
|
||||
64,20440,10172,10268,0,2,49.77,0.1232876712328767
|
||||
65,10310,3473,6837,0,1,33.69,0.08273520853540252
|
||||
66,102534,85466,17068,0,10,83.35,0.20803830924376304
|
||||
67,10261,3435,6826,0,1,33.48,0.085079426956437
|
||||
68,706876,686965,19911,0,69,97.18,0.24237065623956677
|
||||
69,10119,3373,6746,0,1,33.33,0.08577922719636327
|
||||
70,10273,3450,6823,0,1,33.58,0.08575878516499562
|
||||
71,20634,10362,10272,0,2,50.22,0.12537559368033344
|
||||
72,10278,3468,6810,0,1,33.74,0.08085230589608873
|
||||
73,10291,3394,6897,0,1,32.98,0.0769604508794092
|
||||
74,10479,3540,6939,0,1,33.78,0.08121003912587078
|
||||
75,30802,18558,12244,0,3,60.25,0.15236023634828907
|
||||
76,20439,10245,10194,0,2,50.12,0.1278927540486325
|
||||
77,20717,10394,10323,0,2,50.17,0.11956364338465994
|
||||
78,30719,18398,12321,0,3,59.89,0.14867020410820664
|
||||
79,153586,135511,18075,0,15,88.23,0.2179495526936049
|
||||
80,10300,3417,6883,0,1,33.17,0.08067961165048544
|
||||
81,10419,3484,6935,0,1,33.44,0.08273346770323448
|
||||
82,51383,36765,14618,0,5,71.55,0.17768522663137615
|
||||
83,20354,10144,10210,0,2,49.84,0.12533163014640858
|
||||
84,10292,3409,6883,0,1,33.12,0.08268558103381267
|
||||
85,10338,3422,6916,0,1,33.1,0.08299477655252467
|
||||
86,20508,10245,10263,0,2,49.96,0.12497561927052857
|
||||
87,10342,3445,6897,0,1,33.31,0.08470315219493328
|
||||
88,20517,10243,10274,0,2,49.92,0.1270653604328118
|
||||
89,10273,3448,6825,0,1,33.56,0.08244913851844642
|
||||
90,10215,3413,6802,0,1,33.41,0.07949094468918258
|
||||
91,20496,10288,10208,0,2,50.2,0.12578064012490242
|
||||
92,20630,10377,10253,0,2,50.3,0.12331555986427532
|
||||
93,31006,18698,12308,0,3,60.3,0.15268012642714313
|
||||
94,10107,3281,6826,0,1,32.46,0.08419906995151875
|
||||
95,20393,10194,10199,0,2,49.99,0.12484676114352965
|
||||
96,10070,3403,6667,0,1,33.79,0.08262164846077458
|
||||
97,10166,3356,6810,0,1,33.01,0.08253000196734211
|
||||
98,378889,359467,19422,0,37,94.87,0.23680022381225108
|
||||
99,41032,27373,13659,0,4,66.71,0.16894131409631508
|
||||
100,20321,10085,10236,0,2,49.63,0.12686383544116922
|
||||
|
101
experiments/No_Refresh_0_5s_ttl/hit_age.csv
Normal file
101
experiments/No_Refresh_0_5s_ttl/hit_age.csv
Normal file
@@ -0,0 +1,101 @@
|
||||
obj_id,hit_rate,avg_age
|
||||
1,0.32113341204250295,0.25949754901960786
|
||||
2,0.6012686905301314,0.24911185272903436
|
||||
3,0.33656362050586297,0.2513676936366254
|
||||
4,0.32942211792314463,0.26061145740575836
|
||||
5,0.5036729170693988,0.25215889464594127
|
||||
6,0.3346356710294979,0.24022183304144776
|
||||
7,0.7116395346548297,0.244163531754813
|
||||
8,0.33411010777745415,0.25457715780296425
|
||||
9,0.3320059731209557,0.2572713643178411
|
||||
10,0.33169966673201334,0.2559101654846336
|
||||
11,0.5012919896640827,0.24742268041237114
|
||||
12,0.3388921396528184,0.25410071942446044
|
||||
13,0.32775657959103804,0.2435820895522388
|
||||
14,0.3390787807965722,0.23233773693279725
|
||||
15,0.4988266353769434,0.25600313633245125
|
||||
16,0.49887848644431443,0.2494379826018962
|
||||
17,0.34254304893472126,0.2408406702641295
|
||||
18,0.3311752010986855,0.25385071090047395
|
||||
19,0.5999151602166678,0.24704922491161274
|
||||
20,0.33441239945065726,0.23907304194778528
|
||||
21,0.33223747824405336,0.2511641443538999
|
||||
22,0.338966588966589,0.2532951289398281
|
||||
23,0.334656725089571,0.23755787037037038
|
||||
24,0.5009748488984207,0.2547188168904456
|
||||
25,0.3331361530119294,0.24918614974844627
|
||||
26,0.34389272179574387,0.24102853913534897
|
||||
27,0.3316841288319752,0.246855805791167
|
||||
28,0.7125808544521558,0.24732369495640658
|
||||
29,0.33679553760338526,0.23757852655625358
|
||||
30,0.3357699805068226,0.2444121915820029
|
||||
31,0.3319937267202509,0.25627398878063185
|
||||
32,0.666967311020647,0.25287818427689046
|
||||
33,0.3327843441193567,0.24512372634643376
|
||||
34,0.6676013752407891,0.24931516855984515
|
||||
35,0.3308154173929886,0.25
|
||||
36,0.3275350859853726,0.24984912492456246
|
||||
37,0.3373388894272701,0.25280091927607007
|
||||
38,0.5985520480041743,0.2494279176201373
|
||||
39,0.798835824194717,0.2491314373558801
|
||||
40,0.33008288639687955,0.23604135893648448
|
||||
41,0.6672280393449025,0.24794234919705893
|
||||
42,0.6670900297982512,0.2510618043350908
|
||||
43,0.5011827321111768,0.24916420845624385
|
||||
44,0.329854273335959,0.26477611940298507
|
||||
45,0.3305377405032067,0.24447761194029852
|
||||
46,0.3336556124915402,0.2512315270935961
|
||||
47,0.8329951219512195,0.2547843807828348
|
||||
48,0.3284990563226383,0.24947081947384336
|
||||
49,0.33031674208144796,0.24806432400238237
|
||||
50,0.3307478122513922,0.24684305472038484
|
||||
51,0.7144917087238645,0.2461613985327406
|
||||
52,0.8168167185027555,0.24996993947814933
|
||||
53,0.33107244667256464,0.25445368171021376
|
||||
54,0.33784837263691286,0.2333429477934814
|
||||
55,0.33365579955499663,0.2516671498985213
|
||||
56,0.33194733194733195,0.25111840143155384
|
||||
57,0.3333658156304814,0.2560654779304297
|
||||
58,0.8946863786421703,0.2486716463884183
|
||||
59,0.5020855563100204,0.25048299845440497
|
||||
60,0.33830364058869095,0.24470520892959358
|
||||
61,0.9286734361119545,0.24863778364371686
|
||||
62,0.3279,0.24031716986886245
|
||||
63,0.331435862204338,0.254071661237785
|
||||
64,0.49765166340508804,0.2477388910735352
|
||||
65,0.33685741998060137,0.24560898358767635
|
||||
66,0.8335381434451011,0.24958463014532095
|
||||
67,0.3347626936945717,0.2541484716157205
|
||||
68,0.9718324005907684,0.24939552961213454
|
||||
69,0.3333333333333333,0.2573376815890898
|
||||
70,0.3358317920763166,0.2553623188405797
|
||||
71,0.5021808665309683,0.24966222736923374
|
||||
72,0.3374197314652656,0.23961937716262977
|
||||
73,0.3298027402584783,0.23335297583971715
|
||||
74,0.33781849413111936,0.2403954802259887
|
||||
75,0.6024933445880137,0.25288285375579267
|
||||
76,0.5012476148539556,0.2551488530990727
|
||||
77,0.5017135685668774,0.23831056378680007
|
||||
78,0.598912725023601,0.2482335036417002
|
||||
79,0.8823134921151667,0.2470205370781708
|
||||
80,0.33174757281553396,0.24319578577699735
|
||||
81,0.33438909684230733,0.24741676234213547
|
||||
82,0.7155090204931592,0.24833401332789337
|
||||
83,0.49837869706200255,0.2514787066246057
|
||||
84,0.3312281383598912,0.2496333235552948
|
||||
85,0.3310118011220739,0.25073056691992984
|
||||
86,0.49956114686951436,0.2501708150317228
|
||||
87,0.3331077161090698,0.2542815674891147
|
||||
88,0.4992445289272311,0.25451527872693547
|
||||
89,0.3356371069794607,0.24564965197215777
|
||||
90,0.3341164953499755,0.23791385877527102
|
||||
91,0.501951600312256,0.25058320373250387
|
||||
92,0.5030053320407174,0.24515755998843597
|
||||
93,0.6030445720183191,0.2531821585196278
|
||||
94,0.32462649648758285,0.2593721426394392
|
||||
95,0.49987740891482374,0.2497547577006082
|
||||
96,0.33793445878848066,0.24449015574493094
|
||||
97,0.33012000786936846,0.25
|
||||
98,0.9487396044751893,0.24959453858073202
|
||||
99,0.6671134724117762,0.2532422460088408
|
||||
100,0.4962846316618277,0.2556271690629648
|
||||
|
Binary file not shown.
Binary file not shown.
BIN
experiments/No_Refresh_0_5s_ttl/objects_in_cache_over_time.pdf
Normal file
BIN
experiments/No_Refresh_0_5s_ttl/objects_in_cache_over_time.pdf
Normal file
Binary file not shown.
9
experiments/No_Refresh_0_5s_ttl/overall_hit_age.csv
Normal file
9
experiments/No_Refresh_0_5s_ttl/overall_hit_age.csv
Normal file
@@ -0,0 +1,9 @@
|
||||
,hit_rate,avg_age
|
||||
count,100.0,100.0
|
||||
mean,0.4604085321620298,0.24888160993165884
|
||||
std,0.1786893776002831,0.006148512551458182
|
||||
min,0.32113341204250295,0.23233773693279725
|
||||
25%,0.3320029115207795,0.24563948487603743
|
||||
50%,0.3378334333840161,0.24952772480958216
|
||||
75%,0.5031722282978878,0.25319718039193106
|
||||
max,0.9718324005907684,0.26477611940298507
|
||||
|
101
experiments/No_Refresh_1_0s_ttl/details.csv
Normal file
101
experiments/No_Refresh_1_0s_ttl/details.csv
Normal file
@@ -0,0 +1,101 @@
|
||||
obj_id,access_count,hits,misses,mu,lambda,hit_rate,avg_age
|
||||
1,10321,5191,5130,0,1,50.3,0.2558860575525627
|
||||
2,20430,13645,6785,0,2,66.79,0.3350954478707783
|
||||
3,40652,32482,8170,0,4,79.9,0.39936534487848074
|
||||
4,10296,5146,5150,0,1,49.98,0.24271561771561773
|
||||
5,10144,5028,5116,0,1,49.57,0.2430993690851735
|
||||
6,10255,5144,5111,0,1,50.16,0.24748902974158946
|
||||
7,10292,5137,5155,0,1,49.91,0.24319860085503303
|
||||
8,295834,285945,9889,0,29,96.66,0.4777848387947295
|
||||
9,10192,5069,5123,0,1,49.74,0.25755494505494503
|
||||
10,500429,490403,10026,0,49,98.0,0.4930909279837899
|
||||
11,10248,5123,5125,0,1,49.99,0.24775565964090554
|
||||
12,10245,5132,5113,0,1,50.09,0.24509516837481699
|
||||
13,10072,4994,5078,0,1,49.58,0.24344718030182685
|
||||
14,10200,5096,5104,0,1,49.96,0.2513725490196078
|
||||
15,10329,5187,5142,0,1,50.22,0.2589795720786136
|
||||
16,10166,5054,5112,0,1,49.71,0.2506393861892583
|
||||
17,922930,912814,10116,0,90,98.9,0.49657828871095316
|
||||
18,10196,5095,5101,0,1,49.97,0.24627304825421734
|
||||
19,51302,42761,8541,0,5,83.35,0.4175080893532416
|
||||
20,20581,13739,6842,0,2,66.76,0.33351149118118656
|
||||
21,10434,5292,5142,0,1,50.72,0.25886524822695034
|
||||
22,173975,164325,9650,0,17,94.45,0.47176318436556974
|
||||
23,10439,5281,5158,0,1,50.59,0.24877861864163234
|
||||
24,10358,5228,5130,0,1,50.47,0.2560339833944777
|
||||
25,30679,23015,7664,0,3,75.02,0.37823918641415955
|
||||
26,30612,22918,7694,0,3,74.87,0.37811969162419967
|
||||
27,20361,13574,6787,0,2,66.67,0.3323019498060017
|
||||
28,10273,5165,5108,0,1,50.28,0.25902852136668936
|
||||
29,20350,13555,6795,0,2,66.61,0.328992628992629
|
||||
30,20492,13637,6855,0,2,66.55,0.33627757173531136
|
||||
31,20685,13825,6860,0,2,66.84,0.34072999758278943
|
||||
32,10276,5197,5079,0,1,50.57,0.24815103152977813
|
||||
33,10295,5207,5088,0,1,50.58,0.2541039339485187
|
||||
34,418664,408677,9987,0,41,97.61,0.4910094968757763
|
||||
35,20556,13741,6815,0,2,66.85,0.3401926444833625
|
||||
36,61554,52775,8779,0,6,85.74,0.4230594274945576
|
||||
37,10400,5252,5148,0,1,50.5,0.2570192307692308
|
||||
38,234838,225035,9803,0,23,95.83,0.4802246655140991
|
||||
39,10238,5105,5133,0,1,49.86,0.2558116819691346
|
||||
40,102360,93061,9299,0,10,90.92,0.45374169597499026
|
||||
41,10328,5215,5113,0,1,50.49,0.2555189775367932
|
||||
42,51435,42894,8541,0,5,83.39,0.41372606202002526
|
||||
43,10152,5077,5075,0,1,50.01,0.2518715524034673
|
||||
44,20511,13692,6819,0,2,66.75,0.339720150163327
|
||||
45,30442,22793,7649,0,3,74.87,0.3702450561723934
|
||||
46,20289,13470,6819,0,2,66.39,0.32815811523485633
|
||||
47,10192,5118,5074,0,1,50.22,0.2588304552590267
|
||||
48,10400,5220,5180,0,1,50.19,0.2547115384615385
|
||||
49,10080,5026,5054,0,1,49.86,0.2427579365079365
|
||||
50,20564,13754,6810,0,2,66.88,0.3315989107177592
|
||||
51,10176,5069,5107,0,1,49.81,0.24597091194968554
|
||||
52,10049,4935,5114,0,1,49.11,0.24559657677380833
|
||||
53,30768,23098,7670,0,3,75.07,0.37714508580343215
|
||||
54,10058,4948,5110,0,1,49.19,0.24169815072579043
|
||||
55,10202,5088,5114,0,1,49.87,0.2488727700450892
|
||||
56,20279,13452,6827,0,2,66.33,0.3287637457468317
|
||||
57,10324,5212,5112,0,1,50.48,0.24961255327392484
|
||||
58,10168,5065,5103,0,1,49.81,0.24537765538945713
|
||||
59,50847,42342,8505,0,5,83.27,0.41611107833303834
|
||||
60,10149,5063,5086,0,1,49.89,0.2488915164055572
|
||||
61,10000,4936,5064,0,1,49.36,0.2535
|
||||
62,10298,5160,5138,0,1,50.11,0.25043697805399107
|
||||
63,10203,5098,5105,0,1,49.97,0.2486523571498579
|
||||
64,30986,23292,7694,0,3,75.17,0.37194216743045244
|
||||
65,10324,5176,5148,0,1,50.14,0.2516466485858195
|
||||
66,31014,23323,7691,0,3,75.2,0.3704778487134842
|
||||
67,20419,13597,6822,0,2,66.59,0.32930114109407904
|
||||
68,10202,5083,5119,0,1,49.82,0.250735149970594
|
||||
69,10332,5187,5145,0,1,50.2,0.24961285327138985
|
||||
70,20406,13576,6830,0,2,66.53,0.3301479956875429
|
||||
71,50839,42332,8507,0,5,83.27,0.4158421684140129
|
||||
72,122940,113497,9443,0,12,92.32,0.4595005693834391
|
||||
73,10349,5208,5141,0,1,50.32,0.24939607691564403
|
||||
74,40948,32759,8189,0,4,80.0,0.40487935918726187
|
||||
75,10482,5304,5178,0,1,50.6,0.25472238122495705
|
||||
76,20015,13250,6765,0,2,66.2,0.32880339745191106
|
||||
77,10141,5051,5090,0,1,49.81,0.25184893008579035
|
||||
78,20454,13645,6809,0,2,66.71,0.32893321599687103
|
||||
79,20365,13537,6828,0,2,66.47,0.3289958261723545
|
||||
80,20377,13603,6774,0,2,66.76,0.3276242822790401
|
||||
81,10297,5165,5132,0,1,50.16,0.25308342235602604
|
||||
82,747292,737198,10094,0,73,98.65,0.4909379466125691
|
||||
83,20370,13582,6788,0,2,66.68,0.3318605792832597
|
||||
84,10160,5073,5087,0,1,49.93,0.2518700787401575
|
||||
85,1964390,1954214,10176,0,192,99.48,0.4986204368786239
|
||||
86,123492,114064,9428,0,12,92.37,0.4611715738671331
|
||||
87,10150,5008,5142,0,1,49.34,0.2504433497536946
|
||||
88,10017,4974,5043,0,1,49.66,0.2448836977138864
|
||||
89,30598,22933,7665,0,3,74.95,0.3759722857703118
|
||||
90,20466,13667,6799,0,2,66.78,0.33699794781588976
|
||||
91,92180,82970,9210,0,9,90.01,0.44574745064005206
|
||||
92,10110,5015,5095,0,1,49.6,0.24787339268051434
|
||||
93,10091,5047,5044,0,1,50.01,0.2511148548211277
|
||||
94,10219,5094,5125,0,1,49.85,0.24728447010470692
|
||||
95,10172,5093,5079,0,1,50.07,0.24695241840346047
|
||||
96,41141,32935,8206,0,4,80.05,0.4031744488466493
|
||||
97,10233,5096,5137,0,1,49.8,0.24694615459786964
|
||||
98,10153,5038,5115,0,1,49.62,0.24485373781148428
|
||||
99,61303,52526,8777,0,6,85.68,0.4244816730013213
|
||||
100,10178,5065,5113,0,1,49.76,0.24759284731774414
|
||||
|
101
experiments/No_Refresh_1_0s_ttl/hit_age.csv
Normal file
101
experiments/No_Refresh_1_0s_ttl/hit_age.csv
Normal file
@@ -0,0 +1,101 @@
|
||||
obj_id,hit_rate,avg_age
|
||||
1,0.5029551400058134,0.508765170487382
|
||||
2,0.6678903573176701,0.5017222425796996
|
||||
3,0.7990258781855751,0.49981528231020256
|
||||
4,0.4998057498057498,0.4856198989506413
|
||||
5,0.49566246056782337,0.4904534606205251
|
||||
6,0.5016089712335446,0.49339035769828926
|
||||
7,0.4991255343956471,0.48724936733502044
|
||||
8,0.966572469695843,0.4943083460105964
|
||||
9,0.497350863422292,0.5178536200434011
|
||||
10,0.979965189867094,0.5031718810855562
|
||||
11,0.4999024199843872,0.49560804216279525
|
||||
12,0.5009272816007808,0.4892829306313328
|
||||
13,0.4958300238284353,0.49098918702442934
|
||||
14,0.4996078431372549,0.5031397174254317
|
||||
15,0.5021783328492594,0.5157123578176209
|
||||
16,0.49714735392484755,0.5041551246537396
|
||||
17,0.9890392554148202,0.5020814755251344
|
||||
18,0.49970576696743824,0.4928361138370952
|
||||
19,0.833515262562863,0.5009003531255115
|
||||
20,0.6675574559059326,0.49959967974379504
|
||||
21,0.5071880391029328,0.5103930461073318
|
||||
22,0.9445322603822388,0.4994675186368477
|
||||
23,0.5058913689050676,0.49176292368869534
|
||||
24,0.5047306429812705,0.5072685539403213
|
||||
25,0.750187424622706,0.504192917662394
|
||||
26,0.7486606559519143,0.5050615236931669
|
||||
27,0.6666666666666666,0.4984529247090025
|
||||
28,0.5027742626301956,0.5151984511132623
|
||||
29,0.6660933660933661,0.49391368498708965
|
||||
30,0.6654792113995706,0.5053164185671335
|
||||
31,0.6683587140439933,0.5098010849909584
|
||||
32,0.505741533670689,0.4906676928997499
|
||||
33,0.5057795046138902,0.5024006145573267
|
||||
34,0.9761455486977624,0.503008488366118
|
||||
35,0.6684666277485892,0.5089149261334692
|
||||
36,0.8573772622412841,0.49343439128375177
|
||||
37,0.505,0.508948971820259
|
||||
38,0.9582563298955025,0.5011442664474415
|
||||
39,0.49863254541902713,0.513026444662096
|
||||
40,0.9091539663931223,0.49908124778371177
|
||||
41,0.5049380325329202,0.5060402684563758
|
||||
42,0.8339457567804025,0.49610668158716836
|
||||
43,0.5000985027580772,0.503643884183573
|
||||
44,0.6675442445517039,0.5089103125912942
|
||||
45,0.7487352999145916,0.4944939235730268
|
||||
46,0.6639065503474789,0.4942835931700074
|
||||
47,0.5021585557299842,0.5154357170769832
|
||||
48,0.5019230769230769,0.5074712643678161
|
||||
49,0.4986111111111111,0.4868682849184242
|
||||
50,0.668838747325423,0.4957830449323833
|
||||
51,0.49813286163522014,0.4937857565594792
|
||||
52,0.4910936411583242,0.5001013171225938
|
||||
53,0.750715028601144,0.502381158541865
|
||||
54,0.4919467090872937,0.4913096200485044
|
||||
55,0.4987257400509704,0.49901729559748426
|
||||
56,0.6633463188520144,0.4956140350877193
|
||||
57,0.5048430840759396,0.4944359171143515
|
||||
58,0.4981313926042486,0.49259624876604147
|
||||
59,0.8327334946014514,0.4996929762410845
|
||||
60,0.4988668834367918,0.49891368753703336
|
||||
61,0.4936,0.5135737439222042
|
||||
62,0.5010681685764226,0.4998062015503876
|
||||
63,0.49965696363814566,0.49764613573950567
|
||||
64,0.7516943135609631,0.4948050832904001
|
||||
65,0.501356063541263,0.5019319938176198
|
||||
66,0.752015218933385,0.49264674355786137
|
||||
67,0.6658994074146628,0.4945208501875414
|
||||
68,0.4982356400705744,0.5032461144993114
|
||||
69,0.5020325203252033,0.4972045498361288
|
||||
70,0.6652945212192493,0.49624337065409546
|
||||
71,0.8326678337496803,0.4994094302182746
|
||||
72,0.9231901740686513,0.497731217565222
|
||||
73,0.5032370277321481,0.4955837173579109
|
||||
74,0.800014652730292,0.5060899294850271
|
||||
75,0.5060103033772181,0.503393665158371
|
||||
76,0.6620034973769673,0.4966792452830189
|
||||
77,0.49807711271077804,0.50564244704019
|
||||
78,0.6671066784003129,0.49307438622205935
|
||||
79,0.6647188804321139,0.494939794636921
|
||||
80,0.6675663738528733,0.490774093949864
|
||||
81,0.5016024084684859,0.5045498547918683
|
||||
82,0.9864925624789239,0.49766005876304603
|
||||
83,0.6667648502700049,0.49771756736857603
|
||||
84,0.49931102362204727,0.5044352454169131
|
||||
85,0.9948197659324268,0.5012168575191868
|
||||
86,0.9236549736015288,0.4992898723523636
|
||||
87,0.4933990147783251,0.5075878594249201
|
||||
88,0.4965558550464211,0.4931644551668677
|
||||
89,0.7494934309431989,0.5016351981860201
|
||||
90,0.6677904817746506,0.5046462281407771
|
||||
91,0.9000867867216316,0.4952271905508015
|
||||
92,0.4960435212660732,0.49970089730807576
|
||||
93,0.5001486473094837,0.5020804438280166
|
||||
94,0.4984832175359624,0.4960738123282293
|
||||
95,0.5006881635863154,0.4932259964657373
|
||||
96,0.8005396076906249,0.5036283588887202
|
||||
97,0.49799667741620246,0.4958791208791209
|
||||
98,0.4962080173347779,0.49344978165938863
|
||||
99,0.856825930215487,0.4954117960629022
|
||||
100,0.49764197288268813,0.49753208292201384
|
||||
|
Binary file not shown.
BIN
experiments/No_Refresh_1_0s_ttl/lambda_vs_access_count.pdf
Normal file
BIN
experiments/No_Refresh_1_0s_ttl/lambda_vs_access_count.pdf
Normal file
Binary file not shown.
BIN
experiments/No_Refresh_1_0s_ttl/objects_in_cache_over_time.pdf
Normal file
BIN
experiments/No_Refresh_1_0s_ttl/objects_in_cache_over_time.pdf
Normal file
Binary file not shown.
9
experiments/No_Refresh_1_0s_ttl/overall_hit_age.csv
Normal file
9
experiments/No_Refresh_1_0s_ttl/overall_hit_age.csv
Normal file
@@ -0,0 +1,9 @@
|
||||
,hit_rate,avg_age
|
||||
count,100.0,100.0
|
||||
mean,0.6330971683479719,0.49974051080586995
|
||||
std,0.16365629584245692,0.006763722459258895
|
||||
min,0.4910936411583242,0.4856198989506413
|
||||
25%,0.49964468351292296,0.49451411853391275
|
||||
50%,0.5058354367594788,0.4993496512853191
|
||||
75%,0.7496669293630757,0.5037716943011146
|
||||
max,0.9948197659324268,0.5178536200434011
|
||||
|
101
experiments/No_Refresh_2_0s_ttl/details.csv
Normal file
101
experiments/No_Refresh_2_0s_ttl/details.csv
Normal file
@@ -0,0 +1,101 @@
|
||||
obj_id,access_count,hits,misses,mu,lambda,hit_rate,avg_age
|
||||
1,10104,6718,3386,0,1,66.49,0.660827395091053
|
||||
2,10000,6591,3409,0,1,65.91,0.6574
|
||||
3,20425,16321,4104,0,2,79.91,0.806217870257038
|
||||
4,10313,6891,3422,0,1,66.82,0.6775913895083875
|
||||
5,30759,26375,4384,0,3,85.75,0.8561071556292468
|
||||
6,10401,6935,3466,0,1,66.68,0.6596481107585809
|
||||
7,10443,6970,3473,0,1,66.74,0.6758594273676146
|
||||
8,10329,6895,3434,0,1,66.75,0.6658921483202633
|
||||
9,20668,16545,4123,0,2,80.05,0.7909812270176118
|
||||
10,10313,6874,3439,0,1,66.65,0.6701250848443712
|
||||
11,10251,6801,3450,0,1,66.34,0.6685201443761585
|
||||
12,112754,107837,4917,0,11,95.64,0.9583872855951895
|
||||
13,10198,6768,3430,0,1,66.37,0.6693469307707394
|
||||
14,10418,6974,3444,0,1,66.94,0.6684584373200231
|
||||
15,10205,6797,3408,0,1,66.6,0.6775110240078392
|
||||
16,92491,87622,4869,0,9,94.74,0.9381669567849845
|
||||
17,10340,6892,3448,0,1,66.65,0.6625725338491296
|
||||
18,10342,6928,3414,0,1,66.99,0.6865209824018565
|
||||
19,10374,6928,3446,0,1,66.78,0.6789088104877579
|
||||
20,10326,6907,3419,0,1,66.89,0.6616308347859772
|
||||
21,10273,6849,3424,0,1,66.67,0.66338946753626
|
||||
22,10075,6690,3385,0,1,66.4,0.6625310173697271
|
||||
23,10241,6836,3405,0,1,66.75,0.6706376330436481
|
||||
24,10354,6909,3445,0,1,66.73,0.6609039984547035
|
||||
25,10217,6775,3442,0,1,66.31,0.6645786434374082
|
||||
26,134088,129133,4955,0,13,96.3,0.9625544418590776
|
||||
27,20646,16526,4120,0,2,80.04,0.7985566211372663
|
||||
28,20629,16518,4111,0,2,80.07,0.7993116486499589
|
||||
29,10110,6690,3420,0,1,66.17,0.6439169139465876
|
||||
30,20311,16220,4091,0,2,79.86,0.8037516616611688
|
||||
31,10298,6872,3426,0,1,66.73,0.667216935327248
|
||||
32,20693,16549,4144,0,2,79.97,0.7979026724012951
|
||||
33,92953,88081,4872,0,9,94.76,0.943186341484406
|
||||
34,154493,149517,4976,0,15,96.78,0.9748143928851145
|
||||
35,10082,6671,3411,0,1,66.17,0.6580043642134498
|
||||
36,10130,6718,3412,0,1,66.32,0.6568608094768016
|
||||
37,10403,6948,3455,0,1,66.79,0.6757666057867923
|
||||
38,10282,6835,3447,0,1,66.48,0.6668936004668352
|
||||
39,31120,26696,4424,0,3,85.78,0.8627570694087403
|
||||
40,113233,108317,4916,0,11,95.66,0.9557461164148261
|
||||
41,669320,664216,5104,0,65,99.24,0.9823193689117313
|
||||
42,10308,6844,3464,0,1,66.4,0.6667636786961583
|
||||
43,20631,16510,4121,0,2,80.03,0.802384760796859
|
||||
44,10290,6866,3424,0,1,66.72,0.6727891156462585
|
||||
45,10290,6846,3444,0,1,66.53,0.6646258503401361
|
||||
46,10118,6736,3382,0,1,66.57,0.6720695789681755
|
||||
47,10130,6708,3422,0,1,66.22,0.6615004935834156
|
||||
48,92556,87680,4876,0,9,94.73,0.9463676044772894
|
||||
49,10237,6807,3430,0,1,66.49,0.66269414867637
|
||||
50,10366,6917,3449,0,1,66.73,0.6664094153964886
|
||||
51,10066,6678,3388,0,1,66.34,0.6649115835485794
|
||||
52,10338,6900,3438,0,1,66.74,0.6627007158057652
|
||||
53,31189,26781,4408,0,3,85.87,0.8622591298214114
|
||||
54,10381,6952,3429,0,1,66.97,0.6724785666120797
|
||||
55,10299,6871,3428,0,1,66.72,0.6700650548596951
|
||||
56,10251,6822,3429,0,1,66.55,0.6652033947907521
|
||||
57,10164,6752,3412,0,1,66.43,0.6712908303817394
|
||||
58,10155,6734,3421,0,1,66.31,0.683505662235352
|
||||
59,31048,26625,4423,0,3,85.75,0.8572532852357639
|
||||
60,10415,6982,3433,0,1,67.04,0.6662506000960153
|
||||
61,10223,6820,3403,0,1,66.71,0.6738726401252079
|
||||
62,10360,6942,3418,0,1,67.01,0.6756756756756757
|
||||
63,72258,67453,4805,0,7,93.35,0.9317169033186636
|
||||
64,20608,16514,4094,0,2,80.13,0.806046195652174
|
||||
65,92677,87807,4870,0,9,94.75,0.951541374882657
|
||||
66,20544,16448,4096,0,2,80.06,0.806756230529595
|
||||
67,20607,16467,4140,0,2,79.91,0.8011355364681905
|
||||
68,41070,36496,4574,0,4,88.86,0.8941806671536401
|
||||
69,10325,6922,3403,0,1,67.04,0.6650847457627118
|
||||
70,41221,36648,4573,0,4,88.91,0.8889158438659907
|
||||
71,10123,6701,3422,0,1,66.2,0.6680825842141658
|
||||
72,10296,6869,3427,0,1,66.72,0.668997668997669
|
||||
73,10084,6671,3413,0,1,66.15,0.653312177707259
|
||||
74,10412,6968,3444,0,1,66.92,0.6566461774875144
|
||||
75,10390,6975,3415,0,1,67.13,0.6796920115495669
|
||||
76,20528,16406,4122,0,2,79.92,0.7993472330475448
|
||||
77,10219,6770,3449,0,1,66.25,0.6641550053821313
|
||||
78,10241,6864,3377,0,1,67.02,0.6729811541841617
|
||||
79,10085,6658,3427,0,1,66.02,0.6535448686167575
|
||||
80,10262,6839,3423,0,1,66.64,0.6625414149288638
|
||||
81,184351,179346,5005,0,18,97.29,0.9742122364402689
|
||||
82,10247,6824,3423,0,1,66.6,0.6655606518981165
|
||||
83,10282,6845,3437,0,1,66.57,0.6648511962653181
|
||||
84,10355,6904,3451,0,1,66.67,0.6693384838242395
|
||||
85,20551,16412,4139,0,2,79.86,0.8041457836601625
|
||||
86,10181,6802,3379,0,1,66.81,0.6746881445830468
|
||||
87,51114,46447,4667,0,5,90.87,0.9127244981805376
|
||||
88,10189,6779,3410,0,1,66.53,0.6714103444891549
|
||||
89,10313,6884,3429,0,1,66.75,0.6650829050712693
|
||||
90,30827,26416,4411,0,3,85.69,0.848152593505693
|
||||
91,10282,6875,3407,0,1,66.86,0.682260260649679
|
||||
92,10264,6830,3434,0,1,66.54,0.6677708495713173
|
||||
93,10190,6788,3402,0,1,66.61,0.6714425907752699
|
||||
94,20797,16660,4137,0,2,80.11,0.8132903784199644
|
||||
95,10408,6985,3423,0,1,67.11,0.6622790161414297
|
||||
96,30763,26365,4398,0,3,85.7,0.8571010629652505
|
||||
97,10291,6857,3434,0,1,66.63,0.6533864541832669
|
||||
98,10268,6832,3436,0,1,66.54,0.6722828204129334
|
||||
99,10391,6944,3447,0,1,66.83,0.6803964969685304
|
||||
100,10253,6836,3417,0,1,66.67,0.6542475373061543
|
||||
|
101
experiments/No_Refresh_2_0s_ttl/hit_age.csv
Normal file
101
experiments/No_Refresh_2_0s_ttl/hit_age.csv
Normal file
@@ -0,0 +1,101 @@
|
||||
obj_id,hit_rate,avg_age
|
||||
1,0.6648851939825812,0.9938969931527241
|
||||
2,0.6591,0.9974207252313761
|
||||
3,0.7990697674418604,1.0089455302983885
|
||||
4,0.6681857849316397,1.0140763314468146
|
||||
5,0.8574726096427062,0.9984075829383886
|
||||
6,0.6667628112681473,0.9893294881038212
|
||||
7,0.6674327300584123,1.0126255380200861
|
||||
8,0.6675379998063704,0.9975344452501813
|
||||
9,0.8005128701374105,0.9880930794802055
|
||||
10,0.6665373800058179,1.0053826011056153
|
||||
11,0.6634474685396546,1.0076459344214086
|
||||
12,0.9563917909785905,1.0020864823761788
|
||||
13,0.6636595410864875,1.0085697399527187
|
||||
14,0.6694183144557496,0.998566102667049
|
||||
15,0.666046055854973,1.0172134765337648
|
||||
16,0.9473570401444464,0.9902992399169158
|
||||
17,0.6665377176015473,0.9940510737086478
|
||||
18,0.6698897698704313,1.0248267898383372
|
||||
19,0.6678234046655099,1.0165993071593533
|
||||
20,0.6688940538446639,0.9891414507021862
|
||||
21,0.6666991141828094,0.9950357716454957
|
||||
22,0.6640198511166253,0.9977578475336323
|
||||
23,0.6675129381896299,1.0046811000585139
|
||||
24,0.667278346532741,0.990447242726878
|
||||
25,0.6631105021043359,1.0022140221402214
|
||||
26,0.9630466559274506,0.9994888990420729
|
||||
27,0.8004456068972198,0.9976400822945661
|
||||
28,0.8007174366183528,0.9982443395084151
|
||||
29,0.6617210682492581,0.9730941704035875
|
||||
30,0.7985820491359362,1.0064734895191123
|
||||
31,0.6673140415614682,0.9998544819557625
|
||||
32,0.7997390421881796,0.9977037887485649
|
||||
33,0.9475864146396566,0.9953565468148636
|
||||
34,0.9677914209705294,1.007256699907034
|
||||
35,0.6616742709779806,0.9944536051566482
|
||||
36,0.6631786771964462,0.9904733551652277
|
||||
37,0.6678842641545708,1.0118019573978123
|
||||
38,0.6647539389223887,1.003218727139722
|
||||
39,0.857840616966581,1.0057311956847468
|
||||
40,0.9565850944512642,0.9991229446901225
|
||||
41,0.9923743500866551,0.9898677538632011
|
||||
42,0.6639503298409003,1.0042372881355932
|
||||
43,0.800252047889099,1.002665051483949
|
||||
44,0.6672497570456755,1.008301776871541
|
||||
45,0.6653061224489796,0.9989775051124744
|
||||
46,0.6657442182249457,1.009501187648456
|
||||
47,0.6621915103652517,0.9989564698867024
|
||||
48,0.9473183802238645,0.9989963503649635
|
||||
49,0.6649409006544886,0.9966211253121786
|
||||
50,0.6672776384333398,0.9986988578863669
|
||||
51,0.6634214186369958,1.0022461814914645
|
||||
52,0.6674405107370864,0.9928985507246377
|
||||
53,0.8586681201705729,1.0041820693775438
|
||||
54,0.6696850014449475,1.0041714614499424
|
||||
55,0.6671521506942422,1.0043661766846166
|
||||
56,0.6654960491659351,0.9995602462620933
|
||||
57,0.6643053915781189,1.0105154028436019
|
||||
58,0.663121614967996,1.0307395307395308
|
||||
59,0.8575431589796444,0.9996619718309859
|
||||
60,0.670379260681709,0.993841306215984
|
||||
61,0.66712315367309,1.0101173020527858
|
||||
62,0.67007722007722,1.0083549409392105
|
||||
63,0.9335021727697971,0.9980875572620936
|
||||
64,0.8013392857142857,1.0058738040450528
|
||||
65,0.9474519028453662,1.0043162845786782
|
||||
66,0.8006230529595015,1.007660505836576
|
||||
67,0.7990973940893871,1.002550555656768
|
||||
68,0.8886291697102507,1.0062472599736958
|
||||
69,0.670411622276029,0.9920543195608206
|
||||
70,0.8890614007423401,0.9998362802881466
|
||||
71,0.6619579176133558,1.0092523503954633
|
||||
72,0.6671522921522921,1.002766050371233
|
||||
73,0.661543038476795,0.9875580872432919
|
||||
74,0.6692278140606992,0.9811997703788748
|
||||
75,0.6713185755534168,1.0124731182795699
|
||||
76,0.7992010911925176,1.0001828599292941
|
||||
77,0.6624914375183482,1.0025110782865583
|
||||
78,0.6702470461868958,1.004079254079254
|
||||
79,0.6601883986117997,0.9899369179933915
|
||||
80,0.6664392905866303,0.9941511916946922
|
||||
81,0.9728507032779861,1.001399529401269
|
||||
82,0.6659510100517224,0.9994138335287222
|
||||
83,0.6657265123516826,0.9986851716581446
|
||||
84,0.6667310478029937,1.0039107763615296
|
||||
85,0.7985986083402268,1.0069461369729467
|
||||
86,0.6681072586189962,1.0098500441046752
|
||||
87,0.908694291192237,1.004435162658514
|
||||
88,0.6653253508685838,1.0091458917244431
|
||||
89,0.6675070299621837,0.9963683904706566
|
||||
90,0.8569111493171571,0.9897789218655361
|
||||
91,0.6686442326395643,1.0203636363636364
|
||||
92,0.6654325798908808,1.0035139092240117
|
||||
93,0.6661432777232581,1.007955215085445
|
||||
94,0.8010770784247728,1.0152460984393759
|
||||
95,0.6711183704842429,0.9868289191123837
|
||||
96,0.8570360498000845,1.0000758581452684
|
||||
97,0.6663103682829657,0.980603762578387
|
||||
98,0.6653681340085703,1.0103922716627636
|
||||
99,0.6682706188047348,1.0181451612903225
|
||||
100,0.6667316882863552,0.981275599765945
|
||||
|
Binary file not shown.
Binary file not shown.
BIN
experiments/No_Refresh_2_0s_ttl/objects_in_cache_over_time.pdf
Normal file
BIN
experiments/No_Refresh_2_0s_ttl/objects_in_cache_over_time.pdf
Normal file
Binary file not shown.
9
experiments/No_Refresh_2_0s_ttl/overall_hit_age.csv
Normal file
9
experiments/No_Refresh_2_0s_ttl/overall_hit_age.csv
Normal file
@@ -0,0 +1,9 @@
|
||||
,hit_rate,avg_age
|
||||
count,100.0,100.0
|
||||
mean,0.733978802245101,1.0013731222328242
|
||||
std,0.10479274510693432,0.009391010197280551
|
||||
min,0.6591,0.9730941704035875
|
||||
25%,0.6656688965552457,0.9965579416017981
|
||||
50%,0.6676807022359401,1.001743005888724
|
||||
75%,0.8004624227072674,1.0073540085356276
|
||||
max,0.9923743500866551,1.0307395307395308
|
||||
|
101
experiments/No_Refresh_3_0s_ttl/details.csv
Normal file
101
experiments/No_Refresh_3_0s_ttl/details.csv
Normal file
@@ -0,0 +1,101 @@
|
||||
obj_id,access_count,hits,misses,mu,lambda,hit_rate,avg_age
|
||||
1,30567,27493,3074,0,3,89.94,1.337128275591324
|
||||
2,10330,7769,2561,0,1,75.21,1.1316553727008714
|
||||
3,10302,7743,2559,0,1,75.16,1.135701805474665
|
||||
4,10270,7712,2558,0,1,75.09,1.1236611489776047
|
||||
5,10256,7680,2576,0,1,74.88,1.127242589703588
|
||||
6,10247,7682,2565,0,1,74.97,1.1255001463843075
|
||||
7,10171,7618,2553,0,1,74.9,1.138826074132337
|
||||
8,10279,7742,2537,0,1,75.32,1.1329895904270844
|
||||
9,470989,467598,3391,0,46,99.28,1.497631579506103
|
||||
10,10323,7756,2567,0,1,75.13,1.1152765668894702
|
||||
11,10371,7791,2580,0,1,75.12,1.1276636775624338
|
||||
12,10239,7680,2559,0,1,75.01,1.1261841976755542
|
||||
13,40736,37582,3154,0,4,92.26,1.3787313432835822
|
||||
14,10201,7649,2552,0,1,74.98,1.1466522889912754
|
||||
15,10274,7727,2547,0,1,75.21,1.1216663422230875
|
||||
16,102392,99087,3305,0,10,96.77,1.4431010235174624
|
||||
17,20553,17622,2931,0,2,85.74,1.2870140612076095
|
||||
18,10255,7690,2565,0,1,74.99,1.1212091662603607
|
||||
19,10243,7681,2562,0,1,74.99,1.1168602948354973
|
||||
20,71505,68246,3259,0,7,95.44,1.4363051534857703
|
||||
21,41259,38101,3158,0,4,92.35,1.3931505853268378
|
||||
22,10160,7594,2566,0,1,74.74,1.1190944881889764
|
||||
23,10292,7730,2562,0,1,75.11,1.112417411581811
|
||||
24,61350,58112,3238,0,6,94.72,1.4142461287693562
|
||||
25,41234,38078,3156,0,4,92.35,1.3850948246592618
|
||||
26,81902,78622,3280,0,8,96.0,1.4366193743742521
|
||||
27,10147,7590,2557,0,1,74.8,1.1366906474820144
|
||||
28,71544,68280,3264,0,7,95.44,1.430308621268031
|
||||
29,40964,37814,3150,0,4,92.31,1.3832145298310712
|
||||
30,10371,7809,2562,0,1,75.3,1.142030662424067
|
||||
31,40686,37537,3149,0,4,92.26,1.3885857543135232
|
||||
32,10101,7533,2568,0,1,74.58,1.1287001287001286
|
||||
33,10292,7747,2545,0,1,75.27,1.1353478429848427
|
||||
34,20207,17288,2919,0,2,85.55,1.286138466867917
|
||||
35,10143,7582,2561,0,1,74.75,1.1277728482697427
|
||||
36,10253,7689,2564,0,1,74.99,1.125426704379206
|
||||
37,10380,7806,2574,0,1,75.2,1.1270712909441234
|
||||
38,10000,7445,2555,0,1,74.45,1.1287
|
||||
39,10185,7630,2555,0,1,74.91,1.1270495827196858
|
||||
40,10136,7583,2553,0,1,74.81,1.1037884767166535
|
||||
41,10437,7875,2562,0,1,75.45,1.1317428379802625
|
||||
42,40917,37766,3151,0,4,92.3,1.3858787301121782
|
||||
43,10373,7809,2564,0,1,75.28,1.1315916321218549
|
||||
44,30434,27370,3064,0,3,89.93,1.346126043241112
|
||||
45,10262,7712,2550,0,1,75.15,1.120249464042097
|
||||
46,10246,7693,2553,0,1,75.08,1.1247316025766152
|
||||
47,10363,7794,2569,0,1,75.21,1.1348065232075655
|
||||
48,40600,37449,3151,0,4,92.24,1.3829310344827586
|
||||
49,10177,7622,2555,0,1,74.89,1.1257738036749534
|
||||
50,50976,47779,3197,0,5,93.73,1.4054260828625236
|
||||
51,30487,27407,3080,0,3,89.9,1.345917932233411
|
||||
52,71920,68658,3262,0,7,95.46,1.4373748609566184
|
||||
53,143192,139856,3336,0,14,97.67,1.4652424716464607
|
||||
54,10271,7708,2563,0,1,75.05,1.1308538603836042
|
||||
55,10314,7741,2573,0,1,75.05,1.1037424859414389
|
||||
56,10431,7866,2565,0,1,75.41,1.1262582686223757
|
||||
57,10304,7743,2561,0,1,75.15,1.1184976708074534
|
||||
58,10334,7781,2553,0,1,75.3,1.1323785562221793
|
||||
59,10375,7802,2573,0,1,75.2,1.1201927710843373
|
||||
60,10288,7732,2556,0,1,75.16,1.1369556765163298
|
||||
61,10256,7709,2547,0,1,75.17,1.1382605304212168
|
||||
62,143793,140458,3335,0,14,97.68,1.455182102049474
|
||||
63,40843,37698,3145,0,4,92.3,1.395710403251475
|
||||
64,10290,7720,2570,0,1,75.02,1.1291545189504373
|
||||
65,10065,7489,2576,0,1,74.41,1.127471435668157
|
||||
66,10159,7598,2561,0,1,74.79,1.1202874298651442
|
||||
67,30822,27744,3078,0,3,90.01,1.3478684056842516
|
||||
68,10292,7736,2556,0,1,75.17,1.1420520792848814
|
||||
69,10280,7738,2542,0,1,75.27,1.1160505836575876
|
||||
70,30689,27627,3062,0,3,90.02,1.356837954967578
|
||||
71,61315,58082,3233,0,6,94.73,1.4129658321780967
|
||||
72,10413,7815,2598,0,1,75.05,1.1094785364448285
|
||||
73,30522,27445,3077,0,3,89.92,1.344603892274425
|
||||
74,10281,7717,2564,0,1,75.06,1.129073047368933
|
||||
75,10192,7635,2557,0,1,74.91,1.1304945054945055
|
||||
76,10231,7667,2564,0,1,74.94,1.1153357443065195
|
||||
77,10225,7664,2561,0,1,74.95,1.1271393643031784
|
||||
78,10323,7745,2578,0,1,75.03,1.1218637992831542
|
||||
79,10161,7607,2554,0,1,74.86,1.1370928058261982
|
||||
80,10378,7817,2561,0,1,75.32,1.1160146463673155
|
||||
81,10335,7774,2561,0,1,75.22,1.126463473633285
|
||||
82,10284,7734,2550,0,1,75.2,1.1260210035005835
|
||||
83,10283,7711,2572,0,1,74.99,1.1354663036078965
|
||||
84,30821,27753,3068,0,3,90.05,1.3493397358943577
|
||||
85,10344,7784,2560,0,1,75.25,1.120262954369683
|
||||
86,10255,7683,2572,0,1,74.92,1.1198439785470502
|
||||
87,10224,7647,2577,0,1,74.79,1.107394366197183
|
||||
88,2059016,2055606,3410,0,201,99.83,1.4875770756516704
|
||||
89,20550,17618,2932,0,2,85.73,1.282043795620438
|
||||
90,20552,17629,2923,0,2,85.78,1.2814811210587778
|
||||
91,20548,17623,2925,0,2,85.77,1.2788592563753163
|
||||
92,10190,7642,2548,0,1,75.0,1.1343473994111875
|
||||
93,10103,7552,2551,0,1,74.75,1.1411461941997427
|
||||
94,10415,7852,2563,0,1,75.39,1.1408545367258762
|
||||
95,20601,17672,2929,0,2,85.78,1.2943546429784962
|
||||
96,10120,7559,2561,0,1,74.69,1.1271739130434784
|
||||
97,41195,38037,3158,0,4,92.33,1.3787352834081805
|
||||
98,10184,7628,2556,0,1,74.9,1.1277494108405341
|
||||
99,10508,7948,2560,0,1,75.64,1.122287780738485
|
||||
100,10332,7777,2555,0,1,75.27,1.131145954316686
|
||||
|
101
experiments/No_Refresh_3_0s_ttl/hit_age.csv
Normal file
101
experiments/No_Refresh_3_0s_ttl/hit_age.csv
Normal file
@@ -0,0 +1,101 @@
|
||||
obj_id,hit_rate,avg_age
|
||||
1,0.899434030163248,1.4866329611173754
|
||||
2,0.752081316553727,1.5046981593512678
|
||||
3,0.7516016307513105,1.5110422316931422
|
||||
4,0.7509250243427459,1.4963692946058091
|
||||
5,0.748829953198128,1.5053385416666667
|
||||
6,0.7496828340001952,1.5013017443374121
|
||||
7,0.7489922328187986,1.5204778156996588
|
||||
8,0.7531861075980154,1.5042624644794627
|
||||
9,0.9928002564815739,1.5084923374351473
|
||||
10,0.7513319771384287,1.484399174832388
|
||||
11,0.7512293896442002,1.5010910024387114
|
||||
12,0.7500732493407559,1.5014322916666667
|
||||
13,0.9225746268656716,1.4944388270980788
|
||||
14,0.7498284481913537,1.529219505817754
|
||||
15,0.7520926610862371,1.4913938138993141
|
||||
16,0.9677220876630986,1.4912349753247147
|
||||
17,0.8573930813019998,1.5010781977074112
|
||||
18,0.749878108239883,1.49518855656697
|
||||
19,0.7498779654398126,1.4893894024215597
|
||||
20,0.9544227676386267,1.5048940597251121
|
||||
21,0.9234591240698999,1.5086218209495814
|
||||
22,0.7474409448818897,1.4972346589412695
|
||||
23,0.7510687912942091,1.4811125485122898
|
||||
24,0.9472208638956805,1.4930479074889869
|
||||
25,0.9234612213222099,1.4998949524659908
|
||||
26,0.9599521379209299,1.4965531276233115
|
||||
27,0.7480043362570218,1.519631093544137
|
||||
28,0.9543777255954378,1.4986818980667838
|
||||
29,0.9231032125768968,1.4984397313164437
|
||||
30,0.7529649985536593,1.5167114867460623
|
||||
31,0.9226023693653836,1.505074992673895
|
||||
32,0.7457677457677457,1.5134740475242268
|
||||
33,0.7527205596579868,1.508325803536853
|
||||
34,0.8555451081308457,1.5032970846830171
|
||||
35,0.7475105984422754,1.5087048272223689
|
||||
36,0.7499268506778504,1.5007153075822603
|
||||
37,0.7520231213872832,1.4987189341532154
|
||||
38,0.7445,1.516051040967092
|
||||
39,0.7491408934707904,1.5044560943643512
|
||||
40,0.7481254932912391,1.4754055123302123
|
||||
41,0.7545271629778671,1.499936507936508
|
||||
42,0.9229904440697021,1.5015092940740349
|
||||
43,0.7528198206883254,1.5031374055576898
|
||||
44,0.8993231254517974,1.4968213372305443
|
||||
45,0.7515104268173846,1.4906639004149378
|
||||
46,0.7508295920359165,1.49798518133368
|
||||
47,0.752098813085014,1.5088529638183217
|
||||
48,0.9223891625615763,1.499292370957836
|
||||
49,0.7489436965706986,1.503148779847809
|
||||
50,0.93728421217828,1.4994662927227442
|
||||
51,0.8989733328959885,1.4971722552632538
|
||||
52,0.9546440489432703,1.505665763640071
|
||||
53,0.9767026090843064,1.5001930557144492
|
||||
54,0.7504624671404927,1.5068759730150494
|
||||
55,0.7505332557688579,1.4706110321663868
|
||||
56,0.7540983606557377,1.4935163996948895
|
||||
57,0.7514557453416149,1.488441172672091
|
||||
58,0.7529514224888717,1.5039198046523583
|
||||
59,0.752,1.489618046654704
|
||||
60,0.7515552099533437,1.5128039317123643
|
||||
61,0.7516575663026521,1.5143338954468804
|
||||
62,0.9768069377507945,1.489733585840607
|
||||
63,0.9229978209240262,1.5121491856331901
|
||||
64,0.750242954324587,1.5050518134715025
|
||||
65,0.7440635866865375,1.5152890906663106
|
||||
66,0.7479082586868786,1.4978941826796526
|
||||
67,0.9001362663032899,1.4974048442906573
|
||||
68,0.7516517683637777,1.5193898655635987
|
||||
69,0.7527237354085603,1.4826828637890928
|
||||
70,0.9002248362605494,1.5072211966554458
|
||||
71,0.94727228247574,1.4916153025033574
|
||||
72,0.7505041774704696,1.4783109404990402
|
||||
73,0.8991874713321538,1.4953543450537439
|
||||
74,0.7506079175177512,1.504211481145523
|
||||
75,0.7491169544740973,1.5091028159790438
|
||||
76,0.7493891115238002,1.4883265944958914
|
||||
77,0.7495354523227384,1.5037839248434237
|
||||
78,0.7502663954276857,1.4952872821174952
|
||||
79,0.7486467867335892,1.5188642040226108
|
||||
80,0.753227982270187,1.4816425738774466
|
||||
81,0.7522012578616353,1.4975559557499356
|
||||
82,0.7520420070011669,1.4972847168347556
|
||||
83,0.7498784401439269,1.51420049280249
|
||||
84,0.9004574802894131,1.4985046661622168
|
||||
85,0.7525135344160866,1.4886947584789312
|
||||
86,0.7491955143832277,1.494728621632175
|
||||
87,0.7479460093896714,1.480580619850922
|
||||
88,0.9983438691102935,1.4900447848469016
|
||||
89,0.857323600973236,1.495402429333636
|
||||
90,0.8577753989879331,1.4939588178569403
|
||||
91,0.8576503795989877,1.4911195596663451
|
||||
92,0.7499509322865554,1.5125621565035332
|
||||
93,0.7475007423537563,1.5266154661016949
|
||||
94,0.7539126260201632,1.5132450331125828
|
||||
95,0.8578224358040872,1.5088841104572204
|
||||
96,0.7469367588932806,1.50906204524408
|
||||
97,0.9233402111906784,1.4932039855929753
|
||||
98,0.7490180675569521,1.5056371263765076
|
||||
99,0.7563760944042635,1.4837695017614494
|
||||
100,0.752710027100271,1.5027645621705028
|
||||
|
Binary file not shown.
BIN
experiments/No_Refresh_3_0s_ttl/lambda_vs_access_count.pdf
Normal file
BIN
experiments/No_Refresh_3_0s_ttl/lambda_vs_access_count.pdf
Normal file
Binary file not shown.
BIN
experiments/No_Refresh_3_0s_ttl/objects_in_cache_over_time.pdf
Normal file
BIN
experiments/No_Refresh_3_0s_ttl/objects_in_cache_over_time.pdf
Normal file
Binary file not shown.
9
experiments/No_Refresh_3_0s_ttl/overall_hit_age.csv
Normal file
9
experiments/No_Refresh_3_0s_ttl/overall_hit_age.csv
Normal file
@@ -0,0 +1,9 @@
|
||||
,hit_rate,avg_age
|
||||
count,100.0,100.0
|
||||
mean,0.8084803040405154,1.5004162909676702
|
||||
std,0.08449567004331755,0.01094342334307551
|
||||
min,0.7440635866865375,1.4706110321663868
|
||||
25%,0.749878357167916,1.4938482133164275
|
||||
50%,0.752086988819982,1.5000647818254786
|
||||
75%,0.89935085162966,1.5074973483757976
|
||||
max,0.9983438691102935,1.529219505817754
|
||||
|
101
experiments/No_Refresh_4_0s_ttl/details.csv
Normal file
101
experiments/No_Refresh_4_0s_ttl/details.csv
Normal file
@@ -0,0 +1,101 @@
|
||||
obj_id,access_count,hits,misses,mu,lambda,hit_rate,avg_age
|
||||
1,20435,18160,2275,0,2,88.87,1.7857597259603621
|
||||
2,81256,78782,2474,0,8,96.96,1.950932854189229
|
||||
3,10278,8246,2032,0,1,80.23,1.6109165207238763
|
||||
4,20294,18024,2270,0,2,88.81,1.783433527150882
|
||||
5,10110,8071,2039,0,1,79.83,1.5979228486646884
|
||||
6,40580,38182,2398,0,4,94.09,1.8920896993592904
|
||||
7,81588,79113,2475,0,8,96.97,1.9418174241309996
|
||||
8,10025,7994,2031,0,1,79.74,1.5697755610972568
|
||||
9,30536,28180,2356,0,3,92.28,1.8446096410793817
|
||||
10,20308,18048,2260,0,2,88.87,1.7812684656293087
|
||||
11,61345,58898,2447,0,6,96.01,1.9128209308012063
|
||||
12,10244,8193,2051,0,1,79.98,1.6127489262007029
|
||||
13,10287,8252,2035,0,1,80.22,1.5930786429474093
|
||||
14,10228,8187,2041,0,1,80.04,1.596304262807978
|
||||
15,10154,8111,2043,0,1,79.88,1.5791806184754777
|
||||
16,10277,8222,2055,0,1,80.0,1.5889851123868832
|
||||
17,10303,8249,2054,0,1,80.06,1.6019605940017472
|
||||
18,20458,18185,2273,0,2,88.89,1.7886401407762245
|
||||
19,51095,48666,2429,0,5,95.25,1.910695762794794
|
||||
20,10226,8197,2029,0,1,80.16,1.5989634265597497
|
||||
21,20571,18300,2271,0,2,88.96,1.7734188906713335
|
||||
22,20516,18246,2270,0,2,88.94,1.7836810294404368
|
||||
23,295812,293282,2530,0,29,99.14,1.9740612280772922
|
||||
24,10305,8270,2035,0,1,80.25,1.606501698204755
|
||||
25,20376,18103,2273,0,2,88.84,1.7651158225363173
|
||||
26,20402,18132,2270,0,2,88.87,1.7657582589942162
|
||||
27,10030,7995,2035,0,1,79.71,1.6048853439680957
|
||||
28,10125,8071,2054,0,1,79.71,1.5887407407407408
|
||||
29,112722,110227,2495,0,11,97.79,1.9490339064246553
|
||||
30,10190,8155,2035,0,1,80.03,1.6080471050049068
|
||||
31,20412,18140,2272,0,2,88.87,1.763668430335097
|
||||
32,10216,8176,2040,0,1,80.03,1.600626468285043
|
||||
33,10224,8187,2037,0,1,80.08,1.6048513302034428
|
||||
34,10359,8303,2056,0,1,80.15,1.591080220098465
|
||||
35,10388,8335,2053,0,1,80.24,1.6205236811705814
|
||||
36,20367,18099,2268,0,2,88.86,1.77713949035204
|
||||
37,20371,18107,2264,0,2,88.89,1.781257670217466
|
||||
38,30393,28038,2355,0,3,92.25,1.867403678478597
|
||||
39,20361,18092,2269,0,2,88.86,1.7774667256028682
|
||||
40,10214,8164,2050,0,1,79.93,1.5947718817309575
|
||||
41,20237,17970,2267,0,2,88.8,1.7825764688441963
|
||||
42,40847,38438,2409,0,4,94.1,1.8866746639900116
|
||||
43,30414,28066,2348,0,3,92.28,1.8445123956072862
|
||||
44,10204,8157,2047,0,1,79.94,1.5944727557820462
|
||||
45,10350,8296,2054,0,1,80.15,1.5795169082125604
|
||||
46,20228,17968,2260,0,2,88.83,1.766363456594819
|
||||
47,10295,8259,2036,0,1,80.22,1.602525497814473
|
||||
48,10227,8183,2044,0,1,80.01,1.594113620807666
|
||||
49,40854,38454,2400,0,4,94.13,1.8942576002349831
|
||||
50,10355,8314,2041,0,1,80.29,1.614196040560116
|
||||
51,10294,8242,2052,0,1,80.07,1.5964639595881096
|
||||
52,10228,8181,2047,0,1,79.99,1.6165428236214314
|
||||
53,81599,79123,2476,0,8,96.97,1.938798269586637
|
||||
54,20433,18155,2278,0,2,88.85,1.788968824940048
|
||||
55,10169,8122,2047,0,1,79.87,1.5943553938440358
|
||||
56,10174,8131,2043,0,1,79.92,1.5905248673088264
|
||||
57,10247,8208,2039,0,1,80.1,1.592563677173807
|
||||
58,10367,8311,2056,0,1,80.17,1.6178257933828495
|
||||
59,10238,8193,2045,0,1,80.03,1.6112521976948624
|
||||
60,10266,8232,2034,0,1,80.19,1.6083187219949346
|
||||
61,10131,8079,2052,0,1,79.75,1.5869114598756293
|
||||
62,10230,8186,2044,0,1,80.02,1.6131964809384165
|
||||
63,10180,8159,2021,0,1,80.15,1.619056974459725
|
||||
64,20508,18244,2264,0,2,88.96,1.7919836161497953
|
||||
65,10284,8234,2050,0,1,80.07,1.6067677946324388
|
||||
66,30601,28244,2357,0,3,92.3,1.8235024999183034
|
||||
67,10167,8126,2041,0,1,79.93,1.6418805940788828
|
||||
68,10063,8010,2053,0,1,79.6,1.5928649508098975
|
||||
69,20183,17916,2267,0,2,88.77,1.7774364564237228
|
||||
70,20651,18382,2269,0,2,89.01,1.7801075008474165
|
||||
71,10281,8240,2041,0,1,80.15,1.5826281490127418
|
||||
72,10214,8178,2036,0,1,80.07,1.5974153123164285
|
||||
73,51166,48737,2429,0,5,95.25,1.9054645663135676
|
||||
74,10238,8185,2053,0,1,79.95,1.6050986520804844
|
||||
75,10027,7986,2041,0,1,79.64,1.5802333699012665
|
||||
76,10050,8036,2014,0,1,79.96,1.6217910447761195
|
||||
77,10184,8145,2039,0,1,79.98,1.6089945011783189
|
||||
78,10220,8193,2027,0,1,80.17,1.6072407045009784
|
||||
79,10160,8137,2023,0,1,80.09,1.6166338582677164
|
||||
80,122432,119933,2499,0,12,97.96,1.9536395713538943
|
||||
81,40903,38502,2401,0,4,94.13,1.870425152189326
|
||||
82,81311,78838,2473,0,8,96.96,1.9353961948567844
|
||||
83,10199,8154,2045,0,1,79.95,1.6078046867339935
|
||||
84,10202,8154,2048,0,1,79.93,1.6100764555969418
|
||||
85,20238,17974,2264,0,2,88.81,1.7719142207728036
|
||||
86,10137,8087,2050,0,1,79.78,1.609450527769557
|
||||
87,10143,8102,2041,0,1,79.88,1.5938085379079168
|
||||
88,10110,8073,2037,0,1,79.85,1.5952522255192878
|
||||
89,10221,8176,2045,0,1,79.99,1.609822913609236
|
||||
90,40845,38443,2402,0,4,94.12,1.9007467254253887
|
||||
91,10242,8201,2041,0,1,80.07,1.5639523530560437
|
||||
92,20294,18022,2272,0,2,88.8,1.7786537892973293
|
||||
93,40970,38565,2405,0,4,94.13,1.8723456187454235
|
||||
94,30953,28591,2362,0,3,92.37,1.8392724453203244
|
||||
95,20475,18207,2268,0,2,88.92,1.773040293040293
|
||||
96,10000,7977,2023,0,1,79.77,1.5817
|
||||
97,10281,8238,2043,0,1,80.13,1.6159906623869273
|
||||
98,10136,8094,2042,0,1,79.85,1.6071428571428572
|
||||
99,20392,18127,2265,0,2,88.89,1.7948705374656728
|
||||
100,10191,8155,2036,0,1,80.02,1.5958198410362083
|
||||
|
101
experiments/No_Refresh_4_0s_ttl/hit_age.csv
Normal file
101
experiments/No_Refresh_4_0s_ttl/hit_age.csv
Normal file
@@ -0,0 +1,101 @@
|
||||
obj_id,hit_rate,avg_age
|
||||
1,0.8886713971127966,2.0094713656387664
|
||||
2,0.9695530176233139,2.0121982178670255
|
||||
3,0.8022961665693715,2.007882609750182
|
||||
4,0.8881442790972701,2.0080448291167334
|
||||
5,0.7983184965380811,2.0016107049931855
|
||||
6,0.9409068506653524,2.0109213765648737
|
||||
7,0.9696646565671422,2.0025659499702955
|
||||
8,0.7974064837905237,1.9686014510883163
|
||||
9,0.9228451663610165,1.9988289567068842
|
||||
10,0.888713807366555,2.0043218085106385
|
||||
11,0.9601108484799087,1.99229175863357
|
||||
12,0.7997852401405701,2.0164774807762726
|
||||
13,0.8021775055895791,1.9859428017450316
|
||||
14,0.8004497457958545,1.9942591914010015
|
||||
15,0.798798503052984,1.9769448896560227
|
||||
16,0.8000389218643573,1.9861347603989297
|
||||
17,0.8006405901193827,2.0008485877076008
|
||||
18,0.8888943200703882,2.012207863623866
|
||||
19,0.9524611018690674,2.006061726872971
|
||||
20,0.8015841971445336,1.994754178357936
|
||||
21,0.8896018667055564,1.9934972677595628
|
||||
22,0.8893546500292455,2.00559026635975
|
||||
23,0.9914472705637364,1.9910904862896461
|
||||
24,0.8025230470645318,2.001813784764208
|
||||
25,0.8884471927758146,1.9867425288626195
|
||||
26,0.8887363983923144,1.9868188837414515
|
||||
27,0.7971086739780658,2.013383364602877
|
||||
28,0.7971358024691358,1.9930615784908934
|
||||
29,0.9778659001792019,1.9931504985166975
|
||||
30,0.8002944062806673,2.009319435928878
|
||||
31,0.8886929257299627,1.9845644983461963
|
||||
32,0.8003132341425215,2.0
|
||||
33,0.8007629107981221,2.004152925369488
|
||||
34,0.8015252437493967,1.9850656389256895
|
||||
35,0.802368117058144,2.0196760647870424
|
||||
36,0.8886433937251436,1.9998342449859108
|
||||
37,0.8888616170045653,2.003976362732645
|
||||
38,0.9225150528082124,2.0242527997717383
|
||||
39,0.8885614655468789,2.0003869113420296
|
||||
40,0.7992950851772077,1.9952229299363058
|
||||
41,0.887977467015862,2.007456872565387
|
||||
42,0.94102382059882,2.0049170092096364
|
||||
43,0.922798711119879,1.998824200099765
|
||||
44,0.7993923951391612,1.994605859997548
|
||||
45,0.8015458937198068,1.9705882352941178
|
||||
46,0.888273680047459,1.9885351736420303
|
||||
47,0.8022340942204954,1.9975783993219518
|
||||
48,0.8001368925393566,1.992301112061591
|
||||
49,0.9412542223527683,2.0124824465595257
|
||||
50,0.8028971511347175,2.0104642771229253
|
||||
51,0.8006605789780454,1.993933511283669
|
||||
52,0.79986312084474,2.0210243246546877
|
||||
53,0.9696564908883687,1.9994691808955676
|
||||
54,0.888513678852836,2.0134398237400166
|
||||
55,0.7987019372603009,1.9961832061068703
|
||||
56,0.799194023982701,1.9901611117943672
|
||||
57,0.8010149311993754,1.988182261208577
|
||||
58,0.8016784026237098,2.01804836963061
|
||||
59,0.8002539558507521,2.013426095447333
|
||||
60,0.8018702513150204,2.005709426627794
|
||||
61,0.7974533609712763,1.9899740066839955
|
||||
62,0.8001955034213099,2.01600293183484
|
||||
63,0.8014734774066797,2.020100502512563
|
||||
64,0.8896040569533841,2.0143608857706643
|
||||
65,0.8006612213146636,2.006801068739373
|
||||
66,0.9229763733211332,1.9756762498229712
|
||||
67,0.7992524835251303,2.0542702436623186
|
||||
68,0.7959852926562655,2.001123595505618
|
||||
69,0.8876777486003072,2.0023442732752845
|
||||
70,0.8901263861314223,1.9998367968664998
|
||||
71,0.8014784554031709,1.974635922330097
|
||||
72,0.8006657528881926,1.9951088285644412
|
||||
73,0.9525270687565962,2.0004308841332046
|
||||
74,0.7994725532330533,2.007697006719609
|
||||
75,0.7964495861174828,1.9840971700475833
|
||||
76,0.7996019900497513,2.0282478845196614
|
||||
77,0.7997839748625295,2.0117863720073665
|
||||
78,0.8016634050880627,2.004882216526303
|
||||
79,0.8008858267716535,2.0185572078161487
|
||||
80,0.9795886696288552,1.9943468436543736
|
||||
81,0.9413001491333154,1.9870656069814554
|
||||
82,0.969585910885366,1.9961059387604962
|
||||
83,0.7994901460927542,2.011037527593819
|
||||
84,0.7992550480297981,2.0144714250674514
|
||||
85,0.8881312382646507,1.9951040391676866
|
||||
86,0.7977705435533196,2.017435390132311
|
||||
87,0.7987774820072957,1.9953098000493705
|
||||
88,0.7985163204747775,1.9977703455964326
|
||||
89,0.799921729772038,2.0124755381604698
|
||||
90,0.9411923124005386,2.0195094035325027
|
||||
91,0.8007225151337629,1.9531764418973296
|
||||
92,0.8880457278013206,2.002885362334924
|
||||
93,0.9412985111056871,1.9891092959937768
|
||||
94,0.9236907569540916,1.99122101360568
|
||||
95,0.8892307692307693,1.9939034437304333
|
||||
96,0.7977,1.9828256236680457
|
||||
97,0.8012839217974905,2.0167516387472686
|
||||
98,0.7985398579321231,2.0126019273535953
|
||||
99,0.8889270302079246,2.019142715286589
|
||||
100,0.8002158767539986,1.9942366646229308
|
||||
|
BIN
experiments/No_Refresh_4_0s_ttl/lambda_distribution.pdf
Normal file
BIN
experiments/No_Refresh_4_0s_ttl/lambda_distribution.pdf
Normal file
Binary file not shown.
BIN
experiments/No_Refresh_4_0s_ttl/lambda_vs_access_count.pdf
Normal file
BIN
experiments/No_Refresh_4_0s_ttl/lambda_vs_access_count.pdf
Normal file
Binary file not shown.
BIN
experiments/No_Refresh_4_0s_ttl/objects_in_cache_over_time.pdf
Normal file
BIN
experiments/No_Refresh_4_0s_ttl/objects_in_cache_over_time.pdf
Normal file
Binary file not shown.
9
experiments/No_Refresh_4_0s_ttl/overall_hit_age.csv
Normal file
9
experiments/No_Refresh_4_0s_ttl/overall_hit_age.csv
Normal file
@@ -0,0 +1,9 @@
|
||||
,hit_rate,avg_age
|
||||
count,100.0,100.0
|
||||
mean,0.8510557628431259,2.0010172191143316
|
||||
std,0.06321177863870277,0.014208951960786203
|
||||
min,0.7959852926562655,1.9531764418973296
|
||||
25%,0.7999070775402135,1.9931282685102465
|
||||
50%,0.8017743269693651,2.0006397359204025
|
||||
75%,0.8892617394303883,2.011224738697206
|
||||
max,0.9914472705637364,2.0542702436623186
|
||||
|
101
experiments/No_Refresh_5_0s_ttl/details.csv
Normal file
101
experiments/No_Refresh_5_0s_ttl/details.csv
Normal file
@@ -0,0 +1,101 @@
|
||||
obj_id,access_count,hits,misses,mu,lambda,hit_rate,avg_age
|
||||
1,20339,18479,1860,0,2,90.86,2.27017060819116
|
||||
2,10130,8439,1691,0,1,83.31,2.0746298124383022
|
||||
3,10236,8533,1703,0,1,83.36,2.1051191871824932
|
||||
4,10206,8504,1702,0,1,83.32,2.067705271408975
|
||||
5,337084,335059,2025,0,33,99.4,2.4886942127184914
|
||||
6,10235,8540,1695,0,1,83.44,2.0965315095261357
|
||||
7,10061,8368,1693,0,1,83.17,2.1009839976145512
|
||||
8,20019,18166,1853,0,2,90.74,2.2494130575952846
|
||||
9,40733,38791,1942,0,4,95.23,2.3839147619865955
|
||||
10,10170,8483,1687,0,1,83.41,2.0863323500491644
|
||||
11,60945,58976,1969,0,6,96.77,2.429977848880138
|
||||
12,20228,18381,1847,0,2,90.87,2.245451848922286
|
||||
13,30786,28873,1913,0,3,93.79,2.340446956408757
|
||||
14,20305,18456,1849,0,2,90.89,2.2825412459985226
|
||||
15,10133,8430,1703,0,1,83.19,2.1018454554426134
|
||||
16,10232,8535,1697,0,1,83.41,2.083463643471462
|
||||
17,20384,18527,1857,0,2,90.89,2.282182103610675
|
||||
18,172949,170936,2013,0,17,98.84,2.476631839443998
|
||||
19,10273,8579,1694,0,1,83.51,2.06823712644797
|
||||
20,10053,8356,1697,0,1,83.12,2.0936038993335324
|
||||
21,40600,38661,1939,0,4,95.22,2.3798029556650246
|
||||
22,10251,8545,1706,0,1,83.36,2.0913081650570677
|
||||
23,10000,8294,1706,0,1,82.94,2.0405
|
||||
24,10159,8461,1698,0,1,83.29,2.059553105620632
|
||||
25,10015,8309,1706,0,1,82.97,2.059211183225162
|
||||
26,10136,8428,1708,0,1,83.15,2.0944159431728493
|
||||
27,10193,8498,1695,0,1,83.37,2.0631806141469635
|
||||
28,51036,49073,1963,0,5,96.15,2.4281879457637747
|
||||
29,70592,68613,1979,0,7,97.2,2.430969514959202
|
||||
30,10219,8513,1706,0,1,83.31,2.111361189940307
|
||||
31,10178,8483,1695,0,1,83.35,2.1005109058754177
|
||||
32,81130,79143,1987,0,8,97.55,2.4394675212621717
|
||||
33,30477,28564,1913,0,3,93.72,2.350854742920891
|
||||
34,10178,8470,1708,0,1,83.22,2.1021811750835133
|
||||
35,91956,89964,1992,0,9,97.83,2.4512592979250947
|
||||
36,10253,8552,1701,0,1,83.41,2.094703989076368
|
||||
37,10180,8484,1696,0,1,83.34,2.0740667976424363
|
||||
38,20269,18418,1851,0,2,90.87,2.2567467561300507
|
||||
39,20493,18637,1856,0,2,90.94,2.272092909774069
|
||||
40,10164,8460,1704,0,1,83.23,2.0839236521054705
|
||||
41,20209,18358,1851,0,2,90.84,2.261715077440744
|
||||
42,10327,8624,1703,0,1,83.51,2.048997772828508
|
||||
43,10160,8465,1695,0,1,83.32,2.0996062992125983
|
||||
44,112266,110266,2000,0,11,98.22,2.4545454545454546
|
||||
45,10315,8608,1707,0,1,83.45,2.0952011633543384
|
||||
46,10300,8595,1705,0,1,83.45,2.0733009708737864
|
||||
47,10086,8397,1689,0,1,83.25,2.0808050763434465
|
||||
48,10211,8497,1714,0,1,83.21,2.055528351777495
|
||||
49,152402,150392,2010,0,15,98.68,2.4713061508379157
|
||||
50,20385,18531,1854,0,2,90.91,2.281236203090508
|
||||
51,20085,18237,1848,0,2,90.8,2.275379636544685
|
||||
52,10124,8433,1691,0,1,83.3,2.0587712366653497
|
||||
53,71299,69318,1981,0,7,97.22,2.4399220185416346
|
||||
54,10042,8346,1696,0,1,83.11,2.057159928301135
|
||||
55,10076,8394,1682,0,1,83.31,2.0668916236601826
|
||||
56,20766,18911,1855,0,2,91.07,2.2754502552248868
|
||||
57,10246,8566,1680,0,1,83.6,2.0716377122779623
|
||||
58,20214,18359,1855,0,2,90.82,2.290739091718611
|
||||
59,71129,69150,1979,0,7,97.22,2.4332269538444233
|
||||
60,10144,8445,1699,0,1,83.25,2.071076498422713
|
||||
61,20377,18529,1848,0,2,90.93,2.266329685429651
|
||||
62,10267,8564,1703,0,1,83.41,2.077237752021038
|
||||
63,10030,8344,1686,0,1,83.19,2.089531405782652
|
||||
64,10058,8366,1692,0,1,83.18,2.100914694770332
|
||||
65,30672,28760,1912,0,3,93.77,2.324954355764215
|
||||
66,10239,8538,1701,0,1,83.39,2.088289872057818
|
||||
67,10131,8433,1698,0,1,83.24,2.0949560754121013
|
||||
68,10031,8343,1688,0,1,83.17,2.0731731631940984
|
||||
69,10269,8565,1704,0,1,83.41,2.0710877397993963
|
||||
70,305170,303147,2023,0,30,99.34,2.4785332765343906
|
||||
71,10134,8450,1684,0,1,83.38,2.0746003552397867
|
||||
72,10387,8682,1705,0,1,83.59,2.091364205256571
|
||||
73,40590,38651,1939,0,4,95.22,2.3761763981276176
|
||||
74,40322,38388,1934,0,4,95.2,2.3638956400972173
|
||||
75,20298,18443,1855,0,2,90.86,2.264952212040595
|
||||
76,10017,8330,1687,0,1,83.16,2.1029250274533293
|
||||
77,20194,18338,1856,0,2,90.81,2.257056551450926
|
||||
78,10215,8527,1688,0,1,83.48,2.052080274106706
|
||||
79,10126,8421,1705,0,1,83.16,2.097768121666996
|
||||
80,10243,8537,1706,0,1,83.34,2.0985062969833055
|
||||
81,10068,8374,1694,0,1,83.17,2.0969408025427096
|
||||
82,40821,38880,1941,0,4,95.25,2.3762769162930844
|
||||
83,10119,8420,1699,0,1,83.21,2.0855815792074317
|
||||
84,10048,8359,1689,0,1,83.19,2.082703025477707
|
||||
85,40534,38594,1940,0,4,95.21,2.3784477228992946
|
||||
86,20327,18477,1850,0,2,90.9,2.283219363408275
|
||||
87,10035,8339,1696,0,1,83.1,2.0907822620827106
|
||||
88,10202,8494,1708,0,1,83.26,2.0655753773769847
|
||||
89,10273,8565,1708,0,1,83.37,2.0735909666115058
|
||||
90,10116,8408,1708,0,1,83.12,2.0856069592724396
|
||||
91,30630,28719,1911,0,3,93.76,2.3531178583088477
|
||||
92,30356,28444,1912,0,3,93.7,2.324548688891817
|
||||
93,10237,8535,1702,0,1,83.37,2.092214515971476
|
||||
94,10219,8521,1698,0,1,83.38,2.0911048047754184
|
||||
95,20157,18306,1851,0,2,90.82,2.2860048618345985
|
||||
96,20564,18712,1852,0,2,90.99,2.271250729430072
|
||||
97,10253,8569,1684,0,1,83.58,2.0926558080561786
|
||||
98,10125,8417,1708,0,1,83.13,2.089283950617284
|
||||
99,20511,18658,1853,0,2,90.97,2.265321047242943
|
||||
100,61194,59224,1970,0,6,96.78,2.42376703598392
|
||||
|
101
experiments/No_Refresh_5_0s_ttl/hit_age.csv
Normal file
101
experiments/No_Refresh_5_0s_ttl/hit_age.csv
Normal file
@@ -0,0 +1,101 @@
|
||||
obj_id,hit_rate,avg_age
|
||||
1,0.9085500762082698,2.4986741706802316
|
||||
2,0.8330700888450148,2.4903424576371607
|
||||
3,0.8336264165689723,2.5252548927692486
|
||||
4,0.8332353517538703,2.48153809971778
|
||||
5,0.9939925953174876,2.503735163060834
|
||||
6,0.8343917928676111,2.512646370023419
|
||||
7,0.8317264685418945,2.5260516252390057
|
||||
8,0.9074379339627354,2.478861609600352
|
||||
9,0.9523236687697936,2.5032610657111185
|
||||
10,0.8341199606686333,2.501237769656961
|
||||
11,0.9676921814751005,2.5111062126966903
|
||||
12,0.9086909234724144,2.471084271802405
|
||||
13,0.9378613655557722,2.495514840854778
|
||||
14,0.9089386850529426,2.511215864759428
|
||||
15,0.8319352610283233,2.526453143534994
|
||||
16,0.834147771696638,2.497715289982425
|
||||
17,0.908899136577708,2.510929994062719
|
||||
18,0.9883607306200094,2.5057974914587917
|
||||
19,0.8351017229631071,2.476628977736333
|
||||
20,0.8311946682582314,2.5187888942077548
|
||||
21,0.9522413793103448,2.499159359561315
|
||||
22,0.8335772119793191,2.5088355763604446
|
||||
23,0.8294,2.4602122015915118
|
||||
24,0.8328575647209371,2.472875546625694
|
||||
25,0.8296555167249127,2.482007461788422
|
||||
26,0.8314917127071824,2.5188656858092076
|
||||
27,0.8337094084175415,2.4746999293951517
|
||||
28,0.9615369543067639,2.5253194220854644
|
||||
29,0.971965661831369,2.5010858000670426
|
||||
30,0.8330560720227028,2.534476682720545
|
||||
31,0.8334643348398506,2.5202169043970293
|
||||
32,0.9755084432392457,2.500713897628344
|
||||
33,0.9372313547921384,2.5082971572608876
|
||||
34,0.8321870701513068,2.5260920897284533
|
||||
35,0.9783374657444865,2.505535547552354
|
||||
36,0.8340973373646737,2.511342376052385
|
||||
37,0.8333988212180746,2.4886845827439887
|
||||
38,0.9086782771720361,2.4835487023563907
|
||||
39,0.9094324891426341,2.498363470515641
|
||||
40,0.8323494687131051,2.503664302600473
|
||||
41,0.9084071453312881,2.4897592330319207
|
||||
42,0.8350924760336981,2.453617810760668
|
||||
43,0.8331692913385826,2.520023626698169
|
||||
44,0.9821851673703526,2.499065895198883
|
||||
45,0.8345128453708192,2.5106877323420074
|
||||
46,0.8344660194174758,2.484584060500291
|
||||
47,0.8325401546698393,2.499345004168155
|
||||
48,0.8321418078542748,2.470165940920325
|
||||
49,0.9868111967034553,2.50433533698601
|
||||
50,0.9090507726269316,2.5094706168042737
|
||||
51,0.9079910380881254,2.505949443439162
|
||||
52,0.8329711576451996,2.471599667971066
|
||||
53,0.9722155990967615,2.5096511728555355
|
||||
54,0.8311093407687712,2.475197699496765
|
||||
55,0.833068678046844,2.481057898498928
|
||||
56,0.9106712896080131,2.498651578446407
|
||||
57,0.8360335740776889,2.477936026149895
|
||||
58,0.9082319184723459,2.5221961980500027
|
||||
59,0.9721773116450393,2.5028633405639913
|
||||
60,0.8325118296529969,2.487744227353464
|
||||
61,0.9093095156303675,2.4923633223595445
|
||||
62,0.8341287620531801,2.490308267164876
|
||||
63,0.8319042871385842,2.511744966442953
|
||||
64,0.8317757009345794,2.52581879034186
|
||||
65,0.9376630151278038,2.47952016689847
|
||||
66,0.8338704951655435,2.5043335675802294
|
||||
67,0.832395617411904,2.5167793193406856
|
||||
68,0.8317216628451799,2.492628550880978
|
||||
69,0.834063686824423,2.4831290134267365
|
||||
70,0.9933709080184815,2.4950733472539723
|
||||
71,0.8338267219261891,2.4880473372781067
|
||||
72,0.8358525079426206,2.5020732550103664
|
||||
73,0.9522296132052229,2.4953817495019535
|
||||
74,0.9520361093199742,2.4829894758778783
|
||||
75,0.9086116858803823,2.4927614813208265
|
||||
76,0.8315863032844165,2.528811524609844
|
||||
77,0.9080915123303952,2.485494601374196
|
||||
78,0.8347528144884974,2.458308901137563
|
||||
79,0.8316215682401739,2.5225032656454105
|
||||
80,0.8334472322561749,2.5178634180625514
|
||||
81,0.8317441398490266,2.5211368521614523
|
||||
82,0.95245094436687,2.4949074074074074
|
||||
83,0.8320980334025101,2.506413301662708
|
||||
84,0.831906847133758,2.5035291302787415
|
||||
85,0.9521389450831401,2.498004871223506
|
||||
86,0.9089880454567816,2.511825512799697
|
||||
87,0.8309915296462381,2.5160091138026144
|
||||
88,0.8325818466967261,2.480927713680245
|
||||
89,0.8337389272851163,2.487098657326328
|
||||
90,0.8311585606959272,2.509276879162702
|
||||
91,0.9376101860920666,2.5096974128625646
|
||||
92,0.9370140993543287,2.480804387568556
|
||||
93,0.8337403536192244,2.5094317516110136
|
||||
94,0.8338389274880125,2.5078042483276612
|
||||
95,0.9081708587587438,2.5171528460614008
|
||||
96,0.9099397004473838,2.4960453185121847
|
||||
97,0.8357553886667317,2.5039094410082856
|
||||
98,0.8313086419753086,2.513247000118807
|
||||
99,0.9096582321681049,2.490299067424161
|
||||
100,0.9678073013694153,2.5043901121167096
|
||||
|
BIN
experiments/No_Refresh_5_0s_ttl/lambda_distribution.pdf
Normal file
BIN
experiments/No_Refresh_5_0s_ttl/lambda_distribution.pdf
Normal file
Binary file not shown.
BIN
experiments/No_Refresh_5_0s_ttl/lambda_vs_access_count.pdf
Normal file
BIN
experiments/No_Refresh_5_0s_ttl/lambda_vs_access_count.pdf
Normal file
Binary file not shown.
BIN
experiments/No_Refresh_5_0s_ttl/objects_in_cache_over_time.pdf
Normal file
BIN
experiments/No_Refresh_5_0s_ttl/objects_in_cache_over_time.pdf
Normal file
Binary file not shown.
9
experiments/No_Refresh_5_0s_ttl/overall_hit_age.csv
Normal file
9
experiments/No_Refresh_5_0s_ttl/overall_hit_age.csv
Normal file
@@ -0,0 +1,9 @@
|
||||
,hit_rate,avg_age
|
||||
count,100.0,100.0
|
||||
mean,0.8785973318800118,2.4997258275889482
|
||||
std,0.056440312317261106,0.01696772212165293
|
||||
min,0.8294,2.453617810760668
|
||||
25%,0.8327886352148843,2.487971559796946
|
||||
50%,0.8344894323941474,2.501655512333664
|
||||
75%,0.9101225977375411,2.511133625712375
|
||||
max,0.9939925953174876,2.534476682720545
|
||||
|
17
experiments/README.md
Normal file
17
experiments/README.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# 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
|
||||
- `lambda_vs_access_count.pdf`: Displays the access count against lambda,
|
||||
expecting a higher lambda to result in a higher access count.
|
||||
- `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.
|
||||
8
experiments/avg_ages.md
Normal file
8
experiments/avg_ages.md
Normal file
@@ -0,0 +1,8 @@
|
||||
| | avg_ages |
|
||||
|:-----|-----------:|
|
||||
| 0.5s | 0.248882 |
|
||||
| 1.0s | 0.499741 |
|
||||
| 2.0s | 1.00137 |
|
||||
| 3.0s | 1.50042 |
|
||||
| 4.0s | 2.00102 |
|
||||
| 5.0s | 2.49973 |
|
||||
8
experiments/hit_rates.md
Normal file
8
experiments/hit_rates.md
Normal file
@@ -0,0 +1,8 @@
|
||||
| | hit_rates |
|
||||
|:-----|------------:|
|
||||
| 0.5s | 0.460409 |
|
||||
| 1.0s | 0.633097 |
|
||||
| 2.0s | 0.733979 |
|
||||
| 3.0s | 0.80848 |
|
||||
| 4.0s | 0.851056 |
|
||||
| 5.0s | 0.878597 |
|
||||
BIN
experiments/hr_and_age_vs_ttl.png
Normal file
BIN
experiments/hr_and_age_vs_ttl.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 38 KiB |
511
multi_aoi_cache_simulation.ipynb
Normal file
511
multi_aoi_cache_simulation.ipynb
Normal file
@@ -0,0 +1,511 @@
|
||||
{
|
||||
"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",
|
||||
"\n",
|
||||
"# Types of cache\n",
|
||||
"class CacheType(Enum):\n",
|
||||
" LRU = 1\n",
|
||||
" RANDOM_EVICTION = 2\n",
|
||||
"\n",
|
||||
"# Constants\n",
|
||||
"SEED = 42\n",
|
||||
"DATABASE_OBJECTS = 100 # Number of objects in the database\n",
|
||||
"ACCESS_COUNT_LIMIT = 10000 # 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": "markdown",
|
||||
"id": "9a37d7a3-3e11-4b89-8dce-6091dd38b16f",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"How to set certain parameters for specific scenarios\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"| Name | Cache Capacity | MAX_REFRESH_RATE | cache_type | CACHE_TTL |\n",
|
||||
"| -------------------- | -------------------- | ---------------- | ------------------------- | --------- |\n",
|
||||
"| Default | DATABASE_OBJECTS | 1< | CacheType.LRU | 5 |\n",
|
||||
"| No Refresh | DATABASE_OBJECTS | 0 | CacheType.LRU | 5 |\n",
|
||||
"| Infinite TTL | DATABASE_OBJECTS / 2 | 0 | CacheType.LRU | 0 |\n",
|
||||
"| Random Eviction (RE) | DATABASE_OBJECTS / 2 | 1< | CacheType.RANDOM_EVICTION | 5 |\n",
|
||||
"| RE without Refresh | DATABASE_OBJECTS / 2 | 0 | CacheType.RANDOM_EVICTION | 5 |\n",
|
||||
"\n",
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"id": "3d0ab5b1-162a-42c8-80a3-d31f763101f1",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Configuration (Just example, will be overwritten in next block\n",
|
||||
"\n",
|
||||
"CACHE_CAPACITY = DATABASE_OBJECTS # Maximum number of objects the cache can hold\n",
|
||||
"\n",
|
||||
"# MAX_REFRESH_RATE is used as the maximum for a uniform\n",
|
||||
"# distribution for mu.\n",
|
||||
"# If MAX_REFRESH_RATE is 0, we do not do any refreshes.\n",
|
||||
"MAX_REFRESH_RATE = 0\n",
|
||||
"\n",
|
||||
"cache_type = CacheType.LRU\n",
|
||||
"\n",
|
||||
"# CACHE_TTL is used to determin which TTL to set when an\n",
|
||||
"# object is pulled into the cache\n",
|
||||
"# If CACHE_TTL is set to 0, the TTL is infinite\n",
|
||||
"CACHE_TTL = 5\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"id": "5cea042f-e9fc-4a1e-9750-de212ca70601",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"class Database:\n",
|
||||
" def __init__(self):\n",
|
||||
" # Each object now has a specific refresh rate 'mu'\n",
|
||||
" self.data = {i: f\"Object {i}\" for i in range(1, DATABASE_OBJECTS + 1)}\n",
|
||||
" self.lambda_values = {i: np.random.zipf(ZIPF_CONSTANT) for i in range(1, DATABASE_OBJECTS + 1)} # Request rate 'lambda' for each object\n",
|
||||
" # Refresh rate 'mu' for each object\n",
|
||||
" if MAX_REFRESH_RATE == 0:\n",
|
||||
" self.mu_values = {i: 0 for i in range(1,DATABASE_OBJECTS + 1)} \n",
|
||||
" else:\n",
|
||||
" self.mu_values = {i: np.random.uniform(1, MAX_REFRESH_RATE) for i in range(1, DATABASE_OBJECTS + 1)}\n",
|
||||
" self.next_request = {i: np.random.exponential(1/self.lambda_values[i]) for i in range(1, DATABASE_OBJECTS + 1)}\n",
|
||||
"\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": 4,
|
||||
"id": "499bf543-b2c6-4e4d-afcc-0a6665ce3ae1",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"class Cache:\n",
|
||||
" def __init__(self, env, db, cache_type):\n",
|
||||
" self.cache_type = cache_type\n",
|
||||
" self.env = env\n",
|
||||
" self.db = db\n",
|
||||
" self.storage = {} # Dictionary to store cached objects\n",
|
||||
" self.ttl = {} # Dictionary to store TTLs\n",
|
||||
" self.age = {} # Dictionary to store age of each object\n",
|
||||
" self.cache_size_over_time = [] # To record cache state at each interval\n",
|
||||
" self.cache_next_request_over_time = []\n",
|
||||
" self.request_log = {i: [] for i in range(1, DATABASE_OBJECTS + 1)}\n",
|
||||
" self.hits = {i: 0 for i in range(1, DATABASE_OBJECTS + 1)} # Track hits per object\n",
|
||||
" self.misses = {i: 0 for i in range(1, DATABASE_OBJECTS + 1)} # Track misses per object\n",
|
||||
" self.cumulative_age = {i: 0 for i in range(1, DATABASE_OBJECTS + 1)} # Track cumulative age per object\n",
|
||||
" self.access_count = {i: 0 for i in range(1, DATABASE_OBJECTS + 1)} # Track access count per object\n",
|
||||
" self.next_refresh = {} # Track the next refresh time for each cached object\n",
|
||||
" \n",
|
||||
" def get(self, obj_id):\n",
|
||||
" if obj_id in self.storage and \\\n",
|
||||
" (self.ttl[obj_id] > env.now or CACHE_TTL == 0):\n",
|
||||
" # Cache hit: increment hit count and update cumulative age\n",
|
||||
" self.hits[obj_id] += 1\n",
|
||||
" self.cumulative_age[obj_id] += self.age[obj_id]\n",
|
||||
" self.access_count[obj_id] += 1\n",
|
||||
" else:\n",
|
||||
" # Cache miss: increment miss count\n",
|
||||
" self.misses[obj_id] += 1\n",
|
||||
" self.cumulative_age[obj_id] += 0\n",
|
||||
" self.access_count[obj_id] += 1\n",
|
||||
" \n",
|
||||
" # Fetch the object from the database if it’s not in cache\n",
|
||||
" obj = self.db.get_object(obj_id)\n",
|
||||
" \n",
|
||||
" # If the cache is full, evict the oldest object\n",
|
||||
" if len(self.storage) > CACHE_CAPACITY:\n",
|
||||
" if self.cache_type == CacheType.LRU:\n",
|
||||
" self.evict_oldest()\n",
|
||||
" elif self.cache_type == CacheType.RANDOM_EVICTION:\n",
|
||||
" self.evict_random()\n",
|
||||
" \n",
|
||||
" # Add the object to cache, set TTL, reset age, and schedule next refresh\n",
|
||||
" self.storage[obj_id] = obj\n",
|
||||
" if CACHE_TTL != 0:\n",
|
||||
" self.ttl[obj_id] = env.now + CACHE_TTL\n",
|
||||
" else:\n",
|
||||
" self.ttl[obj_id] = 0\n",
|
||||
" self.age[obj_id] = 0\n",
|
||||
" if MAX_REFRESH_RATE != 0:\n",
|
||||
" self.next_refresh[obj_id] = env.now + np.random.exponential(1/self.db.mu_values[obj_id]) # Schedule refresh\n",
|
||||
"\n",
|
||||
" \n",
|
||||
" def evict_oldest(self):\n",
|
||||
" \"\"\"Remove the oldest item from the cache to make space.\"\"\"\n",
|
||||
" oldest_id = max(self.age, key=self.age.get) # Find the oldest item by age\n",
|
||||
" print(f\"[{env.now:.2f}] Cache: Evicting oldest object {oldest_id} to make space at {self.ttl[oldest_id]:.2f}\")\n",
|
||||
" del self.storage[oldest_id]\n",
|
||||
" del self.ttl[oldest_id]\n",
|
||||
" del self.age[oldest_id]\n",
|
||||
"\n",
|
||||
" def evict_random(self):\n",
|
||||
" \"\"\"Remove a random item from the cache to make space.\"\"\"\n",
|
||||
" random_id = np.random.choice(list(self.storage.keys())) # Select a random key from the cache\n",
|
||||
" print(f\"[{env.now:.2f}] Cache: Evicting random object {random_id} to make space at {self.ttl[random_id]:.2f}\")\n",
|
||||
" del self.storage[random_id]\n",
|
||||
" del self.ttl[random_id]\n",
|
||||
" del self.age[random_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",
|
||||
" obj = self.db.get_object(obj_id)\n",
|
||||
" self.storage[obj_id] = obj\n",
|
||||
" if CACHE_TTL != 0:\n",
|
||||
" self.ttl[obj_id] = env.now + CACHE_TTL\n",
|
||||
" else:\n",
|
||||
" self.ttl[obj_id] = 0\n",
|
||||
" self.age[obj_id] = 0\n",
|
||||
" # print(f\"[{env.now:.2f}] Cache: Refreshed object {obj_id}\")\n",
|
||||
" \n",
|
||||
" def age_objects(self):\n",
|
||||
" \"\"\"Increment age of each cached object.\"\"\"\n",
|
||||
" for obj_id in list(self.age.keys()):\n",
|
||||
" if CACHE_TTL != 0:\n",
|
||||
" if self.ttl[obj_id] > env.now:\n",
|
||||
" self.age[obj_id] += 1\n",
|
||||
" # print(f\"[{env.now:.2f}] Cache: Object {obj_id} aged to {self.age[obj_id]}\")\n",
|
||||
" else:\n",
|
||||
" # Remove object if its TTL expired\n",
|
||||
" # print(f\"[{env.now:.2f}] Cache: Object {obj_id} expired\")\n",
|
||||
" del self.storage[obj_id]\n",
|
||||
" del self.ttl[obj_id]\n",
|
||||
" del self.age[obj_id]\n",
|
||||
" else:\n",
|
||||
" self.age[obj_id] += 1\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((env.now, len(self.storage)))\n",
|
||||
" self.cache_next_request_over_time.append((env.now, self.db.next_request.copy()))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"id": "7286d498-aa6c-4efb-bb28-fe29736eab64",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def age_cache_process(env, cache):\n",
|
||||
" \"\"\"Process that ages cache objects over time, removes expired items, and refreshes based on object-specific intervals.\"\"\"\n",
|
||||
" while True:\n",
|
||||
" cache.age_objects() # Age objects and remove expired ones\n",
|
||||
"\n",
|
||||
"\n",
|
||||
" if MAX_REFRESH_RATE != 0:\n",
|
||||
" # Refresh objects based on their individual refresh intervals\n",
|
||||
" for obj_id in list(cache.storage.keys()):\n",
|
||||
" # Check if it's time to refresh this object based on next_refresh\n",
|
||||
" if env.now >= cache.next_refresh[obj_id]:\n",
|
||||
" cache.refresh_object(obj_id)\n",
|
||||
" # Schedule the next refresh based on the object's mu\n",
|
||||
" cache.next_refresh[obj_id] = env.now + np.random.exponential(1/cache.db.mu_values[obj_id])\n",
|
||||
" \n",
|
||||
" cache.record_cache_state() # Record cache state at each time step\n",
|
||||
" yield env.timeout(1) # Run every second\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"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",
|
||||
" obj_id, next_request = min(cache.db.next_request.items(), key=lambda x: x[1])\n",
|
||||
" yield env.timeout(next_request - env.now)\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",
|
||||
" if env.now >= next_request:\n",
|
||||
" # print(f\"[{env.now:.2f}] Client: Requesting object {obj_id}\")\n",
|
||||
" cache.get(obj_id)\n",
|
||||
" \n",
|
||||
" # print(f\"[{env.now:.2f}] Client: Schedule next request for {obj_id}\")\n",
|
||||
" next_request = env.now + np.random.exponential(1/cache.db.lambda_values[obj_id])\n",
|
||||
" cache.request_log[obj_id].append(next_request)\n",
|
||||
" cache.db.next_request[obj_id] = next_request\n",
|
||||
" if all(access_count >= ACCESS_COUNT_LIMIT for access_count in cache.access_count.values()):\n",
|
||||
" event.succeed()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"id": "342d1932-94b5-4e0b-89b5-d4edaaccc59c",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"configurations = {\n",
|
||||
" \"default\": (DATABASE_OBJECTS, 10, CacheType.LRU, 5),\n",
|
||||
" \"No Refresh\": (DATABASE_OBJECTS, 0, CacheType.LRU, 5),\n",
|
||||
" \"Infinite TTL\": (int(DATABASE_OBJECTS / 2), 0, CacheType.LRU, 0),\n",
|
||||
" \"Random Eviction\": (int(DATABASE_OBJECTS / 2), 10, CacheType.RANDOM_EVICTION, 5),\n",
|
||||
" \"RE without Refresh\": (int(DATABASE_OBJECTS / 2), 0, CacheType.RANDOM_EVICTION, 5),\n",
|
||||
" \"No Refresh (0.5s ttl)\": (DATABASE_OBJECTS, 0, CacheType.LRU, 0.5),\n",
|
||||
" \"No Refresh (1.0s ttl)\": (DATABASE_OBJECTS, 0, CacheType.LRU, 1),\n",
|
||||
" \"No Refresh (2.0s ttl)\": (DATABASE_OBJECTS, 0, CacheType.LRU, 2),\n",
|
||||
" \"No Refresh (3.0s ttl)\": (DATABASE_OBJECTS, 0, CacheType.LRU, 3),\n",
|
||||
" \"No Refresh (4.0s ttl)\": (DATABASE_OBJECTS, 0, CacheType.LRU, 4),\n",
|
||||
" \"No Refresh (5.0s ttl)\": (DATABASE_OBJECTS, 0, CacheType.LRU, 5),\n",
|
||||
"}\n",
|
||||
"experiments = configurations.keys()\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"id": "6b9680ed-19bc-4f5b-8f22-95ffb319f068",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"['No Refresh (0.5s ttl)',\n",
|
||||
" 'No Refresh (1.0s ttl)',\n",
|
||||
" 'No Refresh (2.0s ttl)',\n",
|
||||
" 'No Refresh (3.0s ttl)',\n",
|
||||
" 'No Refresh (4.0s ttl)',\n",
|
||||
" 'No Refresh (5.0s ttl)']"
|
||||
]
|
||||
},
|
||||
"execution_count": 8,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"experiments = [e for e in experiments if \"ttl)\" in e]\n",
|
||||
"experiments"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "3ff299ca-ec65-453b-b167-9a0f7728a207",
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Progress: 69%|███████████████████████████████████ | 6876/10000 [00:40<00:18, 169.24it/s]"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"%%time\n",
|
||||
"for experiment_name in experiments:\n",
|
||||
" config = configurations[experiment_name]\n",
|
||||
"\n",
|
||||
" CACHE_CAPACITY = config[0]\n",
|
||||
" MAX_REFRESH_RATE = config[1]\n",
|
||||
" cache_type = config[2]\n",
|
||||
" CACHE_TTL = config[3]\n",
|
||||
"\n",
|
||||
" # Initialize simulation environment\n",
|
||||
" env = simpy.Environment()\n",
|
||||
"\n",
|
||||
" # Instantiate components\n",
|
||||
" db = Database()\n",
|
||||
" cache = Cache(env, db, cache_type)\n",
|
||||
" stop_event = env.event()\n",
|
||||
"\n",
|
||||
" # Start processes\n",
|
||||
" env.process(age_cache_process(env, cache))\n",
|
||||
" env.process(client_request_process(env, cache, stop_event))\n",
|
||||
"\n",
|
||||
" # Run the simulation\n",
|
||||
" env.run(until=stop_event)\n",
|
||||
"\n",
|
||||
" statistics = []\n",
|
||||
" # Calculate and print hit rate and average age for each object\n",
|
||||
" for obj_id in range(1, DATABASE_OBJECTS + 1):\n",
|
||||
" if cache.access_count[obj_id] != 0:\n",
|
||||
" hit_rate = cache.hits[obj_id] / max(1, cache.access_count[obj_id]) # Avoid division by zero\n",
|
||||
" avg_age = cache.cumulative_age[obj_id] / max(1, cache.hits[obj_id]) # Only average over hits\n",
|
||||
" statistics.append({\"obj_id\": obj_id,\"hit_rate\": hit_rate,\"avg_age\": avg_age})\n",
|
||||
"\n",
|
||||
" 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\")\n",
|
||||
"\n",
|
||||
" avg_age = {\n",
|
||||
" obj_id: cache.cumulative_age[obj_id] / max(1, cache.access_count[obj_id]) \n",
|
||||
" for obj_id in range(1, DATABASE_OBJECTS + 1)\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" hit_rate = {\n",
|
||||
" obj_id: np.round((cache.hits[obj_id] / max(1, cache.access_count[obj_id]))*100,2) \n",
|
||||
" for obj_id in range(1, DATABASE_OBJECTS + 1)\n",
|
||||
" }\n",
|
||||
" \n",
|
||||
" 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(db.mu_values, orient='index', columns=['mu'])\n",
|
||||
" lmbda = pd.DataFrame.from_dict(db.lambda_values, orient='index', columns=['lambda'])\n",
|
||||
" hit_rate = pd.DataFrame.from_dict(hit_rate, orient='index', columns=['hit_rate'])\n",
|
||||
" avg_age = pd.DataFrame.from_dict(avg_age, orient='index', columns=['avg_age'])\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).merge(avg_age, left_index=True, right_index=True)\n",
|
||||
" merged.to_csv(f\"{TEMP_BASE_DIR}/details.csv\", index_label=\"obj_id\")\n",
|
||||
"\n",
|
||||
" # 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()\n",
|
||||
"\n",
|
||||
" from collections import Counter\n",
|
||||
" # Count occurrences of each number\n",
|
||||
" count = Counter(list(db.lambda_values.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()\n",
|
||||
"\n",
|
||||
" # 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()\n",
|
||||
"\n",
|
||||
" from collections import Counter\n",
|
||||
" # Count occurrences of each number\n",
|
||||
" count = Counter(np.array(list(db.mu_values.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()\n",
|
||||
"\n",
|
||||
" 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",
|
||||
"\n",
|
||||
" 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)\n",
|
||||
"\n",
|
||||
" del env\n",
|
||||
" del cache\n",
|
||||
" del db"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "b0827d71-e5bd-4303-b806-a19e17b28855",
|
||||
"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
|
||||
}
|
||||
@@ -83,15 +83,4 @@ CPU times: user 3min 46s, sys: 43 s, total: 4min 29s
|
||||
Wall time: 4min 29s
|
||||
for ACCESS_COUNT_LIMIT = 10_000 # Total time to run the simulation
|
||||
|
||||
## 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
|
||||
## Notes 11/27/2024
|
||||
101
test.csv
101
test.csv
@@ -1,101 +0,0 @@
|
||||
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