-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathselector.m
More file actions
36 lines (29 loc) · 1009 Bytes
/
Copy pathselector.m
File metadata and controls
36 lines (29 loc) · 1009 Bytes
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
function selector()
% Parameters given by Prof:
global token reward
horizon = 500;
% ---------------------------------------------------------------------
numArms = 10; %numSlotMachines the Agent shall play
algoName = 'ucb2'; % 'greedy' 'softmax' 'ucb1' 'ucb2' 'thompson'
AG = MABAgent(numArms,reward, algoName, horizon);
% Plotting Function:
% ---------------------------------------
trackArms = zeros(1,horizon);
trackRewards = zeros(1,horizon);
% ---------------------------------------------------------------------
% Simulation Run of the Agent's Finite Time-step play
for k=1:horizon
arm = AG.agentArmSelect(k, reward); % select new arm and archive old rewardValue
slotmachine(arm) ; % ENVIRONMENT
AG.agentArmUpdate(arm, reward); % update slotMachineModel with reward info obtained.
% ----------------
trackArms(k) = arm;
trackRewards(k) = reward;
end
fig1 = figure(1)
subplot(2,1,1)
plot(trackArms)
subplot(2,1,2)
hist(trackArms)
fig2 = figure(2)
plot(trackRewards)