mirror of
https://github.com/ANL-CEEESA/MIPLearn.git
synced 2025-12-06 09:28:51 -06:00
Remove obsolete extractor classes
This commit is contained in:
@@ -22,7 +22,6 @@ from .components.primal import PrimalSolutionComponent
|
||||
from .components.steps.convert_tight import ConvertTightIneqsIntoEqsStep
|
||||
from .components.steps.drop_redundant import DropRedundantInequalitiesStep
|
||||
from .components.steps.relax_integrality import RelaxIntegralityStep
|
||||
from .extractors import InstanceFeaturesExtractor
|
||||
from .instance import (
|
||||
Instance,
|
||||
PickleGzInstance,
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
# 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.
|
||||
|
||||
import logging
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
import numpy as np
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Extractor(ABC):
|
||||
@abstractmethod
|
||||
def extract(self, instances):
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def split_variables(instance):
|
||||
result = {}
|
||||
lp_solution = instance.training_data[0].lp_solution
|
||||
for var_name in lp_solution:
|
||||
for index in lp_solution[var_name]:
|
||||
category = instance.get_variable_category(var_name, index)
|
||||
if category is None:
|
||||
continue
|
||||
if category not in result:
|
||||
result[category] = []
|
||||
result[category] += [(var_name, index)]
|
||||
return result
|
||||
|
||||
|
||||
class InstanceFeaturesExtractor(Extractor):
|
||||
def extract(self, instances):
|
||||
return np.vstack(
|
||||
[
|
||||
np.hstack(
|
||||
[
|
||||
instance.get_instance_features(),
|
||||
instance.training_data[0].lp_value,
|
||||
]
|
||||
)
|
||||
for instance in instances
|
||||
]
|
||||
)
|
||||
Reference in New Issue
Block a user