【发布时间】:2014-04-18 23:45:25
【问题描述】:
为了解决set of Boolean equations,我正在使用以下输入尝试Constraint-Programming Solver MiniZinc:
% Solve system of Brent's equations modulo 2
% Matrix dimensions
int: aRows = 3;
int: aCols = 3;
int: bCols = 3;
int: noOfProducts = 23;
% Dependent parameters
int: bRows = aCols;
int: cRows = aRows;
int: cCols = bCols;
set of int: products = 1..noOfProducts;
% Corefficients are stored in arrays
array[1..aRows, 1..aCols, products] of var bool: A;
array[1..bRows, 1..bCols, products] of var bool: B;
array[1..cRows, 1..cCols, products] of var bool: C;
constraint
forall(rowA in 1..aRows, colA in 1..aCols) (
forall(rowB in 1..bRows, colB in 1..bCols) (
forall (rowC in 1..cRows, colC in 1..cCols) (
xorall (k in products) (
A[rowA, colA, k] /\ B[rowB, colB, k] /\ C[rowC, colC, k]
) == ((rowA == rowC) /\ (colB == colC) /\ (colA == rowB))
)
)
);
solve satisfy;
% Output solution as table of variable value assignments
output
["\nSolution for <" ++ show(aRows) ++ ", " ++ show(aCols) ++
", " ++ show(bCols) ++ "> " ++ show(noOfProducts) ++ " products:"] ++
["\nF" ++ show(100*rowA+10*colA+k) ++ " = " ++
show(bool2int(A[rowA, colA, k])) |
rowA in 1..aRows, colA in 1..aCols, k in products] ++
["\nG" ++ show(100*rowB+10*colB+k) ++ " = " ++
show(bool2int(B[rowB, colB, k])) |
rowB in 1..bRows, colB in 1..bCols, k in products] ++
["\nD" ++ show(100*rowC+10*colC+k) ++ " = " ++
show(bool2int(C[rowC, colC, k])) |
rowC in 1..cRows, colC in 1..cCols, k in products];
MiniZinc 确实为小参数 (rows=cols=2, products=7) 找到了解决方案,但并没有随着略微增加的参数而结束。
我想将生成的FlatZinc 模型输入到SAT solver 中,例如Cryptominisat、Lingeling 或Clasp。我希望这些工具的性能可能优于现有的 MiniZinc 后端。
我的问题:
是否有任何工具可用于将纯布尔 FlatZinc 模型转换为 CNF (DIMACS)?
我可以做些什么来替换 xorall() 谓词,因为一些 MiniZinc 后端似乎不支持它?
【问题讨论】:
标签: constraint-programming satisfiability minizinc