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

Hinge on specific districts #120

Closed sthau closed 2 years ago

sthau commented 2 years ago

Similar to redist.group.percent() for Shortburst, it would be useful to be able to set hinge constraints on a particular district (ie setting a constraint on the 4th highest BVAP district). It's similar to the existing ability to input multiple targets, but would be useful to be able to target one non-top district. Would be nice to have the ability to hinge in both directions.

christopherkenny commented 2 years ago

@sthau, the issue here is that knowing what district 4 or 5 is can't really be done in the SMC framework. I added the inverse hinge constraint in dev. Seems very unlikely that we will do a district-specific constraint, as we want the constraints to be completely transferable between algorithms. Thoughts @CoryMcCartan?

CoryMcCartan commented 2 years ago

Yeah, this isn't possible for SMC. So for M-S you'd have to write a custom constraint that calculates the BVAP percent for all the districts, sorts it, and then applies the appropriate penalty.

Something like

function(plan, distr) {
    bvap = tapply(map$bvap, plan, sum) / tapply(map$vap, plan, sum)
    if (order(bvap)[distr] == 4) {
        max(bvap[distr] - 0.55, 0)
    }
}
sthau commented 2 years ago

Ok that makes sense with wanting to make sure that they transfer -- I had written a variant of that for MS as a custom constraint so I can just stick with that in the future when this comes up.