"""
This python file corresponds to the Example 3 under known position effects
"""

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


# Example 3 setting:
# pos: the position effect vector
# v: the preference vector
# r: the revenue vector
# T: horizon length
# simu_times: number of replications
pos = [1,1/2,1/3,1/4,1/5]
v = [(10-i)/10 for i in range(10)]
r = [0.3, 0.2, 0.7, 0.4, 0.5, 0.6, 0.1, 0.9, 1.0, 0.8]
T = 1000000
simu_times = 500

# more parameters for TLR-UCB, LR-UCB, and A-UCB-V:
# v_max: \nu_{0}, an upper bound for all items' preferences
# lam: lambda
# c_UCB: UCB constant ahead of the bonus
# rsd: np.random.seed
v_max = 1
lam = 1
c_UCB = 0.01
rsd = 0


# apply TLR-UCB, LR-UCB and A-UCB-V policies
reg_mean_TLR_UCB_Ex3 = TU.TLR_UCB(pos,v,r,v_max,T,simu_times,lam,c_UCB,rsd)
print(np.sum(reg_mean_TLR_UCB_Ex3))

reg_mean_LR_UCB_Ex3 = LU.LR_UCB(pos,v,r,v_max,T,simu_times,lam,c_UCB,rsd)
print(np.sum(reg_mean_LR_UCB_Ex3))

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


# save the results
os.chdir('/Your Path/Data_Code/Simulation/Results')
np.save("TLR-UCB_Ex3_reg_mean_1.npy",reg_mean_TLR_UCB_Ex3)
np.save("LR-UCB_Ex3_reg_mean_1.npy",reg_mean_LR_UCB_Ex3)
np.save("A-UCB-V_Ex3_reg_mean_1.npy",reg_mean_A_UCB_V_Ex3)











