Skip to content

Commit

Permalink
Merge pull request #286 from QuantEcon/gt_docs
Browse files Browse the repository at this point in the history
DOC: Generate doc files for game_theory
  • Loading branch information
mmcky authored Feb 23, 2017
2 parents 31aa2e7 + 6d19fd7 commit 31ca47b
Show file tree
Hide file tree
Showing 26 changed files with 71 additions and 159 deletions.
8 changes: 8 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ srcclean:
rm -f source/index.rst
rm -f source/models.rst
rm -f source/tools.rst
rm -rf source/game_theory
rm -f source/game_theory.rst
rm -rf source/markov
rm -f source/markov.rst
rm -rf source/random
rm -f source/random.rst
rm -rf source/util
rm -f source/util.rst

myhtml:
make srcclean
Expand Down
6 changes: 6 additions & 0 deletions docs/source/game_theory.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,10 @@ Game theory
.. toctree::
:maxdepth: 2

game_theory/lemke_howson
game_theory/mclennan_tourky
game_theory/normal_form_game
game_theory/pure_nash
game_theory/random
game_theory/support_enumeration
game_theory/utilities
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
arellano_vfi
lemke_howson
============

.. automodule:: quantecon.models.arellano_vfi
.. automodule:: quantecon.game_theory.lemke_howson
:members:
:undoc-members:
:show-inheritance:
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
common_messages
mclennan_tourky
===============

.. automodule:: quantecon.common_messages
.. automodule:: quantecon.game_theory.mclennan_tourky
:members:
:undoc-members:
:show-inheritance:
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
lucastree
pure_nash
=========

.. automodule:: quantecon.models.lucastree
.. automodule:: quantecon.game_theory.pure_nash
:members:
:undoc-members:
:show-inheritance:
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
timing
random
======

.. automodule:: quantecon.timing
.. automodule:: quantecon.game_theory.random
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/game_theory/support_enumeration.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
support_enumeration
===================

.. automodule:: quantecon.game_theory.support_enumeration
:members:
:undoc-members:
:show-inheritance:
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
optgrowth
utilities
=========

.. automodule:: quantecon.models.optgrowth
.. automodule:: quantecon.game_theory.utilities
:members:
:undoc-members:
:show-inheritance:
17 changes: 0 additions & 17 deletions docs/source/models.rst

This file was deleted.

7 changes: 0 additions & 7 deletions docs/source/models/asset_pricing.rst

This file was deleted.

7 changes: 0 additions & 7 deletions docs/source/models/career.rst

This file was deleted.

7 changes: 0 additions & 7 deletions docs/source/models/ifp.rst

This file was deleted.

7 changes: 0 additions & 7 deletions docs/source/models/jv.rst

This file was deleted.

7 changes: 0 additions & 7 deletions docs/source/models/lake.rst

This file was deleted.

7 changes: 0 additions & 7 deletions docs/source/models/odu.rst

This file was deleted.

7 changes: 0 additions & 7 deletions docs/source/models/solow/ces.rst

This file was deleted.

7 changes: 0 additions & 7 deletions docs/source/models/solow/cobb_douglas.rst

This file was deleted.

7 changes: 0 additions & 7 deletions docs/source/models/solow/impulse_response.rst

This file was deleted.

7 changes: 0 additions & 7 deletions docs/source/models/solow/model.rst

This file was deleted.

7 changes: 0 additions & 7 deletions docs/source/models/uncertainty_traps.rst

This file was deleted.

7 changes: 0 additions & 7 deletions docs/source/tools/external.rst

This file was deleted.

7 changes: 0 additions & 7 deletions docs/source/util/external.rst

This file was deleted.

14 changes: 7 additions & 7 deletions quantecon/compute_fp.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import warnings
import numpy as np
from numba import jit, generated_jit, types
from .game_theory.lemke_howson import lemke_howson_tbl, get_mixed_actions
from .game_theory.lemke_howson import _lemke_howson_tbl, _get_mixed_actions


def _print_after_skip(skip, it=None, dist=None, etime=None):
Expand Down Expand Up @@ -48,13 +48,13 @@ def _is_approx_fp(T, v, error_tol, *args, **kwargs):

def compute_fixed_point(T, v, error_tol=1e-3, max_iter=50, verbose=2,
print_skip=5, method='iteration', *args, **kwargs):
"""
r"""
Computes and returns an approximate fixed point of the function `T`.
The default method `'iteration'` simply iterates the function given
an initial condition `v` and returns :math:`T^k v` when the
condition :math:`\lVert T^k v - T^{k-1} v\rVert \leq
\mathrm{error_tol}` is satisfied or the number of iterations
\mathrm{error\_tol}` is satisfied or the number of iterations
:math:`k` reaches `max_iter`. Provided that `T` is a contraction
mapping or similar, :math:`T^k v` will be an approximation to the
fixed point.
Expand Down Expand Up @@ -225,7 +225,7 @@ def _compute_fixed_point_ig(T, v, max_iter, verbose, print_skip, is_approx_fp,

tableaux = tuple(np.empty((buff_size, buff_size*2+1)) for i in range(2))
bases = tuple(np.empty(buff_size, dtype=int) for i in range(2))
max_piv = 10**6 # Max number of pivoting steps in lemke_howson_tbl
max_piv = 10**6 # Max number of pivoting steps in _lemke_howson_tbl

while True:
y_new = T(x_new, *args, **kwargs)
Expand Down Expand Up @@ -259,10 +259,10 @@ def _compute_fixed_point_ig(T, v, max_iter, verbose, print_skip, is_approx_fp,
tableaux_curr = tuple(tableau[:m, :2*m+1] for tableau in tableaux)
bases_curr = tuple(basis[:m] for basis in bases)
_initialize_tableaux_ig(X[:m], Y[:m], tableaux_curr, bases_curr)
converged, num_iter = lemke_howson_tbl(
converged, num_iter = _lemke_howson_tbl(
tableaux_curr, bases_curr, init_pivot=m-1, max_iter=max_piv
)
_, rho = get_mixed_actions(tableaux_curr, bases_curr)
_, rho = _get_mixed_actions(tableaux_curr, bases_curr)

if Y.ndim <= 2:
x_new = rho.dot(Y[:m])
Expand Down Expand Up @@ -290,7 +290,7 @@ def _initialize_tableaux_ig(X, Y, tableaux, bases):
"""
Given sequences `X` and `Y` of ndarrays, initialize the tableau and
basis arrays in place for the "geometric" imitation game as defined
in McLennan and Tourky (2006), to be passed to `lemke_howson_tbl`.
in McLennan and Tourky (2006), to be passed to `_lemke_howson_tbl`.
Parameters
----------
Expand Down
Loading

0 comments on commit 31ca47b

Please sign in to comment.