Implements Uncoordinated PGT Intelligence for SemiNFG objects
Created on Wed Jan 2 16:33:36 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 uncoordinated approach because intelligence is assigned to decision nodes instead of being assigned to players. As a result, it takes much longer to run than pynfg.pgtsolutions.intelligence.coordinated.coordinated_MC
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.uncoordinated import uncoordinated_MC
intelMC, funcoutMC, weightMC = uncoordinated_MC(GG, S, noise, X, M,
innoise=.2,
delta=1,
integrand=welfare,
mix=False,
satisfice=GG)
Run Metropolis-Hastings 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 uncoordinated approach because intelligence is assigned to decision nodes instead of being assigned to players. As a result, it takes much longer to run than pynfg.pgtsolutions.intelligence.coordinated.coordinated_MH
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.uncoordinated import uncoordinated_MH
intelMH, funcoutMH, densMH = uncoordinated_MH(GG, S, density, noise,
X, M,
innoise=.2,
delta=1,
integrand=welfare,
mix=False,
satisfice=GG)
Estimate IQ of policy at the current decision node
Parameters: |
|
---|---|
Returns: | an estimate of the fraction of alternative strategies that yield lower expected utility than the current policy. |