mirror of
https://github.com/ANL-CEEESA/MIPLearn.git
synced 2025-12-07 18:08:51 -06:00
Add Component.xy and PrimalSolutionComponent.xy
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
# Released under the modified BSD license. See COPYING.md for more details.
|
||||
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import Any, List, Union, TYPE_CHECKING
|
||||
from typing import Any, List, Union, TYPE_CHECKING, Tuple, Dict
|
||||
|
||||
from miplearn.instance import Instance
|
||||
from miplearn.types import LearningSolveStats, TrainingSample
|
||||
@@ -12,6 +12,7 @@ if TYPE_CHECKING:
|
||||
from miplearn.solvers.learning import LearningSolver
|
||||
|
||||
|
||||
# noinspection PyMethodMayBeStatic
|
||||
class Component(ABC):
|
||||
"""
|
||||
A Component is an object which adds functionality to a LearningSolver.
|
||||
@@ -135,6 +136,17 @@ class Component(ABC):
|
||||
) -> None:
|
||||
return
|
||||
|
||||
def xy(
|
||||
self,
|
||||
instance: Any,
|
||||
training_sample: TrainingSample,
|
||||
) -> Tuple[Dict, Dict]:
|
||||
"""
|
||||
Given a training sample, returns a pair of x and y dictionaries containing,
|
||||
respectively, the matrices of ML features and the labels for the sample.
|
||||
"""
|
||||
return {}, {}
|
||||
|
||||
def iteration_cb(
|
||||
self,
|
||||
solver: "LearningSolver",
|
||||
|
||||
Reference in New Issue
Block a user