"""
This python file corresponds to the Example 2 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 2 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]
v = [1,4/5,3/5,2/5,1/5]
r = [2/5,1/5,4/5,3/5,1]
T = 200000
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_Ex2 = TU.TLR_UCB(pos,v,r,v_max,T,simu_times,lam,c_UCB,rsd)
print(np.sum(reg_mean_TLR_UCB_Ex2))

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

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


# save the results
os.chdir('/Your Path/Data_Code/Simulation/Results')
np.save("TLR-UCB_Ex2_reg_mean_1.npy",reg_mean_TLR_UCB_Ex2)
np.save("LR-UCB_Ex2_reg_mean_1.npy",reg_mean_LR_UCB_Ex2)
np.save("A-UCB-V_Ex2_reg_mean_1.npy",reg_mean_A_UCB_V_Ex2)











