alarm-redist / redist

Simulation methods for legislative redistricting.
https://alarm-redist.github.io/redist/
GNU General Public License v2.0
66 stars 23 forks source link

redist_mergesplit_parallel() error in dev branch #132

Closed dinosg closed 2 years ago

dinosg commented 2 years ago

returns error on redist_mergesplit_parallel(map, {other args}...) Error in { : task 1 failed - "Evaluation error: object 'map' not found."

in code it says "cli_abort(c("Adaptive {.var k} not found. This error should not happen.", ">"="Please file an issue

dinosg commented 2 years ago

when running with a constraint, errors can differ: for example when running this code pa_plans_0 = redist_mergesplit(pa_map, nsims = 10000, compactness = 1, counties = pa_map$FIPS, constraints = list( splits = list(strength = 3) ) )

get Using k = 1 Error in { : task 1 failed - "Index out of bounds: [index='admin']."

when running with a custom constraint, constr = redist_constr(pa_map) constr = add_constr_custom(constr, 3, # the constraint strength function(plan, distr) { check_ctys = unique(pa_map$FIPS[plan == distr]) # which counties this district touches is_split = sapply(check_ctys, function(cty) n_distinct(plan[pa_map$FIPS == cty]) > 1) sum(is_split) # penalty = # of counties split by this district })

constr = add_constr_multisplits(constr, strength=1.5, admin=FIPS) pa_plans_31 = redist_mergesplit(pa_map, nsims = 1000, compactness = 1, init_plan = pa_map$HDlrc, counties = pa_map$FIPS, constraints = constr )

get: Error in { : task 1 failed - "Evaluation error: object 'pa_map' not found."

using the flag cl_type="FORK" didn't fix any problems

CoryMcCartan commented 2 years ago

I can't reproduce this, as I don't have your data. I am also able to reproduce it with a similar type of constraint on our own data. Can you provide a reproducible example?