OptaPlanner logo
  • Download
  • Learn
    • Documentation
    • Videos
    • Slides
    • Training

    • Use cases
    • Compatibility
    • Testimonials and case studies
  • Get help
  • Blog
  • Source
  • Team
  • Services
  • KIE
    • Drools
    • OptaPlanner
    • jBPM
    • Kogito
  • Star
  • T
  • L
  • F
  • YT
Fork me on GitHub

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 an 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.


Permalink
 tagged as use case

Comments

Visit our forum to comment

Giscus Comments

AtomNews feed
Don’t want to miss a single blog post?
Follow us on
  • T
  • L
  • F
Blog archive
Latest release
  • 8.14.0.Final released
    Wed 8 December 2021
Upcoming events
  • DevConf.CZ
    Brno, Czech Republic (virtual) - Fri 28 January 2022
    • Artificial Intelligence on Quarkus: I love it when an OptaPlan comes together by Geoffrey De Smet
  • JFokus
    Stockholm, Sweden - Mon 7 February 2022
    • AI maintenance scheduling with OptaPlanner on Quarkus by Geoffrey De Smet
  • Add event / Archive
Latest blog posts
  • OptaPlanner documentation turns over a new leaf
    Tue 26 October 2021
    Radovan Synek
  • Order picking optimization in warehouses and supermarkets with OptaPlanner
    Thu 14 October 2021
    Walter Medvedeo
  • Monitor OptaPlanner solvers through Micrometer
    Tue 12 October 2021
    Christopher Chianelli
  • A new AI constraint solver for Python: OptaPy
    Tue 5 October 2021
    Christopher Chianelli
  • How much faster is Java 17?
    Wed 15 September 2021
    Geoffrey De Smet
  • Constraint Streams get some more love
    Thu 19 August 2021
    Lukáš Petrovický
  • Let’s OptaPlan your jBPM tasks (part 2) - BPM Task assigning in the cloud
    Mon 26 July 2021
    Walter Medvedeo
  • Blog archive
Latest videos
  • AI lesson scheduling on Quarkus with OptaPlanner
    Thu 18 November 2021
    Geoffrey De Smet
  • Maintenance scheduling
    Fri 12 November 2021
    Geoffrey De Smet
  • Optimized order picking in warehouses and supermarkets
    Tue 26 October 2021
    Walter Medvedeo
  • A modern OO/FP constraint solver
    Tue 14 September 2021
    Geoffrey De Smet
  • Business processes task optimization in Kogito
    Tue 7 September 2021
    Walter Medvedeo
  • School timetable optimization
    Mon 6 September 2021
    Geoffrey De Smet
  • Schedule incoming calls real-time
    Mon 23 August 2021
    Radovan Synek
  • Video archive

OptaPlanner is open. All dependencies of this project are available under the Apache Software License 2.0 or a compatible license. OptaPlanner is trademarked.

This website was built with JBake and is open source.

Community

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

Code

  • Build from source
  • Issue tracker
  • Release notes
  • Upgrade recipes
  • Logo and branding

KIE projects

  • Drools rule engine
  • OptaPlanner constraint solver
  • jBPM workflow engine
  • Kogito Business Automation platform
CC by 3.0 | Privacy Policy
Sponsored by Red Hat