Skip to content

This project is my first experience with estimation algorithms to find districting solutions for states of voters.

Notifications You must be signed in to change notification settings

jomadu/SimulatedAnnealing_Gerrymandering

Repository files navigation

Bias-Free Gerrymandering Using Simulated Annealing

Author: Max Dunn

How to run:

From the terminal or command prompt:

> python main.py smallState.py or > python main.py largeState.py

Example user input prompt:

State Initialized:
 - Number of Voters: 64
 - Rows: 8
 - Columns: 8
Please enter a number of districts for this statethat is a factor of 64:
>

At this point, the user should enter a factor of 64, such as 8.

Example Program Output:

---------------------------------------
 Program Summary
---------------------------------------
|------------------------------------------------|
|  Solution:                                     |
|------------------------------------------------|

Row\Col |    0    1    2    3    4    5    6    7
-------------------------------------------------
0       |   0    0    1    1    2    2    1    4 
1       |   0    0    1    2    1    1    3    4 
2       |   0    1    3    2    1    3    4    3 
3       |   0    2    2    3    3    4    5    5 
4       |   0    0    2    3    4    5    6    6 
5       |   7    2    3    7    4    6    5    5 
6       |   7    7    7    4    4    5    6    6 
7       |   7    7    7    6    6    6    5    5 
-------------------------------------------------

|------------------------------------------------|
|  Fitness: 0.047619047619
|------------------------------------------------|

|------------------------------------------------|
|  Party Division in population                  |
|------------------------------------------------|
|            d: 56.25%                           |
|            r: 43.75%                           |
|  Independent:  0.00%                           |
|------------------------------------------------|

|------------------------------------------------|
|  Districts                                     |
|------------------------------------------------|
 District 1  : (0,2) (0,3) (0,6) (1,2) (1,4) (1,5) (2,1) (2,4)
 District 0  : (0,0) (0,1) (1,0) (1,1) (2,0) (3,0) (4,0) (4,1)
 District 3  : (1,6) (2,2) (2,5) (2,7) (3,3) (3,4) (4,3) (5,2)
 District 2  : (0,4) (0,5) (1,3) (2,3) (3,1) (3,2) (4,2) (5,1)
 District 5  : (3,6) (3,7) (4,5) (5,6) (5,7) (6,5) (7,6) (7,7)
 District 4  : (0,7) (1,7) (2,6) (3,5) (4,4) (5,4) (6,3) (6,4)
 District 7  : (5,0) (5,3) (6,0) (6,1) (6,2) (7,0) (7,1) (7,2)
 District 6  : (4,6) (4,7) (5,5) (6,6) (6,7) (7,3) (7,4) (7,5)
|------------------------------------------------|

|------------------------------------------------|
|  Number of District Votes by Party             |
|------------------------------------------------|
|       d:   4                                   |
|       r:   3                                   |
|------------------------------------------------|

---------------------------------------
 Program Summary
---------------------------------------
 Search States Explored: 334
---------------------------------------

Known Bugs:

When running with 'smallState.py', keep number of districts above 4. I'm working on a solution.

About

This project is my first experience with estimation algorithms to find districting solutions for states of voters.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages