Alternative ways of creating PowerRelation
objects.
Usage
as.PowerRelation(x, ...)
# S3 method for character
as.PowerRelation(x, ...)
# S3 method for list
as.PowerRelation(x, ..., comparators = c(">"))
Arguments
- x
An object
- ...
Optional additional parameters
- comparators
Vector of ">" or "~" characters
Using a character string
The same way a power relation \(\succsim\) may be represented in literature (or printed by an PowerRelation
object),
a simple string containing letters, numbers, >
or ~
can be used to input a new power relation.
Every special character is ignored, with the exception of \(\succsim\) ("\u227B"
) and \(\sim\) ("\u223C"
).
Every letter or number is assumed to be an individual element.
"abc > ac"
therefore would represent two coalitions, the first one of size 3 with the elements a
, b
, and c
.
This method does not allow for elements to be entered that are supposed to be multiple characters long.
An empty coalitions can be simply left blank (i.e., "abc > ~ ac"
),
though it is often clearer if curly braces are used to indicate such (i.e., "abc > {} ~ ac"
).
Using a list
Create a PowerRelation
object with an unnested list of coalition vectors.
By default, a linear order is assumed on the coalitions.
I.e., if it is given list(c(1,2),1,2)
, these three coalitions are put into their own equivalence class,
producing 12 > 1 > 2
.
The comparators in-between can be adjusted to indicate
whether the relation between two coalitions is that of strict preference >
or indifference ~
.
Examples
# Using character strings
as.PowerRelation("abc > ab > ({} ~ c) > (a ~ b ~ ac) > bc")
#> abc > ab > ({} ~ c) > (a ~ b ~ ac) > bc
# abc > ab > ({} ~ c) > (a ~ b ~ ac) > bc
# using createPowerset(), then shifting coalitions up and down using Alt+Up and Alt+Down
if(interactive()) {
createPowerset(1:2, result = "copy")
}
as.PowerRelation("
12
> 1
~ {}
> 2
")
#> 12 > (1 ~ {}) > 2
# Using lists
as.PowerRelation(list(c(1,2), 2, c(), 1))
#> 12 > 2 > {} > 1
# 12 > 2 > {} > 1
as.PowerRelation(list(c(1,2), 2, c(), 1), comparators = c("~", ">", ">"))
#> (12 ~ 2) > {} > 1
# (12 ~ 2) > {} > 1
# the length of comparators doesn't necessarily matter.
# If comparators are missing, the existing ones are simply repeated...
as.PowerRelation(list(c(1,2), 2, c(), 1), comparators = "~")
#> (12 ~ 2 ~ {} ~ 1)
# (12 ~ 2 ~ {} ~ 1)
as.PowerRelation(list(c(1,2), 2, c(), 1), comparators = c("~", ">"))
#> (12 ~ 2) > ({} ~ 1)
# (12 ~ 2) > ({} ~ 1)
# ... or the rest is cut off
as.PowerRelation(list(c(1,2), 2, c(), 1), comparators = c("~", ">", "~", "~", ">"))
#> (12 ~ 2) > ({} ~ 1)
# (12 ~ 2) > ({} ~ 1)