Discarding Order-Dependent Subalgebras (#14)

This commit is contained in:
Brandon Rozek 2025-02-09 11:29:57 -05:00 committed by GitHub
commit 2d8540f5c2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 55 additions and 12 deletions

View file

@ -3,7 +3,7 @@ from os import cpu_count
import argparse
import multiprocessing as mp
from logic import Conjunction, Disjunction, Implication
from logic import Conjunction, Disjunction, Negation, Implication
from parse_magic import SourceFile, parse_matrices
from vsp import has_vsp, VSP_Result
@ -28,7 +28,7 @@ if __name__ == "__main__":
# NOTE: When subprocess gets spawned, the logical operations will
# have a different memory address than what's expected in interpretation.
# This will make it so that we can pass the model functions directly instead.
# Therefore, we need to pass the model functions directly instead.
solutions_expanded = []
for model, interpretation in solutions:
# If skip_to is defined, then don't process models
@ -40,14 +40,15 @@ if __name__ == "__main__":
impfunction = interpretation[Implication]
mconjunction = interpretation.get(Conjunction)
mdisjunction = interpretation.get(Disjunction)
solutions_expanded.append((model, impfunction, mconjunction, mdisjunction))
mnegation = interpretation.get(Negation)
solutions_expanded.append((model, impfunction, mconjunction, mdisjunction, mnegation))
num_has_vsp = 0
num_cpu = args.get("c", max(cpu_count() - 2, 1))
with mp.Pool(processes=num_cpu) as pool:
results = [
pool.apply_async(has_vsp, (model, impfunction, mconjunction, mdisjunction,))
for model, impfunction, mconjunction, mdisjunction in solutions_expanded
pool.apply_async(has_vsp, (model, impfunction, mconjunction, mdisjunction, mnegation))
for model, impfunction, mconjunction, mdisjunction, mnegation in solutions_expanded
]
for i, result in enumerate(results):