Implements Uncoordinated PGT Intelligence for iterSemiNFG objects
Created on Wed Jan 2 16:33:36 2013
Copyright (C) 2013 James Bono
GNU Affero General Public License
Run Importance Sampling on policy sequences for PGT IQ 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 an uncoordinated approach because intelligence is assigned to a decision node instead of players. As a result, it takes much longer to run than pynfg.pgtsolutions.intelligence.policy.policy_MC
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.iterated import iterated_MC
intelMC, funcoutMC, weightMC = iterated_MC(GG, S, noise, X, M,
innoise=.2,
delta=1,
integrand=welfare,
mix=False,
satisfice=GG)
Run Metropolis-Hastings on policy sequences for PGT IQ 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 an uncoordinated approach because intelligence is assigned to a decision node instead of players. As a result, it takes much longer to run than pynfg.pgtsolutions.intelligence.policy.policy_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 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.iterated import iterated_MH
intelMH, funcoutMH, densMH = iterated_MH(GG, S, density, noise, X, M,
innoise=.2,
delta=1,
integrand=welfare,
mix=False,
satisfice=GG)
Estimate IQ of player’s policy at a given time step
Parameters: |
|
---|---|
Returns: | an estimate of the fraction of alternative policies at the given time step that have a lower npv reward than the current policy. |