mirror of
https://github.com/ANL-CEEESA/MIPLearn.git
synced 2025-12-06 01:18:52 -06:00
Add _gurobipy suffix to all build_model functions
This commit is contained in:
@@ -62,7 +62,7 @@ def test_usage_stab(
|
||||
stab_pyo_h5: List[str],
|
||||
default_extractor: FeaturesExtractor,
|
||||
) -> None:
|
||||
for (h5, build_model) in [
|
||||
for h5, build_model in [
|
||||
(stab_pyo_h5, build_stab_model_pyomo),
|
||||
(stab_gp_h5, build_stab_model_gurobipy),
|
||||
]:
|
||||
|
||||
@@ -56,7 +56,7 @@ def test_usage_tsp(
|
||||
tsp_pyo_h5: List[str],
|
||||
default_extractor: FeaturesExtractor,
|
||||
) -> None:
|
||||
for (h5, build_model) in [
|
||||
for h5, build_model in [
|
||||
(tsp_pyo_h5, build_tsp_model_pyomo),
|
||||
(tsp_gp_h5, build_tsp_model_gurobipy),
|
||||
]:
|
||||
|
||||
@@ -5,7 +5,11 @@
|
||||
import numpy as np
|
||||
from scipy.stats import uniform, randint
|
||||
|
||||
from miplearn.problems.binpack import build_binpack_model, BinPackData, BinPackGenerator
|
||||
from miplearn.problems.binpack import (
|
||||
build_binpack_model_gurobipy,
|
||||
BinPackData,
|
||||
BinPackGenerator,
|
||||
)
|
||||
|
||||
|
||||
def test_binpack_generator() -> None:
|
||||
@@ -48,7 +52,7 @@ def test_binpack_generator() -> None:
|
||||
|
||||
|
||||
def test_binpack() -> None:
|
||||
model = build_binpack_model(
|
||||
model = build_binpack_model_gurobipy(
|
||||
BinPackData(
|
||||
sizes=np.array([4, 8, 1, 4, 2, 1]),
|
||||
capacity=10,
|
||||
|
||||
@@ -8,7 +8,7 @@ from scipy.stats import uniform, randint
|
||||
from miplearn.problems.multiknapsack import (
|
||||
MultiKnapsackGenerator,
|
||||
MultiKnapsackData,
|
||||
build_multiknapsack_model,
|
||||
build_multiknapsack_model_gurobipy,
|
||||
)
|
||||
|
||||
|
||||
@@ -56,6 +56,6 @@ def test_knapsack_model() -> None:
|
||||
]
|
||||
),
|
||||
)
|
||||
model = build_multiknapsack_model(data)
|
||||
model = build_multiknapsack_model_gurobipy(data)
|
||||
model.optimize()
|
||||
assert model.inner.objVal == -460.0
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import numpy as np
|
||||
from scipy.stats import uniform, randint
|
||||
|
||||
from miplearn.problems.pmedian import PMedianGenerator, build_pmedian_model
|
||||
from miplearn.problems.pmedian import PMedianGenerator, build_pmedian_model_gurobipy
|
||||
|
||||
|
||||
def test_pmedian() -> None:
|
||||
@@ -46,7 +46,7 @@ def test_pmedian() -> None:
|
||||
[31.95, 17.05, 67.62, 58.88, 0.0],
|
||||
]
|
||||
|
||||
model = build_pmedian_model(data[0])
|
||||
model = build_pmedian_model_gurobipy(data[0])
|
||||
assert model.inner.numVars == 30
|
||||
assert model.inner.numConstrs == 11
|
||||
model.optimize()
|
||||
|
||||
@@ -6,7 +6,7 @@ import numpy as np
|
||||
|
||||
from miplearn.problems.setpack import (
|
||||
SetPackData,
|
||||
build_setpack_model,
|
||||
build_setpack_model_gurobipy,
|
||||
)
|
||||
|
||||
|
||||
@@ -21,6 +21,6 @@ def test_setpack() -> None:
|
||||
],
|
||||
),
|
||||
)
|
||||
model = build_setpack_model(data)
|
||||
model = build_setpack_model_gurobipy(data)
|
||||
model.optimize()
|
||||
assert model.inner.objval == -22.0
|
||||
|
||||
@@ -7,7 +7,7 @@ from scipy.stats import uniform, randint
|
||||
|
||||
from miplearn.problems.uc import (
|
||||
UnitCommitmentData,
|
||||
build_uc_model,
|
||||
build_uc_model_gurobipy,
|
||||
UnitCommitmentGenerator,
|
||||
)
|
||||
|
||||
@@ -60,12 +60,12 @@ def test_uc() -> None:
|
||||
cost_prod=np.array([1.0, 1.25, 1.5]),
|
||||
cost_fixed=np.array([10, 12, 9]),
|
||||
)
|
||||
model = build_uc_model(data)
|
||||
model = build_uc_model_gurobipy(data)
|
||||
model.optimize()
|
||||
assert model.inner.objVal == 154.5
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
data = UnitCommitmentGenerator().generate(1)[0]
|
||||
model = build_uc_model(data)
|
||||
model = build_uc_model_gurobipy(data)
|
||||
model.optimize()
|
||||
|
||||
@@ -7,7 +7,7 @@ import numpy as np
|
||||
|
||||
from miplearn.problems.vertexcover import (
|
||||
MinWeightVertexCoverData,
|
||||
build_vertexcover_model,
|
||||
build_vertexcover_model_gurobipy,
|
||||
)
|
||||
|
||||
|
||||
@@ -16,6 +16,6 @@ def test_stab() -> None:
|
||||
graph=nx.cycle_graph(5),
|
||||
weights=np.array([1.0, 1.0, 1.0, 1.0, 1.0]),
|
||||
)
|
||||
model = build_vertexcover_model(data)
|
||||
model = build_vertexcover_model_gurobipy(data)
|
||||
model.optimize()
|
||||
assert model.inner.objVal == 3.0
|
||||
|
||||
Reference in New Issue
Block a user