Mercurial > hg > camir-aes2014
comparison toolboxes/FullBNT-1.0.7/bnt/potentials/@upot/upot_to_opt_policy.m @ 0:e9a9cd732c1e tip
first hg version after svn
author | wolffd |
---|---|
date | Tue, 10 Feb 2015 15:05:51 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e9a9cd732c1e |
---|---|
1 function [policy, EU] = upot_to_opt_policy(pot) | |
2 % UPOT_TO_OPT_POLICY Compute an optimal deterministic policy given a utility potential | |
3 % [policy, EU] = upot_to_opt_policy(pot) | |
4 % | |
5 % policy(a,b, ..., z) = P(do z | a, b, ..), which will be a delta function | |
6 % EU is the contraction of this potential, i.e., P .* U | |
7 | |
8 sz = pot.sizes; % mysize(pot.p); | |
9 if isempty(sz) | |
10 EU = pot.u; | |
11 policy = []; | |
12 return; | |
13 end | |
14 | |
15 parent_size = prod(sz(1:end-1)); | |
16 self_size = sz(end); | |
17 C = pot.p .* pot.u; % contraction | |
18 C = reshape(C, parent_size, self_size); | |
19 policy = zeros(parent_size, self_size); | |
20 for i=1:parent_size | |
21 act = argmax(C(i,:)); | |
22 policy(i, act) = 1; | |
23 end | |
24 policy = myreshape(policy, sz); | |
25 EU = sum(C(:)); |