| Title: | A Laboratory for TU Games |
|---|---|
| Description: | Cooperative game theory models decision-making situations in which a group of agents, called players, may achieve certain benefits by cooperating to reach an optimal outcome. It has great potential in different fields, since it offers a scenario to analyze and solve problems in which cooperation is essential to achieve a common goal. The 'TUGLab' (Transferable Utility Games Laboratory) R package contains a set of scripts that could serve as a helpful complement to the books and other materials used in courses on cooperative game theory, and also as a practical tool for researchers working in this field. The 'TUGLab' project was born in 2006 trying to highlight the geometrical aspects of the theory of cooperative games for 3 and 4 players. 'TUGlabWeb' is an online platform on which the basic functions of 'TUGLab' are implemented, and it is being used all over the world as a resource in degree, master's and doctoral programs. This package is an extension of the first versions and enables users to work with games in general (computational restrictions aside). The user can check properties of games, compute well-known games and calculate several set-valued and single-valued solutions such as the core, the Shapley value, the nucleolus or the core-center. The package also illustrates how the Shapley value flexibly adapts to various cooperative game settings, including weighted players and coalitions, a priori unions, and restricted communication structures. In keeping with the original philosophy of the first versions, special emphasis is placed on the graphical representation of the solution concepts for 3 and 4 players. |
| Authors: | Álvaro de Prado Saborido [aut, cre] (Departamento de Estatística e Investigación Operativa. Universidade de Vigo. Spain), Alejandro Bernárdez Ferradás [ctb] (ORCID: <https://orcid.org/0009-0006-0960-3555>, SiDOR. Departamento de Estatística e Investigación Operativa. Universidade de Vigo. CITMAga. Spain), Miguel Ángel Mirás Calvo [aut] (ORCID: <https://orcid.org/0000-0001-7247-1926>, RGEAF. Departamento de Matemáticas. Universidade de Vigo. Spain), Iago Núñez Lugilde [aut] (ORCID: <https://orcid.org/0000-0003-3382-0737>, Departamento de Matemáticas. MODES. Universidade da Coruña. Spain), Carmen Quinteiro Sandomingo [aut] (ORCID: <https://orcid.org/0000-0002-2711-1945>, Departamento de Matemáticas. Universidade de Vigo. Spain), Estela Sánchez Rodríguez [aut] (ORCID: <https://orcid.org/0000-0002-0933-6411>, SiDOR. Departamento de Estatística e Investigación Operativa. Universidade de Vigo. CITMAga. Spain), MCIN/AEI/10.13039/501100011033 [fnd] (Project PID2021-124030NB-C33. ERDF A way of making Europe/EU) |
| Maintainer: | Álvaro de Prado Saborido <[email protected]> |
| License: | GPL-3 |
| Version: | 0.0.1 |
| Built: | 2026-06-05 08:33:09 UTC |
| Source: | https://github.com/cran/TUGLab |
This function checks if the given game is additive.
additivecheck(v, binary = FALSE, instance = FALSE)additivecheck(v, binary = FALSE, instance = FALSE)
v |
A characteristic function, as a vector. |
binary |
A logical value. By default, |
instance |
A logical value. By default, |
A game is additive if for all .
TRUE if the game defined by v is additive, FALSE otherwise. If instance=TRUE and the game is not additive, the position (binary order position if binary=TRUE; lexicographic order position otherwise) of a coalition for which additivity is violated is also returned.
additivegame, superadditivecheck
v <- c(1, 5, 40, 100, 6, 41, 101, 45, 105, 140, 46, 106, 141, 145, 146) additivecheck(v) additivecheck(v, binary = TRUE, instance = TRUE)v <- c(1, 5, 40, 100, 6, 41, 101, 45, 105, 140, 46, 106, 141, 145, 146) additivecheck(v) additivecheck(v, binary = TRUE, instance = TRUE)
Given the value of each player, this function returns the characteristic function of the associated additive game.
additivegame(a, binary = FALSE)additivegame(a, binary = FALSE)
a |
A vector containing the player values. |
binary |
A logical value. By default, |
The characteristic function of the additive game given by is defined for each by .
The characteristic function of the associated additive game, as a vector in binary order if binary=TRUE and in lexicographic order otherwise.
additivecheck, strategicallyequivalentcheck, superadditivecheck
a <- c(1,5,10,13,58) additivegame(a, binary = FALSE)a <- c(1,5,10,13,58) additivegame(a, binary = FALSE)
Given an airfield problem, this function returns the associated airfield game.
airfieldgame(c, binary = FALSE)airfieldgame(c, binary = FALSE)
c |
A vector of costs defining the airfield problem. |
binary |
A logical value. By default, |
Let denote a set of agents, and let be a cost vector.
Each represents the cost of the service required by agent .
Segmental costs are defined as the difference between a given cost and the first immediately lower cost: for .
Each defines an airfield problem, which is associated to an airfield game , is defined by
Airfield games, as defined, are cost games, but they can also be expressed as savings games. Additional tools and methods for addressing airfield problems are available in the AirportProblems package Bernárdez Ferradás et al. (2025).
The characteristic function of the airfield game, as a vector in binary order if binary=TRUE and in lexicographic order otherwise.
Bernárdez Ferradás, A., Sánchez Rodríguez, E., Mirás Calvo, M., & Quinteiro Sandomingo, C. (2025). AirportProblems: Analysis of Cost Allocation for Airport Problems. R package version 0.1.0. https://CRAN.R-project.org/package=AirportProblems
Littlechild, S.C., & Owen, G. (1973). A Simple Expression for the Shapely Value in a Special Case. Management Science, 23, 370-372.
c <- c(2000,3200,4100,5100) airfieldgame(c,binary=TRUE)c <- c(2000,3200,4100,5100) airfieldgame(c,binary=TRUE)
This function checks if the given game is balanced and computes its balanced cover.
balancedcheck(v, game = FALSE, binary = FALSE, tol = 100 * .Machine$double.eps)balancedcheck(v, game = FALSE, binary = FALSE, tol = 100 * .Machine$double.eps)
v |
A characteristic function, as a vector. |
game |
A logical value. By default, |
binary |
A logical value. By default, |
tol |
A tolerance parameter, as a non-negative number. |
Let . A family of non-empty coalitions of
is balanced if there exists a weight family such that
for each and ,
being the characteristic vector of , that is, the vector
in which if and if ).
The game is balanced if, for each balanced family , it is true that
The balanced cover of is the game defined by
for all and
being the set of the weight families associated with the balanced families of .
A game is balanced if and only if it coincides with its balanced cover. By the Bondareva-Shapley Theorem, a game has a non-empty core if and only if it is balanced.
TRUE if the game is balanced, FALSE otherwise. If game=TRUE, the balanced cover of the game is also returned.
Maschler, M., Solan, E., & Zamir, S. (2013). Game Theory. Cambridge University Press.
balancedcheck(c(12,10,20,20,50,70,70), game=TRUE) balancedcheck(c(rep(0,4), rep(30,6), rep(0,4), 50)) v <- runif(2^3-1,0,10) # random three-player game balancedcheck(v, game=TRUE) balancedcheck(balancedcheck(v, game=TRUE)$game) # balanced cover is indeed balanced balancedcheck(runif(2^(15)-1,min=10,max=20)) # random gamebalancedcheck(c(12,10,20,20,50,70,70), game=TRUE) balancedcheck(c(rep(0,4), rep(30,6), rep(0,4), 50)) v <- runif(2^3-1,0,10) # random three-player game balancedcheck(v, game=TRUE) balancedcheck(balancedcheck(v, game=TRUE)$game) # balanced cover is indeed balanced balancedcheck(runif(2^(15)-1,min=10,max=20)) # random game
This function checks if the given family is balanced.
balancedfamilycheck(Fam, n = NULL, tol = 100 * .Machine$double.eps)balancedfamilycheck(Fam, n = NULL, tol = 100 * .Machine$double.eps)
Fam |
A vector containing the binary order positions of a family of coalitions. |
n |
The number of players in the set of players from which |
tol |
A tolerance parameter, as a non-negative number. |
A family of non-empty coalitions of a set of players
is balanced if there exists a weight family such that
for each and ,
being the characteristic vector of , that is, the vector
in which if and if ).
A balanced family is said to be minimal if there does not exist
a balanced family such that .
This function returns three outputs: check, minimal and delta.
If Fam is not a balanced family: check=FALSE and both minimal and delta are NULL.
If Fam is a balanced family: check=TRUE, minimal=TRUE if Fam is minimal (minimal=FALSE otherwise), and delta returns an associated weight family.
Maschler, M., Solan, E., & Zamir, S. (2013). Game Theory. Cambridge University Press.
balancedcheck, kohlbergcriterion, totallybalancedcheck
balancedfamilycheck(c(3,6,13,8)) # balanced and minimal balancedfamilycheck(c(3,5,9,4,8,14)) # balanced but not minimal balancedfamilycheck(c(1,2,4,12,13)) # not balancedbalancedfamilycheck(c(3,6,13,8)) # balanced and minimal balancedfamilycheck(c(3,5,9,4,8,14)) # balanced but not minimal balancedfamilycheck(c(1,2,4,12,13)) # not balanced
This function checks if an allocation belongs to the core of a game.
belong2corecheck(v, binary = FALSE, x, instance = FALSE)belong2corecheck(v, binary = FALSE, x, instance = FALSE)
v |
A characteristic function, as a vector. |
binary |
A logical value. By default, |
x |
An allocation, as a vector. |
instance |
A logical value. By default, |
The core of a game is the set of all its stable imputations:
where .
TRUE if x belongs to the core of v, FALSE otherwise. If instance=TRUE and x does not belong to the core of v, a justification is also provided: if efficiency is violated, not efficient is returned; if efficiency is not violated, the position (binary order position if binary=TRUE; lexicographic order position otherwise) of a coalition for which rationality is violated is returned.
Gillies, D. (1953). Some theorems on n-person games. PhD thesis, Princeton, University Press Princeton, New Jersey.
v <- c(0, 0, 0, 2, 1, 4, 6) a <- c(3, 1, 2) # an allocation for v b <- c(2, 2, 2) # egalitarian solution for v belong2corecheck(v = v, binary = TRUE, x = a, instance = TRUE) belong2corecheck(v = v, binary = FALSE, x = b, instance = TRUE) # What if the game is a cost game? cost.v <- c(2,2,2,3,4,4,5) # cost game cost.x <- c(1,2,2) # core allocation of cost.v belong2corecheck(v = -cost.v, x = -cost.x)v <- c(0, 0, 0, 2, 1, 4, 6) a <- c(3, 1, 2) # an allocation for v b <- c(2, 2, 2) # egalitarian solution for v belong2corecheck(v = v, binary = TRUE, x = a, instance = TRUE) belong2corecheck(v = v, binary = FALSE, x = b, instance = TRUE) # What if the game is a cost game? cost.v <- c(2,2,2,3,4,4,5) # cost game cost.x <- c(1,2,2) # core allocation of cost.v belong2corecheck(v = -cost.v, x = -cost.x)
Given a characteristic function in binary order, this function returns the characteristic function in lexicographic order.
bin2lex(v)bin2lex(v)
v |
A characteristic function, as a vector in binary order. |
The binary order position of a coalition is given by . Lexicographic order arranges coalitions in ascending order according to size, and applies lexicographic order to break ties among coalitions of the same size.
The characteristic function, as a vector in lexicographic order.
codebin2lex, codelex2bin, lex2bin
v <- seq(1:31) bin2lex(v) lex2bin(bin2lex(v))==vv <- seq(1:31) bin2lex(v) lex2bin(bin2lex(v))==v
Given a claims problem, this function returns the associated pessimistic claims game.
claimsgame(E, d, binary = FALSE)claimsgame(E, d, binary = FALSE)
E |
An endowment, as a positive number. |
d |
A vector of claims. |
binary |
A logical value. By default, |
A claims problem is a triple where is an amount to be distributed among a set of agents and is a vector of claims satisfying .
Given a claims problem , its associated claims game, , is defined by
For further analysis and computational methods related to conflicting claims problems, see the ClaimsProblems package Sánchez Rodríguez et al. (2025).
The characteristic function of the pessimistic claims game, as a vector in binary order if binary=TRUE and in lexicographic order otherwise.
O’Neill, B. (1982). A problem of rights arbitration from the Talmud. Mathematical Social Sciences, 2, 345–371.
Sánchez Rodríguez, E., Núñez Lugilde, I., Mirás Calvo, M., & Quinteiro Sandomingo, C. (2025). ClaimsProblems: Analysis of Conflicting Claims. R package version 1.0.0.
https://CRAN.R-project.org/package=ClaimsProblems
E <- 10 d <- c(2,4,7,8) claimsgame(E,d)E <- 10 d <- c(2,4,7,8) claimsgame(E,d)
Given a game and a weight family, this function returns the coalition-weighted Shapley value.
coalitionweightedshapleyvalue(v, delta, binary = FALSE, game = FALSE)coalitionweightedshapleyvalue(v, delta, binary = FALSE, game = FALSE)
v |
A characteristic function, as a vector. |
delta |
A weight family. It can be introduced in two different ways: as a non-negative vector whose length is the number of coalitions (thus specifying all coalition weights) or as a non-negative vector whose length is the number of players (thus specifying the weights of single-player coalitions and implying that the rest of weights are 0). In any case, if the introduced weights do not add up to 1, the weight family is computed by normalization. |
binary |
A logical value. By default, |
game |
A logical value. By default, |
A weight family is a collection of real numbers such that for each and .
For each and each , the T-marginal game of , denoted , is defined as
For each game and each weight family , the -weighted game is defined as
Given a game , its -weighted Shapley value, , is the Shapley value of the -weighted game:
The coalition-weighted Shapley value, as a vector. If game=TRUE, the coalition-weighted game is also returned, as a vector in binary order if binary=TRUE and in lexicographic order otherwise.
Sánchez Rodríguez, E., Mirás Calvo, M. A., Quinteiro Sandomingo, C., & Núñez Lugilde, I. (2024). Coalition-weighted Shapley values. International Journal of Game Theory, 53, 547-577.
marginalgame, shapleyvalue, weightedshapleyvalue
v <- c(0,0,0,0,0,0,1,0,0,1,3,4,6,8,10) delta <- c(0.3,0.1,0,0.6,0,0,0,0,0,0,0,0,0,0,0) coalitionweightedshapleyvalue(v, delta, binary=TRUE) v <- c(0,0,0,0,0,0,0,0,1,4,1,3,6,8,10) delta <- c(0.25,0.25,0.25,0.25) a <- coalitionweightedshapleyvalue(v, delta, game=TRUE) b <- coalitionweightedshapleyvalue(a$game, delta, game=TRUE) c <- coalitionweightedshapleyvalue(b$game, delta, game=TRUE) plotcoresets(rbind(v, a$game, b$game, c$game), imputations=FALSE) # Games a, b and c have the same Shapley value: all(sapply(list(a$value, b$value, c$value, shapleyvalue(v)), function(x) all.equal(x, a$value) == TRUE))v <- c(0,0,0,0,0,0,1,0,0,1,3,4,6,8,10) delta <- c(0.3,0.1,0,0.6,0,0,0,0,0,0,0,0,0,0,0) coalitionweightedshapleyvalue(v, delta, binary=TRUE) v <- c(0,0,0,0,0,0,0,0,1,4,1,3,6,8,10) delta <- c(0.25,0.25,0.25,0.25) a <- coalitionweightedshapleyvalue(v, delta, game=TRUE) b <- coalitionweightedshapleyvalue(a$game, delta, game=TRUE) c <- coalitionweightedshapleyvalue(b$game, delta, game=TRUE) plotcoresets(rbind(v, a$game, b$game, c$game), imputations=FALSE) # Games a, b and c have the same Shapley value: all(sapply(list(a$value, b$value, c$value, shapleyvalue(v)), function(x) all.equal(x, a$value) == TRUE))
Given the binary order position of a coalition, this function returns the corresponding lexicographic order position.
codebin2lex(n, Nbin)codebin2lex(n, Nbin)
n |
Number of players, as an integer. |
Nbin |
A binary order position, as an integer between 1 and |
The binary order position of a coalition is given by . Lexicographic order arranges coalitions in ascending order according to size, and applies lexicographic order to break ties among coalitions of the same size.
The corresponding lexicographic order position, as an integer between 1 and .
codebin2lex(5, 4)codebin2lex(5, 4)
Given the lexicographic order position of a coalition, this function returns the corresponding binary order position.
codelex2bin(n, Nlex)codelex2bin(n, Nlex)
n |
Number of players. |
Nlex |
A lexicographic order position, as an integer between 1 and |
Lexicographic order arranges coalitions in ascending order according to size, and applies lexicographic order to break ties among coalitions of the same size. The binary order position of a coalition is given by .
The corresponding binary order position, as an integer between 1 and .
codelex2bin(5, 4)codelex2bin(5, 4)
This function checks if the given game is compromise-admissible.
compromiseadmissiblecheck(v, binary = FALSE, instance = FALSE)compromiseadmissiblecheck(v, binary = FALSE, instance = FALSE)
v |
A characteristic function, as a vector. |
binary |
A logical value. By default, |
instance |
A logical value. By default, |
Let .
The utopia payoff of player is defined as .
The minimal right of player is defined as .
The game is said to be compromise-admissible if its core-cover is not empty, that is, if the following conditions hold:
1) .
2) .
TRUE if the game is compromise-admissible, FALSE otherwise. If instance=TRUE and , one of the players in that set is also returned.
compromiseadmissiblecheck(c(0,0,0,0,10,40,30,60,10,20,90,90,90,130,160)) compromiseadmissiblecheck(c(1,2,2), instance=TRUE) # What if the game is a cost game? cost.v <- c(30, 20, 50, 40, 60, 60, 75) # compromise-admissible cost game compromiseadmissiblecheck(-c(30, 20, 50, 40, 60, 60, 75))compromiseadmissiblecheck(c(0,0,0,0,10,40,30,60,10,20,90,90,90,130,160)) compromiseadmissiblecheck(c(1,2,2), instance=TRUE) # What if the game is a cost game? cost.v <- c(30, 20, 50, 40, 60, 60, 75) # compromise-admissible cost game compromiseadmissiblecheck(-c(30, 20, 50, 40, 60, 60, 75))
This function computes the characteristic function of the specified constant sum game.
constantsumgame(halfv, vN)constantsumgame(halfv, vN)
halfv |
The first half (according to lexicographic or binary order) of the characteristic function (excluding the grand coalition), as a vector. |
vN |
The utility of the grand coalition. |
A game is a constant sum game if, for each ,
. Thus, if is a constant sum game and is
a family of coalitions such that for any ,
the full characteristic function of is strictly determined by the utilities of
the coalitions in and the utility of the grand coalition.
The characteristic function of the constant sum game. It is to be interpreted according to the order that halfv is introduced in.
constantsumgame(c(0,0,0), 1) # the dollar game # Building a random constant sum game: players <- sample(3:6,1) # random number of players between three and six halfv <- runif(2^(players-1)-1, 0, 10) # random halfv vN <- runif(1,30,50) # random vN constantsumgame(halfv, vN)constantsumgame(c(0,0,0), 1) # the dollar game # Building a random constant sum game: players <- sample(3:6,1) # random number of players between three and six halfv <- runif(2^(players-1)-1, 0, 10) # random halfv vN <- runif(1,30,50) # random vN constantsumgame(halfv, vN)
This function checks if the given game is convex.
convexcheck(v, binary = FALSE, instance = FALSE)convexcheck(v, binary = FALSE, instance = FALSE)
v |
A characteristic function, as a vector. |
binary |
A logical value. By default, |
instance |
A logical value. By default, |
A game is convex if for all
. Zumsteg, S. (1995) shows that is convex if for all
and such that .
A game is concave if is convex.
TRUE if the game is convex, FALSE otherwise. If instance=TRUE and the game is not convex, the function also returns the positions (binary order positions if binary=TRUE; lexicographic order positions otherwise) of a pair of coalitions violating the Zumsteg convexity characterization.
Zumsteg, S. (1995). Non-cooperative aspects of cooperative game theory and related computational problems. PhD thesis, ETH Zurich.
strategicallyequivalentcheck, superadditivecheck
v1 <- c(5, 2, 2, 1, 8, 8, 6, 4, 3, 3, 12, 10, 10, 6, 14) convexcheck(v1) v2 <- c(0, 0, 0, 2, 2, 1, 3) convexcheck(v2, binary = FALSE, instance = TRUE) # How to check if a game is concave: v.conc <- c(4, 3, 3, 2, 6, 6, 5, 5, 4, 4, 7, 6, 6, 6, 7) # concave game convexcheck(-v.conc)v1 <- c(5, 2, 2, 1, 8, 8, 6, 4, 3, 3, 12, 10, 10, 6, 14) convexcheck(v1) v2 <- c(0, 0, 0, 2, 2, 1, 3) convexcheck(v2, binary = FALSE, instance = TRUE) # How to check if a game is concave: v.conc <- c(4, 3, 3, 2, 6, 6, 5, 5, 4, 4, 7, 6, 6, 6, 7) # concave game convexcheck(-v.conc)
Given a game with a full-dimensional core, this function computes a hit-and-run estimation of its core center.
corecenterhitrun(v, k = 1000, getpoints = FALSE, binary = FALSE)corecenterhitrun(v, k = 1000, getpoints = FALSE, binary = FALSE)
v |
A characteristic function of a game with, as a vector. |
k |
The number of points to be generated by the hit-and-run method, as an integer. By default, |
getpoints |
A logical value. By default, |
binary |
A logical value. By default, |
The core of a game is the set of all its stable imputations:
where . A game is said to be balanced if its core is not empty.
The core-center of a balanced game , , is defined as the expectation
of the uniform distribution over , and thus can be interpreted
as the centroid or center of gravity of .
Let be the -dimensional Lebesgue measure and let
be the volume (measure) of the core. If , then, for each ,
.
The hit-and-run method (Smith, 1984) is a Monte Carlo algorithm that generates uniformly distributed random points within a bounded and convex region, such as a polytope or a convex body in high-dimensional space.
The hit-and-run method is based on the following process. Step 0: choose a point inside the convex body. Step 1: choose a uniformly distributed random direction from the unit sphere in the given dimension. Step 2: determine the longest line segment that, starting from the chosen point and taking the chosen direction, remains entirely within the convex body. Step 3: choose a uniformly distributed along the line segment random point. Step 4: go to Step 1.
A hit-and-run estimation of the core-center, as a vector; and, if getpoints=TRUE, a matrix containing the points generated by the hit-and-run method.
Gonzalez-Díaz, J. & Sánchez-Rodríguez, E. (2007). A natural selection from the core of a TU game: the core-center. International Journal of Game Theory, 36(1), 27-46.
Espinoza-Burgos, N. H. (2020). Comparación de métodos exactos y aproximados para calcular el core-center del juego del aeropuerto. TFM, Máster en Técnicas Estadísticas, http://eio.usc.es/pub/mte/descargas/ProyectosFinMaster/Proyecto_1791.pdf.
Smith, R. L. (1984). Efficient Monte Carlo Procedures for Generating Points Uniformly Distributed Over Bounded Regions. Operations Research, 32(6), 1296-1308.
balancedcheck, corecentervalue, coredimension, corevertices, corevertices234
v1 <- claimsgame(E=8,d=c(3,5,6)) corecenterhitrun(v1,k=1e5) v2 <- c(0,0,0,0,0,0,0,0,1,4,1,3,6,8,10) corecenterhitrun(v2,k=1e5) # Plotting the corecenter and its hit-and-run estimation: plotcoreset(v2,solutions="corecenter",allocations=corecenterhitrun(v2)) # Plotting the points generated by the hit-and-run method: hrpoints <- corecenterhitrun(v2,k=100,getpoints=TRUE)$points plotcoreset(v2,allocations=hrpoints) # What if the game is not full-dimensional because of a dummy player? v3 <- c(440,0,0,0,440,440,440,15,14,7,455,454,447,60,500) # For coredimension to detect that, tolerance has to be appropriate: coredimension(v3,tol=100*.Machine$double.eps) # tolerance too small coredimension(v3) # default tolerance, 1e-12, big enough # Now how to compute the hit-and-run estimation of the core-center? # Knowing that player 1 is a dummy and that the core-center assigns # dummies their individual worth... v3.without1 <- subgame(v3,S=14) # subgame without player 1 ( cc.hr <- c(v3[1],corecenterhitrun(v3.without1,k=100)) ) # Plotting the points when there is a dummy player: points.without1 <- corecenterhitrun(v3.without1,k=100,getpoints=TRUE)$points points.with1 <- cbind(v3[1],points.without1) plotcoreset(v3,allocations=points.with1) # This function does not work if the core is not full-dimensional: v4 <- c(0,0,0,0,2,5,0,5,0,0,10,2,5,5,10) corecenterhitrun(v4,k=1e5)v1 <- claimsgame(E=8,d=c(3,5,6)) corecenterhitrun(v1,k=1e5) v2 <- c(0,0,0,0,0,0,0,0,1,4,1,3,6,8,10) corecenterhitrun(v2,k=1e5) # Plotting the corecenter and its hit-and-run estimation: plotcoreset(v2,solutions="corecenter",allocations=corecenterhitrun(v2)) # Plotting the points generated by the hit-and-run method: hrpoints <- corecenterhitrun(v2,k=100,getpoints=TRUE)$points plotcoreset(v2,allocations=hrpoints) # What if the game is not full-dimensional because of a dummy player? v3 <- c(440,0,0,0,440,440,440,15,14,7,455,454,447,60,500) # For coredimension to detect that, tolerance has to be appropriate: coredimension(v3,tol=100*.Machine$double.eps) # tolerance too small coredimension(v3) # default tolerance, 1e-12, big enough # Now how to compute the hit-and-run estimation of the core-center? # Knowing that player 1 is a dummy and that the core-center assigns # dummies their individual worth... v3.without1 <- subgame(v3,S=14) # subgame without player 1 ( cc.hr <- c(v3[1],corecenterhitrun(v3.without1,k=100)) ) # Plotting the points when there is a dummy player: points.without1 <- corecenterhitrun(v3.without1,k=100,getpoints=TRUE)$points points.with1 <- cbind(v3[1],points.without1) plotcoreset(v3,allocations=points.with1) # This function does not work if the core is not full-dimensional: v4 <- c(0,0,0,0,2,5,0,5,0,0,10,2,5,5,10) corecenterhitrun(v4,k=1e5)
Given a game, this function computes its core center.
corecentervalue(v, binary = FALSE, tol = 1e-12)corecentervalue(v, binary = FALSE, tol = 1e-12)
v |
A characteristic function, as a vector. |
binary |
A logical value. By default, |
tol |
A tolerance parameter, as a non-negative number. By default, |
The core of a game is the set of all its stable imputations:
where . A game is said to be balanced if its core is not empty.
The core-center of a balanced game , , is defined as the expectation
of the uniform distribution over , and thus can be interpreted
as the centroid or center of gravity of .
Let be the -dimensional Lebesgue measure and let
be the volume (measure) of the core. If , then, for each ,
.
The core-center, as a vector.
Gonzalez-Díaz, J. & Sánchez-Rodríguez, E. (2007). A natural selection from the core of a TU game: the core-center. International Journal of Game Theory, 36(1), 27-46.
balancedcheck, corecenterhitrun, coredimension, corevertices, corevertices234
v1 <- claimsgame(E=8,d=c(3,5,6)) corecentervalue(v1) plotcoreset(v1,solutions="corecenter") v2 <- c(0,0,0,0,0,0,0,0,1,4,1,3,6,8,10) corecentervalue(v2) plotcoreset(v2,solutions="corecenter") # What if the game is not full-dimensional because of a dummy player? v3 <- c(440,0,0,0,440,440,440,15,14,7,455,454,447,60,500) dummynull(v3) # player 1 is a dummy in v3, so the core is degenerate # For coredimension to detect that, tolerance has to be appropriate: coredimension(v=v3,tol=100*.Machine$double.eps) # tolerance too small coredimension(v=v3) # default tolerance, 1e-12, big enough # Now how to compute the corecenter? # When given a degenerate game, corecentervalue computes an approximation: ( cc.approx <- corecentervalue(v=v3) ) # approximate core-center # However, knowing that player 1 is a dummy and that the core-center assigns # dummies their individual worth... v3.without1 <- subgame(v=v3,S=14) # subgame without player 1 ( cc.exact <- c(v3[1],corecentervalue(v3.without1)) ) # "exact" core-center # Plotting both results: plotcoreset(v3,allocations=rbind(cc.approx,cc.exact),projected=TRUE)v1 <- claimsgame(E=8,d=c(3,5,6)) corecentervalue(v1) plotcoreset(v1,solutions="corecenter") v2 <- c(0,0,0,0,0,0,0,0,1,4,1,3,6,8,10) corecentervalue(v2) plotcoreset(v2,solutions="corecenter") # What if the game is not full-dimensional because of a dummy player? v3 <- c(440,0,0,0,440,440,440,15,14,7,455,454,447,60,500) dummynull(v3) # player 1 is a dummy in v3, so the core is degenerate # For coredimension to detect that, tolerance has to be appropriate: coredimension(v=v3,tol=100*.Machine$double.eps) # tolerance too small coredimension(v=v3) # default tolerance, 1e-12, big enough # Now how to compute the corecenter? # When given a degenerate game, corecentervalue computes an approximation: ( cc.approx <- corecentervalue(v=v3) ) # approximate core-center # However, knowing that player 1 is a dummy and that the core-center assigns # dummies their individual worth... v3.without1 <- subgame(v=v3,S=14) # subgame without player 1 ( cc.exact <- c(v3[1],corecentervalue(v3.without1)) ) # "exact" core-center # Plotting both results: plotcoreset(v3,allocations=rbind(cc.approx,cc.exact),projected=TRUE)
Given a game, this function computes the dimension of its core.
coredimension(v, binary = FALSE, tol = 1e-12)coredimension(v, binary = FALSE, tol = 1e-12)
v |
A characteristic function, as a vector. |
binary |
A logical value. By default, |
tol |
A tolerance parameter, as a non-negative number. |
The core of a game is the set of all its stable imputations:
where .
The dimension of the core of v, as an integer.
Edgeworth, F. Y. (1881). Mathematical psychics: An essay on the application of mathematics to the moral sciences. CK Paul.
Gillies, D. (1953). Some theorems on n-person games. PhD thesis, Princeton, University Press Princeton, New Jersey.
balancedcheck, corevertices, corevertices234, plotcoreset, plotcoresets
v1 <- c(rep(0,5),rep(1,4),0,rep(1,3),2,2) plotcoreset(v1) coredimension(v1) v2 <- c(rep(0,5),rep(1,4),0,rep(1,4),2) plotcoreset(v2) coredimension(v2) v3 <- marginalgame(c(0,0,0,0,0,0,0,0,1,4,1,3,6,8,10),1) plotcoreset(v3) coredimension(v3) v4 <- c(0,0,0,0,0,0,0,0,1,4,1,3,6,8,10) plotcoreset(v4) coredimension(v4)v1 <- c(rep(0,5),rep(1,4),0,rep(1,3),2,2) plotcoreset(v1) coredimension(v1) v2 <- c(rep(0,5),rep(1,4),0,rep(1,4),2) plotcoreset(v2) coredimension(v2) v3 <- marginalgame(c(0,0,0,0,0,0,0,0,1,4,1,3,6,8,10),1) plotcoreset(v3) coredimension(v3) v4 <- c(0,0,0,0,0,0,0,0,1,4,1,3,6,8,10) plotcoreset(v4) coredimension(v4)
Given a game, this function computes its core vertices.
corevertices(v, binary = FALSE)corevertices(v, binary = FALSE)
v |
A characteristic function, as a vector. |
binary |
A logical value. By default, |
The core of a game is the set of all its stable imputations:
where .
If the core of v is non-empty, the core vertices are returned, as a matrix in which each row is a vertex.
Function corevertices234 can also compute the core vertices of games with less than five players, but takes a different approach.
Edgeworth, F. Y. (1881). Mathematical psychics: An essay on the application of mathematics to the moral sciences. CK Paul.
Gillies, D. (1953). Some theorems on n-person games. PhD thesis, Princeton, University Press Princeton, New Jersey.
balancedcheck, corevertices234, plotcoreset, plotcoresets
v=c(0,0,0,0,0,0,0,0,1,4,1,3,6,8,10) corevertices(v) # What if the game is a cost game? cost.v <- c(2,2,2,3,4,4,5) # cost game -corevertices(-cost.v) # core vertices of the cost gamev=c(0,0,0,0,0,0,0,0,1,4,1,3,6,8,10) corevertices(v) # What if the game is a cost game? cost.v <- c(2,2,2,3,4,4,5) # cost game -corevertices(-cost.v) # core vertices of the cost game
Given a game with no more than four players, this function computes its core vertices.
corevertices234(v, binary = FALSE)corevertices234(v, binary = FALSE)
v |
A characteristic function, as a vector. |
binary |
A logical value. By default, |
The core of a game is the set of all its stable imputations:
where .
If the core of v is non-empty, the core vertices are returned, as a matrix in which each row is a vertex.
Function corevertices can also compute the core vertices of games with less than five players, but takes a different approach.
balancedcheck, corevertices, plotcoreset,
# 2 players: corevertices234(c(-58,4,13)) # 3 players: corevertices234(c(1,5,10,6,11,15,16)) # additive game # 4 players: corevertices234(c(0,0,0,0,4,3,5,2,4,5,10,19,20,30,100)) # convex game corevertices234(c(0,0,0,0,1,2,1,1,1,1,4,3,2,1,7)) # not convex game # What if the game is a cost game? cost.v <- c(2,2,2,3,4,4,5) # cost game -corevertices234(-cost.v) # core vertices of the cost game# 2 players: corevertices234(c(-58,4,13)) # 3 players: corevertices234(c(1,5,10,6,11,15,16)) # additive game # 4 players: corevertices234(c(0,0,0,0,4,3,5,2,4,5,10,19,20,30,100)) # convex game corevertices234(c(0,0,0,0,1,2,1,1,1,1,4,3,2,1,7)) # not convex game # What if the game is a cost game? cost.v <- c(2,2,2,3,4,4,5) # cost game -corevertices234(-cost.v) # core vertices of the cost game
This function checks if the given game is degenerate.
degeneratecheck(v, binary = FALSE)degeneratecheck(v, binary = FALSE)
v |
A characteristic function, as a vector. |
binary |
A logical value. By default, |
A game is degenerate if .
TRUE if the game is degenerate, FALSE otherwise.
v <- c(1, 5, 10, 0, 0, 0, 16) degeneratecheck(v) w <- c(1, 5, 10, 0, 0, 0, 15) degeneratecheck(w)v <- c(1, 5, 10, 0, 0, 0, 16) degeneratecheck(v) w <- c(1, 5, 10, 0, 0, 0, 15) degeneratecheck(w)
Given the characteristic function of a game, this function returns the characteristic function of the dual game.
dualgame(v)dualgame(v)
v |
A characteristic function, as a vector. |
The dual game of is defined by for all .
The characteristic function of the dual game. It is to be interpreted according to the order that v is introduced in.
v <- c(rep(0,4),rep(5,6),rep(20,4),40) dualgame(v) v <- seq(1:31) dualgame(v) dualgame(dualgame(v)) == vv <- c(rep(0,4),rep(5,6),rep(20,4),40) dualgame(v) v <- seq(1:31) dualgame(v) dualgame(dualgame(v)) == v
Given a game, this function identifies its dummy players and null players.
dummynull(v, binary = FALSE, tol = 100 * .Machine$double.eps)dummynull(v, binary = FALSE, tol = 100 * .Machine$double.eps)
v |
A characteristic function, as a vector. |
binary |
A logical value. By default, |
tol |
A tolerance parameter, as a non-negative number. |
Given a game , is said to be a dummy player
if for all .
A dummy player is said to be a null player if .
Two different vectors are returned: one containing the dummy players and the other containing the null players.
v <- c(0,1,0,1,0,1,1) dummynull(v) # Checking if a particular player is a dummy player: 2 %in% dummynull(v)$dummy # player 2 is a dummy player in v 2 %in% dummynull(v)$null # player 2 is not a null player in vv <- c(0,1,0,1,0,1,1) dummynull(v) # Checking if a particular player is a dummy player: 2 %in% dummynull(v)$dummy # player 2 is a dummy player in v 2 %in% dummynull(v)$null # player 2 is not a null player in v
This function checks if the given game is essential.
essentialcheck(v, binary = FALSE)essentialcheck(v, binary = FALSE)
v |
A characteristic function, as a vector. |
binary |
A logical value. By default, |
A game is essential if its set of imputations is non-empty, that is,
if .
TRUE if the game is essential, FALSE otherwise.
v <- c(0, 0, 0, 2, 3, 4, 1) essentialcheck(v, binary = TRUE) essentialcheck(v, binary = FALSE) # What if the game is a cost game? cost.v <- c(2,2,2,3,4,4,5) # essential cost game essentialcheck(-cost.v)v <- c(0, 0, 0, 2, 3, 4, 1) essentialcheck(v, binary = TRUE) essentialcheck(v, binary = FALSE) # What if the game is a cost game? cost.v <- c(2,2,2,3,4,4,5) # essential cost game essentialcheck(-cost.v)
Given a game and an allocation, this function computes the excess of each coalition.
excesses(v, binary = FALSE, x)excesses(v, binary = FALSE, x)
v |
A characteristic function, as a vector. |
binary |
A logical value. By default, |
x |
An allocation, as a vector. |
Given a game and an allocation , the excess of coalition
with respect to is defined as , where .
The excesses of all coalitions, as a vector in binary order if binary=TRUE and in lexicographic order otherwise.
nucleolusvalue, nucleoluspcvalue
excesses(v=c(0,0,3,0,3,8,6,0,6,9,15,8,16,17,20), binary=TRUE, x=c(8,7,2,3)) excesses(v=c(1,5,10,6,11,15,16), x=c(1,5,10)) <= 0 # core allocationexcesses(v=c(0,0,3,0,3,8,6,0,6,9,15,8,16,17,20), binary=TRUE, x=c(8,7,2,3)) excesses(v=c(1,5,10,6,11,15,16), x=c(1,5,10)) <= 0 # core allocation
This function returns the players that form the coalition whose binary order position coincides with the given integer.
getcoalition(num)getcoalition(num)
num |
A binary order position of a coalition, as an integer. |
A coalition can be represented by the -digit binary number in which if and otherwise. The binary order position of a coalition is given by .
The players that form the coalition whose binary order position is the given integer, as a vector.
codebin2lex, codelex2bin, getcoalitionnumber
num <- 5 getcoalition(num) n <- 4 for (i in 1:(2^n - 1)){ cat("[", i, "]", paste(getcoalition(i)),"\n") }num <- 5 getcoalition(num) n <- 4 for (i in 1:(2^n - 1)){ cat("[", i, "]", paste(getcoalition(i)),"\n") }
This function returns the binary order position of the coalition formed by the given players.
getcoalitionnumber(S)getcoalitionnumber(S)
S |
The players forming the coalition, as a vector. |
A coalition can be represented by the -digit binary number where if and otherwise. The binary order position of a coalition is given by .
The binary order position of the coalition formed by the given players.
codebin2lex, codelex2bin, getcoalition
N <- c(1:5) S <- c(1, 2, 3) getcoalitionnumber(S) n <- length(N) # number of players NS <- setdiff(N,S) # complementary coalition getcoalitionnumber(S) + getcoalitionnumber(NS) == 2^n - 1N <- c(1:5) S <- c(1, 2, 3) getcoalitionnumber(S) n <- length(N) # number of players NS <- setdiff(N,S) # complementary coalition getcoalitionnumber(S) + getcoalitionnumber(NS) == 2^n - 1
Given a number of players and a position, this function returns the permutation of players that occupies the given position when permutations are arranged according to the Lehmer code.
getpermutation(n, pos)getpermutation(n, pos)
n |
Number of players, as an integer. |
pos |
Position according to the Lehmer code, as an integer. |
The Lehmer code makes use of the fact that there are permutations of a sequence of numbers.
If a permutation is specified by the sequence , its Lehmer code is the
sequence , where .
The position of permutation according to the Lehmer code order is
.
The permutation of n players whose Lehmer code position is pos, as a vector.
getpermutation(4, 5) n <- 4 for (i in 1:factorial(n)) { cat("[", i, "]", paste(getpermutation(n,i)), "\n") }getpermutation(4, 5) n <- 4 for (i in 1:factorial(n)) { cat("[", i, "]", paste(getpermutation(n,i)), "\n") }
Given a permutation, this function returns its position in the Lehmer code order.
getpermutationnumber(permutation)getpermutationnumber(permutation)
permutation |
A permutation, as a vector. |
The Lehmer code makes use of the fact that there are permutations of a sequence of numbers.
If a permutation is specified by the sequence , its Lehmer code is the
sequence , where .
The position of permutation according to the Lehmer code order is
.
The position of the permutation according to the Lehmer code order, as an integer.
getpermutationnumber(c(1, 2, 5, 4, 3))getpermutationnumber(c(1, 2, 5, 4, 3))
This function computes the Harsanyi dividend of the given coalition in the given game.
harsanyidividend(v, S, binary = FALSE)harsanyidividend(v, S, binary = FALSE)
v |
A characteristic function, as a vector. |
S |
The position of a coalition, as an integer. |
binary |
A logical value. By default, |
The Harsanyi dividends of are the coordinates of the game in the base of unanimity games.
They are defined, for all , by
.
The Harsanyi dividend of the coalition that occupies the given position in the given order.
Hammer, P.J., Peled, U.N., & Sorensen, S. (1977). Pseudo-boolean function and game theory I. Core elements and Shapley value. Cahiers du Centre d'Etudes de Recherche Opérationnelle, 19, 156-176.
n <- 3 v <- c(1, 5, 10, 7, 11, 15, 16) # introduced in lexicographic order coalitionsvector<-character() dividendsvector<-numeric() for (i in 1:(2^n-1)){ coalitionsvector <- c(coalitionsvector, paste(getcoalition(i)[getcoalition(i) != 0],collapse = " ")) dividendsvector <- c(dividendsvector, harsanyidividend(v, codelex2bin(n,i), binary = FALSE)) } data.frame(Coalition = coalitionsvector, Dividend = dividendsvector) data.frame(Coalition = bin2lex(coalitionsvector), Dividend = bin2lex(dividendsvector))n <- 3 v <- c(1, 5, 10, 7, 11, 15, 16) # introduced in lexicographic order coalitionsvector<-character() dividendsvector<-numeric() for (i in 1:(2^n-1)){ coalitionsvector <- c(coalitionsvector, paste(getcoalition(i)[getcoalition(i) != 0],collapse = " ")) dividendsvector <- c(dividendsvector, harsanyidividend(v, codelex2bin(n,i), binary = FALSE)) } data.frame(Coalition = coalitionsvector, Dividend = dividendsvector) data.frame(Coalition = bin2lex(coalitionsvector), Dividend = bin2lex(dividendsvector))
This function applies the Kohlberg criterion to check if the given efficient allocation is the prenucleolus of the given game.
kohlbergcriterion(v, x, binary = FALSE, tol = 100 * .Machine$double.eps)kohlbergcriterion(v, x, binary = FALSE, tol = 100 * .Machine$double.eps)
v |
A characteristic function, as a vector. |
x |
An efficient allocation, as a vector. |
binary |
A logical value. By default, |
tol |
A tolerance parameter, as a non-negative number. |
Given and with ,
let be the number of different excesses in .
According to the Kohlberg criterion for the prenucleolus, is the prenucleolus of
if and only if, for each ,
is a balanced family, being the set of coalitions associated with the excess
that occupies position when excesses are arranged in decreasing order.
TRUE if x is the prenucleolus of v, FALSE otherwise.
Kohlberg, E. (1971). On the Nucleolus of a Characteristic Function Game. SIAM Journal on Applied Mathematics, 20(1), 62–66.
balancedfamilycheck, excesses, prenucleolusvalue
v <- c(0,0,0,0,10,40,30,60,10,20,90,90,90,130,160) x <- prenucleolusvalue(v) kohlbergcriterion(v, x) # x is the prenucleolus of v y <- prenucleolusvalue(v) + c(1,-1,0,0) kohlbergcriterion(v, y) # y is not the prenucleolus of v # If the game is 0-monotonic, its nucleolus coincides with its prenucleolus, # and therefore must pass the Kohlberg criterion for the prenucleolus: v4 <- c(-2,-2,-2,7,7,7,6) zeromonotoniccheck(v4) kohlbergcriterion(v4, nucleolusvalue(v4))v <- c(0,0,0,0,10,40,30,60,10,20,90,90,90,130,160) x <- prenucleolusvalue(v) kohlbergcriterion(v, x) # x is the prenucleolus of v y <- prenucleolusvalue(v) + c(1,-1,0,0) kohlbergcriterion(v, y) # y is not the prenucleolus of v # If the game is 0-monotonic, its nucleolus coincides with its prenucleolus, # and therefore must pass the Kohlberg criterion for the prenucleolus: v4 <- c(-2,-2,-2,7,7,7,6) zeromonotoniccheck(v4) kohlbergcriterion(v4, nucleolusvalue(v4))
Given a game, this function computes its least core.
leastcore(v, binary = FALSE, tol = 100 * .Machine$double.eps)leastcore(v, binary = FALSE, tol = 100 * .Machine$double.eps)
v |
A characteristic function, as a vector. |
binary |
A logical value. By default, |
tol |
A tolerance parameter, as a non-negative number. |
Given a game and a number , the -core of is defined as
where .
The least core of is defined as the intersection of all non-empty -cores of :
The implementation of this function is based on the algorithm presented in Derks and Kuipers (1997) and on the MATLAB package WCGT2005 by J. Derks.
This function returns four outputs:
t |
The excess value that defines the least core. |
sat |
The positions (binary order positions if |
x |
A least core allocation, as a vector. |
vt |
The game whose core is the least core of |
Derks, J. & Kuipers, J. (1997). Implementing the simplex method for computing the prenucleolus of transferable utility games.
Software by J. Derks (Copyright 2005 Universiteit Maastricht, dept. of Mathematics), available in package MatTuGames,
https://www.shorturl.at/i6aTF.
excesses, nucleoluspcvalue, nucleolusvalue, prenucleolusvalue
v <- c(0,0,0,0,10,40,30,60,10,20,90,90,90,130,160) ( vt <- leastcore(v)$vt ) # Plotting the core and the least core of v: plotcoresets(games = rbind(v,vt), imputations = FALSE) # What if the game is a cost game? cost.v <- c(2,2,2,3,4,4,5) # characteristic function of the cost game -leastcore(-cost.v)$t # the excess value that defines the least core of cost.v leastcore(-cost.v)$sat # the saturated coalitions -leastcore(-cost.v)$x # a least core allocation -leastcore(-cost.v)$vt # the cost game whose core is the least core of cost.vv <- c(0,0,0,0,10,40,30,60,10,20,90,90,90,130,160) ( vt <- leastcore(v)$vt ) # Plotting the core and the least core of v: plotcoresets(games = rbind(v,vt), imputations = FALSE) # What if the game is a cost game? cost.v <- c(2,2,2,3,4,4,5) # characteristic function of the cost game -leastcore(-cost.v)$t # the excess value that defines the least core of cost.v leastcore(-cost.v)$sat # the saturated coalitions -leastcore(-cost.v)$x # a least core allocation -leastcore(-cost.v)$vt # the cost game whose core is the least core of cost.v
Given a characteristic function in lexicographic order, this function returns the characteristic function in binary order.
lex2bin(v)lex2bin(v)
v |
A characteristic function, as a vector in lexicographic order. |
Lexicographic order arranges coalitions in ascending order according to size, and applies lexicographic order to break ties among coalitions of the same size. The binary order position of a coalition is given by .
The characteristic function, as a vector in binary order.
bin2lex, codebin2lex, codelex2bin
v <- seq(1:31) lex2bin(v) bin2lex(lex2bin(v))==vv <- seq(1:31) lex2bin(v) bin2lex(lex2bin(v))==v
Given two awards vectors, this function returns the Lorenz dominance relation between them.
lorenzdominancerelation(x, y)lorenzdominancerelation(x, y)
x |
A vector. |
y |
A vector. |
In order to compare two vectors through the Lorenz criterion,
both of them must be rearranged in non-decreasing order; thus, let and
be the vectors obtained by rearranging and , respectively, in non-decreasing order.
It is said that Lorenz-dominates (or that is Lorenz-dominated by )
if all the cumulative sums of are not less than those of .
That is, Lorenz-dominates if
and, for each ,
If Lorenz-dominates and Lorenz-dominates ,
then and are said to be Lorenz-equal.
If does not Lorenz-dominate and does not Lorenz-dominate ,
then and are not Lorenz-comparable.
There are four possible outputs:
-1 |
if the introduced vectors are not Lorenz-comparable. |
0 |
if the vectors are Lorenz-equal. |
1 |
if the vectors are not Lorenz-equal and the first one Lorenz-dominates the second one. |
2 |
if the vectors are not Lorenz-equal and the second one Lorenz-dominates the first one. |
Lorenz, M. O. (1905). Methods of Measuring the Concentration of Wealth. Publications of the American Statistical Association, 9(70), 209-219.
lorenzdominancerelation(c(1,2,3), c(1,1,4)) lorenzdominancerelation(c(1,2,7,2), c(1,1,4,6))lorenzdominancerelation(c(1,2,3), c(1,1,4)) lorenzdominancerelation(c(1,2,7,2), c(1,1,4,6))
Given a game and a coalition, this function returns the characteristic function of the corresponding marginal game.
marginalgame(v, S, binary = FALSE)marginalgame(v, S, binary = FALSE)
v |
Characteristic function, as a vector. |
S |
The position of a coalition, as an integer. |
binary |
A logical value. By default, |
Given a game and a coalition , the S-marginal game, ,
is defined by
The characteristic function of the S-marginal game, as a vector in binary order if binary=TRUE and in lexicographic order otherwise.
Sánchez Rodríguez, E., Mirás Calvo, M.A., Quinteiro Sandomingo, C., & Núñez Lugilde, I. (2024). Coalition-weighted Shapley values. International Journal of Game Theory 53, 547-577.
v <- c(0, 0, 0, 2, 3, 10, 20) marginalgame(v, 5, binary = TRUE) # coalition {1,3} n <- 3 for (i in 1:(2^n - 1)) { cat("[", i, "]", paste(marginalgame(lex2bin(v),codebin2lex(n,i),binary=TRUE)),"\n") } for (i in 1:(2^n - 1)) { cat("[", i, "]", paste(marginalgame(v,i)),"\n") }v <- c(0, 0, 0, 2, 3, 10, 20) marginalgame(v, 5, binary = TRUE) # coalition {1,3} n <- 3 for (i in 1:(2^n - 1)) { cat("[", i, "]", paste(marginalgame(lex2bin(v),codebin2lex(n,i),binary=TRUE)),"\n") } for (i in 1:(2^n - 1)) { cat("[", i, "]", paste(marginalgame(v,i)),"\n") }
Given a game and a permutation, this function returns the corresponding marginal contributions vector.
marginalvector(v, binary = FALSE, permutation)marginalvector(v, binary = FALSE, permutation)
v |
A characteristic function, as a vector. |
binary |
A logical value. By default, |
permutation |
Position of the permutation in the Lehmer code order, as an integer. |
Given a game and an order of the players in ,
the marginal contributions associated with order is defined, for all , as
, being .
The vector of marginal contributions.
getpermutation, getpermutationnumber
n <- 3 v <- c(1, 5, 10, 30, 60, 90, 200) for (i in 1:factorial(n)) { cat("[", i, "]", paste(getpermutation(3,i))," ", paste(marginalvector(v,binary=FALSE,i)), "\n") }n <- 3 v <- c(1, 5, 10, 30, 60, 90, 200) for (i in 1:factorial(n)) { cat("[", i, "]", paste(getpermutation(3,i))," ", paste(marginalvector(v,binary=FALSE,i)), "\n") }
This function computes the minimal rights vector of a game.
minimalrightsvector(v, binary = FALSE)minimalrightsvector(v, binary = FALSE)
v |
A characteristic function, as a vector. |
binary |
A logical value. By default, |
Given , the utopia payoff of player is defined as
.
The minimal right of player is defined as .
The minimal rights vector.
v <- c(0, 0, 0, 1, 1, 1, 2) minimalrightsvector(v) convexcheck(v) minimalrightsvector(v) == c(v[1],v[2],v[3]) w <- c(0,0,0,4,7,6,10) convexcheck(w) minimalrightsvector(w) == c(w[1],w[2],w[3])v <- c(0, 0, 0, 1, 1, 1, 2) minimalrightsvector(v) convexcheck(v) minimalrightsvector(v) == c(v[1],v[2],v[3]) w <- c(0,0,0,4,7,6,10) convexcheck(w) minimalrightsvector(w) == c(w[1],w[2],w[3])
This function checks if the given game is monotonic.
monotoniccheck(v, binary = FALSE, instance = FALSE)monotoniccheck(v, binary = FALSE, instance = FALSE)
v |
A characteristic function, as a vector. |
binary |
A logical value. By default, |
instance |
A logical value. By default, |
A game is monotonic if for all such that .
TRUE if the game is monotonic, FALSE otherwise. If instance=TRUE and the game is not monotonic, the function also returns the positions (binary order positions if binary=TRUE; lexicographic order positions otherwise) of a pair of coalitions violating monotonicity.
additivecheck, superadditivecheck, zeromonotoniccheck
v <- c(0, 0, 1, 5, 1, 1, 2) monotoniccheck(v, binary=FALSE, instance=TRUE)v <- c(0, 0, 1, 5, 1, 1, 2) monotoniccheck(v, binary=FALSE, instance=TRUE)
This function returns the characteristic function of the described museum pass game.
museumpassgame(V, p = rep(1, dim(V)[2]), binary = FALSE)museumpassgame(V, p = rep(1, dim(V)[2]), binary = FALSE)
V |
A matrix of zeros and ones where each row represents a museum and each column represents a visitor. If museum |
p |
A vector containing the price that each visitor pays for their pass. By default, it is a vector of ones. |
binary |
A logical value. By default, |
Let be a non-empty and finite set of museums and let be a non-empty and finite set of visitors.
The museum matrix, , specifies which museums are visited by which visitors: if and only if museum
is visited by visitor . The vector represents, for each visitor , the price they pay for their museum pass
(all passes are equal, in the sense that they grant access to the same set of museums, but the price may not be the same for all visitors).
The total revenue is to be divided among the museums. Given a museum pass situation , the museum pass game is defined by
where is the set of museums visited by .
The characteristic function of the museum pass game, as a vector in binary order if binary=TRUE and in lexicographic order otherwise.
Ginsburgh, V. & Zang, I. (2003). The museum pass game and its value. Games and economic behavior, 43(2), 322-325.
V <- rbind(c(1,0,1,1,0), c(0,1,1,1,0), c(1,1,0,0,1), c(1,0,1,0,1)) museumpassgame(V, p=c(1,1,4,5,8))V <- rbind(c(1,0,1,1,0), c(0,1,1,1,0), c(1,1,0,0,1), c(1,0,1,0,1)) museumpassgame(V, p=c(1,1,4,5,8))
Given a game and a communications network, this function computes the Myerson value.
myersonvalue(v, binary = FALSE, communications, game = FALSE)myersonvalue(v, binary = FALSE, communications, game = FALSE)
v |
A characteristic function, as a vector. |
binary |
A logical value. By default, |
communications |
An undirected communications network, as a list of vectors (their order being irrelevant), each containing two different players (their order being irrelevant). If two players are able to communicate with each other, a bidimensional vector containing them should be present in the list; otherwise, the vector should be absent. When |
game |
A logical value. By default, |
Let . Assuming that communication between players is necessary for their cooperation,
the game with restricted communication, , is defined by
if the players of S can communicate and otherwise, for each .
The Myerson value is the Shapley value of the game .
The corresponding Myerson value, as a vector.
Myerson, R. B. (1977). Graphs and cooperation in games. Mathematics of Operations Research, 2(3), 225-229.
v <- c(0,0,0,0,30,30,40,40,50,50,60,70,80,90,100) communications <- list(c(1,2), c(1,3), c(1,4)) myersonvalue(v, binary=FALSE, communications)v <- c(0,0,0,0,30,30,40,40,50,50,60,70,80,90,100) communications <- list(c(1,2), c(1,3), c(1,4)) myersonvalue(v, binary=FALSE, communications)
Given a game, this function returns the characteristic function of its 0-1-normalization, its 0-(-1) normalization or its 0-0 normalization, as appropriate.
normalizedgame(v, binary = FALSE)normalizedgame(v, binary = FALSE)
v |
A characteristic function, as a vector. |
binary |
A logical value. By default, |
A game is: 0-1 normalized if for all and ;
0-0 normalized if for all and ;
and 0-(-1) normalized if for all and .
If , the 0-1 normalized game of , , is defined by
for all .
If , the 0-(-1) normalized game of , , is defined by
for all .
If , the 0-0 normalized game of , , is defined by
for all .
The characteristic function of the 0-1-normalized game, the 0-(-1) normalized game or the 0-0 normalized game; as a vector in binary order if binary=TRUE and in lexicographic order otherwise.
strategicallyequivalentcheck, zeronormalizedcheck, zeronormalizedgame
v <- c(1, 5, 11, 6, 11, 15, 16) normalizedgame(v, binary = TRUE) w <- c(4, 3, 8, 16, 17, 18, 15) normalizedgame(w) z <- c(2,3,5,10,12,14,5) normalizedgame(z)v <- c(1, 5, 11, 6, 11, 15, 16) normalizedgame(v, binary = TRUE) w <- c(4, 3, 8, 16, 17, 18, 15) normalizedgame(w) z <- c(2,3,5,10,12,14,5) normalizedgame(z)
Given a game, this function computes its per capita nucleolus.
nucleoluspcvalue(v, binary = FALSE, tol = 100 * .Machine$double.eps)nucleoluspcvalue(v, binary = FALSE, tol = 100 * .Machine$double.eps)
v |
A characteristic function, as a vector. |
binary |
A logical value. By default, |
tol |
A tolerance parameter, as a non-negative number. |
Given a game and an allocation , the per capita excess
of each coalition with respect to is defined as
The per capita excesses of all non-empty coalitions, sorted in non-increasing order, are stored
in the per capita excesses vector, .
For any game with a non-empty set of imputations, the per capita nucleolus
is defined as the only imputation that satisfies
for each
and for all .
This function is programmed following the algorithm of Potters, J.A., et al. (1996).
The per capita nucleolus of the game, as a vector.
Grotte, J. (1970). Computation of and Observations on the Nucleolus, the Normalized Nucleolus and the Central Games. Master’s thesis), Cornell University, Ithaca.
Potters, J. A., Reijnierse, J. H., & Ansing, M. (1996). Computing the nucleolus by solving a prolonged simplex algorithm. Mathematics of Operations Research, 21(3), 757-768.
excesses, leastcore, nucleolusvalue, prenucleolusvalue
nucleoluspcvalue(c(1,5,10,6,11,15,16)) nucleoluspcvalue(c(0,0,0,30,30,80,100)) # Computing the per capita nucleolus of a random essential game: n <- 10 # number of players in the game v <- c(rep(0,n),runif(2^n-(n+1),min=10,max=20)) # random essential game nucleoluspcvalue(v) # What if the game is a cost game? cost.v <- airfieldgame(c(1,5,10,15)) # cost game -nucleoluspcvalue(-cost.v) # per capita nucleolus of the cost gamenucleoluspcvalue(c(1,5,10,6,11,15,16)) nucleoluspcvalue(c(0,0,0,30,30,80,100)) # Computing the per capita nucleolus of a random essential game: n <- 10 # number of players in the game v <- c(rep(0,n),runif(2^n-(n+1),min=10,max=20)) # random essential game nucleoluspcvalue(v) # What if the game is a cost game? cost.v <- airfieldgame(c(1,5,10,15)) # cost game -nucleoluspcvalue(-cost.v) # per capita nucleolus of the cost game
Given a game, this function computes its nucleolus.
nucleolusvalue(v, binary = FALSE, tol = 100 * .Machine$double.eps)nucleolusvalue(v, binary = FALSE, tol = 100 * .Machine$double.eps)
v |
A characteristic function, as a vector. |
binary |
A logical value. By default, |
tol |
A tolerance parameter, as a non-negative number. |
Given a game and an allocation ,
the excess of coalition with respect to is defined as , where .
By sorting the excesses of all coalitions in non-increasing order, a -tuple of complaints, denoted by , is obtained.
Thus, for all with .
The nucleolus can be computed through the following process.
First, consider only the imputations that would minimize the first complaint, that is,
find the set .
Then, among those imputations, consider only those that would minimize the second complaint, that is,
find the set .
Repeat the same operation with successive complaints. Eventually, a set is reached. This is the nucleolus.
If is essential, the nucleolus exists and comprises a single imputation:
the only imputation that satisfies (lexicographically) for all .
If the core of is not empty, the nucleolus belongs to it.
This function is programmed following the algorithm of Potters, J.A., et al. (1996).
The nucleolus of the game, as a vector.
Potters, J. A., Reijnierse, J. H., & Ansing, M. (1996). Computing the nucleolus by solving a prolonged simplex algorithm. Mathematics of Operations Research, 21(3), 757-768.
Schmeidler, D. (1969). The nucleolus of a characteristic function game. SIAM Journal on Applied Mathematics, 17(6), 1163-1170.
excesses, leastcore, nucleoluspcvalue, prenucleolusvalue
v1 <- c(0,0,3,0,3,8,6,0,6,9,15,8,16,17,20) nucleolusvalue(v1,binary=TRUE) v2 <- c(0,0,0.7,0,0.4925,0.68,0.83,0,0.56,0.74,0.64,0.46,0.55,0.57,0.61,0, 0.35,0.56,0.72,0.8125,0.69,0.48,0.95,0.88,0.71,0.91,0.44,0.89,0.37,0.63,1) nucleolusvalue(v2,binary=TRUE) # Computing the nucleolus of a random essential game: n <- 10 # number of players in the game v3 <- c(rep(0,n),runif(2^(n)-(n+1),min=10,max=20)) # random essential game nucleolusvalue(v3) # If the game is 0-monotonic, its nucleolus coincides with its prenucleolus, # and therefore must pass the Kohlberg criterion for the prenucleolus: v4 <- c(-2,-2,-2,7,7,7,6) zeromonotoniccheck(v4) kohlbergcriterion(v4,nucleolusvalue(v4)) # What if the game is a cost game? cost.v <- c(2,2,2,3,4,4,5) # cost game -nucleolusvalue(-cost.v) # nucleolus of the cost gamev1 <- c(0,0,3,0,3,8,6,0,6,9,15,8,16,17,20) nucleolusvalue(v1,binary=TRUE) v2 <- c(0,0,0.7,0,0.4925,0.68,0.83,0,0.56,0.74,0.64,0.46,0.55,0.57,0.61,0, 0.35,0.56,0.72,0.8125,0.69,0.48,0.95,0.88,0.71,0.91,0.44,0.89,0.37,0.63,1) nucleolusvalue(v2,binary=TRUE) # Computing the nucleolus of a random essential game: n <- 10 # number of players in the game v3 <- c(rep(0,n),runif(2^(n)-(n+1),min=10,max=20)) # random essential game nucleolusvalue(v3) # If the game is 0-monotonic, its nucleolus coincides with its prenucleolus, # and therefore must pass the Kohlberg criterion for the prenucleolus: v4 <- c(-2,-2,-2,7,7,7,6) zeromonotoniccheck(v4) kohlbergcriterion(v4,nucleolusvalue(v4)) # What if the game is a cost game? cost.v <- c(2,2,2,3,4,4,5) # cost game -nucleolusvalue(-cost.v) # nucleolus of the cost game
Given a game and a partition of the set of players, this function computes the Owen value.
owenvalue(v, binary = FALSE, partition = NULL, game = FALSE)owenvalue(v, binary = FALSE, partition = NULL, game = FALSE)
v |
A characteristic function, as a vector. |
binary |
A logical value. By default, |
partition |
A partition of the set of players, as a list of vectors. When not specified, it is taken to be the partition whose only element is the set of all players. |
game |
A logical value. By default, |
Let and let be a partition of the set of players.
For each , let and for each .
Being the Harsanyi dividend of coalition , the Owen value of each player is defined as
The corresponding Owen value, as a vector; and, if game=TRUE, the associated quotient game, as a vector in binary order if binary=TRUE and in lexicographic order otherwise.
Owen, G. (1977). Values of Games with a Priori Unions. In R. Henn and O. Moeschlin (Eds.), Mathematical Economics and Game Theory (pp. 76-88), Springer.
shapleyvalue, harsanyidividend
v <- c(0,0,0,0,30,30,40,40,50,50,60,70,80,90,100) # in lexicographic order owenvalue(v, partition=list(c(1,3),c(2),c(4))) owenvalue(v) round(owenvalue(v),10) == round(shapleyvalue(v),10) w <- c(0,0,0,0,0,10,10,20,10,20,10,20,10,20,10,20,40,20,40,20,40, 20,40,20,20,80,60,80,80,60,100) # in lexicographic order owenvalue(w, partition=list(c(1,2,3),c(4,5)))v <- c(0,0,0,0,30,30,40,40,50,50,60,70,80,90,100) # in lexicographic order owenvalue(v, partition=list(c(1,3),c(2),c(4))) owenvalue(v) round(owenvalue(v),10) == round(shapleyvalue(v),10) w <- c(0,0,0,0,0,10,10,20,10,20,10,20,10,20,10,20,40,20,40,20,40, 20,40,20,20,80,60,80,80,60,100) # in lexicographic order owenvalue(w, partition=list(c(1,2,3),c(4,5)))
This function returns the perfect core game with a given number of players.
perfectcoregame(n, binary = FALSE)perfectcoregame(n, binary = FALSE)
n |
A number of players, as an integer. |
binary |
A logical value. By default, |
The perfect core game of players is defined by
where .
The characteristic function of the perfect core game with n players, as a vector in binary order if binary=TRUE and in lexicographic order otherwise.
Shapley, L. S. (1971). Cores of convex games. International Journal of Game Theory, 1(3), 11-26.
perfectcoregame(6)perfectcoregame(6)
Given a game with two, three or four players, this function plots its core set and set of imputations.
plotcoreset( v, binary = FALSE, imputations = TRUE, projected = FALSE, solutions = NULL, allocations = NULL, color = "blue" )plotcoreset( v, binary = FALSE, imputations = TRUE, projected = FALSE, solutions = NULL, allocations = NULL, color = "blue" )
v |
A characteristic function, as a vector. The game represented by |
binary |
A logical value. By default, |
imputations |
A logical value. By default, |
projected |
A logical value. By default, |
solutions |
Optional. A character vector containing a solution or a series of solutions to be added to the plot. Valid solutions:
|
allocations |
Optional. A matrix containing an allocation or a series of allocations to be added to the plot. The matrix should have as many columns as players in |
color |
The color in which the core set is to be drawn. By default, |
The core of a game is the set of all its stable imputations:
where .
A core set plot with the specified features.
v1 <- claimsgame(E=8,d=c(3,5,6)) plotcoreset(v1,solutions=c("nucleolus","shapleyvalue")) v2 <- c(0,0,0,0,0,0,0,0,1,4,1,3,6,8,10) plotcoreset(v2,solutions=c("corecenter","nucleoluspc"))v1 <- claimsgame(E=8,d=c(3,5,6)) plotcoreset(v1,solutions=c("nucleolus","shapleyvalue")) v2 <- c(0,0,0,0,0,0,0,0,1,4,1,3,6,8,10) plotcoreset(v2,solutions=c("corecenter","nucleoluspc"))
Given multiple games with two, three or four players, this function draws in a single plot their projected core sets and sets of imputations.
plotcoresets(games, binary = FALSE, imputations = TRUE)plotcoresets(games, binary = FALSE, imputations = TRUE)
games |
A matrix in which each row is a characteristic function. |
binary |
A logical value. By default, |
imputations |
A logical value. By default, |
The core of a game is the set of all its stable imputations:
where .
A plot of the given core sets.
# Plotting the core and the least core of a game: v <- c(0,0,0,0,10,40,30,60,10,20,90,90,90,130,160) vt <- leastcore(v)$vt plotcoresets(games = rbind(v,vt), imputations = FALSE)# Plotting the core and the least core of a game: v <- c(0,0,0,0,10,40,30,60,10,20,90,90,90,130,160) vt <- leastcore(v)$vt plotcoresets(games = rbind(v,vt), imputations = FALSE)
Given a game, this function computes its prenucleolus.
prenucleolusvalue(v, binary = FALSE, tol = 100 * .Machine$double.eps)prenucleolusvalue(v, binary = FALSE, tol = 100 * .Machine$double.eps)
v |
A characteristic function, as a vector. |
binary |
A logical value. By default, |
tol |
A tolerance parameter, as a non-negative number. |
Given a game and an allocation , the excess of coalition
with respect to is defined as , where .
Let be a vector of excesses at arranged in non-increasing order.
It is said that a vector is lexicographically greater than another vector
if and the first non-zero coordinate of vector is positive.
The prenucleolus is the set of the efficient allocations that produce a lexicographically minimal vector of excesses. It is always non-empty and it actually comprises a single allocation, which in zero-monotonic games coincides with the nucleolus.
The implementation of this function is based on the algorithm presented in Derks and Kuipers (1997) and on the MATLAB package WCGT2005 by J. Derks.
The prenucleolus of the game, as a vector.
Derks, J. & Kuipers, J. (1997). Implementing the simplex method for computing the prenucleolus of transferable utility games.
Schmeider, D. (1969). The Nucleolus of a Characteristic Function Game. SIAM Journal on Applied Mathematics, 17(6), 1163–1170.
Software by J. Derks (Copyright 2005 Universiteit Maastricht, dept. of Mathematics), available in package MatTuGames,
https://www.shorturl.at/i6aTF.
excesses, kohlbergcriterion, leastcore, nucleoluspcvalue, nucleolusvalue
prenucleolusvalue(c(0,0,0,0,10,40,30,60,10,20,90,90,90,130,160)) v <- runif(2^6-1, min = 10, max = 20) # random 6-player game prenucleolusvalue(v) # The prenucleolus of v must pass the Kohlberg criterion. # In some cases, though, the tolerance might have to be adjusted # to avoid numerical error: kohlbergcriterion(v,prenucleolusvalue(v)) kohlbergcriterion(v,prenucleolusvalue(v),tol=10^(-6)) # What if the game is a cost game? cost.v <- c(2,2,2,3,4,4,5) # cost game -prenucleolusvalue(-cost.v) # prenucleolus of the cost gameprenucleolusvalue(c(0,0,0,0,10,40,30,60,10,20,90,90,90,130,160)) v <- runif(2^6-1, min = 10, max = 20) # random 6-player game prenucleolusvalue(v) # The prenucleolus of v must pass the Kohlberg criterion. # In some cases, though, the tolerance might have to be adjusted # to avoid numerical error: kohlbergcriterion(v,prenucleolusvalue(v)) kohlbergcriterion(v,prenucleolusvalue(v),tol=10^(-6)) # What if the game is a cost game? cost.v <- c(2,2,2,3,4,4,5) # cost game -prenucleolusvalue(-cost.v) # prenucleolus of the cost game
Given a cost game, this function returns the associated savings game.
savingsgame(c, binary = FALSE)savingsgame(c, binary = FALSE)
c |
The characteristic function of a cost game, as a vector. |
binary |
A logical value. By default, |
Let be a cost game. Its associated savings game, , is defined by
Thus, for each coalition , can be interpreted as the collective reduction of cost resulting from the cooperation of the members of , with respect to the scenario of non-cooperation.
The characteristic function of the savings game, as a vector in binary order if binary=TRUE and in lexicographic order otherwise.
airfieldgame, zeronormalizedgame
savingsgame(c(360,60,288,390,468,318,468)) v.random <- rnorm(2^5-1,58,13) savingsgame(v.random) == -zeronormalizedgame(v.random)savingsgame(c(360,60,288,390,468,318,468)) v.random <- rnorm(2^5-1,58,13) savingsgame(v.random) == -zeronormalizedgame(v.random)
Given a sequencing situation with an initial order, this function returns the characteristic function of the associated sequencing game.
sequencinggame(p, alpha, pi0, binary = FALSE)sequencinggame(p, alpha, pi0, binary = FALSE)
p |
A vector containing the processing time of each job. |
alpha |
A vector containing the cost per unit of time that each job generates while unfinished. |
pi0 |
An initial order, as a vector. |
binary |
A logical value. By default, |
Given a coalition , is the set of orders of , that is, the set of all bijective functions from to . A generic order of is denoted by .
Given and , let be the set of predecessors of according to order .
A sequencing situation is a triple and, possibly, some (information on the) initial order, where is a finite set of agents, each one having one job that has to be processed on a machine. To simplify, agent 's job is identified with . The processing times
of the jobs are given by with for all . For each agent there is a cost function , so that represents the cost incurred when job is completed exactly at time . Assuming that is linear for all , there exist such that for all , where is a fixed service cost and is the completion cost.
For any , is the aggregate completion cost of coalition in the order , formally defined as
A sequencing situation with initial order is a quadruple where is the initial order of the jobs.
A coalition is said to be connected in order if, for all and , implies . We say that a coalition is a component of if , is connected, and for every , is not connected. The components of form a partition of that is denoted by . Curiel et al. (1989) define the gain of swapping and as .
The sequencing game is defined, for all , by
The characteristic function of the sequencing game (interpreted as a savings game), as a vector in binary order if binary=TRUE and in lexicographic order otherwise.
Curiel, I., Pederzoli, G., & Tijs, S. (1989). Sequencing games. European Journal of Operational Research, 40(3), 344-351.
p <- c(1,2,3,4) alpha <- c(4,5,1,2) pi0 <- c(2,3,1,4) sequencinggame(p, alpha, pi0)p <- c(1,2,3,4) alpha <- c(4,5,1,2) pi0 <- c(2,3,1,4) sequencinggame(p, alpha, pi0)
Given a game, this function computes its Shapley value.
shapleyvalue(v, binary = FALSE)shapleyvalue(v, binary = FALSE)
v |
A characteristic function, as a vector. |
binary |
A logical value. By default, |
Given , the Shapley value of each player can be defined as
It is also possible to compute it as
where if and if .
The Shapley value of the game, as a vector.
Le Creurer, I. J., Mirás Calvo, M. A., Núñez Lugilde, I., Quinteiro Sandomingo, C., & Sánchez Rodríguez, E. (2024). On the computation of the Shapley value and the random arrival rule. Available at https://papers.ssrn.com/sol3/papers.cfm?abstract_id=4293746.
Shapley, L. S. (1953). A value for n-person games. Contribution to the Theory of Games, 2.
shapleyvalue(c(0,0,3,0,3,8,6,0,6,9,15,8,16,17,20), binary=TRUE) shapleyvalue(claimsgame(E=69.420,d=runif(10,5,10)))shapleyvalue(c(0,0,3,0,3,8,6,0,6,9,15,8,16,17,20), binary=TRUE) shapleyvalue(claimsgame(E=69.420,d=runif(10,5,10)))
Given a game, this function computes its solidarity value.
solidarityvalue(v, binary = FALSE, amc = FALSE)solidarityvalue(v, binary = FALSE, amc = FALSE)
v |
A characteristic function, as a vector. |
binary |
A logical value. By default, |
amc |
A logical value. By default, |
Given , the average marginal contribution to coalition is defined as
The solidarity value of each player can be defined as
The solidarity value of the game, as a vector. If amc=TRUE, a vector (in binary order if binary=TRUE and in lexicographic order otherwise) containing the average marginal contribution to each coalition is also returned.
Nowak, A. S. & Radzik, T. (1994). A solidarity value for n-person transferable utility games. International Journal of Game Theory, 23, 43-48.
solidarityvalue(c(0,0,0,1,1,1,2), binary=TRUE) solidarityvalue(bin2lex(c(0,0,1,2,5,5,7))) solidarityvalue(bin2lex(c(0,0,2,7,9,10,12,9,11,12,14,19,21,22,24)), amc=TRUE)solidarityvalue(c(0,0,0,1,1,1,2), binary=TRUE) solidarityvalue(bin2lex(c(0,0,1,2,5,5,7))) solidarityvalue(bin2lex(c(0,0,2,7,9,10,12,9,11,12,14,19,21,22,24)), amc=TRUE)
This function classifies and solves the given linear system.
solvels(A, tol = 100 * .Machine$double.eps)solvels(A, tol = 100 * .Machine$double.eps)
A |
The augmented matrix of a linear system. |
tol |
A tolerance parameter, as a non-negative number. |
This function returns two outputs: solution and flag.
If the introduced linear system is inconsistent: flag=-1 and solution=Inf.
If it is consistent and has infinitely many solutions: flag=0 and solution returns one of the solutions, as a vector.
If it is consistent and has a unique solution: flag=1 and solution returns the unique solution, as a vector.
# Consistent and determinate system: solvels(matrix(c(1,1,1,6,2,-1,1,3,-1,-1,1,0), byrow=TRUE, nrow = 3, ncol = 4)) # Consistent and indeterminate system: solvels(matrix(c(1,1,-3,0,2,-1,-3,3,4,1,-9,3), byrow=TRUE, nrow = 3, ncol = 4)) # Inconsistent system: solvels(matrix(c(-2,1,1,1,1,-2,1,1,1,1,-2,1), byrow=TRUE, nrow = 3, ncol = 4))# Consistent and determinate system: solvels(matrix(c(1,1,1,6,2,-1,1,3,-1,-1,1,0), byrow=TRUE, nrow = 3, ncol = 4)) # Consistent and indeterminate system: solvels(matrix(c(1,1,-3,0,2,-1,-3,3,4,1,-9,3), byrow=TRUE, nrow = 3, ncol = 4)) # Inconsistent system: solvels(matrix(c(-2,1,1,1,1,-2,1,1,1,1,-2,1), byrow=TRUE, nrow = 3, ncol = 4))
This function checks if two games are strategically equivalent.
strategicallyequivalentcheck(v, w, binary = FALSE, parameters = FALSE)strategicallyequivalentcheck(v, w, binary = FALSE, parameters = FALSE)
v |
A characteristic function, as a vector. |
w |
A characteristic function, as a vector. |
binary |
A logical value. By default, |
parameters |
A logical value. By default, |
Games and are strategically equivalent if there exist and an additive game such that for all .
TRUE if v and w are strategically equivalent, FALSE otherwise. If parameters=TRUE, whenever v and w are strategically equivalent, the function also returns k (a positive integer) and a (the characteristic function of an additive game, as a vector in binary order if binary=TRUE and in lexicographic order otherwise) such that .
additivegame, normalizedgame, zeronormalizedgame
w <- c(1000, 0, 0, 2000, 3000, 2000, 4000) v <- 4.5 * w + additivegame(c(4, 6, 1), binary = TRUE) strategicallyequivalentcheck(v, w, binary = TRUE, parameters = TRUE)w <- c(1000, 0, 0, 2000, 3000, 2000, 4000) v <- 4.5 * w + additivegame(c(4, 6, 1), binary = TRUE) strategicallyequivalentcheck(v, w, binary = TRUE, parameters = TRUE)
Given a game and a coalition, this function returns the characteristic function of the subgame of the given coalition.
subgame(v, S, binary = FALSE)subgame(v, S, binary = FALSE)
v |
A characteristic function, as a vector. |
S |
The position of a coalition, as an integer. |
binary |
A logical value. By default, |
Given , the subgame of coalition is defined by
for all .
The characteristic function of the subgame of the given coalition, as a vector in binary order if binary=TRUE and in lexicographic order otherwise.
v <- c(0, 0, 0, 0, 2, 3, 4, 5, 6, 9, 1, 15, 20, 30, 100) S <- 13 subgame(v, S) n <- 4 for (i in 1 : (2^n-1)) { cat("[", i, "]", paste(subgame(v,i)), "\n") } subgame(v,15)==vv <- c(0, 0, 0, 0, 2, 3, 4, 5, 6, 9, 1, 15, 20, 30, 100) S <- 13 subgame(v, S) n <- 4 for (i in 1 : (2^n-1)) { cat("[", i, "]", paste(subgame(v,i)), "\n") } subgame(v,15)==v
This function checks if the given game is superadditive.
superadditivecheck(v, binary = FALSE, instance = FALSE)superadditivecheck(v, binary = FALSE, instance = FALSE)
v |
A characteristic function, as a vector. |
binary |
A logical value. By default, |
instance |
A logical value. By default, |
A game is superadditive if for all with .
A game is subadditive if is superadditive.
TRUE if the game is superadditive, FALSE otherwise. If instance=TRUE and the game is not superadditive, the function also returns the positions (binary order positions if binary=TRUE; lexicographic order positions otherwise) of a pair of coalitions violating superadditivity.
additivecheck, convexcheck, monotoniccheck, strategicallyequivalentcheck
v <- c(2, 2, 4, 2, 4, 5, 6) superadditivecheck(v, binary = TRUE, instance = TRUE) # How to check if a game is subadditive: v.sub <- c(40, 30, 50, 60, 70, 65, 90) # subadditive game superadditivecheck(-v.sub)v <- c(2, 2, 4, 2, 4, 5, 6) superadditivecheck(v, binary = TRUE, instance = TRUE) # How to check if a game is subadditive: v.sub <- c(40, 30, 50, 60, 70, 65, 90) # subadditive game superadditivecheck(-v.sub)
Given a game and two players, this function checks if those are symmetric players.
symmetrycheck(v, i, j, binary = FALSE, tol = 100 * .Machine$double.eps)symmetrycheck(v, i, j, binary = FALSE, tol = 100 * .Machine$double.eps)
v |
A characteristic function, as a vector. |
i |
The position of an individual coalition, as an integer. |
j |
The position of another individual coalition, as an integer. |
binary |
A logical value. By default, |
tol |
A tolerance parameter, as a non-negative number. |
Let . Players are symmetric in if,
for each with , .
TRUE if i and j are symmetric in v, FALSE otherwise.
symmetrycheck(c(13,13,0,0,58,58,0),1,2) # players 1 and 2 are symmetricsymmetrycheck(c(13,13,0,0,58,58,0),1,2) # players 1 and 2 are symmetric
Given a sequencing situation without an initial order, this function returns the characteristic function of the associated tail game.
tailgame(p, alpha, binary = FALSE)tailgame(p, alpha, binary = FALSE)
p |
A vector containing the processing time of each job. |
alpha |
A vector containing the cost per unit of time that each job generates while unfinished. |
binary |
A logical value. By default, |
Given , is the set of orders of , that is, the set of all bijective functions from to . A generic order of is denoted by .
Given and , let be the set of predecessors of according to order .
A sequencing situation is a triple and, possibly, some (information on the) initial order, where is a finite set of agents, each one having one job that has to be processed on a machine. To simplify, agent 's job is identified with . The processing times
of the jobs are given by with for all . For each agent there is a cost function , so that represents the cost incurred when job is completed exactly at time . Assuming that is linear for all , there exist such that for all , where is a fixed service cost and is the completion cost.
For any , is the aggregate completion cost of coalition in the order , formally defined as
A sequencing situation without initial order is a triple in which there is no information about an initial order.
An order that minimizes the aggregate completion cost of coalition is called an optimal order and denoted by . Defining the urgency index of each as , an optimal order can be obtained by arranging jobs in such a way that the corresponding arrangement of their urgency indices is non-increasing. Given a sequencing situation , denotes the set of those optimal orders that also satisfy the following condition: if two jobs share the same urgency index but not the same processing, the one with shortest processing time goes first.
The characteristic function of the tail game associated to a sequencing situation
is defined, for each , by
where and .
Having no information about an initial order, coalitions assume they will be processed at the tail of some "artificial" initial order.
The characteristic function of the tail game (interpreted as a cost game), as a vector in binary order if binary=TRUE and in lexicographic order otherwise.
Klijn, F. & Sánchez, E. (2006). Sequencing games without initial order. Mathematical Methods of Operations Research, 63, 53-62.
p <- c(1,2,3,4) alpha <- c(4,5,1,2) tailgame(p,alpha)p <- c(1,2,3,4) alpha <- c(4,5,1,2) tailgame(p,alpha)
-valueGiven a game, this function computes its -value.
tauvalue(v, binary = FALSE)tauvalue(v, binary = FALSE)
v |
A characteristic function, as a vector. |
binary |
A logical value. By default, |
The -value of is given by
where is the vector of utopia payoffs, is the vector of minimal rights, and is the value for which .
The -value of the game, as a vector.
Tijs, S. H. (1981). Bounds for the core of a game and the -value. In O. Moeschlin and D. Pallaschke (Eds.), Game theory and mathematical economics (pp. 123-132).
minimalrightsvector, utopiapayoffsvector.
tauvalue(c(0,0,0,0,10,40,30,60,10,20,90,90,90,130,160)) # What if the game is a cost game? cost.v <- c(2,2,2,3,4,4,5) # cost game -tauvalue(-cost.v) # tau-value of the cost gametauvalue(c(0,0,0,0,10,40,30,60,10,20,90,90,90,130,160)) # What if the game is a cost game? cost.v <- c(2,2,2,3,4,4,5) # cost game -tauvalue(-cost.v) # tau-value of the cost game
This function checks if the given game is totally balanced and computes its totally balanced cover.
totallybalancedcheck( v, game = FALSE, binary = FALSE, tol = 100 * .Machine$double.eps )totallybalancedcheck( v, game = FALSE, binary = FALSE, tol = 100 * .Machine$double.eps )
v |
A characteristic function, as a vector. |
game |
A logical value. By default, |
binary |
A logical value. By default, |
tol |
A tolerance parameter, as a non-negative number. |
A game is totally balanced if all of its subgames are balanced
(the subgame of each coalition with respect to is defined by
for all ).
TRUE if the game is totally balanced, FALSE otherwise. If game=TRUE, the totally balanced cover of the game is also returned.
Maschler, M., Solan, E., & Zamir, S. (2013). Game Theory. Cambridge University Press.
totallybalancedcheck(c(0,0,0,0,1/2,0,0,1/2,0,1/2,1/2,1/2,1/2,1/2,1)) totallybalancedcheck(c(0,0,0,0,1,1,0,1,0,0,1,1,1,1,2),game=TRUE)totallybalancedcheck(c(0,0,0,0,1/2,0,0,1/2,0,1/2,1/2,1/2,1/2,1/2,1)) totallybalancedcheck(c(0,0,0,0,1,1,0,1,0,0,1,1,1,1,2),game=TRUE)
This function computes a square upper triangular version of the given matrix.
triangularup(V, tol = 100 * .Machine$double.eps)triangularup(V, tol = 100 * .Machine$double.eps)
V |
A matrix. |
tol |
A tolerance parameter, as a non-negative number. |
A square upper triangular version of the given matrix.
This function returns two outputs:
SUT, the square upper triangular matrix.
pivot, a vector indicating pivot rows.
set.seed(58) triangularup(matrix(sample(1:10, 16, replace = TRUE), nrow = 4, ncol = 4)) triangularup(matrix(c(7,8,5,5,3,5,4,1,3,10,4,4,6,7,8,8),byrow=TRUE, nrow = 4, ncol = 4)) triangularup(matrix(c(1,2,1,1,-2,0,1,1),byrow=TRUE, nrow = 2, ncol = 4)) triangularup(matrix(c(1,2,1,-2,0,1,3,-1,1,-2,3,3),byrow=TRUE, nrow = 4, ncol = 3))set.seed(58) triangularup(matrix(sample(1:10, 16, replace = TRUE), nrow = 4, ncol = 4)) triangularup(matrix(c(7,8,5,5,3,5,4,1,3,10,4,4,6,7,8,8),byrow=TRUE, nrow = 4, ncol = 4)) triangularup(matrix(c(1,2,1,1,-2,0,1,1),byrow=TRUE, nrow = 2, ncol = 4)) triangularup(matrix(c(1,2,1,-2,0,1,3,-1,1,-2,3,3),byrow=TRUE, nrow = 4, ncol = 3))
This function returns the characteristic function of the unanimity game of a coalition.
unanimitygame(n, S, binary = FALSE)unanimitygame(n, S, binary = FALSE)
n |
Number of players, as an integer. |
S |
The position of a coalition, as an integer. |
binary |
A logical value. By default, |
The characteristic function of the unanimity game of a coalition
is defined, for each , as if and otherwise.
The characteristic function of the unanimity game of coalition S, as a vector in binary order if binary=TRUE and in lexicographic order otherwise.
unanimitygame(n=4,S=7)unanimitygame(n=4,S=7)
This function computes the utopia payoffs vector of a game.
utopiapayoffsvector(v, binary = FALSE)utopiapayoffsvector(v, binary = FALSE)
v |
A characteristic function, as a vector. |
binary |
A logical value. By default, |
Given , the utopia payoff of player is defined as
.
The utopia payoffs vector.
v <- c(0, 10, 200, 1, 4, 7, 7) utopiapayoffsvector(v, binary = FALSE)v <- c(0, 10, 200, 1, 4, 7, 7) utopiapayoffsvector(v, binary = FALSE)
This function returns the characteristic function of the described weighted majority game.
weightedmajoritygame(q, w, binary = FALSE)weightedmajoritygame(q, w, binary = FALSE)
q |
A quota, as a number between 0 and the sum of player weights. |
w |
The player weights, as a vector of non-negative numbers. |
binary |
A logical value. By default, |
Given a situation in which a number of agents have to vote for or against a certain measure,
let be the set of voters, be a non-negative vector of voter weights (the weight of each voter is the number of votes or the proportion of total votes they hold),
and be the quota (the minimum number of votes or the minimum proportion of total votes needed to pass the measure).
The corresponding weighted majority game, , is defined by
The characteristic function of the weighted majority game associated with the described situation, as a vector in binary order if binary=TRUE and in lexicographic order otherwise.
q <- 39 w <- c(rep(7,5),rep(1,10)) weightedmajoritygame(q,w)q <- 39 w <- c(rep(7,5),rep(1,10)) weightedmajoritygame(q,w)
Given a game, positive player weights and an ordered partition of the set of players, this function returns the corresponding weighted Shapley value.
weightedshapleyvalue(v, binary = FALSE, weights, partition = NULL)weightedshapleyvalue(v, binary = FALSE, weights, partition = NULL)
v |
A characteristic function, as a vector. |
binary |
A logical value. By default, |
weights |
The player weights, as a vector of positive numbers. |
partition |
An ordered partition of the set of players, as a list of vectors. When not specified, it is taken to be the partition whose only element is the set of all players. |
A weight system is a pair where is a positive weight vector ( for each ) and is an ordered partition of .
The weighted Shapley value with weight system is the linear map that assigns to each unanimity game , with ,
the allocations if and if ,
where . Then, for each and being the Harsanyi dividend of coalition ,
The positively weighted Shapley value of the game, as a vector.
Shapley, L. S. (1953). Additive and non-additive set functions. PhD thesis, Department of Mathematics, Princeton University.
coalitionweightedshapleyvalue, harsanyidividend, shapleyvalue
v <- c(0,0,0,0,0,0,1,0,0,1,3,4,6,8,10) weightedshapleyvalue(v,binary=TRUE,weights=c(0.5,0.2,0.2,0.1)) w <- c(0,0,0,0,30,30,40,40,50,50,60,70,80,90,100) weightedshapleyvalue(w,weights=c(1,2,3,4),partition=list(c(1,2),c(3,4)))v <- c(0,0,0,0,0,0,1,0,0,1,3,4,6,8,10) weightedshapleyvalue(v,binary=TRUE,weights=c(0.5,0.2,0.2,0.1)) w <- c(0,0,0,0,30,30,40,40,50,50,60,70,80,90,100) weightedshapleyvalue(w,weights=c(1,2,3,4),partition=list(c(1,2),c(3,4)))
This function checks if the given game is 0-monotonic.
zeromonotoniccheck(v, binary = FALSE, instance = FALSE)zeromonotoniccheck(v, binary = FALSE, instance = FALSE)
v |
A characteristic function, as a vector. |
binary |
A logical value. By default, |
instance |
A logical value. By default, |
A game is 0-monotonic if for all such that , being the 0-normalization of .
TRUE if the game is 0-monotonic, FALSE otherwise. If instance=TRUE and the game is not 0-monotonic, the function also returns the positions (binary order positions if binary=TRUE; lexicographic order positions otherwise) of a pair of coalitions violating 0-monotonicity.
monotoniccheck, zeronormalizedgame, zeronormalizedcheck
v <- c(0, 0, 0, 1, 1, 1, 2) zeromonotoniccheck(v, binary = TRUE) monotoniccheck(v, binary = TRUE) w <- c(-2,-2,-2,7,7,7,6) zeromonotoniccheck(w) monotoniccheck(w) z <- c(1, 1, 1, 2, 2, 2, 2) zeromonotoniccheck(z) monotoniccheck(z)v <- c(0, 0, 0, 1, 1, 1, 2) zeromonotoniccheck(v, binary = TRUE) monotoniccheck(v, binary = TRUE) w <- c(-2,-2,-2,7,7,7,6) zeromonotoniccheck(w) monotoniccheck(w) z <- c(1, 1, 1, 2, 2, 2, 2) zeromonotoniccheck(z) monotoniccheck(z)
This function checks if the given game is 0-normalized.
zeronormalizedcheck(v, binary = FALSE, instance = FALSE)zeronormalizedcheck(v, binary = FALSE, instance = FALSE)
v |
A characteristic function, as a vector. |
binary |
A logical value. By default, |
instance |
A logical value. By default, |
A game is 0-normalized if for all .
TRUE if the game is 0-normalized, FALSE otherwise. If instance=TRUE and the game is not 0-normalized, the function also returns a player for whose value is not zero.
normalizedgame, strategicallyequivalentcheck, zeromonotoniccheck, zeronormalizedgame
v <- c(rep(0, 4), 1, rep(30, 20), rep(3, 5), 50) # v(5)=1 zeronormalizedcheck(v, binary = FALSE, instance = TRUE)v <- c(rep(0, 4), 1, rep(30, 20), rep(3, 5), 50) # v(5)=1 zeronormalizedcheck(v, binary = FALSE, instance = TRUE)
Given a game, this function returns the characteristic function of its 0-normalization.
zeronormalizedgame(v, binary = FALSE)zeronormalizedgame(v, binary = FALSE)
v |
A characteristic function, as a vector. |
binary |
A logical value. By default, |
The 0-normalization of a given is defined by
for each .
The characteristic function of the 0-normalized game, as a vector in binary order if binary=TRUE and in lexicographic order otherwise.
normalizedgame, savingsgame, strategicallyequivalentcheck, zeromonotoniccheck, zeronormalizedcheck
zeronormalizedgame(c(0,3,7,15,17,27,30)) zeronormalizedgame(c(1,5,10,6,11,15,16)) v.random <- rnorm(2^5-1,58,13) zeronormalizedgame(v.random) == -savingsgame(v.random)zeronormalizedgame(c(0,3,7,15,17,27,30)) zeronormalizedgame(c(1,5,10,6,11,15,16)) v.random <- rnorm(2^5-1,58,13) zeronormalizedgame(v.random) == -savingsgame(v.random)