MIPLearn v0.3

This commit is contained in:
2023-06-08 11:25:39 -05:00
parent 6cc253a903
commit 1ea989d48a
172 changed files with 10495 additions and 24812 deletions

View File

@@ -0,0 +1,26 @@
# MIPLearn: Extensible Framework for Learning-Enhanced Mixed-Integer Optimization
# Copyright (C) 2020-2022, UChicago Argonne, LLC. All rights reserved.
# Released under the modified BSD license. See COPYING.md for more details.
from typing import List, Dict, Any
from unittest.mock import Mock
from miplearn.components.primal.actions import SetWarmStart, FixVariables
from miplearn.components.primal.expert import ExpertPrimalComponent
def test_expert(multiknapsack_h5: List[str]) -> None:
model = Mock()
stats: Dict[str, Any] = {}
comp = ExpertPrimalComponent(action=SetWarmStart())
comp.before_mip(multiknapsack_h5[0], model, stats)
model.set_warm_starts.assert_called()
names, starts, _ = model.set_warm_starts.call_args.args
assert names.shape == (100,)
assert starts.shape == (1, 100)
comp = ExpertPrimalComponent(action=FixVariables())
comp.before_mip(multiknapsack_h5[0], model, stats)
model.fix_variables.assert_called()
names, v, _ = model.fix_variables.call_args.args
assert names.shape == (100,)
assert v.shape == (100,)