-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ilija Vukotic
committed
Mar 26, 2020
1 parent
88dc0dc
commit 9c60a98
Showing
12 changed files
with
84 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
|
||
import matplotlib.pyplot as plt | ||
import pandas as pd | ||
# import numpy as np | ||
TB = 1024 * 1024 * 1024 | ||
df = None | ||
names = ['20TB_LRU', '100TB_LRU', 'InfiniteCache_LRU'] | ||
|
||
|
||
f, (ax1, ax2) = plt.subplots(2, 1, sharex=True, gridspec_kw={'hspace': 0.15}) | ||
f.suptitle(' '.join(names)) | ||
|
||
for name in names: | ||
|
||
with pd.HDFStore(name + '.h5') as hdf: | ||
print("keys:", hdf.keys()) | ||
df = hdf.select(name) | ||
print("data loaded:", df.shape[0]) | ||
|
||
print(df) | ||
df['ch_files'] = df['cache hit'].cumsum() | ||
df['CHR files'] = df['ch_files'] / df.index | ||
|
||
df['tmp'] = df['cache hit'] * df['kB'] | ||
df['ch_data'] = df['tmp'].cumsum() | ||
df['data delivered'] = df['kB'].cumsum() | ||
del df['tmp'] | ||
df['CHR data'] = df['ch_data'] / df['data delivered'] | ||
df["cache size"] = df["cache size"] / TB | ||
print(df) | ||
|
||
# ax22 = ax2.twinx() | ||
ax1.plot(df["CHR files"], label=name) | ||
ax2.plot(df["CHR data"], label=name) | ||
|
||
# ax2.plot(df["reward"].cumsum()) | ||
# ax22.plot(df["cache size"]) | ||
# ax22.set_ylabel('cache fill [TB]', color='b') | ||
# ax22.plot(df["reward"].rolling(500).sum()) | ||
# ax22.set_ylabel('rolling reward', color='b') | ||
|
||
ax1.legend() | ||
ax2.legend() | ||
ax1.set_ylabel('cache hit rate [files]') | ||
ax2.set_ylabel('cache hit rate [data]') | ||
ax2.set_xlabel('files accessed') | ||
ax1.grid(True) | ||
ax2.grid(True) | ||
# plt.tight_layout() | ||
plt.savefig('plots/combinations/combination.png') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,24 @@ | ||
# this actor does always the same action or a random one. | ||
|
||
import gym | ||
|
||
env = gym.make('gym_cache:Cache-v0') | ||
env.reset() | ||
|
||
total_reward = 0 | ||
for i in range(1000000): | ||
if not i % 1000: | ||
print(i, 'total reward', total_reward) | ||
# env.render() | ||
act = env.action_space.sample() | ||
|
||
# --- random prediction | ||
# act = env.action_space.sample() | ||
# --- always predict cache miss | ||
act = 0 | ||
# print('action:', act) | ||
|
||
acc, rew, done, smt = env.step(act) | ||
# print('access:', acc, 'rew:', rew) | ||
total_reward += rew | ||
|
||
env.close() | ||
print('total_reward:', total_reward) | ||
print('Finished. Total reward:', total_reward) |