mirror of
https://github.com/Brandon-Rozek/matmod.git
synced 2025-07-29 20:52:01 +00:00
Don't rely on shared memory for logic operators
This commit is contained in:
parent
29526dbec3
commit
b06dd8ee01
2 changed files with 13 additions and 8 deletions
5
vsp.py
5
vsp.py
|
@ -98,14 +98,11 @@ Subalgebra 1: {set_to_str(self.subalgebra1)}
|
|||
Subalgebra 2: {set_to_str(self.subalgebra2)}
|
||||
"""
|
||||
|
||||
def has_vsp(model: Model, interpretation: Dict[Operation, ModelFunction]) -> VSP_Result:
|
||||
def has_vsp(model: Model, impfunction: ModelFunction, mconjunction: Optional[ModelFunction] = None, mdisjunction: Optional[ModelFunction] = None) -> VSP_Result:
|
||||
"""
|
||||
Checks whether a model has the variable
|
||||
sharing property.
|
||||
"""
|
||||
impfunction = interpretation[Implication]
|
||||
mconjunction = interpretation.get(Conjunction)
|
||||
mdisjunction = interpretation.get(Disjunction)
|
||||
top = find_top(model.carrier_set, mconjunction, mdisjunction)
|
||||
bottom = find_bottom(model.carrier_set, mconjunction, mdisjunction)
|
||||
|
||||
|
|
16
vspursuer.py
16
vspursuer.py
|
@ -1,7 +1,8 @@
|
|||
#!/usr/bin/env python3
|
||||
from os import cpu_count
|
||||
import argparse
|
||||
import multiprocessing
|
||||
import multiprocessing as mp
|
||||
from logic import Implication, Conjunction, Disjunction
|
||||
|
||||
from parse_magic import (
|
||||
SourceFile,
|
||||
|
@ -24,11 +25,18 @@ if __name__ == "__main__":
|
|||
solutions = parse_matrices(SourceFile(data_file))
|
||||
print(f"Parsed {len(solutions)} matrices")
|
||||
|
||||
solutions_prep = []
|
||||
for model, interpretation in solutions:
|
||||
impfunction = interpretation[Implication]
|
||||
mconjunction = interpretation.get(Conjunction)
|
||||
mdisjunction = interpretation.get(Disjunction)
|
||||
solutions_prep.append((model, impfunction, mconjunction, mdisjunction))
|
||||
|
||||
num_has_vsp = 0
|
||||
with multiprocessing.Pool(processes=max(cpu_count() - 2, 1)) as pool:
|
||||
with mp.Pool(processes=max(cpu_count() - 2, 1)) as pool:
|
||||
results = [
|
||||
pool.apply_async(has_vsp, (model, interpretation,))
|
||||
for model, interpretation in solutions
|
||||
pool.apply_async(has_vsp, (model, impfunction, mconjunction, mdisjunction,))
|
||||
for model, impfunction, mconjunction, mdisjunction in solutions_prep
|
||||
]
|
||||
|
||||
for i, result in enumerate(results):
|
||||
|
|
Loading…
Add table
Reference in a new issue