Skip to content

Commit 7d866f2

Browse files
committed
Switched from CBC to HiGHS
1 parent dcc412e commit 7d866f2

File tree

7 files changed

+13
-13
lines changed

7 files changed

+13
-13
lines changed

pabutools/analysis/fairshare.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from pulp import LpProblem, LpMaximize, LpBinary, LpVariable, lpSum, PULP_CBC_CMD, value
1+
from pulp import LpProblem, LpMaximize, LpBinary, LpVariable, lpSum, value, HiGHS
22

33
from pabutools.election import Instance, AbstractApprovalProfile
44
from pabutools.fractions import frac
@@ -76,7 +76,7 @@ def min_distance_to_fair_share(instance: Instance, profile: AbstractApprovalProf
7676
mip_model += share_abs_vars[i] >= share_vars[i] - float(ballot_fairshare)
7777
mip_model += share_abs_vars[i] >= float(ballot_fairshare) - share_vars[i]
7878

79-
mip_model.solve(PULP_CBC_CMD(msg=False))
79+
mip_model.solve(HiGHS(msg=False))
8080

8181
return value(mip_model.objective)
8282

pabutools/analysis/priceability.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ def priceable(
417417
else:
418418
model += 0 # No-op objective if none is specified
419419

420-
solver = pulp.PULP_CBC_CMD(msg=verbose, timeLimit=max_seconds)
420+
solver = pulp.HiGHS(msg=verbose, timeLimit=max_seconds)
421421
status = model.solve(solver)
422422

423423
if status not in [pulp.LpStatusOptimal]:

pabutools/election/instance.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from collections.abc import Collection, Generator
1010

11-
from pulp import LpProblem, LpMaximize, LpVariable, LpBinary, lpSum, PULP_CBC_CMD, LpStatusOptimal, value
11+
from pulp import LpProblem, LpMaximize, LpVariable, LpBinary, lpSum, LpStatusOptimal, value, HiGHS
1212

1313
from pabutools.utils import Numeric
1414

@@ -185,7 +185,7 @@ def max_budget_allocation_cost(
185185
mip_model += lpSum(p_vars[p] * p.cost for p in projects) <= budget_limit
186186

187187
# Solve the model
188-
mip_model.solve(PULP_CBC_CMD(msg=False))
188+
mip_model.solve(HiGHS(msg=False))
189189

190190
if mip_model.status == LpStatusOptimal:
191191
max_cost = value(mip_model.objective)

pabutools/election/satisfaction/additivesatisfaction.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from collections.abc import Callable, Collection
88

9-
from pulp import LpProblem, LpMaximize, LpBinary, LpVariable, lpSum, PULP_CBC_CMD, value
9+
from pulp import LpProblem, LpMaximize, LpBinary, LpVariable, lpSum, value, HiGHS
1010

1111
from pabutools.utils import Numeric
1212

@@ -794,7 +794,7 @@ def preprocessing(
794794
# Budget constraint
795795
mip_model += lpSum(p_vars[p] * p.cost for p in instance) <= instance.budget_limit
796796

797-
mip_model.solve(PULP_CBC_CMD(msg=False))
797+
mip_model.solve(HiGHS(msg=False))
798798

799799
res = value(mip_model.objective)
800800

pabutools/rules/maximin_support.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from collections.abc import Collection
1010

11-
from pulp import LpProblem, LpMinimize, LpVariable, lpSum, LpStatusOptimal, value, PULP_CBC_CMD
11+
from pulp import LpProblem, LpMinimize, LpVariable, lpSum, LpStatusOptimal, value, HiGHS
1212

1313
from pabutools.election import (
1414
Instance,
@@ -152,7 +152,7 @@ def _compute_optimal_load(projects, profile):
152152

153153
prob += z # Objective: minimize max load
154154

155-
status = prob.solve(PULP_CBC_CMD(msg=False))
155+
status = prob.solve(HiGHS(msg=False))
156156

157157
# This can mean a project that no one approves of for instance
158158
if status != LpStatusOptimal:

pabutools/rules/maxwelfare.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import math
1111

12-
from pulp import LpProblem, LpMaximize, LpVariable, LpBinary, lpSum, PULP_CBC_CMD, value, LpStatusOptimal
12+
from pulp import LpProblem, LpMaximize, LpVariable, LpBinary, lpSum, value, LpStatusOptimal, HiGHS
1313

1414
from pabutools.election import (
1515
Instance,
@@ -83,7 +83,7 @@ def max_additive_utilitarian_welfare_ilp_scheme(
8383
available_budget = instance.budget_limit - total_cost(initial_budget_allocation)
8484
mip_model += lpSum(p_vars[p] * p.cost for p in p_vars) <= available_budget
8585

86-
mip_model.solve(PULP_CBC_CMD(msg=False))
86+
mip_model.solve(HiGHS(msg=False))
8787
opt_value = value(mip_model.objective)
8888

8989
# First allocation
@@ -113,7 +113,7 @@ def max_additive_utilitarian_welfare_ilp_scheme(
113113
lpSum(p_vars[p] for p in p_vars if p not in previous_partial_alloc)
114114
) <= len(previous_partial_alloc) - 1
115115

116-
mip_model.solve(PULP_CBC_CMD(msg=False))
116+
mip_model.solve(HiGHS(msg=False))
117117

118118
if mip_model.status != LpStatusOptimal:
119119
break

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ dependencies = [
3131
"preflibtools>=2.0.33",
3232
"natsort",
3333
"pulp",
34-
"gurobipy"
34+
"highspy"
3535
]
3636

3737
[project.optional-dependencies]

0 commit comments

Comments
 (0)