-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathact.m
More file actions
37 lines (29 loc) · 1 KB
/
Copy pathact.m
File metadata and controls
37 lines (29 loc) · 1 KB
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
function [mc, task] = act(mc, task,settings, g)
%Action determination of each system based on Q-values associated with the
%dispalyed stimulus.
% Input needed:
invtemp=settings.invtemp;
for i = 1:settings.nsystems
%% get Q values for given stimuli
Q = [];
for q = 1:2 %2 stimuli
if mc.dims(i) == 1
Q(q) = mc.Q{i}(task.shown_stimulus(q,1,g),end);
elseif mc.dims(i) == 2
Q(q) = mc.Q{i}(task.shown_stimulus(q,1,g),task.shown_stimulus(q,2,g),end);
elseif mc.dims(i) == 3
Q(q) = mc.Q{i}(task.shown_stimulus(q,1,g),task.shown_stimulus(q,2,g),task.shown_stimulus(q,3,g),end);
else
error('undefined model')
end
end
%% action selection of system
%choice is made using a softmax
pi = 1 / (1 + exp(-(Q(1)-Q(2))*invtemp));
if rand < pi
mc.act{i}(g) = 1;
else
mc.act{i}(g) = 2;
end
end
end