View source: R/redist_shortburst.R
redist_shortburst | R Documentation |
This function uses redist_mergesplit()
or redist_flip()
to optimize a
redistrict plan according to a user-provided criteria. It does so by running
the Markov chain for "short bursts" of usually 10 iterations, and then
starting the chain anew from the best plan in the burst, according to the
criteria. This implements the ideas in the below-referenced paper, "Voting
Rights, Markov Chains, and Optimization by Short Bursts."
redist_shortburst(
map,
score_fn = NULL,
stop_at = NULL,
burst_size = ifelse(backend == "mergesplit", 10L, 50L),
max_bursts = 500L,
maximize = TRUE,
init_plan = NULL,
counties = NULL,
constraints = redist_constr(map),
compactness = 1,
adapt_k_thresh = 0.95,
reversible = TRUE,
fixed_k = NULL,
return_all = TRUE,
thin = 1L,
backend = "mergesplit",
flip_lambda = 0,
flip_eprob = 0.05,
verbose = TRUE
)
map |
A redist_map object. |
score_fn |
A function which takes a matrix of plans and returns a score
(or, generally, a row vector) for each plan. Can also be a purrr-style
anonymous function. See |
stop_at |
A threshold to stop optimization at. When |
burst_size |
The size of each burst. 10 is recommended for the
|
max_bursts |
The maximum number of bursts to run before returning. |
maximize |
If |
init_plan |
The initial state of the map. If not provided, will default to
the reference map of the |
counties |
A vector containing county (or other administrative or
geographic unit) labels for each unit, which may be integers ranging from 1
to the number of counties, or a factor or character vector. If provided, the
algorithm will only generate maps which split up to |
constraints |
A |
compactness |
Controls the compactness of the generated districts, with
higher values preferring more compact districts. Must be non-negative. See
|
adapt_k_thresh |
The threshold value used in the heuristic to select a
value |
reversible |
If |
fixed_k |
If not |
return_all |
Whether to return all the burst results or just the best one (generally, the Pareto frontier). Recommended for monitoring purposes. |
thin |
Save every |
backend |
the MCMC algorithm to use within each burst, either "mergesplit" or "flip". |
flip_lambda |
The parameter determining the number of swaps to attempt each iteration of flip mcmc. The number of swaps each iteration is equal to Pois(lambda) + 1. The default is 0. |
flip_eprob |
The probability of keeping an edge connected in flip mcmc. The default is 0.05. |
verbose |
Whether to print out intermediate information while sampling. Recommended for monitoring purposes. |
a redist_plans
object containing the final best plan
(or the best plans after each burst, if return_all=TRUE
.
Cannon, S., Goldbloom-Helzner, A., Gupta, V., Matthews, J. N., & Suwal, B. (2020). Voting Rights, Markov Chains, and Optimization by Short Bursts. arXiv preprint arXiv:2011.02288.
data(iowa)
iowa_map <- redist_map(iowa, existing_plan = cd_2010, pop_tol = 0.01)
redist_shortburst(iowa_map, scorer_frac_kept(iowa_map), max_bursts = 50)
redist_shortburst(iowa_map, ~ 1 - scorer_frac_kept(iowa_map)(.), max_bursts = 50)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.