Learn R Programming

TUGLab (version 0.0.1)

getcoalition: Get coalition

Description

This function returns the players that form the coalition whose binary order position coincides with the given integer.

Usage

getcoalition(num)

Value

The players that form the coalition whose binary order position is the given integer, as a vector.

Arguments

num

A binary order position of a coalition, as an integer.

Details

A coalition \(S\in 2^N\) can be represented by the \(n\)-digit binary number \(s_1\dots s_n\) in which \(s_i=1\) if \(i\in S\) and \(s_i=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, getcoalitionnumber

Examples

Run this code
num <- 5
getcoalition(num)
n <- 4
for (i in 1:(2^n - 1)){
  cat("[", i, "]", paste(getcoalition(i)),"\n")
}

Run the code above in your browser using DataLab