"""
This python file corresponds to the Example 2 under unknown position effects
"""

import sys
import os
import numpy as np
sys.path.append('/Your Path/Data_Code/Methods')
import EI_TLR as ET
import A_UCB as AU
import S_ETC as SE


# 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 EI-TLR, A-UCB, and S-ETC:
# v_max: \nu_{0}, an upper bound for all items' preferences
# lam: lambda
# c_UCB: UCB constant ahead of the bonus
# thr: threshold in applying Alternate Minimization Algorithm
# exp_c: constant affecting number of exploration epochs
# end_cri: binary ending criteria for the exploration phase
# kappa: a constant in S-ETC
# rsd: np.random.seed and random.seed
v_max = 1
lam = 1
c_UCB = 0.01
thr = 0.0001
exp_c = 0.1
end_cri = 1
kappa = 20
rsd = 0


# apply EI-TLR, A-UCB and S-ETC policies
reg_mean_EI_TLR_Ex2, _ = ET.EI_TLR(pos,v,r,v_max,T,simu_times,lam,c_UCB,thr,exp_c,end_cri,rsd)
print(np.sum(reg_mean_EI_TLR_Ex2))

reg_mean_A_UCB_Ex2 = AU.A_UCB(pos,v,r,T,simu_times,c_UCB,rsd)
print(np.sum(reg_mean_A_UCB_Ex2))

reg_mean_S_ETC_Ex2 = SE.S_ETC(pos,v,r,T,simu_times,kappa,rsd)
print(np.sum(reg_mean_S_ETC_Ex2))


# save the results
os.chdir('/Your Path/Data_Code/Simulation/Results')
np.save("EI-TLR_Ex2_reg_mean_1.npy",reg_mean_EI_TLR_Ex2)
np.save("A-UCB_Ex2_reg_mean_1.npy",reg_mean_A_UCB_Ex2)
np.save("S-ETC_Ex2_reg_mean_1.npy",reg_mean_S_ETC_Ex2)