mirror of
https://github.com/ANL-CEEESA/MIPLearn.git
synced 2025-12-06 09:28:51 -06:00
Objective: Use LP value as feature
This commit is contained in:
@@ -108,9 +108,8 @@ class ObjectiveValueComponent(Component):
|
|||||||
def x(instances: Union[List[str], List[Instance]]) -> np.ndarray:
|
def x(instances: Union[List[str], List[Instance]]) -> np.ndarray:
|
||||||
result = []
|
result = []
|
||||||
for instance in InstanceIterator(instances):
|
for instance in InstanceIterator(instances):
|
||||||
for _ in instance.training_data:
|
for sample in instance.training_data:
|
||||||
instance_features = instance.get_instance_features()
|
result.append(instance.get_instance_features() + [sample["LP value"]])
|
||||||
result.append(instance_features)
|
|
||||||
return np.array(result)
|
return np.array(result)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
@@ -23,10 +23,12 @@ def test_x_y_predict() -> None:
|
|||||||
{
|
{
|
||||||
"Lower bound": 1.0,
|
"Lower bound": 1.0,
|
||||||
"Upper bound": 2.0,
|
"Upper bound": 2.0,
|
||||||
|
"LP value": 3.0,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Lower bound": 1.5,
|
"Lower bound": 1.5,
|
||||||
"Upper bound": 2.2,
|
"Upper bound": 2.2,
|
||||||
|
"LP value": 3.4,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -41,7 +43,7 @@ def test_x_y_predict() -> None:
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Should build x correctly
|
# Should build x correctly
|
||||||
x_expected = np.array([[1.0, 2.0], [1.0, 2.0]])
|
x_expected = np.array([[1.0, 2.0, 3.0], [1.0, 2.0, 3.4]])
|
||||||
assert_array_equal(comp.x([instance]), x_expected)
|
assert_array_equal(comp.x([instance]), x_expected)
|
||||||
|
|
||||||
# Should build y correctly
|
# Should build y correctly
|
||||||
|
|||||||
Reference in New Issue
Block a user