Revision Protocol¶
—
Base Class
The abstract base class for all revision protocols is defined below.
- class popgames.revision_protocol.RevisionProtocolABC[source]¶
Bases:
ABC
Abstract base class for revision protocols.
- abstractmethod __call__(p, x)[source]¶
Subclasses must implement this method to enable the revision protocol to be called as a function.
- Parameters:
p (np.ndarray) – The payoff vector with shape (n, 1).
x (np.ndarray) – The population state vector with shape (n, 1).
- Returns:
The switching probabilities as a matrix with shape (n, n).
- Return type:
np.ndarray
—
Softmax Revision Protocol
- class popgames.revision_protocol.Softmax(eta)[source]¶
Bases:
RevisionProtocolABC
Softmax revision protocol. Also known as Logit-Choice revision protocol.
Initialize the Softmax revision protocol object.
- Parameters:
eta (float) – The temperature or noise parameter.
- __call__(p, x)[source]¶
Evaluate the Softmax revision protocol.
- Parameters:
p (np.ndarray) – The payoff vector with shape (n, 1).
x (np.ndarray) – The population state vector with shape (n, 1).
- Returns:
The switching probabilities as a matrix with shape (n, n).
- Return type:
np.ndarray
Examples
>>> import numpy as np >>> from popgames.revision_protocol import Softmax >>> softmax = Softmax(eta=1) >>> p = np.array([1, -1, 2]).reshape(3, 1) >>> x = np.array([0.1, 0.7, 0.2]).reshape(3, 1) >>> softmax(p, x) array([[0.25949646, 0.25949646, 0.25949646], [0.03511903, 0.03511903, 0.03511903], [0.70538451, 0.70538451, 0.70538451]])
—
Brown-von Neumann-Nash (BNN) Revision Protocol
- class popgames.revision_protocol.BNN(scale)[source]¶
Bases:
RevisionProtocolABC
Brown-von Neumann-Nash (BNN) revision protocol.
Initialize the BNN revision protocol object.
- Parameters:
scale (float) – The scale parameter to ensure well-posed probabilities.
- __call__(p, x)[source]¶
Evaluate the BNN revision protocol.
- Parameters:
p (np.ndarray) – The payoff vector with shape (n, 1).
x (np.ndarray) – The population state vector with shape (n, 1).
- Returns:
The switching probabilities as a matrix with shape (n, n).
- Return type:
np.ndarray
Examples
>>> import numpy as np >>> from popgames.revision_protocol import BNN >>> bnn = BNN(scale=0.1) >>> p = np.array([1, -1, 2]).reshape(3, 1) >>> x = np.array([0.1, 0.7, 0.2]).reshape(3, 1) >>> bnn(p, x) array([[0.12, 0.12, 0.12], [0. , 0. , 0. ], [0.22, 0.22, 0.22]])
–
Smith Revision Protocol
- class popgames.revision_protocol.Smith(scale)[source]¶
Bases:
RevisionProtocolABC
Smith revision protocol.
Initialize the Smith revision protocol object.
- Parameters:
scale (float) – The scale parameter to ensure well-posed probabilities.
- __call__(p, x)[source]¶
Evaluate the Smith revision protocol.
- Parameters:
p (np.ndarray) – The payoff vector with shape (n, 1).
x (np.ndarray) – The population state vector with shape (n, 1).
- Returns:
The switching probabilities as a matrix with shape (n, n).
- Return type:
np.ndarray
Examples
>>> import numpy as np >>> from popgames.revision_protocol import Smith >>> smith = Smith(scale=0.1) >>> p = np.array([1, -1, 2]).reshape(3, 1) >>> x = np.array([0.1, 0.7, 0.2]).reshape(3, 1) >>> smith(p, x) array([[0. , 0.2, 0. ], [0. , 0. , 0. ], [0.1, 0.3, 0. ]])