-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfigures_optimal_advertising.py
62 lines (52 loc) · 1.72 KB
/
figures_optimal_advertising.py
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import jax.numpy as jnp
import matplotlib.pyplot as plt
import numpy as np
import os
from new_optimal_advertising_matern import (
optimal_advertising_matern,
)
from mpl_toolkits.axes_grid1.inset_locator import (
zoomed_inset_axes,
mark_inset,
inset_axes,
)
fontsize = 17
ticksize = 16
figsize = (15, 7)
params = {
"font.family": "serif",
"figure.figsize": figsize,
"figure.dpi": 80,
"figure.edgecolor": "k",
"font.size": fontsize,
"axes.labelsize": fontsize,
"axes.titlesize": fontsize,
"xtick.labelsize": ticksize,
"ytick.labelsize": ticksize,
}
plt.rcParams.update(params)
## Plot for optimal advertising
sol = optimal_advertising_matern()
output_path = "figures/optimal_advertising.pdf"
plt.figure(figsize=(15, 7))
x_hat = sol["x_test"]
mu_hat = sol["mu_test"]
u_hat = sol["u_test"]
T = sol["t_train"].max()
t = sol["t_test"]
ax_market_share = plt.subplot(1, 2, 1)
plt.plot(t, x_hat, color="k", label=r"$\hat{x}(t)$: Kernel Approximation")
#plt.axhline(y=sol["x_ss"], linestyle="-.", color="k", label=r"$x^*$: Steady-State")
plt.axvline(x=T, color="k", linestyle=":", label="Extrapolation/Interpolation")
plt.ylabel("Market Share: $x(t)$")
plt.xlabel("Time")
plt.legend() # Show legend with labels
ax_mu = plt.subplot(1, 2, 2)
plt.plot(t, mu_hat, color="blue", label=r"$\hat{\mu}(t)$: Kernel Approximation")
#plt.axhline(y=sol["mu_ss"], linestyle="-.", color="b", label=r"$\mu^*$: Steady-State")
plt.axvline(x=T, color="k", linestyle=":", label="Extrapolation/Interpolation")
plt.ylabel("Co-state Variable: $\mu(t)$")
plt.xlabel("Time")
plt.legend() # Show legend with labels
plt.tight_layout()
plt.savefig(output_path, format="pdf")