# Plot results for real car data under known position effects
# Reproduce the left panel of Figure 4 in the manuscript

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 and process data
simu_times = 50
T = 4000000

os.chdir('/Your Path/Data_Code/Real_Application/Results/TLR_UCB')
y_tlr_0 = np.zeros((simu_times,T))
for i in range(simu_times):
    s = "TLR-UCB_reg_mean_" + str(i+1) + ".npy"
    y_tlr_0[i,] = np.load(s)
y_tlr = np.mean(y_tlr_0,axis=0)
y_tlr = acu(y_tlr)

os.chdir('/Your Path/Data_Code/Real_Application/Results/LR_UCB')
y_lr_0 = np.zeros((simu_times,T))
for i in range(simu_times):
    s = "LR-UCB_reg_mean_" + str(i+1) + ".npy"
    y_lr_0[i,] = np.load(s)
y_lr = np.mean(y_lr_0,axis=0)
y_lr = acu(y_lr)

os.chdir('/Your Path/Data_Code/Real_Application/Results/A_UCB_V')
y_av_0 = np.zeros((simu_times,T))
for i in range(simu_times):
    s = "A-UCB-V_reg_mean_" + str(i+1) + ".npy"
    y_av_0[i,] = np.load(s)
y_av = np.mean(y_av_0,axis=0)
y_av = acu(y_av)

os.chdir('/Your Path/Data_Code/Real_Application/Results/A_UCB')
y_a_0 = np.zeros((simu_times,T))
for i in range(simu_times):
    s = "A-UCB_reg_mean_" + str(i+1) + ".npy"
    y_a_0[i,] = np.load(s)
y_a = np.mean(y_a_0,axis=0)
y_a = acu(y_a)


horizon = len(y_tlr)
x0 = list(range(1,horizon+1))
l1 = plt.plot(x0,y_lr,color='purple',linewidth=1.5,linestyle=':')
l2 = plt.plot(x0,y_av,color='green',linewidth=1.5,linestyle='-.')
l3 = plt.plot(x0,y_tlr,color='red',linewidth=1.5)
plt.legend(labels=['LR-UCB','A-UCB-V','TLR-UCB'],loc='best',fontsize = 12)
plt.axis([0,horizon,0,max(max(y_av),max(y_tlr),max(y_a))])
plt.xlabel("Time",fontsize=20)
plt.ylabel("Regret",fontsize=20)
plt.title("Car Data: Known Position Effects",fontsize=20)
plt.show()