coalitions <- createPowerset(c('a','b'), includeEmptySet = FALSE)
# list(c('a','b'), 'a', 'b')
gen <- powerRelationGenerator(coalitions)
while(!is.null(pr <- gen())) {
print(pr)
}
# (ab ~ a ~ b)
# (ab ~ a) > b
# (ab ~ b) > a
# (a ~ b) > ab
# ab > (a ~ b)
# a > (ab ~ b)
# b > (ab ~ a)
# ab > a > b
# ab > b > a
# a > ab > b
# b > ab > a
# a > b > ab
# b > a > ab
# from now on, gen() always returns NULL
gen()
# NULL
# Use generateNextPartition() to skip certain partitions
gen <- powerRelationGenerator(coalitions)
gen <- generateNextPartition(gen)
gen <- generateNextPartition(gen)
gen()
# ab > (a ~ b)
gen <- generateNextPartition(gen)
gen()
# ab > a > b
coalitions <- createPowerset(c('a','b'), includeEmptySet = FALSE)
# list(c('a','b'), 'a', 'b')
gen <- powerRelationGenerator(coalitions)
gen()
# (ab ~ a ~ b)
gen()
# (ab ~ b) > a
# skipping partition of size two, where the first partition has
# 2 coalitions and the second partition has 1 coalition
gen <- generateNextPartition(gen)
gen()
# ab > (a ~ b)
# only remaining partition is one of size 3, wherein each
# equivalence class is of size 1
gen <- generateNextPartition(gen)
gen()
# ab > a > b
# went through all partitions, it will only generate NULL now
gen <- generateNextPartition(gen)
stopifnot(is.null(gen()))
# create random power relation
generateRandomPowerRelation(coalitions)
# make sure it's monotonic, i.e., {1} > {1,2} cannot exist
# because {1} is a subset of {1,2}
generateRandomPowerRelation(coalitions, monotonic = TRUE)
Run the code above in your browser using DataLab