mirror of
https://github.com/ANL-CEEESA/MIPLearn.git
synced 2025-12-06 09:28:51 -06:00
Combine np.ndarray conversion with rounding
This commit is contained in:
@@ -16,8 +16,8 @@ from miplearn.solvers.internal import InternalSolver
|
||||
from miplearn.solvers.learning import LearningSolver
|
||||
|
||||
# noinspection PyUnresolvedReferences
|
||||
from miplearn.solvers.tests import _round
|
||||
from tests.solvers.test_internal_solver import internal_solvers
|
||||
from miplearn.solvers.tests import assert_equals
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -51,7 +51,7 @@ def test_learning_solver(
|
||||
after_lp = sample.after_lp
|
||||
assert after_lp is not None
|
||||
assert after_lp.variables is not None
|
||||
assert _round(after_lp.variables.values) == [1.0, 0.923077, 1.0, 0.0, 67.0]
|
||||
assert_equals(after_lp.variables.values, [1.0, 0.923077, 1.0, 0.0, 67.0])
|
||||
assert after_lp.lp_solve is not None
|
||||
assert after_lp.lp_solve.lp_value is not None
|
||||
assert round(after_lp.lp_solve.lp_value, 3) == 1287.923
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
# Copyright (C) 2020-2021, UChicago Argonne, LLC. All rights reserved.
|
||||
# Released under the modified BSD license. See COPYING.md for more details.
|
||||
|
||||
import numpy as np
|
||||
|
||||
from miplearn.features import (
|
||||
FeaturesExtractor,
|
||||
InstanceFeatures,
|
||||
@@ -9,11 +11,7 @@ from miplearn.features import (
|
||||
ConstraintFeatures,
|
||||
)
|
||||
from miplearn.solvers.gurobi import GurobiSolver
|
||||
from miplearn.solvers.tests import (
|
||||
assert_equals,
|
||||
_round,
|
||||
)
|
||||
import numpy as np
|
||||
from miplearn.solvers.tests import assert_equals
|
||||
|
||||
inf = float("inf")
|
||||
|
||||
@@ -30,7 +28,7 @@ def test_knapsack() -> None:
|
||||
assert features.instance is not None
|
||||
|
||||
assert_equals(
|
||||
_round(features.variables),
|
||||
features.variables,
|
||||
VariableFeatures(
|
||||
names=["x[0]", "x[1]", "x[2]", "x[3]", "z"],
|
||||
basis_status=["U", "B", "U", "L", "U"],
|
||||
@@ -64,7 +62,7 @@ def test_knapsack() -> None:
|
||||
),
|
||||
)
|
||||
assert_equals(
|
||||
_round(features.constraints),
|
||||
features.constraints,
|
||||
ConstraintFeatures(
|
||||
basis_status=["N"],
|
||||
categories=["eq_capacity"],
|
||||
|
||||
Reference in New Issue
Block a user