Skip to content

coopgt

coopgt is a Python library for the study of cooperative game theory. It works with characteristic function games and provides the Shapley value, checks of standard properties (validity, monotonicity, superadditivity, convexity), and core membership.


Installation

python -m pip install coopgt

Where to start

This documentation follows the Diátaxis framework.

A first example

A characteristic function is a dictionary mapping each coalition (a tuple of players, numbered from 1) to its value:

>>> import coopgt.shapley_value
>>> characteristic_function = {
...     (): 0,
...     (1,): 0,
...     (2,): 0,
...     (1, 2): 10,
... }
>>> shapley = coopgt.shapley_value.calculate(characteristic_function)
>>> [round(float(value), 2) for value in shapley]
[5.0, 5.0]