"""
This python file corresponds to A-UCB-V policy implemented on real car data under known position effects
"""

import sys
import os
import numpy as np
sys.path.append('/Your Path/Data_Code/Methods')
import A_UCB_V as AUV


# Real car data setting:
# pos: the position effect vector
# v: the preference vector
# r: the revenue vector
# T: horizon length
# simu_times: number of replications
K = 100
c_pos = 2
pos = []
for i in range(K):
    pos.append(2**(-c_pos*i/(K-1)))
os.chdir('/Your Path/Data_Code/Real_Application/Pre_Process')
v_ori = np.load("Car_Pre.npy")
v = list(v_ori)
print("Car preferences", v)

r = [1 for i in range(len(v))]

T = 4000000
simu_times = 50

# more parameters for A-UCB-V:
# c_UCB: UCB constant ahead of the bonus
c_UCB = 0.01



# two options:
# option 1: apply A-UCB-V with "simu_times" replications, quite time-consuming
# for i in range(simu_times):
#     # rsd: np.random.seed
#     rsd = i + 1

#     reg_mean_A_UCB_V_Car = AUV.A_UCB_V(pos,v,r,T,1,c_UCB,rsd)
#     print(np.sum(reg_mean_A_UCB_V_Car))

#     # save the results
#     os.chdir('/Your Path/Data_Code/Real_Application/Results/A_UCB_V')
#     s = "A-UCB-V_reg_mean_" + str(i+1) + ".npy"
#     np.save(s,reg_mean_A_UCB_V_Car)

# option 2 (recommended): apply A-UCB-V separately for each replication
# need to manually vary i from 0 -- 49 (=simu_times-1) to obtain all data needed
i = 0
rsd = i + 1

reg_mean_A_UCB_V_Car = AUV.A_UCB_V(pos,v,r,T,1,c_UCB,rsd)
print(np.sum(reg_mean_A_UCB_V_Car))

# save the results
os.chdir('/Your Path/Data_Code/Real_Application/Results/A_UCB_V')
s = "A-UCB-V_reg_mean_" + str(i+1) + ".npy"
np.save(s,reg_mean_A_UCB_V_Car)