-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun_mdp_simulation.m
57 lines (49 loc) · 1.94 KB
/
run_mdp_simulation.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
function MDP = run_mdp_simulation(varargin)
%% usage: run_mdp_simulation(simulation_params)
% runs the MDP visceral inference simulation with any combination
% of optional parameters. Simulation parameters are a structure with the
% following optional fields:
% --------------------- OPTIONAL ARGUMENTS ----------------------
% wI = Interoceptive (inverse) volatility
% wE = Exteroceptive (inverse) volatility
% xi = Preferences
% zI = Interoceptive sensory precision
% zE = Exteroceptive sensory precision
% T =timesteps to run
% ---------------------------- OUTPUT ----------------------------
% MDP - structure with all simulated data
%% check all the inputs and if they do not exist then revert to default settings
% input parsing settings
p = inputParser;
p.CaseSensitive = true;
p.Parameters;
p.Results;
p.KeepUnmatched = true;
% set the desired and optional input arguments
addOptional(p, 'wI', .1, @isnumeric)
addOptional(p, 'wE', .1, @isnumeric)
addOptional(p, 'zI', 1, @isnumeric)
addOptional(p, 'zE', 1, @isnumeric)
addOptional(p, 'xi', 3, @isnumeric)
addOptional(p, 'T', 20, @isnumeric)
addOptional(p, 'E', 1, @isnumeric); % parasympathetic policy 1 = default, 2 = para, 3 = symp
addOptional(p, 'so', 0, @isnumeric); % binary flag to control outcomes
addOptional(p, 'o', [], @isnumeric); % if outcomes are controlled, feed in a vector here
addOptional(p, 'r', 1, @isnumeric); % randomization 1 = default (reset RNG), 2 = no rng reset
addOptional(p, 'ss', 0, @isnumeric); % flag for states
addOptional(p, 's', [], @isnumeric);
% parse the input
parse(p,varargin{:});
% then set/get all the inputs out of this structure
params.wI = p.Results.wI; params.wE = p.Results.wE;
params.xi = p.Results.xi;
params.zI = p.Results.zI; params.zE = p.Results.zE;
params.T = p.Results.T;
params.E = p.Results.E;
params.so = p.Results.so;
params.o = p.Results.o;
params.r = p.Results.r;
params.ss = p.Results.ss;
params.s = p.Results.s;
MDP = MDP_interoception_run(params);
end