mirror of
https://github.com/Brandon-Rozek/matmod.git
synced 2025-07-31 21:01:59 +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)}
|
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
|
Checks whether a model has the variable
|
||||||
sharing property.
|
sharing property.
|
||||||
"""
|
"""
|
||||||
impfunction = interpretation[Implication]
|
|
||||||
mconjunction = interpretation.get(Conjunction)
|
|
||||||
mdisjunction = interpretation.get(Disjunction)
|
|
||||||
top = find_top(model.carrier_set, mconjunction, mdisjunction)
|
top = find_top(model.carrier_set, mconjunction, mdisjunction)
|
||||||
bottom = find_bottom(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
|
#!/usr/bin/env python3
|
||||||
from os import cpu_count
|
from os import cpu_count
|
||||||
import argparse
|
import argparse
|
||||||
import multiprocessing
|
import multiprocessing as mp
|
||||||
|
from logic import Implication, Conjunction, Disjunction
|
||||||
|
|
||||||
from parse_magic import (
|
from parse_magic import (
|
||||||
SourceFile,
|
SourceFile,
|
||||||
|
@ -24,11 +25,18 @@ if __name__ == "__main__":
|
||||||
solutions = parse_matrices(SourceFile(data_file))
|
solutions = parse_matrices(SourceFile(data_file))
|
||||||
print(f"Parsed {len(solutions)} matrices")
|
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
|
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 = [
|
results = [
|
||||||
pool.apply_async(has_vsp, (model, interpretation,))
|
pool.apply_async(has_vsp, (model, impfunction, mconjunction, mdisjunction,))
|
||||||
for model, interpretation in solutions
|
for model, impfunction, mconjunction, mdisjunction in solutions_prep
|
||||||
]
|
]
|
||||||
|
|
||||||
for i, result in enumerate(results):
|
for i, result in enumerate(results):
|
||||||
|
|
Loading…
Add table
Reference in a new issue