mirror of
https://github.com/ANL-CEEESA/MIPLearn.git
synced 2025-12-11 11:58:51 -06:00
MIPLearn v0.3
This commit is contained in:
26
tests/components/primal/test_expert.py
Normal file
26
tests/components/primal/test_expert.py
Normal 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,)
|
||||
Reference in New Issue
Block a user