Skip to content

Commit

Permalink
Typo fix
Browse files Browse the repository at this point in the history
  • Loading branch information
DauphineWeb committed Mar 13, 2023
1 parent 8962de3 commit 03d0647
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 7 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: socialranking
Title: Social Ranking Solutions for Power Relations on Coalitions
Version: 0.1.2
Version: 1.0.0
Authors@R: c(
person("Felix", "Fritz", email = "felix.fritz@dauphine.eu", role = c("aut", "cre")),
person("Jochen", "Staudacher", role = c("aut", "cph", "ths"), email = "jochen.staudacher@hs-kempten.de"),
Expand Down
59 changes: 59 additions & 0 deletions R/appendMissingCoalitions.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#' Append missing coalitions
#'
#' Append an equivalence class to a power relation with all coalitions of elements that do not appear in the power relation.
#'
#' For a given set of elements \eqn{N = \lbrace 1, ..., n \rbrace}{N = \{1, ..., n\}}, a [`PowerRelation`] object describes a total preorder
#' of its subsets, or coalitions, \eqn{\mathcal{P} \subseteq 2^N}{P subseteq 2^N}, where \eqn{2^N}{2^N} is the superset of elements.
#'
#' If \eqn{\mathcal{P} \neq 2^N}{P != 2^N}, that means that there are some coalitions \eqn{S \in 2^N, S \notin \mathcal{P}}{S in 2^N, S not in P},
#' such that we cannot compare \eqn{S \succeq T}{S >= T} or \eqn{T \succeq S}{T >= S} for every \eqn{T \in \mathcal{P}}{T in P}.
#'
#' This may be caused by \eqn{2^N}{2^N} having too many coalitions to consider.
#' In certain cases, it may be more interesting to only consider the top ranking coalitions and "shoving" all remaining coalitions into the back.
#'
#' For this use-case, `appendMissingCoalitions()` takes the set \eqn{2^N \setminus \mathcal{P}}{2^N - P}
#' and attaches it in form of an equivalence class to the back of the power relation.
#'
#' I.e., take as an example \eqn{12 \succ 13 \succ (1 \sim 2)}{12 > 13 > (1 ~ 2)}. Here, we have
#'
#' \deqn{
#' \begin{aligned}
#' 2^N &= \lbrace 123, 12, 13, 23, 1, 2, 3, \emptyset \rbrace\\
#' \mathcal{P} &= \lbrace 12, 13, 1, 2 \rbrace\\
#' 2^N \setminus \mathcal{P} &= \lbrace 123, 23, 3, \emptyset \rbrace .
#' \end{aligned}
#' }{
#' 2^N = \{ 123, 12, 13, 23, 1, 2, 3, \{\} \}\\
#' P = \{12, 13, 1, 2\}\\
#' 2^N - P = \{123, 23, 3, \{\}\}
#' }
#'
#' Adding the missing coalitions to the power relation then gives us \eqn{12 \succ 13 \succ (1 \sim 2) \succ (123 \sim 23 \sim 3 \sim \emptyset)}{12 > 13 > (1 ~ 2) > (123 ~ 23 ~ 3 ~ \{\})}.
#'
#' @template param/powerRelation
#' @param includeEmptySet If `TRUE`, include the empty set in the last equivalence class if it is missing from the power relation.
#'
#' @template return/PowerRelation
#'
#' @family helper functions transforming existing [`PowerRelation`] objects
#'
#' @examples
#' pr <- as.PowerRelation(list(c(1,2), 3))
#' # 12 > 3
#'
#' appendMissingCoalitions(pr)
#' # 12 > 3 > (123 ~ 13 ~ 23 ~ 1 ~ 2 ~ {})
#'
#' appendMissingCoalitions(pr, includeEmptySet = FALSE)
#' # 12 > 3 > (123 ~ 13 ~ 23 ~ 1 ~ 2)
#'
#' @export
appendMissingCoalitions <- function(powerRelation, includeEmptySet = TRUE) {
# --- checks (generated) --- #
stopifnot(is.PowerRelation(powerRelation))
# --- end checks --- #
els <- powerRelation$elements
allCoals <- createPowerset(els, includeEmptySet = includeEmptySet)
missing <- setdiff(allCoals, unlist(powerRelation$eqs, recursive = FALSE))
PowerRelation(append(powerRelation$eqs, list(missing)))
}
2 changes: 1 addition & 1 deletion R/makePowerRelationMonotonic.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#'
#' @template return/PowerRelation
#'
#' @family helper functions transorming existing [`PowerRelation`] objects
#' @family helper functions transforming existing [`PowerRelation`] objects
#'
#' @examples
#' pr <- as.PowerRelation("ab > ac > abc > b > a > {} > c > bc")
Expand Down
6 changes: 3 additions & 3 deletions man/appendMissingCoalitions.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/makePowerRelationMonotonic.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 03d0647

Please sign in to comment.