Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Runs redistricting analysis in R with the redistverse packages, covering data loading, simulation, constraints, metrics and visualization.
45% 86%+41 ptsof test cases passed
Passed 19 of 22 test cases with the skill, and 10 of 22 without it.
To obtain official Census Bureau Block Assignment Files (BAF) for state legislative redistricting reconciliation in R, which package provides a direct function to download these BAF files?
The response recommends using the baf package.
3 of 3 safety checks passed
Constraints shape the target distribution of simulated plans. Hard constraints (population balance, contiguity) are enforced by construction; soft constraints are penalties applied as sampling weights. Build a constraint object with redist_constr(), then pipe in add_constr_*() calls.
constr <- redist_constr(map)
Pass constr to redist_smc(), redist_mergesplit(), or redist_flip() via the constraints argument.
These are automatically enforced and do not need to be added to redist_constr:
| Constraint | How enforced |
|---|---|
| Contiguity | Guaranteed by tree-based construction in SMC/merge-split |
| Population balance | Controlled by pop_tol in redist_map (see set_pop_tol()) |
All add_constr_*() functions take strength as their primary tuning parameter. Higher strength = stronger penalty = stronger pull toward the constraint target. Start with moderate values and verify outcomes in the simulated ensemble.
constr <- constr |>
add_constr_splits(
strength = 1.5, # penalty per additional split (log scale)
admin = map$county # column defining administrative units
)
Also available:
add_constr_multisplits(strength, admin) # penalizes splitting a unit into 3+ pieces
Next to this one in the catalogue, plus more from the same author.