# Show influence of varying sub-optimality gaps on convergence of TLR-UCB
# Reproduce Figure 5 in the appendix

import os
import sys
sys.path.append('/Your Path/Data_Code/Methods')
from Pre_Functions import acu
import numpy as np
import matplotlib.pyplot as plt


# read data
os.chdir('/Your Path/Data_Code/Simulation/Results')
y_tlr_1 = np.load("TLR-UCB_Ex4_reg_mean_1.npy")
y_tlr_1 = acu(y_tlr_1)

y_tlr_2 = np.load("TLR-UCB_Ex4_reg_mean_2.npy")
y_tlr_2 = acu(y_tlr_2)

y_tlr_3 = np.load("TLR-UCB_Ex4_reg_mean_3.npy")
y_tlr_3 = acu(y_tlr_3)

y_tlr_4 = np.load("TLR-UCB_Ex4_reg_mean_4.npy")
y_tlr_4 = acu(y_tlr_4)

y_tlr_5 = np.load("TLR-UCB_Ex4_reg_mean_5.npy")
y_tlr_5 = acu(y_tlr_5)


horizon = len(y_tlr_1)
x0 = list(range(1,horizon+1))
l1 = plt.plot(x0,y_tlr_1,color='red',linewidth=1.5)
l2 = plt.plot(x0,y_tlr_2,color='orange',linewidth=1.5,linestyle='--')
l3 = plt.plot(x0,y_tlr_3,color='green',linewidth=1.5,linestyle='-.')
l4 = plt.plot(x0,y_tlr_4,color='blue',linewidth=1.5,linestyle=':')
l5 = plt.plot(x0,y_tlr_5,color='purple',linewidth=1.5,linestyle='--')
plt.legend(labels=[r'TLR-UCB: $\epsilon$=0.25',r'TLR-UCB: $\epsilon$=0.20',r'TLR-UCB: $\epsilon$=0.15',r'TLR-UCB: $\epsilon$=0.10',r'TLR-UCB: $\epsilon$=0.05'],loc='best',fontsize = 12)
plt.axis([0,horizon,0,max(max(y_tlr_1),max(y_tlr_2),max(y_tlr_3),max(y_tlr_4),max(y_tlr_5))])
plt.xlabel("Time",fontsize = 20)
plt.ylabel("Regret",fontsize = 20)
plt.title("Example 4: Regret v.s. Gap",fontsize = 24)
plt.show()