Iterated Semi-NFG

Implements the iterSemiNFG class

Part of: PyNFG - a Python package for modeling and solving Network Form Games

Created on Mon Feb 18 10:37:29 2013

Copyright (C) 2013 James Bono

GNU Affero General Public License

class pynfg.classes.iterseminfg.iterSemiNFG(nodes, r_functions=None)[source]

Implements the iterated semi-NFG formalism created by D. Wolpert

For an example, see PyNFG/bin/hideandseek.py

Parameters:
  • nodes (set) – members are nodes.ChanceNode, nodes.DecisionNode, or nodes.DeterNode. The basename and time attributes must be set for all nodes used in an iterSemiNFG.
  • r_functions (dict) – One entry for each player. Keys are player names. Values are keyword functions from the basename variables to real numbers.

An iterated semi-NFG is a semi-NFG created from iteratively gluing a kernel to a base. It is a Markov iterated semi-NFG if the t’th copy of the kernel is conditionally independent of all nodes in the t-2’th copy and earlier. Instead of utility functions, iterated semi-NFGs use reward functions.

Note

This class is a subclass of seminfg.SemiNFG. It inherits all of the SemiNFG functionality except seminfg.SemiNFG.utiity() is replaced by seminfg.iterSemiNFG.reward().

Note

An object that consists of all of these elements except the reward functions is called a iterated semi-Bayes net. When initialized with r_functions=None, the result is an iterated semi-Bayes net.

Note

For a node in nodes, the parent attribute, e.g. nodes.ChanceNode.parents, must not have parents that are not in the set of nodes passed to seminfg.SemiNFG.

Some useful methods:

  • seminfg.SemiNFG.ancestors()
  • seminfg.SemiNFG.descendants()
  • seminfg.SemiNFG.children()
  • seminfg.SemiNFG.loglike()
  • seminfg.SemiNFG.sample()
  • seminfg.SemiNFG.draw_graph()
  • seminfg.iterSemiNFG.reward()
  • seminfg.iterSemiNFG.sample_timesteps()

Upon initialization, the following private methods are called:

  • seminfg.SemiNFG._set_node_dict()
  • seminfg.SemiNFG._set_partition()
  • seminfg.SemiNFG._set_edges()
  • seminfg.SemiNFG._topological_sort()
  • seminfg.iterSemiNFG._set_time_partition()
  • seminfg.iterSemiNFG.self._set_bn_part()
get_values(nodenames=None)[source]

Retrieve the values of the nodes comprising the SemiNFG.

Parameters:nodenames (set or list) – (Optional) The names of the nodes whose values should be returned. If no names are specified, all node values are returned.
Returns:dict where keys are node names and values are node values
npv_reward(player, start, delta, nodeinput=None)[source]

Return the npv of rewards from start using delta discount factor

Parameters:
  • player (str) – the name of the player to evaluate
  • start (int) – the starting time step
  • delta (float) – the discount factor for the npv calculation
  • nodeinput – Optional dict of node name, node values for use in calculating the rewards
reward(player, t, nodeinput=None)[source]

Evaluate the reward of the specified player in the specified time.

Parameters:
  • player (str.) – The name of a player with a reward function specified.
  • nodeinput (dict) – Optional. Keys are basenames. Values are node values. The values in nodeinput merely override the current node values, so nodeinput does not need to specify values for every argument to a player’s reward function.
sample_timesteps(start, stop=None, basenames=None)[source]

Sample the nodes from a starting time through a stopping time.

Parameters:
  • start (integer) – the first timestep to be sampled
  • stop (integer) – (Optional) the last timestep to be sampled. If unspecified, the net will be sampled to completion.
  • basenames – (Optional) a list of strings that give the basenames the user wants to collect as output. If omitted, there is no output.
Returns:

a dict keyed by base names in basenames input. Values are time series of values from start to stop of nodes that share that basename.

Warning

The decision nodes must have CPTs before using this function.

set_CPTs(cptdict)[source]

Set CPTs for nodes in the iterSemiNFG by node name or basename

Parameters:cptdict (dict) – dictionary with node names or basenames as keys and CPTs as values. When a basename is given, the corresponding CPT is used for all of the corresponding nodes.

Previous topic

Semi-NFG

Next topic

PGT Solutions

This Page

Mailing List

Join the Google Group: