Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Andrew Friedman
/
Fairly Draw Election Districts
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Pipelines
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
fc361cef
authored
Mar 14, 2017
by
Isaac Wink
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of mit.cs.uchicago.edu:ajfriedman/election_district_drawing
parents
2cfc73d1
34e283c7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
3 deletions
algorithms/algorithms_new.py
algorithms/algorithms_new.py
View file @
fc361cef
...
...
@@ -863,7 +863,6 @@ def make_gap_lower(districts_dict, all_tracts, num_districts, used_tracts,
new_gap
=
calculate_efficiency_gap_from_dict
(
districts_dict
)
# print("hit", new_gap != best_gap)
if
abs
(
new_gap
)
<=
abs
(
best_gap
):
new
=
False
best_total
=
tract_total
...
...
@@ -884,13 +883,12 @@ def make_gap_lower(districts_dict, all_tracts, num_districts, used_tracts,
plus_total_population_D_R
(
districts_dict
,
best_district
,
best_total
,
best_dem
,
best_rep
)
minus_total_population_D_R
(
districts_dict
,
check_pop
,
best_total
,
best_dem
,
best_rep
)
gap
=
calculate_efficiency_gap_from_dict
(
districts_dict
)
printer
=
[
"lower"
,
check_pop
,
count
]
for
num
in
districts_dict
:
printer
.
append
(
districts_dict
[
num
][
"total_population"
])
printer
.
append
(
calculate_efficiency_gap_from_dict
(
districts_dict
))
print
(
printer
)
gap
=
calculate_efficiency_gap_from_dict
(
districts_dict
)
return
districts_dict
...
...
@@ -945,6 +943,13 @@ def completed_result(state, initial_percent_of_people=60, goal=5,
make_gap_lower
(
districts_dict
,
state_tract
,
num_districts
,
used_tracts
,
goal
,
min_pop_district
,
max_pop_district
)
copy
=
dict
(
districts_dict
)
for
district_num
in
copy
:
dist_info
=
districts_dict
[
district_num
]
dist_str
=
str
(
district_num
)
districts_dict
[
dist_str
]
=
dist_info
del
districts_dict
[
district_num
]
create_json_file
(
districts_dict
,
"district_plans/"
+
state
+
special_name
)
...
...
@@ -1052,3 +1057,6 @@ if __name__=="__main__":
#print(district_plan)
print
(
"The efficiency gap for this plan of {} is {}, which indicates that {} receive a districting advantage of {} seats."
.
format
(
sys
.
argv
[
1
],
results_gap
,
party
,
advantage
))
create_json_file
(
district_plan
,
"district_plans/"
+
sys
.
argv
[
1
])
d
=
recover_json
(
"district_plans/"
+
"Iowa"
+
".json"
)
print
(
d
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment