mirror of
https://github.com/ANL-CEEESA/MIPLearn.git
synced 2025-12-09 19:08:51 -06:00
Add first model feature (constraint RHS)
This commit is contained in:
26
miplearn/features.py
Normal file
26
miplearn/features.py
Normal file
@@ -0,0 +1,26 @@
|
||||
# MIPLearn: Extensible Framework for Learning-Enhanced Mixed-Integer Optimization
|
||||
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
|
||||
# Released under the modified BSD license. See COPYING.md for more details.
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from miplearn.types import ModelFeatures
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from miplearn import InternalSolver
|
||||
|
||||
|
||||
class ModelFeaturesExtractor:
|
||||
def __init__(
|
||||
self,
|
||||
internal_solver: "InternalSolver",
|
||||
) -> None:
|
||||
self.internal_solver = internal_solver
|
||||
|
||||
def extract(self) -> ModelFeatures:
|
||||
rhs = {}
|
||||
for cid in self.internal_solver.get_constraint_ids():
|
||||
rhs[cid] = self.internal_solver.get_constraint_rhs(cid)
|
||||
return {
|
||||
"ConstraintRHS": rhs,
|
||||
}
|
||||
Reference in New Issue
Block a user