Majority Rule
The Majority Rule model [1] is a classical binary opinion dynamics model that captures conformity-driven opinion formation through local group interactions. Each node holds a binary opinion \(h \in \{0, 1\}\). At each time step:
a group of \(q\) nodes is selected uniformly at random (with replacement) from the network;
the majority opinion within the group is determined;
all \(q\) selected nodes adopt the majority opinion. When the majority is tied, ties are broken in favour of opinion 1.
Implementation
The Majority Rule model simulates conformity-driven opinion formation by selecting a random panel of \(q\) nodes and forcing them to adopt the panel's majority opinion. Unlike neighbor-based models (e.g., Voter), the group is drawn from the entire population.
At each time step, \(q\) node indices are sampled uniformly at random (with replacement) from the network:
The opinions of all sampled nodes are collected and the majority is determined by counting votes for opinion 1:
The threshold \(\lceil q/2 \rceil\) ensures that for odd \(q\) the standard simple majority applies, while for even \(q\) a tied vote is resolved in favour of opinion 1.
All nodes in the selected group adopt the majority opinion:
All other nodes retain their current opinions.
Status
During the simulation, a node holds a binary opinion value:
Status |
Value |
|---|---|
Opinion |
0 or 1 |
MajorityRuleModel
- class fs_gplib.Opinions.MajorityRuleModel(data, seeds, q, device='cpu', rand_seed=None)[source]
Bases:
DiffusionModelBinary Majority Rule opinion dynamics model on static graphs.
Each node holds a binary opinion in
{0, 1}. At every step, a group of \(q\) nodes is sampled uniformly at random from the whole population with replacement. The majority opinion within that sampled group is computed, and all sampled nodes adopt that majority opinion. If the vote is tied, the tie is resolved in favour of opinion1.Returned node states are encoded as: 0 = opinion 0, 1 = opinion 1.
Unlike neighbor-based models such as Voter or Q-Voter, this implementation does not use local network neighborhoods in the update rule; the graph object is kept mainly for a consistent API and to provide the number of nodes.
- Parameters:
data (torch_geometric.data.Data) -- PyTorch Geometric
Dataobject representing graph \(G=(V,E)\). Must containnum_nodes(\(|V|\)).seeds (list[int] | float | None) -- Initial nodes with opinion
1. Pass a list of node IDs, a float in(0,1)to initialise that fraction of nodes chosen uniformly at random with opinion1, orNone.q (int) -- Size of the randomly sampled discussion group. Must be a positive integer.
device (str | int) -- (optional)
'cpu'or a CUDA device index. Defaults to'cpu'.rand_seed (int | None) -- (optional) Random seed used when seeds is a float. Defaults to
None.
- run_iteration()[source]
Execute a single opinion-update step.
The internal
node_statusis updated so that subsequent calls continue from the latest opinion configuration.- Returns:
Node opinions after one step, shape
(1, N).- Return type:
torch.Tensor
- run_iterations(times)[source]
Execute times opinion-update steps sequentially.
The internal
node_statusis updated in-place so that subsequent calls continue from the latest opinion configuration.- Parameters:
times (int) -- Number of steps to run.
- Returns:
Node opinions at final step, shape
(1, N).- Return type:
torch.Tensor
- run_epoch(iterations_times)[source]
Run a single Monte-Carlo epoch (one independent realisation).
Node opinions are re-initialised before the epoch starts.
- Parameters:
iterations_times (int) -- Number of opinion-update steps per epoch.
- Returns:
Node opinions at final step of the epoch, shape
(1, N).- Return type:
torch.Tensor
- run_epochs(epochs, iterations_times, batch_size=200)[source]
Run multiple independent Monte-Carlo epochs in batches.
Node opinions are re-initialised before the run.
- Parameters:
epochs (int) -- Total number of independent realisations.
iterations_times (int) -- Number of opinion-update steps per epoch.
batch_size (int) -- (optional) Number of epochs processed in parallel per batch. Defaults to
200.
- Returns:
Node opinions at final step of all epochs, shape
(epochs, N).- Return type:
torch.Tensor
Parameters
Name |
Type |
Default |
Required |
Description |
|---|---|---|---|---|
data |
Data |
Yes |
Data of graph. |
|
seeds |
List[int] / None |
Yes |
List of initially activated node indices (opinion = 1) or None. |
|
q |
Int (> 0) |
Yes |
Size of the randomly selected discussion group. |
|
device |
'cpu'/int (CUDA index) |
'cpu' |
No |
Device to run the model on. |
rand_seed |
Int |
None |
No |
Random seed for reproducibility. |