|
|
|
@ -18,6 +18,7 @@ class PrimalSolutionComponent(Component):
|
|
|
|
|
"""
|
|
|
|
|
A component that predicts primal solutions.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
def __init__(self,
|
|
|
|
|
classifier=AdaptiveClassifier(),
|
|
|
|
|
mode="exact",
|
|
|
|
@ -113,7 +114,8 @@ class PrimalSolutionComponent(Component):
|
|
|
|
|
return solution
|
|
|
|
|
|
|
|
|
|
def evaluate(self, instances):
|
|
|
|
|
ev = {}
|
|
|
|
|
ev = {"Fix zero": {},
|
|
|
|
|
"Fix one": {}}
|
|
|
|
|
for instance_idx in tqdm(range(len(instances))):
|
|
|
|
|
instance = instances[instance_idx]
|
|
|
|
|
solution_actual = instance.solution
|
|
|
|
@ -146,8 +148,6 @@ class PrimalSolutionComponent(Component):
|
|
|
|
|
tn_one = len(pred_one_negative & vars_zero)
|
|
|
|
|
fn_one = len(pred_one_negative & vars_one)
|
|
|
|
|
|
|
|
|
|
ev[instance_idx] = {
|
|
|
|
|
"Fix zero": classifier_evaluation_dict(tp_zero, tn_zero, fp_zero, fn_zero),
|
|
|
|
|
"Fix one": classifier_evaluation_dict(tp_one, tn_one, fp_one, fn_one),
|
|
|
|
|
}
|
|
|
|
|
ev["Fix zero"][instance_idx] = classifier_evaluation_dict(tp_zero, tn_zero, fp_zero, fn_zero)
|
|
|
|
|
ev["Fix one"][instance_idx] = classifier_evaluation_dict(tp_one, tn_one, fp_one, fn_one)
|
|
|
|
|
return ev
|
|
|
|
|