quantecon / gametheory.jl Goto Github PK
View Code? Open in Web Editor NEWAlgorithms and data structures for game theory in Julia
License: Other
Algorithms and data structures for game theory in Julia
License: Other
What to display by show(io::IO, g::NormalFormGame)
.
The Python version displays the "payoff profile array" (or bimatrix for a two-player game):
>>> g = NormalFormGame(np.random.randn(3, 2, 2))
>>> g
<3x2 2-player NormalFormGame of dtype float64>
>>> print(g)
2-player NormalFormGame with payoff profile array:
[[[ 0.46084996, 1.34982151], [-0.56152949, -0.53671984]],
[[-0.6511819 , -0.21285249], [-1.15573043, -0.93735687]],
[[ 1.87576693, -0.0829676 ], [ 1.09474488, 2.25462774]]]
>>> g.players[0]
Player([[ 0.46084996, -0.56152949],
[-0.6511819 , -1.15573043],
[ 1.87576693, 1.09474488]])
>>> g.players[1]
Player([[ 1.34982151, -0.21285249, -0.0829676 ],
[-0.53671984, -0.93735687, 2.25462774]])
Documenter.jl is not working since 24 Sep.
@shizejin Could you take a look?
Include docstrings for type aliases in src/Games.jl
into "Base Types and Methods".
!! 6 docstrings potentially missing:
Games.MixedActionProfile
Games.PureAction
Games.PureActionProfile
Games.MixedAction
Games.ActionProfile
Games.Action
Add developer documentation
Translate lemke_howson.py
in QuantEcon.py into Julia.
Cell [20]
in the notebook.
I found the advice from @StefanKarpinski #2 (comment) does not work for type inference in v0.6:
using Games
struct Cournot{N} end
function (::Type{Cournot{N}}){N,T<:Real}(a::Real, c::Real, q_grid::Vector{T})
nums_actions = tuple([length(q_grid) for i in 1:N]...)::NTuple{N,Int}
S = promote_type(typeof(a), typeof(c), T)
payoff_array= Array{T}(nums_actions)
for I in CartesianRange(nums_actions)
Q = zero(S)
for i in 1:N
Q += q_grid[I[i]]::T
end
payoff_array[I] = (a - c - Q) * q_grid[I[1]]
end
players = tuple([Player(payoff_array) for i in 1:N]...)::NTuple{N,Player{N,T}}
return NormalFormGame(players)
end
cournot{T<:Real}(a::Real, c::Real, N::Integer, q_grid::Vector{T}) =
Cournot{N}(a, c, q_grid)
a, c = 80, 20
N = 3
q_grid = [10, 15]
@code_warntype cournot(a, c, N, q_grid)
Variables:
#self#::#cournot
a::Int64
c::Int64
N::Int64
q_grid::Array{Int64,1}
Body:
begin
return ((Core.apply_type)(Main.Cournot, N::Int64)::Type{Cournot{_}} where _)(a::Int64, c::Int64, q_grid::Array{Int64,1})::Games.NormalFormGame{_,_} where _ where _
end::Games.NormalFormGame{_,_} where _ where _
Is it possible to compute everything with exact arithmetic, if the input game is of type Int
or Rational
and the user chooses a Polyhedra
library that supports computation with Rational
such as CDDLib
and LRSLib
(probably through plib
)?
n = 3
g1 = NormalFormGame(Player(collect(1:n)))
pure_nash(g1)
ArgumentError: input tuple must not be empty
Add a method
is_nash(g::NormalFormGame{1}, action::ActionProfile) = is_nash(g, action...)
See #40 (comment)
Instead of Vector{Tuple{2,Vector{Real}}}
, it should be Vector{Tuple{2,Vector{S}}}
where S
is Float if T
is Int or Float, and Rational if T
is Rational.
As @StefanKarpinski told me:
It may be better to represent a player's payoff function by a function, "payoff_function
" or "payoff_func
, instead of array payoff_array
.
It sounds a great idea to me now.
include("test_normal_form_game.jl")
...
Got exception outside of a @test
UndefVarError: CDDSolver not defined
...
auto_doc_gen.jl
, so that each section does not have subsections for files, but just has subsections of "Exported" and "Internal".User Guide
before Library.The problem causing #2 (comment):
If an M-dimensional array is passed with M>=3, then NormalFormGame{T<:Real,M}(payoffs::Array{T,M})
is called, which returns a NormalFormGame
with N=M-1>=2 players.
If a 2-dimensitonal array (matrix) is passed, then NormalFormGame{T<:Real}(payoffs::Matrix{T})
is called and it returns
NormalFormGame
if the input array is n x 1;NormalFormGame
if the input array is n x m with m>=2 and is square (n=m), in which case the game is thought of as a symmetric 2-player game.The latter design is the source of the type instability.
My proposal is:
NormalFormGame{T<:Real}(payoffs::Matrix{T})
always return a 2-player NormalFormGame
(if payoff
is square), so that a 1-player game cannot be constructed by a payoff array (vector in this case) and must be constructed by NormalFormGame(player_with_no_opponent)
, where player_with_no_opponent
is of type Player{1,T}
.See #1 (comment).
@oyamad
Please review the notes on learning algorithms(PR)
Fictitious Play
Local Interaction
Best Response Dynamics
Logit Response Dynamics
Testing outer approximation: Error During Test
Got an exception of type MethodError outside of a @test
MethodError: Cannot `convert` an object of type Polyhedra.Ray{2,Float64} to an object of type Union{GeometryTypes.Vec{2,AbstractFloat}, Polyhedra.Line{2,AbstractFloat}, Polyhedra.Ray{2,AbstractFloat}}
This may have arisen from a call to the constructor Union{GeometryTypes.Vec{2,AbstractFloat}, Polyhedra.Line{2,AbstractFloat}, Polyhedra.Ray{2,AbstractFloat}}(...),
since type constructors fall back to convert methods.
Stacktrace:
[1] push!(::Array{Union{GeometryTypes.Vec{2,AbstractFloat}, Polyhedra.Line{2,AbstractFloat}, Polyhedra.Ray{2,AbstractFloat}},1}, ::Polyhedra.Ray{2,Float64}) at ./array.jl:617
[2] _pushinout!(::Array{Union{GeometryTypes.Vec{2,AbstractFloat}, Polyhedra.Line{2,AbstractFloat}, Polyhedra.Ray{2,AbstractFloat}},1}, ::Array{Union{GeometryTypes.Vec{2,AbstractFloat}, Polyhedra.Line{2,AbstractFloat}, Polyhedra.Ray{2,AbstractFloat}},1}, ::Polyhedra.Line{2,AbstractFloat}, ::Polyhedra.HalfSpace{2,AbstractFloat}) at /Users/oyama/.julia/v0.6/Polyhedra/src/repelemop.jl:88
[3] intersect(::Polyhedra.SimpleVRepresentation{2,AbstractFloat}, ::Polyhedra.HalfSpace{2,AbstractFloat}) at /Users/oyama/.julia/v0.6/Polyhedra/src/repelemop.jl:137
[4] doubledescription(::Polyhedra.SimpleHRepresentation{2,AbstractFloat}) at /Users/oyama/.julia/v0.6/Polyhedra/src/doubledescription.jl:26
[5] computevrep!(::Polyhedra.SimplePolyhedron{2,AbstractFloat}) at /Users/oyama/.julia/v0.6/Polyhedra/src/simplepolyhedron.jl:109
[6] vrep(::Polyhedra.SimplePolyhedron{2,AbstractFloat}) at /Users/oyama/.julia/v0.6/Polyhedra/src/simplepolyhedron.jl:113
[7] collect(::Base.Generator{Array{Polyhedra.SimplePolyhedron{2,AbstractFloat},1},Polyhedra.#nvreps}) at ./array.jl:441
[8] Polyhedra.SimpleVRepresentation{2,AbstractFloat}(::Polyhedra.VRepIterator{2,AbstractFloat,2,AbstractFloat}) at /Users/oyama/.julia/v0.6/Polyhedra/src/simplerep.jl:176
[9] vconvert(::Type{Polyhedra.SimpleVRepresentation{2,AbstractFloat}}, ::Polyhedra.SimplePolyhedron{2,AbstractFloat}) at /Users/oyama/.julia/v0.6/Polyhedra/src/representation.jl:254
[10] Polyhedra.SimpleVRepresentation(::Polyhedra.SimplePolyhedron{2,AbstractFloat}) at /Users/oyama/.julia/v0.6/Polyhedra/src/simplerep.jl:173
[11] #outerapproximation#14(::Int64, ::Float64, ::Int64, ::Bool, ::Bool, ::Int64, ::Polyhedra.SimplePolyhedraLibrary{AbstractFloat}, ::Function, ::Games.RepeatedGame{2,Float64}) at /Users/oyama/.julia/v0.6/Games/src/repeated_game.jl:353
[12] (::Games.#kw##outerapproximation)(::Array{Any,1}, ::Games.#outerapproximation, ::Games.RepeatedGame{2,Float64}) at ./<missing>:0
[13] macro expansion at /Users/oyama/.julia/v0.6/Games/test/test_repeated_game.jl:52 [inlined]
[14] macro expansion at ./test.jl:860 [inlined]
[15] macro expansion at /Users/oyama/.julia/v0.6/Games/test/test_repeated_game.jl:51 [inlined]
[16] macro expansion at ./test.jl:860 [inlined]
[17] anonymous at ./<missing>:?
[18] include_from_node1(::String) at ./loading.jl:569
[19] include(::String) at ./sysimg.jl:14
[20] include_from_node1(::String) at ./loading.jl:569
[21] include(::String) at ./sysimg.jl:14
[22] process_options(::Base.JLOptions) at ./client.jl:305
[23] _start() at ./client.jl:371
@shizejin I got the following error by julia make.jl
(run locally):
$ julia make.jl
Documenter: setting up build directory.
ERROR: LoadError: 'lib/base_types_and_methods.md' is not an existing page!
...
Can you take a look?
By using a nonlinear equation/complementarity problem solver or a polynomial equation solver (if any).
What packages are available in Julia (and in Python)?
Hi @cc7768, I was trying to replicate the result of the example demonstrated at the bottom of the notebook A Recursive Formulation of Repeated Games, but failed:
julia> using Games
julia> pd_payoff = [9.0 1.0
10.0 3.0]
2×2 Array{Float64,2}:
9.0 1.0
10.0 3.0
julia> A = Player(pd_payoff)
2×2 Player{2,Float64}:
9.0 1.0
10.0 3.0
julia> B = Player(pd_payoff)
2×2 Player{2,Float64}:
9.0 1.0
10.0 3.0
julia> pd = NormalFormGame((A, B))
2×2 NormalFormGame{2,Float64}
julia> rpd1 = RepeatedGame(pd, 0.9)
Games.RepeatedGame{2,Float64}(2×2 NormalFormGame{2,Float64}, 0.9)
julia> hp_pts1 = outerapproximation(rpd1; nH=128, maxiter=750, tol=1e-8);
julia> hp_pts1
7×2 Array{Float64,2}:
9.63111 4.7454
9.0 9.0
3.25054 9.85285
3.0 9.80302
2.1328 3.95681
3.0 3.0
9.80302 3.0
Plot it out:
The vertex [2.1328, 3.95681]
should not appear here.
I wonder if this is caused by the mistake that would occur when doing transformation between Hrep and Vrep by polyhedron
. JuliaPolyhedra/Polyhedra.jl#48
I have no idea how.
@shizejin Do you?
Implemented by QuantEcon/QuantEcon.jl#199.
(See also QuantEcon/QuantEcon.py#379 for the Python version.)
It will be helpful to implement a list of sample games, such as
function prisoners_dilemma(;gain::Real=2, loss::Real=2)
gain <= 0 && throw(ArgumentError("gain must be positive"))
loss <= 0 && throw(ArgumentError("loss must be positive"))
payoff_matrix = [1 -loss;
1+gain 0]
return NormalFormGame(payoff_matrix)
end
(This is just one possible, but seemingly popular, way to normalize the payoffs of Prisoners' Dilemma.)
Julia 0.4 support has been dropped by 25e0ffa.
Hi
I am having issues installing the required packages for quantecon. Following the online guide, when I run the code
] add InstantiateFromURL
`
I get an infinite series of errors:
Unsatisfiable requirements detected for package DSP [717857b8]:
DSP [717857b8] log:
├─possible versions are: [0.5.1-0.5.2, 0.6.0-0.6.2] or uninstalled
├─restricted by compatibility requirements with QuantEcon [fcd29c91] to versions: 0.6.0-0.6.2
│ └─QuantEcon [fcd29c91] log:
│ ├─possible versions are: [0.14.3, 0.15.0, 0.16.0-0.16.2] or uninstalled
│ └─restricted to versions 0.16.2 by an explicit requirement, leaving only versions 0.16.2
├─restricted by compatibility requirements with Polynomials [f27b6e38] to versions: [0.5.1-0.5.2, 0.6.0] or uninstalled, leaving only versions: 0.6.0
│ └─Polynomials [f27b6e38] log:
│ ├─possible versions are: [0.5.0-0.5.3, 0.6.0] or uninstalled
│ └─restricted to versions 0.5.2 by an explicit requirement, leaving only versions 0.5.2
└─restricted by compatibility requirements with SpecialFunctions [276daf66] to versions: 0.5.1-0.5.2 or uninstalled — no versions left
└─SpecialFunctions [276daf66] log:
├─possible versions are: [0.7.0-0.7.2, 0.8.0, 0.9.0] or uninstalled
├─restricted by compatibility requirements with ForwardDiff [f6369f11] to versions: [0.7.0-0.7.2, 0.8.0, 0.9.0]
│ └─ForwardDiff [f6369f11] log:
│ ├─possible versions are: [0.9.0, 0.10.0-0.10.8] or uninstalled
│ └─restricted to versions 0.10.3 by an explicit requirement, leaving only versions 0.10.3
└─restricted by compatibility requirements with Distributions [31c24e10] to versions: 0.7.0-0.7.2
└─Distributions [31c24e10] log:
├─possible versions are: [0.16.0-0.16.4, 0.17.0, 0.18.0, 0.19.1-0.19.2, 0.20.0, 0.21.0-0.21.3, 0.21.5-0.21.11] or uninstalled
└─restricted to versions 0.21.3 by an explicit requirement, leaving only versions 0.21.3
Stacktrace:
[1] #propagate_constraints!#61(::Bool, ::typeof(Pkg.GraphType.propagate_constraints!), ::Pkg.GraphType.Graph, ::Set{Int64}) at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.3\Pkg\src\GraphType.jl:1007
[2] propagate_constraints! at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.3\Pkg\src\GraphType.jl:948 [inlined]
[3] #simplify_graph!#121(::Bool, ::typeof(Pkg.GraphType.simplify_graph!), ::Pkg.GraphType.Graph, ::Set{Int64}) at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.3\Pkg\src\GraphType.jl:1462
[4] simplify_graph! at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.3\Pkg\src\GraphType.jl:1462 [inlined] (repeats 2 times)
[5] resolve_versions!(::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}) at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.3\Pkg\src\Operations.jl:321
[6] #add#112(::Bool, ::Pkg.BinaryPlatforms.Windows, ::typeof(Pkg.Operations.add), ::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}, ::Array{Base.UUID,1}) at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.3\Pkg\src\Operations.jl:1010
[7] #add at .\none:0 [inlined]
[8] #add#25(::Bool, ::Pkg.BinaryPlatforms.Windows, ::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::typeof(Pkg.API.add), ::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}) at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.3\Pkg\src\API.jl:102
[9] add(::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}) at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.3\Pkg\src\API.jl:72
[10] do_add!(::Dict{Symbol,Any}, ::Array{Pkg.Types.PackageSpec,1}, ::Dict{Symbol,Any}) at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.3\Pkg\src\REPLMode.jl:505
[11] #invokelatest#1(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::typeof(Base.invokelatest), ::Any, ::Any, ::Vararg{Any,N} where N) at .\essentials.jl:709
[12] invokelatest(::Any, ::Any, ::Vararg{Any,N} where N) at .\essentials.jl:708
[13] do_cmd!(::Pkg.REPLMode.Command, ::IJulia.MiniREPL) at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.3\Pkg\src\REPLMode.jl:412
[14] #do_cmd#23(::Bool, ::typeof(Pkg.REPLMode.do_cmd), ::IJulia.MiniREPL, ::String) at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.3\Pkg\src\REPLMode.jl:391
[15] (::Pkg.REPLMode.var"#kw##do_cmd")(::NamedTuple{(:do_rethrow,),Tuple{Bool}}, ::typeof(Pkg.REPLMode.do_cmd), ::IJulia.MiniREPL, ::String) at .\none:0
[16] top-level scope at In[8]:1
julia> using Games
julia> g = NormalFormGame([1 0; 0 4])
2×2 NormalFormGame{2,Int64}
julia> rpg = RepeatedGame(g, 0.9)
Games.RepeatedGame{2,Int64}(2×2 NormalFormGame{2,Int64}, 0.9)
julia> outerapproximation(rpg)
WARNING: getlibraryfor is deprecated, use similar_library instead. Note that the dimension `N` now needs to be given as `FullDim{N}()`.
Stacktrace:
[1] depwarn(::String, ::Symbol) at ./deprecated.jl:70
[2] getlibraryfor at /Users/oyama/.julia/v0.6/Polyhedra/src/default.jl:52 [inlined]
[3] outerapproximation(::Games.RepeatedGame{2,Int64}) at /Users/oyama/.julia/v0.6/Games/src/repeated_game.jl:341
[4] eval(::Module, ::Any) at ./boot.jl:235
[5] eval_user_input(::Any, ::Base.REPL.REPLBackend) at ./REPL.jl:66
[6] macro expansion at ./REPL.jl:97 [inlined]
[7] (::Base.REPL.##1#2{Base.REPL.REPLBackend})() at ./event.jl:73
while loading no file, in expression starting on line 0
ERROR: MethodError: no method matching similar_library(::Type{Val{2}}, ::Type{Float64})
Closest candidates are:
similar_library(::Polyhedra.Polyhedron{N,T} where T, ::Type{T}) where {N, T} at /Users/oyama/.julia/v0.6/Polyhedra/src/default.jl:36
Stacktrace:
[1] outerapproximation(::Games.RepeatedGame{2,Int64}) at /Users/oyama/.julia/v0.6/Games/src/repeated_game.jl:341
Cc: @blegat
What is the proper Julia counterpart of QuantEcon/QuantEcon.py#382?
Add a field payoff_arrays
to NormalFormGame
:
struct NormalFormGame{N,T<:Real}
players::NTuple{N,Player{N,T}}
nums_actions::NTuple{N,Int}
payoff_arrays::NTuple{N,Array{T,N}}
end
This seems not to be very Julian?
And this requires adding the same code of generating the tuple to many constructors.
Add a method payoff_arrays
to NormalFormGame
:
payoff_arrays(g::NormalFormGame{N,T}) where {N,T} =
tuple([player.payoff_array for player in g.players]...)::NTuple{N,Array{T,N}}
This is what I had in mind initially, but now I want to avoid this as it will introduce a conflict with the likely usage of payoff_arrays
as a variable name.
Name the above method get_payoff_arrays
:
Sounds too long? And to "get" payoff arrays, one could just call g.players[i].payoff_array
.
Translate QuantEcon/QuantEcon.py#263 into Julia.
Distributions.MvNormal
with QuantEcon.MVNSampler
in covariance_game
rng::AbstractRNG
option to random_game
and covariance_game
Refer to QuantEcon/QuantEcon.jl#157
@shizejin Will you take a look?
https://travis-ci.org/QuantEcon/Games.jl/jobs/434985360#L1235-L1270
Julia v0.6.0 has been released and Polyhedral.jl
(and CDDLib.jl
) has added v0.6 support and dropped v0.5. Let's drop v0.5 here too.
using Games
p1 = Player(zeros(2, 2))
p2 = Player(zeros(2, 2))
g = NormalFormGame(p1, p2)
Unreachable reached at 0x12a56f6ff
signal (4): Illegal instruction: 4
in expression starting at no file:0
Type at /Users/oyama/Development/Games.jl/src/normal_form_game.jl:436
jl_fptr_trampoline at /Users/osx/buildbot/slave/package_osx64/build/src/gf.c:1843
do_call at /Users/osx/buildbot/slave/package_osx64/build/src/interpreter.c:324
eval_stmt_value at /Users/osx/buildbot/slave/package_osx64/build/src/interpreter.c:363 [inlined]
eval_body at /Users/osx/buildbot/slave/package_osx64/build/src/interpreter.c:682
jl_interpret_toplevel_thunk_callback at /Users/osx/buildbot/slave/package_osx64/build/src/interpreter.c:808
unknown function (ip: 0xfffffffffffffffe)
unknown function (ip: 0x117991eff)
unknown function (ip: 0xffffffffffffffff)
jl_interpret_toplevel_thunk at /Users/osx/buildbot/slave/package_osx64/build/src/interpreter.c:817
jl_toplevel_eval_flex at /Users/osx/buildbot/slave/package_osx64/build/src/toplevel.c:818
jl_toplevel_eval_in at /Users/osx/buildbot/slave/package_osx64/build/src/builtins.c:622
eval at ./boot.jl:319
eval_user_input at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.1/REPL/src/REPL.jl:85
macro expansion at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.1/REPL/src/REPL.jl:117 [inlined]
#28 at ./task.jl:259
jl_apply at /Users/osx/buildbot/slave/package_osx64/build/src/./julia.h:1559 [inlined]
start_task at /Users/osx/buildbot/slave/package_osx64/build/src/task.c:271
Allocations: 22400045 (Pool: 22397618; Big: 2427); GC: 38
Illegal instruction: 4
julia> versioninfo()
Julia Version 1.0.0
Commit 5d4eaca0c9 (2018-08-08 20:58 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin14.5.0)
CPU: Intel(R) Xeon(R) CPU E5-1650 v2 @ 3.50GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.0 (ORCJIT, ivybridge)
Same error also with Julia 1.1 (Nightly):
julia> versioninfo()
Julia Version 1.1.0-DEV.352
Commit 4851fab9b4 (2018-10-01 13:53 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin14.5.0)
CPU: Intel(R) Xeon(R) CPU E5-1650 v2 @ 3.50GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.1 (ORCJIT, ivybridge)
This does work with Julia 0.7:
julia> versioninfo()
Julia Version 0.7.0
Commit a4cb80f3ed (2018-08-08 06:46 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin14.5.0)
CPU: Intel(R) Xeon(R) CPU E5-1650 v2 @ 3.50GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.0 (ORCJIT, ivybridge)
We have got a permission from the corresponding author of the paper "An Empirical Study of Finding Approximate Equilibria in Bimatrix Games" to include the classes of games studied there into our libraries Games.jl
and quantecon.game_theory
. The associated C code is now distributed under BSD3 license.
Just noting the existence of this very nice code for dynamic games:
http://www.benjaminbrooks.net/software.shtml
Anyone interested in building Julia versions...?
normal_form_game.jl
repeated_game.jl
Would you please add the SSH Deploy Keys for generating documentation?
The test problem of NormalFromGame has been done.
Add random game generators as in QuantEcon/QuantEcon.py#270.
We have some minor type stability issues here.
To see them try the following:
using Games
g3 = NormalFormGame(randn(3,3,3,3))
@code_warntype payoff_vector(g3.players[1], (1, 2))
Also, we should be able to have inference work properly and not use @generated
in the constructor with signature function NormalFormGame{T<:Real}(payoffs::Array{T})
. Ping @StefanKarpinski if you have any ideas why inference wasn't working.
Should we have a specialized constructor, say normal_form_game_sym_2p
, for symmetric NormalFormGame
with two players?
It replaces this:
function normal_form_game_sym_2p{T<:Real}(payoff_matrix::Matrix{T})
n, m = size(payoff_matrix)
n != m && throw(ArgumentError(
"symmetric two-player game must be represented by a square matrix"
))
player = Player(payoff_matrix)
return NormalFormGame(player, player)
end
This will resolve the type instability issue #2 (comment).
Right now ClpSolver
is hard coded.
julia> g = NormalFormGame([1 0; 0 4])
2×2 NormalFormGame{2,Int64}
julia> rpg = RepeatedGame(g, 0.9)
Games.RepeatedGame{2,Int64}(2×2 NormalFormGame{2,Int64}, 0.9)
julia> @code_warntype outerapproximation(rpg)
Variables:
#self#::Games.#outerapproximation
rpd::Games.RepeatedGame{2,Int64}
#temp#@_3::Core.MethodInstance
#temp#@_4::Any
Body:
begin
SSAValue(0) = (Polyhedra.getlibraryfor)((Core.apply_type)(Polyhedra.Val, 2)::Type{Val{_}} where _, Float64)::Union{Polyhedra.IntervalLibrary{Float64}, Polyhedra.SimplePolyhedraLibrary{Float64}}
unless (SSAValue(0) isa Polyhedra.IntervalLibrary{Float64})::Bool goto 5
#temp#@_3::Core.MethodInstance = MethodInstance for #outerapproximation#14(::Int64, ::Float64, ::Int64, ::Bool, ::Bool, ::Int64, ::Polyhedra.IntervalLibrary{Float64}, ::Function, ::Games.RepeatedGame{2,Int64})
goto 14
5:
unless (SSAValue(0) isa Polyhedra.SimplePolyhedraLibrary{Float64})::Bool goto 9
#temp#@_3::Core.MethodInstance = MethodInstance for #outerapproximation#14(::Int64, ::Float64, ::Int64, ::Bool, ::Bool, ::Int64, ::Polyhedra.SimplePolyhedraLibrary{Float64}, ::Function, ::Games.RepeatedGame{2,Int64})
goto 14
9:
goto 11
11:
#temp#@_4::Any = (Games.#outerapproximation#14)(32, 1.0e-8, 500, true, false, 50, SSAValue(0), #self#::Games.#outerapproximation, rpd::Games.RepeatedGame{2,Int64})::Any
goto 16
14:
#temp#@_4::Any = $(Expr(:invoke, :(#temp#@_3), :(Games.#outerapproximation#14), 32, 1.0e-8, 500, true, false, 50, SSAValue(0), :(#self#), :(rpd)))
16:
return #temp#@_4::Any
end::Any
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.