library(redist)
#>
#> Attaching package: 'redist'
#> The following object is masked from 'package:stats':
#>
#> filter
data(iowa)
ia <- redist_map(iowa, existing_plan = cd_2010,
pop_tol = 0.01)
redist_mergesplit_parallel(ia, 10, 2, ncores = 2)
#> Sampling initial plans with SMCSEQUENTIAL MONTE CARLO
#> Sampling 2 99-unit maps with 4 districts and population between 753973 and 769205.
#> Making split 1 of 3Note: maximum hit; falling back to naive k estimator.
#> (using k = 1)
#> >------------------------------ 0% | ETA:?
#> ```
> 25% acceptance rate, 100% efficiency.
> Making split 2 of 3Note: maximum hit; falling back to naive k estimator.
> (using k = 1)
> 29% acceptance rate, 99.8% efficiency.
> Making split 3 of 3Note: maximum hit; falling back to naive k estimator.
> (using k = 1)
> 5.4% acceptance rate, 99.6% efficiency.
> A containing 10 sampled plans and 2 reference plans
> Plans have 4 districts from a 99-unit map, and were drawn using Merge-split
Current fix for anyone:
Specify
init_plan = get_existing(you_map_object)
> 25% acceptance rate, 100% efficiency.
> Making split 2 of 3Note: maximum hit; falling back to naive k estimator.
> (using k = 1)
> 29% acceptance rate, 99.8% efficiency.
> Making split 3 of 3Note: maximum hit; falling back to naive k estimator.
> (using k = 1)
> 5.4% acceptance rate, 99.6% efficiency.
> A containing 10 sampled plans and 2 reference plans
> Plans have 4 districts from a 99-unit map, and were drawn using Merge-split
> Markov chain Monte Carlo.
> Plans matrix: num [1:99, 1:12] 4 4 1 4 4 1 1 2 1 1 …
> # A tibble: 48 x 4
> draw chain district total_pop
>
> 1 1 1 1 759219
> 2 1 1 2 754687
> 3 1 1 3 764154
> 4 1 1 4 768295
> 5 2 2 1 759219
> 6 2 2 2 754687
> 7 2 2 3 764154
> 8 2 2 4 768295
> 9 1 1 1 756937
> 10 1 1 2 764525
> # … with 38 more rows
get_existing(ia)
> [1] 3 3 1 2 4 1 1 4 1 1 4 4 4 4 3 2 4 4 4 2 4 1 2 4 3 2 2 1 2 4 1 4 1 4 4 3 4 4
> [39] 3 4 4 4 4 2 1 4 4 1 1 2 2 2 1 2 4 2 1 2 2 4 3 2 2 1 3 1 4 2 3 2 4 4 3 4 4 4
> [77] 3 3 1 3 4 2 4 4 4 1 3 3 2 2 3 2 2 4 4 1 4 1 4
```
Created on 2021-11-20 by the reprex package (v2.0.1)
The issue appears to be here, where it looks only at
init_plan
, notinit_plans
& init_plan, as
init_plan` isn't updated.