#16954: Game Theory: Build class for normal form games as well as ability to 
obtain
Nash equilibria
-------------------------------------+-------------------------------------
       Reporter:  vinceknight        |        Owner:
           Type:  enhancement        |       Status:  needs_review
       Priority:  major              |    Milestone:  sage-6.4
      Component:  game theory        |   Resolution:
       Keywords:  Game Theory,       |    Merged in:
  Normal Form Games                  |    Reviewers:
        Authors:                     |  Work issues:
Report Upstream:  N/A                |       Commit:
         Branch:                     |  ffa6d525b5e6681687642d9efc80037884823e30
  u/vinceknight/16954                |     Stopgaps:
   Dependencies:                     |
-------------------------------------+-------------------------------------

Comment (by kcrisman):

 Before continuing, I just have to say that this is really exceptionally
 well-organized.  Good work.

 ----

 Moving on to the methods.
  * But what will happen to the deleted game?  Will this raise an error if
 you try to do anything with it?   (Maybe I'll find out later.)
 {{{
             sage: prisoners_dilemma
             {(1, 0): [0, 5], (0, 0): [2, 2], (1, 1): [4, 4]}
 }}}
  * Can you {{{__setitem__}}} for an already-set item in the game?  If not
 (for whatever reason), then this should be doctested.  If yes, I guess
 this should be justified and doctested too.
  * Can you move that method to with the other dictionary-emulating
 methods?  Not super-important but helpful to those reading code.
 {{{__iter__}}} and {{{__len__}}} strictly speaking are not about dict
 emulation but just emulation of iterables.
  * Usually {{{__init__}}} is best at the very first.  Am I missing
 something that the emulation ones are coming first?
  * I would have expected this to list the bimatrix entries.  Instead I get
 a very boring list of the possible pure strategies.
 {{{
             sage: for key in prisoners_dilemma:
             ....:     print key
 }}}
    Will length basically always be n times m in terms of the number of
 strategies?  In which case do you really need all that extra stuff about
 utilities?
  * `Generator function must be a list or nothing` is not doctested.
  * `generator != None` or `generator is not None`?  Just wondering which
 you intend here.
  * `        LaTeX method shows nothing interesting for games with more
 players::` - then you should probably use the `...` like so:
 {{{
 \text{\texttt{<bound{ }method{ }NormalFormGame...[False,{ }False,{
 }False]{\char`\}}>}}
 }}}
    or the like.
  * I still do not like ` return str(self.utilities)` for the string rep.
 It should at least say, at the very least, that it is in fact a normal
 form game!!!  Maybe "Normal Form Game with following utilities" or
 whatever.
  * One of the errors in the payoff matrices method is tested, the other
 isn't.
  * `m1 = matrix(QQ,` - oh, oh.  But didn't you say that Gambit does
 floats?  And what if people input floats?  I'm just thinking of nasty
 things like people inputting `1/sqrt(2)` as a probability, or ones where
 when they are coerced to rationals don't add up to 100%
  * I'd like to see an example with
 {{{
 sage: g._generate_utilities(True)
 }}}
    where it would actually destroy a utility.  Myuh-ha-ha!
  * The line
 {{{
 Checks if ``utilities`` has been completed
 }}}
    doesn't seem to correspond to any errors, though.
  * These mixed strategies
 {{{
 [[(1, 0, 0, 0), (127/1212, 115/1212, 485/606)], [(0, 1, 0, 0), (0, 1/26,
 25/26)]]
 }}}
    seem strange, but I assume correct - can you confirm they are ''exact''
 answers?
  * The line
 {{{
         This particular game has 3 Nash equilibria::
 }}}
    isn't backed up by
 {{{
             sage: g.obtain_Nash(maximization=False)
             [[(1, 0, 0), (0, 1)]]
 }}}
    unless I'm misunderstanding the syntax.  Where are the other two
 equilibria promised to the reader?  This seems to happen in a few other
 examples.   (Actually, I think that some copy-paste is at fault here, esp.
 since `maximization=False` but that isn't mentioned.)
  * The or a?
 {{{
 A function to return the Nash equilibrium for a game.
 }}}
  * When you use `tmp_filename()` in the things themselves (not doctests)
 are there any other strange side-effects?
  * I feel like you tired (understandable!) in the `_solve_enumeration`
 doctests. Most of them should be tests and not examples in any case, I
 suppose.  Here is the funniest of them, I actually laughed at this one.
 {{{
         TESTS:

         Due to the nature of the linear equations solved in this algorithm
         some negative vectors can be returned. Here is a test that ensures
         this doesn't happen::

             sage: a = matrix([[-13, 59],
             ....:             [27, 86]])
             sage: b = matrix([[14, 6],
             ....:             [58, -14]])
             sage: c = NormalFormGame([a, b])
 }}}
    It sure doesn't happen!  Since we never try to find said vectors :-)
  * Adding strategies should then have an example finishing it.
 {{{
     If we do this and try and obtain the Nash equilibrium or view the
 payoff
     matrices(without specifying the utilities), an error is returned::
 }}}
    but it's never finished up.
  * What happens with a completely trivial matrix i.e. all payoffs are
 zero?  Then all mixed strategies are optimal, I guess...

 ----

 Remaining:
  * Making sure the `_solve_enumeration` actually is correct.  I'm sure it
 is, I just haven't had time to look at it.
  * I will have to just trust you on the `_Hrepresentation` method.

 Almost there!

 Finally, as a general rule of thumb, if you have any pretty useful tests
 or examples which are in underscore methods (which won't show up in the
 reference manual) maybe repeat them elsewhere.  I don't know if you do
 that, just mentioning it.

--
Ticket URL: <http://trac.sagemath.org/ticket/16954#comment:15>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to