# Example 1: Using a simulated instance
simulations <- simulate_election(
num_ballots = 20,
num_candidates = 3,
num_groups = 8,
seed = 42
)
result <- get_agg_opt(
X = simulations$X,
W = simulations$W,
sd_threshold = 0.05,
seed = 42
)
result$group_agg # c(3,8)
# This means that the resulting group aggregation consists of
# two macro-groups: one that includes the original groups 1, 2, and 3;
# the remaining one with groups 4, 5, 6, 7 and 8.
# \donttest{
# Example 2: Getting an unfeasible result
result2 <- get_agg_opt(
X = simulations$X,
W = simulations$W,
sd_threshold = 0.001
)
result2$group_agg # Error
result2$X # Input candidates' vote matrix
result2$W # Input group-level voter matrix
# }
Run the code above in your browser using DataLab