-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_5_3.jl
More file actions
46 lines (37 loc) · 1.84 KB
/
example_5_3.jl
File metadata and controls
46 lines (37 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"""
Computing an equilibrium with SGM (Example 5.3, CLP, 2022)
Implementation of Example 5.3 from Carvalho, Lodi, and Pedroso (2022). For futher details,
see:
[*M. Carvalho, A. Lodi, J. P. Pedroso, "Computing equilibria for integer programming games". 2022. European Journal of Operational Research*](https://www.sciencedirect.com/science/article/pii/S0377221722002727)
[*M. Carvalho, A. Lodi, J. P. Pedroso, "Computing Nash equilibria for integer programming games". 2020. arXiv:2012.07082*](https://arxiv.org/abs/2012.07082)
Notes
- SCIP can be replaced with other solvers, such as Gurobi or CPLEX.
"""
using IPG, SCIP
# ==== Player Definition ====
# Strategy spaces are defined through JuMP models
player1 = Player()
@variable(player1.X, x1, start=10.0)
@constraint(player1.X, x1 >= 0)
player2 = Player()
@variable(player2.X, x2, start=10.0)
@constraint(player2.X, x2 >= 0)
# Payoffs are defined using JuMP expressions
set_payoff!(player1, -x1^2 + x1*x2)
set_payoff!(player2, -x2^2 + x1*x2)
# ==== SGM Algorithm Subroutines ====
# The following are the default options for the SGM algorithm, so they can be omitted.
# See docstrings of each parameter for further details
IPG.initialize_strategies = IPG.initialize_strategies_feasibility
IPG.solve = IPG.solve_PNS
IPG.find_deviation = IPG.find_deviation_best_response
# It is also possible to pass custom subroutines. The following is a re-implementation of
# `IPG.get_player_order_random` for demonstration.
using Random
function get_player_random_order(players::Vector{Player}, iter::Integer, Σ_S::Vector{Profile{DiscreteMixedStrategy}}, payoff_improvements::Vector{Tuple{Player,Float64}})
return shuffle(keys(players))
end
IPG.get_player_order = get_player_random_order
# ==== SGM ====
players = [player1, player2]
Σ, payoff_improvements = SGM(players, SCIP.Optimizer, max_iter=100, verbose=true);