Implements Coordinated PGT intelligence for Policies for iterSemiNFG objects
Created on Fri Mar 22 15:32:33 2013
Copyright (C) 2013 James Bono
GNU Affero General Public License
Run Importance Sampling on policies for PGT Intelligence Calculations
For examples, see below or PyNFG/bin/hideandseek.py
Parameters: 


Returns: 

Warning
This will throw an error if there is a decision node in G.starttime that is not repeated throughout the net.
Note
This is the policyapproach because intelligence is assigned to a player instead of being assigned to a DecisionNode, and all DNs with the same basename have the same CPT.
Example:
def welfare(G):
#calculate the welfare of a single sample of the iterSemiNFG G
G.sample()
w = 0
for p in G.players:
w += G.npv_reward(p, G.starttime, 1.0)
return w
import copy
GG = copy.deepcopy(G) #G is an iterSemiNFG
S = 50 #number of MC samples
X = 10 #number of samples of utility of G in calculating iq
M = 20 #number of alternative strategies sampled in calculating iq
noise = .2 #noise in the perturbations of G for MC sampling
from pynfg.pgtsolutions.intelligence.policy import policy_MC
intelMC, funcoutMC, weightMC = policy_MC(GG, S, noise, X, M,
innoise=.2,
delta=1,
integrand=welfare,
mix=False,
satisfice=GG)
Run MetropolisHastings on policies for PGT Intelligence Calculations
For examples, see below or PyNFG/bin/hideandseek.py
Parameters: 


Returns: 

Warning
This will throw an error if there is a decision node in G.starttime that is not repeated throughout the net.
Note
This is the policyapproach because intelligence is assigned to a player instead of being assigned to a DecisionNode, and all DNs with the same basename have the same CPT.
Example:
def density(iqdict):
#calculate the PGT density for a given iqdict
x = iqdict.values()
y = np.power(x,2)
z = np.product(y)
return z
def welfare(G):
#calculate the welfare of a single sample of the iterSemiNFG G
G.sample()
w = 0
for p in G.players:
w += G.npv_reward(p, G.starttime, 1.0)
return w
import copy
GG = copy.deepcopy(G) #G is an iterSemiNFG
S = 50 #number of MH samples
X = 10 #number of samples of utility of G in calculating iq
M = 20 #number of alternative strategies sampled in calculating iq
noise = .2 #noise in the perturbations of G for MH sampling
from pynfg.pgtsolutions.intelligence.policy import policy_MH
intelMH, funcoutMH, densMH = policy_MH(GG, S, density, noise, X, M,
innoise=.2,
delta=1,
integrand=welfare,
mix=False,
satisfice=GG)
Estimate IQ of player’s policy
Parameters: 


Returns:  an estimate of the fraction of alternative policies that have a lower npv reward than the current policy. 