Skip to content

Commit

Permalink
add comment
Browse files Browse the repository at this point in the history
  • Loading branch information
Yan Georget committed Oct 1, 2024
1 parent edac760 commit 5ae7875
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
20 changes: 20 additions & 0 deletions nucs/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import argparse

from rich import print

from nucs.examples.bibd.bibd_problem import BIBDProblem
from nucs.solvers.backtrack_solver import BacktrackSolver
from nucs.statistics import get_statistics

if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("-v", type=int)
parser.add_argument("-b", type=int)
parser.add_argument("-r", type=int)
parser.add_argument("-k", type=int)
parser.add_argument("-l", type=int)
args = parser.parse_args()
problem = BIBDProblem(args.v, args.b, args.r, args.k, args.l)
solver = BacktrackSolver(problem)
solver.solve_all(lambda solution: print(problem.solution_as_matrix(solution)))
print(get_statistics(solver.statistics))
3 changes: 2 additions & 1 deletion nucs/examples/bibd/bibd_problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ def __init__(self, v: int, b: int, r: int, k: int, l: int):
for block_idx in range(0, b):
self.add_propagator((list(range(block_idx, v * b, b)), ALG_EXACTLY_EQ, [1, k]))
# scalar products: conjunctions and counts
# TODO: test with GCC
conj_idx = v * b # index of first redundant variable
for i1 in range(0, v - 1):
for i2 in range(i1 + 1, v):
conj_vars = []
for block_idx in range(0, b):
self.add_propagator(
([(i1 * b + block_idx), (i2 * b + block_idx), conj_idx], ALG_MIN_EQ, [])
([i1 * b + block_idx, i2 * b + block_idx, conj_idx], ALG_MIN_EQ, [])
) # TODO:replace by AND ?
conj_vars.append(conj_idx)
conj_idx += 1
Expand Down

0 comments on commit 5ae7875

Please sign in to comment.