Learn R Programming

TUGLab (version 0.0.1)

getcoalitionnumber: Get coalition number

Description

This function returns the binary order position of the coalition formed by the given players.

Usage

getcoalitionnumber(S)

Value

The binary order position of the coalition formed by the given players.

Arguments

S

The players forming the coalition, as a vector.

Details

A coalition \(S\in 2^N\) can be represented by the \(n\)-digit binary number \(s_1\dots s_n\) where \(s_i=1\) if \(i\in S\) and \(0\) otherwise. The binary order position of a coalition \(S\in 2^N\) is given by \(\sum_{i\in S} 2^{i-1}\).

See Also

codebin2lex, codelex2bin, getcoalition

Examples

Run this code
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 - 1

Run the code above in your browser using DataLab