Extended Conjunctive Normal Form and An Efficient Algorithm for Cardinality Constraints

Zhendong Lei, Shaowei Cai, Chuan Luo

Abstract

This paper introduces Extended Conjunctive Normal Form (ECNF), a novel logic representation designed to natively handle cardinality constraints (e.g., "at least $k$ of $n$ variables must be true"). By eliminating the need for complex auxiliary variable encodings required by standard Conjunctive Normal Form (CNF), ECNF prevents "formula bloat" and maintains a compact problem representation. We present LS-ECNF, a specialized local search solver that leverages the ECNF structure through a violation-degree scoring function and generalized unit propagation. Empirical evaluations on Nurse Rostering and Discrete Tomography benchmarks demonstrate that LS-ECNF significantly outperforms state-of-the-art SAT, MaxSAT, and Integer Linear Programming (ILP) solvers in both scalability and solution quality.

Introduction

Many real-world optimization problems, such as nurse scheduling and medical image reconstruction, are defined by cardinality constraints. Traditionally, these problems are solved by translating them into standard CNF for use with SAT or MaxSAT solvers. However, representing an "at least $k$" constraint in CNF typically requires a complex web of auxiliary variables and additional clauses. This encoding process often results in massive, memory-intensive formulas that obscure the problem's underlying structure and hinder solver efficiency.

The ECNF Framework and LS-ECNF Solver

To address these limitations, we propose ECNF, where each clause is associated with a cardinality threshold $c$. A clause is satisfied if and only if at least $c$ of its literals are true. This allows for a direct, native representation of cardinality constraints.

Accompanying this format is the LS-ECNF solver, a local search algorithm featuring three key innovations:

  1. Violation-Degree Scoring: Unlike traditional solvers that use binary satisfaction scores, LS-ECNF calculates how close a variable flip brings a clause to its required threshold, providing a smoother gradient for the search.
  2. Generalized Unit Propagation (GUP): We adapted the classic SAT technique of unit propagation to ECNF. GUP identifies variables that must be true to satisfy a constraint and uses this to generate high-quality initial assignments.
  3. Weighting-EPMS: An adaptive strategy that increases the weight of unsatisfied constraints over time, preventing the solver from becoming trapped in local optima.

Representation Efficiency

The primary advantage of ECNF is its compactness. By avoiding auxiliary variables, ECNF representations are orders of magnitude smaller than their CNF counterparts.

Table 3: Comparison of variables and clauses between ECNF and various CNF encodings (car, seq, pig) for NRP and DTP benchmarks.

As shown in the data above, for the Nurse Rostering Problem (NRP), the ECNF representation uses approximately $1.2 \times 10^5$ variables, whereas the standard 'car' encoding requires over $6.7 \times 10^6$. This reduction in complexity allows the solver to navigate the search space much more effectively.

Performance and Scalability

We evaluated LS-ECNF against leading solvers, including Gurobi (ILP), Loandra (MaxSAT), and CADICAL (SAT). In the Discrete Tomography Problem (DTP), where the goal is to reconstruct grids based on row and column sums, LS-ECNF demonstrated superior scaling.

Table 4: Solving time (seconds) for Discrete Tomography Problems across different grid sizes.

While traditional SAT and MaxSAT solvers failed to solve instances beyond a $40 \times 40$ grid, LS-ECNF successfully handled $400 \times 400$ grids in roughly two minutes. Furthermore, on large-scale Nurse Rostering instances, LS-ECNF consistently found lower-cost solutions in 300 seconds than the commercial solver Gurobi could find in an hour.

Conclusion

ECNF provides a powerful alternative to standard CNF for problems dominated by cardinality constraints. By treating these constraints as first-class citizens, the LS-ECNF solver achieves unprecedented scalability and efficiency. Future work will focus on extending ECNF to support more complex Pseudo-Boolean constraints and developing complete (CDCL-based) solvers for the ECNF format.

Summary updated

BibTeX
@inproceedings{lei2020extended,
  author = {Zhendong Lei and Shaowei Cai and Chuan Luo},
  title = {{Extended Conjunctive Normal Form and An Efficient Algorithm for Cardinality Constraints}},
  booktitle = {International Joint Conference on Artificial Intelligence},
  year = {2020},
  doi = {10.24963/ijcai.2020/159},
}
Figure