mirror of
https://github.com/ANL-CEEESA/MIPLearn.git
synced 2025-12-08 02:18:51 -06:00
Components: Switch from factory methods to prototype objects
This commit is contained in:
@@ -4,7 +4,6 @@
|
||||
|
||||
import logging
|
||||
import sys
|
||||
from copy import deepcopy
|
||||
from typing import Any, Dict
|
||||
|
||||
import numpy as np
|
||||
@@ -29,6 +28,7 @@ class DynamicLazyConstraintsComponent(Component):
|
||||
classifier: Classifier = CountingClassifier(),
|
||||
threshold: float = 0.05,
|
||||
):
|
||||
assert isinstance(classifier, Classifier)
|
||||
self.threshold: float = threshold
|
||||
self.classifier_prototype: Classifier = classifier
|
||||
self.classifiers: Dict[Any, Classifier] = {}
|
||||
@@ -75,7 +75,7 @@ class DynamicLazyConstraintsComponent(Component):
|
||||
if isinstance(v, list):
|
||||
v = tuple(v)
|
||||
if v not in self.classifiers:
|
||||
self.classifiers[v] = deepcopy(self.classifier_prototype)
|
||||
self.classifiers[v] = self.classifier_prototype.clone()
|
||||
violation_to_instance_idx[v] = []
|
||||
violation_to_instance_idx[v] += [idx]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user