% scriptB321.m
% first build the decision policy
probs = [0.1; 0.7; 0.2];
maxInv = 2;
[valueTable, actionTable] = MakePolicy(maxInv, probs, 1, 1, 3)

% then simulate the decision policy
rng('default')
numScenarios = 1000;
costScenarios = SimulatePolicy(actionTable, probs, 1, 1, 3, numScenarios, 0);
cost0 = mean(costScenarios);
costScenarios = SimulatePolicy(actionTable, probs, 1, 1, 3, numScenarios, 1);
cost1 = mean(costScenarios);
costScenarios = SimulatePolicy(actionTable, probs, 1, 1, 3, numScenarios, 2);
cost2 = mean(costScenarios);
[valueTable(:,1), [cost0;cost1;cost2]]
