forked from jluech/roar_server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot-perf-reward-func.py
More file actions
41 lines (28 loc) · 994 Bytes
/
plot-perf-reward-func.py
File metadata and controls
41 lines (28 loc) · 994 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import math
import os
from matplotlib import use as use_plot_backend
import matplotlib.pyplot as plt
import numpy as np
from environment.state_handling import initialize_storage, cleanup_storage, get_storage_path
def pos(r):
h = +0
return list(map(lambda v: 10 * math.log10(v + 1) + abs(h), r)) # log 10
# return list(map(lambda v: 10 * math.log(v + 1) + abs(h), r)) # log = log_e = ln
def neg(r):
d = -20
return list(map(lambda v: (d/max(v, 1)) - abs(d), r))
try:
initialize_storage()
use_plot_backend("template")
x_lim = 500
description = "pos-{}--neg-{}--h{}--d{}--x-{}".format("10log", "1overX", "+0", "-20", x_lim)
x = np.linspace(0, x_lim)
plt.plot(x, pos(x))
plt.plot(x, neg(x))
plt.ylabel("Reward")
plt.xlabel("Encryption Rate")
plt.legend(["Hidden", "Detected"])
fig_file = os.path.join(get_storage_path(), "reward-func={}.png".format(description))
plt.savefig(fig_file)
finally:
cleanup_storage()