Skip to content

Commit db5ca17

Browse files
committed
update instructions; add payoff explanation
1 parent 8d0e1fa commit db5ca17

File tree

1 file changed

+44
-18
lines changed

1 file changed

+44
-18
lines changed

README.md

Lines changed: 44 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,60 @@ Implementation of the sampled generation method (SGM) for equilibria computation
88

99
[*M. Carvalho, A. Lodi, J. P. Pedroso, "Computing Nash equilibria for integer programming games". 2020. arXiv:2012.07082*](https://arxiv.org/abs/2012.07082)
1010

11-
## Bilateral payoff games
11+
## Game definition
1212

13-
The algorithm is particularly designed for games in which the player have bilaterally-separable payoff functions. This is due to the standard solution method for solving sampled games, which relies on normal form games formulated through the polymatrix. An example of such is the [`QuadraticPayoff`](src/Game/Payoff/BilateralPayoff.jl#L27) structure, which implements the payoff function structure used in the original paper's experiments.
13+
A game is any list of players. To define a player, you must define the strategy space and the payoff function. The strategy space is handled through JuMP models, while payoff functions are handled by our structures (see Bilateral payoff games below for examples). Additionally, we need to keep track of references for the decision variables and the index of each player in the game.
14+
15+
The following illustratest the necessary steps to define a player:
16+
```julia
17+
using IPG
18+
Xp = Model()
19+
20+
@variable(Xp, y[1:5], Int)
21+
@variable(Xp, z >= 0)
22+
23+
@constraint(Xp, ...) # add your constraints
24+
25+
Πp = QuadraticPayoff(...) # payoff definition
26+
27+
player = Player(Xp, [z], Πp, 1) # add first player
28+
```
29+
Note that not all variables have to be provided to the Player definition, only those necessary to compute the payoff. <!-- TODO: See payoff section -->
30+
31+
## Payoff Functions
32+
33+
Properly defining the payoff functions are key for the workings of this implementation. Currently, two types of payoff functions are implemented: quadratic and blackbox, which are illustrated in the examples bellow. The former follows the notation of the original paper and allows for any game definition (in terms of constraints) that your solver of choice supports. The latter only works for two-player games. See `src/Game/Payoff` for more details.
1434

15-
### Example
35+
## Examples
36+
37+
### Bilateral payoff games
38+
39+
The algorithm is particularly designed for games in which the player have bilaterally-separable payoff functions. This is due to the standard solution method for solving sampled games, which relies on normal form games formulated through the polymatrix. An example of such is the [`QuadraticPayoff`](src/Game/Payoff/BilateralPayoff.jl#L27) structure, which implements the payoff function structure used in the original paper's experiments.
1640

1741
This example is based on Example 5.3, from Carvalho, Lodi, and Pedroso (2020).
1842
```julia
1943
julia> using IPG
2044

21-
julia> player_1 = Player(QuadraticPayoff(0, [2, 1], 1), 1);
45+
julia> X1 = Model();
2246

23-
julia> @variable(player_1.Xp, x1, start=10)
47+
julia> @variable(X1, x1, start=10)
2448
x1
2549

26-
julia> @constraint(player_1.Xp, x1 >= 0)
50+
julia> @constraint(X1, x1 >= 0)
2751
x1 0
2852

29-
julia> player_2 = Player(QuadraticPayoff(0, [1, 2], 2), 2);
53+
julia> player_1 = Player(X1, [x1], QuadraticPayoff(0, [2, 1], 1), 1);
3054

31-
julia> @variable(player_2.Xp, x2, start=10)
55+
julia> X2 = Model();
56+
57+
julia> @variable(X2, x2, start=10)
3258
x2
3359

34-
julia> @constraint(player_2.Xp, x2 >= 0)
60+
julia> @constraint(X2, x2 >= 0)
3561
x2 0
3662

63+
julia> player_2 = Player(X2, [x2], QuadraticPayoff(0, [1, 2], 2), 2);
64+
3765
julia> Σ, payoff_improvements = IPG.SGM([player_1, player_2], SCIP.Optimizer, max_iter=5);
3866

3967
julia> Σ[end]
@@ -44,27 +72,25 @@ julia> Σ[end]
4472
```
4573
Further details in [`example-5.3.ipynb`](notebooks/example-5.3.ipynb).
4674

47-
## Two-player games
75+
### Two-player games
4876

4977
A particular case of bilateral payoff functions that can be handled more generally are two-player games. In this case, because any payoff function is bilateral, we handle the more general [`BlackBoxPayoff`](src/Game/Payoff/Payoff.jl#29) through the SGM algorithm.
5078

51-
### Example
52-
5379
Example 5.3 implemented using the BlackBoxPayoff structure.
5480
```julia
5581
julia> using IPG, SCIP
5682

5783
julia> player_payoff(xp, x_others) = -(xp[1] * xp[1]) + xp[1] * prod(x_others[:][1])
5884
player_payoff (generic function with 1 method)
5985

60-
julia> players = [
61-
Player(BlackBoxPayoff(player_payoff), 1),
62-
Player(BlackBoxPayoff(player_payoff), 2)
63-
];
86+
julia> X1 = Model(); @variable(X1, x1, start=10); @constraint(X1, x1 >= 0);
6487

65-
julia> @variable(players[1].Xp, x1, start=10); @constraint(players[1].Xp, x1 >= 0);
88+
julia> X2 = Model(); @variable(X2, x2, start=10); @constraint(X2, x2 >= 0);
6689

67-
julia> @variable(players[2].Xp, x2, start=10); @constraint(players[2].Xp, x2 >= 0);
90+
julia> players = [
91+
Player(X1, [x1], BlackBoxPayoff(player_payoff), 1),
92+
Player(X2, [x2], BlackBoxPayoff(player_payoff), 2)
93+
];
6894

6995
julia> Σ, payoff_improvements = IPG.SGM(players, SCIP.Optimizer, max_iter=5);
7096

0 commit comments

Comments
 (0)