mirror of
https://github.com/ANL-CEEESA/MIPLearn.git
synced 2025-12-06 01:18:52 -06:00
Convert InstanceFeatures into dataclass
This commit is contained in:
@@ -12,7 +12,12 @@ from miplearn import LearningSolver, InternalSolver, Instance
|
||||
from miplearn.classifiers import Classifier
|
||||
from miplearn.classifiers.threshold import Threshold, MinProbabilityThreshold
|
||||
from miplearn.components.lazy_static import StaticLazyConstraintsComponent
|
||||
from miplearn.types import TrainingSample, Features, LearningSolveStats
|
||||
from miplearn.types import (
|
||||
TrainingSample,
|
||||
Features,
|
||||
LearningSolveStats,
|
||||
InstanceFeatures,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@@ -25,9 +30,10 @@ def sample() -> TrainingSample:
|
||||
@pytest.fixture
|
||||
def features() -> Features:
|
||||
return Features(
|
||||
instance={
|
||||
"Lazy constraint count": 4,
|
||||
},
|
||||
instance=InstanceFeatures(
|
||||
user_features=[0],
|
||||
lazy_constraint_count=4,
|
||||
),
|
||||
constraints={
|
||||
"c1": {
|
||||
"Category": "type-a",
|
||||
|
||||
@@ -9,7 +9,7 @@ from numpy.testing import assert_array_equal
|
||||
|
||||
from miplearn import GurobiPyomoSolver, LearningSolver, Regressor
|
||||
from miplearn.components.objective import ObjectiveValueComponent
|
||||
from miplearn.types import TrainingSample, Features
|
||||
from miplearn.types import TrainingSample, Features, InstanceFeatures
|
||||
from tests.fixtures.knapsack import get_knapsack_instance
|
||||
|
||||
import numpy as np
|
||||
@@ -18,9 +18,9 @@ import numpy as np
|
||||
@pytest.fixture
|
||||
def features() -> Features:
|
||||
return Features(
|
||||
instance={
|
||||
"User features": [1.0, 2.0],
|
||||
}
|
||||
instance=InstanceFeatures(
|
||||
user_features=[1.0, 2.0],
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
from miplearn import GurobiSolver
|
||||
from miplearn.features import FeaturesExtractor
|
||||
from miplearn.types import VariableFeatures
|
||||
from miplearn.types import VariableFeatures, InstanceFeatures
|
||||
from tests.fixtures.knapsack import get_knapsack_instance
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ def test_knapsack() -> None:
|
||||
"User features": [0.0],
|
||||
}
|
||||
}
|
||||
assert instance.features.instance == {
|
||||
"User features": [67.0, 21.75],
|
||||
"Lazy constraint count": 0,
|
||||
}
|
||||
assert instance.features.instance == InstanceFeatures(
|
||||
user_features=[67.0, 21.75],
|
||||
lazy_constraint_count=0,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user