mirror of
https://github.com/ANL-CEEESA/MIPLearn.git
synced 2025-12-06 01:18:52 -06:00
Add static_ prefix to all static features
This commit is contained in:
@@ -25,13 +25,13 @@ def training_instances() -> List[Instance]:
|
||||
MemorySample(
|
||||
{
|
||||
"lazy_enforced": {"c1", "c2"},
|
||||
"instance_features": [5.0],
|
||||
"static_instance_features": [5.0],
|
||||
},
|
||||
),
|
||||
MemorySample(
|
||||
{
|
||||
"lazy_enforced": {"c2", "c3"},
|
||||
"instance_features": [5.0],
|
||||
"static_instance_features": [5.0],
|
||||
},
|
||||
),
|
||||
]
|
||||
@@ -56,7 +56,7 @@ def training_instances() -> List[Instance]:
|
||||
MemorySample(
|
||||
{
|
||||
"lazy_enforced": {"c3", "c4"},
|
||||
"instance_features": [8.0],
|
||||
"static_instance_features": [8.0],
|
||||
},
|
||||
)
|
||||
]
|
||||
|
||||
@@ -22,11 +22,11 @@ from miplearn.solvers.tests import assert_equals
|
||||
def sample() -> Sample:
|
||||
sample = MemorySample(
|
||||
{
|
||||
"var_names": ["x[0]", "x[1]", "x[2]", "x[3]"],
|
||||
"var_categories": ["default", None, "default", "default"],
|
||||
"static_var_names": ["x[0]", "x[1]", "x[2]", "x[3]"],
|
||||
"static_var_categories": ["default", None, "default", "default"],
|
||||
"mip_var_values": [0.0, 1.0, 1.0, 0.0],
|
||||
"instance_features": [5.0],
|
||||
"var_features": [
|
||||
"static_instance_features": [5.0],
|
||||
"static_var_features": [
|
||||
[0.0, 0.0],
|
||||
None,
|
||||
[1.0, 0.0],
|
||||
|
||||
@@ -24,16 +24,16 @@ from miplearn.types import (
|
||||
def sample() -> Sample:
|
||||
sample = MemorySample(
|
||||
{
|
||||
"constr_categories": [
|
||||
"static_constr_categories": [
|
||||
"type-a",
|
||||
"type-a",
|
||||
"type-a",
|
||||
"type-b",
|
||||
"type-b",
|
||||
],
|
||||
"constr_lazy": [True, True, True, True, False],
|
||||
"constr_names": ["c1", "c2", "c3", "c4", "c5"],
|
||||
"instance_features": [5.0],
|
||||
"static_constr_lazy": [True, True, True, True, False],
|
||||
"static_constr_names": ["c1", "c2", "c3", "c4", "c5"],
|
||||
"static_instance_features": [5.0],
|
||||
"lazy_enforced": {"c1", "c2", "c4"},
|
||||
"lp_constr_features": [
|
||||
[1.0, 1.0],
|
||||
@@ -42,7 +42,7 @@ def sample() -> Sample:
|
||||
[1.0, 4.0, 0.0],
|
||||
None,
|
||||
],
|
||||
"static_lazy_count": 4,
|
||||
"static_constr_lazy_count": 4,
|
||||
},
|
||||
)
|
||||
return sample
|
||||
|
||||
@@ -24,21 +24,27 @@ def test_knapsack() -> None:
|
||||
# after-load
|
||||
# -------------------------------------------------------
|
||||
extractor.extract_after_load_features(instance, solver, sample)
|
||||
assert_equals(sample.get_vector("var_names"), ["x[0]", "x[1]", "x[2]", "x[3]", "z"])
|
||||
assert_equals(sample.get_vector("var_lower_bounds"), [0.0, 0.0, 0.0, 0.0, 0.0])
|
||||
assert_equals(
|
||||
sample.get_vector("var_obj_coeffs"), [505.0, 352.0, 458.0, 220.0, 0.0]
|
||||
sample.get_vector("static_var_names"), ["x[0]", "x[1]", "x[2]", "x[3]", "z"]
|
||||
)
|
||||
assert_equals(sample.get_vector("var_types"), ["B", "B", "B", "B", "C"])
|
||||
assert_equals(sample.get_vector("var_upper_bounds"), [1.0, 1.0, 1.0, 1.0, 67.0])
|
||||
assert_equals(
|
||||
sample.get_vector("var_categories"),
|
||||
sample.get_vector("static_var_lower_bounds"), [0.0, 0.0, 0.0, 0.0, 0.0]
|
||||
)
|
||||
assert_equals(
|
||||
sample.get_vector("static_var_obj_coeffs"), [505.0, 352.0, 458.0, 220.0, 0.0]
|
||||
)
|
||||
assert_equals(sample.get_vector("static_var_types"), ["B", "B", "B", "B", "C"])
|
||||
assert_equals(
|
||||
sample.get_vector("static_var_upper_bounds"), [1.0, 1.0, 1.0, 1.0, 67.0]
|
||||
)
|
||||
assert_equals(
|
||||
sample.get_vector("static_var_categories"),
|
||||
["default", "default", "default", "default", None],
|
||||
)
|
||||
assert sample.get_vector_list("var_features") is not None
|
||||
assert_equals(sample.get_vector("constr_names"), ["eq_capacity"])
|
||||
assert sample.get_vector_list("static_var_features") is not None
|
||||
assert_equals(sample.get_vector("static_constr_names"), ["eq_capacity"])
|
||||
# assert_equals(
|
||||
# sample.get_vector("constr_lhs"),
|
||||
# sample.get_vector("static_constr_lhs"),
|
||||
# [
|
||||
# [
|
||||
# ("x[0]", 23.0),
|
||||
@@ -49,13 +55,13 @@ def test_knapsack() -> None:
|
||||
# ],
|
||||
# ],
|
||||
# )
|
||||
assert_equals(sample.get_vector("constr_rhs"), [0.0])
|
||||
assert_equals(sample.get_vector("constr_senses"), ["="])
|
||||
assert_equals(sample.get_vector("constr_features"), [None])
|
||||
assert_equals(sample.get_vector("constr_categories"), ["eq_capacity"])
|
||||
assert_equals(sample.get_vector("constr_lazy"), [False])
|
||||
assert_equals(sample.get_vector("instance_features"), [67.0, 21.75])
|
||||
assert_equals(sample.get_scalar("static_lazy_count"), 0)
|
||||
assert_equals(sample.get_vector("static_constr_rhs"), [0.0])
|
||||
assert_equals(sample.get_vector("static_constr_senses"), ["="])
|
||||
assert_equals(sample.get_vector("static_constr_features"), [None])
|
||||
assert_equals(sample.get_vector("static_constr_categories"), ["eq_capacity"])
|
||||
assert_equals(sample.get_vector("static_constr_lazy"), [False])
|
||||
assert_equals(sample.get_vector("static_instance_features"), [67.0, 21.75])
|
||||
assert_equals(sample.get_scalar("static_constr_lazy_count"), 0)
|
||||
|
||||
# after-lp
|
||||
# -------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user