-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathExp3P.m
41 lines (22 loc) · 1.29 KB
/
Exp3P.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
%% Inputs:
% environment: Matrix of size Horizon x NbrArms
% gamma: exploration rate (Default value = 0.05)
%% Outputs:
% gainEXP3P: vector of observations for each time step
function gainEXP3P = Exp3P(environment, gamma)
[Horizon, NbrArms] = size(environment);
if nargin == 1;
gamma = 0.05; % Exploration Rate
end
%---------------------------------------------------------------------------------------------------
%% INITIALIZATION
%--------------------------------------------------------------------------------------------------
[w, gainEXP3P] = EXP3P_Initialize(NbrArms, gamma, Horizon);
%---------------------------------------------------------------------------------------------------
%% INTERACTION
%--------------------------------------------------------------------------------------------------
for t = 1:Horizon;
[ArmToPlay, p] = EXP3_RecommendArm(w, gamma);
reward = rand() < environment(t,ArmToPlay);
[w, gainEXP3P] = EXP3P_ReceiveReward(w, p, reward, NbrArms, Horizon, gamma, ArmToPlay, gainEXP3P);
end