Implements Coordinated PGT Intelligence for SemiNFG objects
Created on Tue Mar 12 17:38:37 2013
Copyright (C) 2013 James Bono
GNU Affero General Public License
Run Importance Sampling on strategies for PGT Intelligence Calculations
For examples, see below or PyNFG/bin/stackelberg.py for SemiNFG or PyNFG/bin/hideandseek.py for iterSemiNFG
Parameters: 


Returns: 

Note
This is the coordinatedapproach because intelligence is assigned to a player instead of being assigned to a DecisionNode
Example:
def welfare(G):
#calculate the welfare of a single sample of the SemiNFG G
G.sample()
w = G.utility('1')+G.utility('2') #'1' & '2' are player names in G
return w
import copy
GG = copy.deepcopy(G) #G is a SemiNFG
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.coordinated import coordinated_MC
intelMC, funcoutMC, weightMC = coordinated_MC(GG, S, noise, X, M,
innoise=.2,
delta=1,
integrand=welfare,
mix=False,
satisfice=GG)
Run MetropolisHastings on strategies for PGT Intelligence Calculations
For examples, see below or PyNFG/bin/stackelberg.py for SemiNFG or PyNFG/bin/hideandseek.py for iterSemiNFG
Parameters: 


Returns: 

Note
This is the coordinatedapproach because intelligence is assigned to a player instead of being assigned to a DecisionNode
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 SemiNFG G
G.sample()
w = G.utility('1')+G.utility('2') #'1' & '2' are player names in G
return w
import copy
GG = copy.deepcopy(G) #G is a SemiNFG
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.coordinated import coordinated_MH
intelMH, funcoutMH, densMH = coordinated_MH(GG, S, density, noise, X, M,
innoise=.2,
delta=1,
integrand=welfare,
mix=False,
satisfice=GG)
Estimate IQ of player’s strategy
Parameters: 


Returns:  an estimate of the fraction of alternative strategies that yield lower expected utility than the current policy. 