Toggle navigation OptaPlanner logo
  • Home
  • Download
  • Learn
    • Documentation
    • Videos
    • Slides
    • Training
    • Use cases
    • Compatibility
    • Testimonials and case studies
  • Get help
  • Source
  • Team
  • Services
  • Star
  • @OptaPlanner
  • Fb
Fork me on GitHub
  • A giant leap forward with multithreaded increme...
  • Unit testing constraints with business input fr...

How to defeat gerrymandering and create fair elections

Wed 25 July 2018

Avatar Justin Goldsmith

Justin Goldsmith


GitHub

Contributor

Over the years, politicians have redrawn electoral voting lines to gain an unfair advantage. This has led to district boundaries with shapes that have no obvious pattern or reason other than political gain. When districts are redrawn you can sway an election’s results without changing a single voter’s mind. Can OptaPlanner draw fair electoral boundaries and save democracy?

Gerrymandering hits the headlines:

  • How gerrymandering has skewed Virginia’s congressional delegation - Roanoke Times

  • What Extreme Partisan Gerrymandering Could Mean For 2018 Midterms - NPR

  • Don’t let politicians choose their voters - USA Today

It is easy to criticize boundary lines and claim gerrymandering, but it is a difficult topic to solve, especially when humans with their own motives pick the boundaries of the legislative borders. Should a "fair" district include an equal mix of underrepresented racial groups? Do you define borders based on competitiveness of party lines? Should geography constrain borders?

Using OptaPlanner we can treat drawing congressional districts as an optimization problem. Obviously our constraints could also be a point of political tension, but at least with software our constraints can be public and not hidden behind politicians private motives. For the sake of this experiment with OptaPlanner, I am only taking into account two constraints:

  • Equalize the population count across districts

  • Make the districts as compact as possible.

North Carolina Example

North Carolina has been one of the states with recent court cases around this topic. Here is the district map both before and after they redrew the districts to try to make it seem fair (source).

NorthCarolinaDistricts2013 2016
NorthCarolinaDistricts2017 2018

While it does seem like it did get better, there are still seemingly random shapes in the 2018 map, that do not seem fair. For example look at the pink district 4 in the middle of the map. It almost seems like two separate areas snaking between other districts.

Here is OptaPlanner’s result:

NorthCarolinaDistrictsOptaPlanner

The shapes in this image are much more regular. The small blocks you see are based of the US 2010 decennial census. There are about 8000 of them in North Carolina and they are the Planning Entity in this example, with the Planning Variable being just a integer 1-13 representing the districts. The average population in each district is about 714,000 people. Each district in this example is about plus or minus 2,000 from each other. Depending on how we want to weight the constraints, we can make the population in each district closer to the average. To get this good of an answer, the problem was run for about 6 minutes. Take a look at the source code.

There are definitely still a lot of improvements to be made to this solution, but all of this was done in a few days work as a side project. With some more time, maybe one day OptaPlanner can solve this contentious political issue.


Comments Permalink
 tagged as use case

Comments

Visit our forum to comment
  • A giant leap forward with multithreaded increme...
  • Unit testing constraints with business input fr...
Atom News feed
Don't want to miss a single blog post?
Follow us on
  • T
  • Fb
Blog archive
Latest release
  • 8.1.0.Final released
    Fri 15 January 2021
Upcoming events
  • KIE Live
    Worldwide - Tue 19 January 2021
    • OptaPlanner Shadow Variables for the Vehicle Routing Problem and Task Assignment by Geoffrey De Smet, Karina Varela, Alex Porcelli
  • Javaland
    Worldwide - Tue 16 March 2021
    • AI on Quarkus: I love it when an OptaPlan comes together by Geoffrey De Smet
Add event / Archive
Latest blog posts
  • Solve the facility location problem
    Fri 9 October 2020
     Jiří Locker
  • OptaPlanner Week 2020 recordings
    Mon 7 September 2020
     Geoffrey De Smet
  • Let’s OptaPlan your jBPM tasks (part 1) - Integrating the two worlds
    Fri 3 July 2020
     Walter Medvedeo
  • AI versus Covid-19: How Java helps nurses and doctors in this fight
    Fri 8 May 2020
     Christopher Chianelli
  • Workflow processes with AI scheduling
    Tue 5 May 2020
     Christopher Chianelli
  • Constraint Streams - Modern Java constraints without the Drools Rule Language
    Tue 7 April 2020
     Geoffrey De Smet
  • How to plan (and optimize) a Secret Santa
    Wed 18 December 2019
     Christopher Chianelli
Blog archive
Latest videos
  • YT Shadow variables
    Tue 19 January 2021
     Geoffrey De Smet
  • YT Domain modeling and design patterns
    Tue 17 November 2020
     Geoffrey De Smet
  • YT Quarkus insights: AI constraint solving
    Tue 20 October 2020
     Geoffrey De Smet
  • YT AI in kotlin
    Wed 23 September 2020
     Geoffrey De Smet
  • YT Planning agility: continuous planning, real-time planning and more
    Thu 3 September 2020
     Geoffrey De Smet
  • YT Quarkus and OptaPlanner: create a school timetable application
    Thu 3 September 2020
     Radovan Synek
  • YT Business use cases and the impact of OptaPlanner
    Thu 3 September 2020
     Satish Kale
Video archive

KIE projects

  • Drools rule engine
  • OptaPlanner constraint solver
  • jBPM workflow engine

Community

  • Blog
  • Get Help
  • Team
  • Governance
  • Academic research

Code

  • Build from source
  • Submit a bug
  • License (Apache-2.0)
  • Release notes
  • Upgrade recipes
Sponsored by
Red Hat
More coder content at
Red Hat Developers
© Copyright 2006-2021, Red Hat, Inc. or third-party contributors - Privacy statement - Terms of use - Website info