fix(simulation): Fixed expected age calculation

Signed-off-by: Tuan-Dat Tran <tuan-dat.tran@tudattr.dev>
This commit is contained in:
Tuan-Dat Tran
2024-12-05 15:53:31 +01:00
parent b7aaa31860
commit 6da629f90e
53 changed files with 1724548 additions and 3309 deletions

View File

@@ -179,7 +179,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 13,
"id": "bd4536e9-273b-4f49-b06c-2f00605e0f7d",
"metadata": {},
"outputs": [],
@@ -200,7 +200,7 @@
" # 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)\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",
@@ -219,14 +219,14 @@
" 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)\"])\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": 11,
"execution_count": 14,
"id": "a92c6772-6609-41a8-a3d1-4d640b69a864",
"metadata": {},
"outputs": [
@@ -235,18 +235,17 @@
"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.7s\n",
"[Parallel(n_jobs=-1)]: Done 1420 tasks | elapsed: 1.3s\n",
"[Parallel(n_jobs=-1)]: Done 55524 tasks | elapsed: 1.2min\n",
"[Parallel(n_jobs=-1)]: Done 64152 out of 64152 | elapsed: 2.6min finished\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 53 s, sys: 1.26 s, total: 54.3 s\n",
"Wall time: 3min 24s\n"
"CPU times: user 42 s, sys: 731 ms, total: 42.7 s\n",
"Wall time: 2min 5s\n"
]
}
],
@@ -272,7 +271,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 15,
"id": "e79e6ed1-d6a5-4b04-a2b2-b3f0984e0fbe",
"metadata": {},
"outputs": [
@@ -285,9 +284,10 @@
"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) 1.5\n",
"c_f (Miss Cost) 0.7\n",
"c_delta (Refresh Cost) 0.01\n",
"Name: 2448, dtype: object\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"
]
}
],
@@ -300,10 +300,37 @@
"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": "924fd9c4-6670-4cf4-93a7-b1484111b333",
"id": "20c943b4-b32b-4294-949b-0f3abe2fb97a",
"metadata": {},
"outputs": [],
"source": []

File diff suppressed because it is too large Load Diff