OptaPlanner logo
  • Download
  • Learn
    • Documentation
    • Videos

    • Use cases
    • Compatibility
    • Testimonials and case studies
  • Get help
  • Blog
  • Source
  • Team
  • Services
  • 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
AtomNews feed
Don’t want to miss a single blog post?
Follow us on
  • T
  • L
  • F
Blog archive
Latest release
  • 9.44.0.Final released
    Wed 6 September 2023
Upcoming events
    Add event / Archive
Latest blog posts
  • Scaling Up Vehicle Routing Problem with planning list variable and Nearby Selector
    Thu 27 April 2023
    Anna Dupliak
  • OptaPlanner 9 has been released
    Mon 24 April 2023
    Radovan Synek
  • OptaPlanner 9 is coming
    Tue 21 February 2023
    Lukáš Petrovický
  • Farewell - a new lead
    Tue 15 November 2022
    Geoffrey De Smet
  • Run OptaPlanner workloads on OpenShift, part II
    Wed 9 November 2022
    Radovan Synek
  • Bavet - A faster score engine for OptaPlanner
    Tue 6 September 2022
    Geoffrey De Smet
  • Run OptaPlanner workloads on OpenShift, part I.
    Thu 9 June 2022
    Radovan Synek
  • Blog archive
Latest videos
  • The Vehicle Routing Problem
    Fri 23 September 2022
    Geoffrey De Smet
  • Introduction to OptaPlanner AI constraint solver
    Thu 25 August 2022
    Anna Dupliak
  • On schedule: Artificial Intelligence plans that meet expectations
    Sat 23 July 2022
    Geoffrey De Smet
  • Host your OptaPlanner app on OpenShift (Kubernetes)
    Mon 7 February 2022
    Geoffrey De Smet
  • OptaPlanner - A fast, easy-to-use, open source AI constraint solver for software developers
    Mon 31 January 2022
  • Order picking planning with OptaPlanner
    Fri 31 December 2021
    Anna Dupliak
  • AI lesson scheduling on Quarkus with OptaPlanner
    Thu 18 November 2021
    Geoffrey De Smet
  • 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
CC by 3.0 | Privacy Policy
Sponsored by Red Hat