mirror of
https://github.com/ANL-CEEESA/MIPLearn.git
synced 2025-12-06 01:18:52 -06:00
Rename Variables and Constraints; move to internal.py
This commit is contained in:
@@ -11,9 +11,9 @@ from numpy.testing import assert_array_equal
|
||||
from miplearn.classifiers import Classifier
|
||||
from miplearn.classifiers.threshold import Threshold, MinProbabilityThreshold
|
||||
from miplearn.components.static_lazy import StaticLazyConstraintsComponent
|
||||
from miplearn.features import Sample, ConstraintFeatures
|
||||
from miplearn.features import Sample
|
||||
from miplearn.instance.base import Instance
|
||||
from miplearn.solvers.internal import InternalSolver
|
||||
from miplearn.solvers.internal import InternalSolver, Constraints
|
||||
from miplearn.solvers.learning import LearningSolver
|
||||
from miplearn.types import (
|
||||
LearningSolveStats,
|
||||
@@ -118,7 +118,7 @@ def test_usage_with_solver(instance: Instance) -> None:
|
||||
|
||||
# Should ask internal solver to verify if constraints in the pool are
|
||||
# satisfied and add the ones that are not
|
||||
c = ConstraintFeatures.from_sample(sample)[[False, False, True, False, False]]
|
||||
c = Constraints.from_sample(sample)[[False, False, True, False, False]]
|
||||
internal.are_constraints_satisfied.assert_called_once_with(c, tol=1.0)
|
||||
internal.are_constraints_satisfied.reset_mock()
|
||||
internal.add_constraints.assert_called_once_with(c)
|
||||
|
||||
@@ -6,10 +6,9 @@ import numpy as np
|
||||
|
||||
from miplearn.features import (
|
||||
FeaturesExtractor,
|
||||
VariableFeatures,
|
||||
ConstraintFeatures,
|
||||
Sample,
|
||||
)
|
||||
from miplearn.solvers.internal import Variables, Constraints
|
||||
from miplearn.solvers.gurobi import GurobiSolver
|
||||
from miplearn.solvers.tests import assert_equals
|
||||
|
||||
@@ -129,7 +128,7 @@ def test_knapsack() -> None:
|
||||
|
||||
|
||||
def test_constraint_getindex() -> None:
|
||||
cf = ConstraintFeatures(
|
||||
cf = Constraints(
|
||||
names=["c1", "c2", "c3"],
|
||||
rhs=[1.0, 2.0, 3.0],
|
||||
senses=["=", "<", ">"],
|
||||
@@ -150,7 +149,7 @@ def test_constraint_getindex() -> None:
|
||||
)
|
||||
assert_equals(
|
||||
cf[[True, False, True]],
|
||||
ConstraintFeatures(
|
||||
Constraints(
|
||||
names=["c1", "c3"],
|
||||
rhs=[1.0, 3.0],
|
||||
senses=["=", ">"],
|
||||
@@ -177,8 +176,8 @@ def test_assert_equals() -> None:
|
||||
np.array([[1.0, 2.0], [3.0, 4.0]]),
|
||||
)
|
||||
assert_equals(
|
||||
VariableFeatures(values=np.array([1.0, 2.0])), # type: ignore
|
||||
VariableFeatures(values=np.array([1.0, 2.0])), # type: ignore
|
||||
Variables(values=np.array([1.0, 2.0])), # type: ignore
|
||||
Variables(values=np.array([1.0, 2.0])), # type: ignore
|
||||
)
|
||||
assert_equals(np.array([True, True]), [True, True])
|
||||
assert_equals((1.0,), (1.0,))
|
||||
|
||||
Reference in New Issue
Block a user