From 2ff9f8134c969bb27ce49ca38e6a437e0787ac70 Mon Sep 17 00:00:00 2001 From: Brandon Rozek Date: Sun, 9 Feb 2025 10:57:52 -0500 Subject: [PATCH 1/2] Implemented optimization #29 --- vsp.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/vsp.py b/vsp.py index ad2849b..b223982 100644 --- a/vsp.py +++ b/vsp.py @@ -3,12 +3,11 @@ Check to see if the model has the variable sharing property. """ from itertools import chain, combinations, product -from typing import Dict, List, Optional, Set, Tuple +from typing import List, Optional, Set, Tuple from common import set_to_str from model import ( Model, model_closure, ModelFunction, ModelValue ) -from logic import Conjunction, Disjunction, Implication, Operation def preseed( initial_set: Set[ModelValue], @@ -145,10 +144,19 @@ def has_vsp(model: Model, impfunction: ModelFunction, mconjunction: Optional[Mod # NOTE: Optimziation before model_closure # If the two subalgebras intersect, move - # onto the next pair + # onto the next pair. if len(xs & ys) > 0: continue + # NOTE: Optimization + # If a subalgebra doesn't have at least one + # designated value, move onto the next pair. + if len(xs & model.designated_values) == 0: + continue + + if len(ys & model.designated_values) == 0: + continue + # NOTE: Optimization # If the left subalgebra contains bottom # or the right subalgebra contains top From f9d307969e9f3b4489a02bfab1159c11cb9f002f Mon Sep 17 00:00:00 2001 From: Brandon Rozek Date: Sun, 9 Feb 2025 11:00:39 -0500 Subject: [PATCH 2/2] Added small note --- vsp.py | 1 + 1 file changed, 1 insertion(+) diff --git a/vsp.py b/vsp.py index b223982..d38ec42 100644 --- a/vsp.py +++ b/vsp.py @@ -151,6 +151,7 @@ def has_vsp(model: Model, impfunction: ModelFunction, mconjunction: Optional[Mod # NOTE: Optimization # If a subalgebra doesn't have at least one # designated value, move onto the next pair. + # Depends on no intersection between xs and ys if len(xs & model.designated_values) == 0: continue