π§© Constraint Solving POTD:SMT β Scheduling Tasks with Mixed Boolean-Arithmetic Constraints #22682
Closed
Replies: 1 comment
-
|
This discussion has been marked as outdated by Constraint Solving β Problem of the Day. A newer discussion is available at Discussion #22898. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Welcome to today's Constraint Solving Problem of the Day! Each post explores a different technique from the constraint solving and combinatorial optimisation world.
Problem Statement
Satisfiability Modulo Theories (SMT) extends Boolean SAT by attaching theory solvers that reason over richer domains β integers, reals, arrays, bit-vectors β while the SAT core handles the propositional skeleton. Today we explore a small but illuminating SMT instance: scheduling tasks with resource and timing constraints expressed as linear arithmetic over integers.
Concrete instance
We have 5 tasks
T1 β¦ T5, each with a durationd_i, and 2 machines. Each task must be assigned to exactly one machine, run without preemption, and no two tasks on the same machine may overlap. We also have a hard deadline: all tasks must finish by timeD = 14.Decision variables
m_i β {0, 1}β machine assignment for taskis_i β β€, s_i β₯ 0β start time for taskiConstraints
s_i + d_i β€ Dfor alli(i, j)on the same machine, eithers_i + d_i β€ s_jors_j + d_j β€ s_i(i, j)is co-located whenm_i = m_jGoal: find a satisfying assignment, or prove infeasibility.
Why It Matters
Software & hardware verification. SMT solvers (Z3, CVC5, Yices2) power bounded model checking, symbolic execution engines (KLEE, angr), and program synthesis tools. Timing and resource constraints map directly to linear arithmetic over integers.
Planning and scheduling under mixed constraints. Many real-world schedules mix Boolean control flow ("if task A runs on machine 1, then B must follow on machine 2") with linear arithmetic timing β a sweet spot for SMT.
Security analysis. Vulnerability scanners encode buffer offsets as bit-vector arithmetic and memory safety as Boolean reachability, then ask an SMT solver whether an exploit path exists.
Modelling Approaches
Approach 1 β Pure SMT (Linear Arithmetic + Booleans)
Encode the problem as a formula in QF_LIA (quantifier-free linear integer arithmetic) combined with Boolean connectives.
s_i : Int,m_i : Bool(m_i = m_j) βΉ (s_i + d_i β€ s_j β¨ s_j + d_j β€ s_i)s_i + d_i β€ DTrade-offs: Very natural to express; the DPLL(T) architecture handles the Boolean structure while the LIA solver handles arithmetic. Works well for small-to-medium instances. The implication encoding requires case-splits that can blow up for dense instances.
Approach 2 β CP with Global
no_overlap+ Boolean ChannelingModel the same problem in a Constraint Programming solver using a global
no_overlap(disjunctive) constraint.s_i β 0..D,m_i β {0,1}m_i = 0 β machine_of(i) = 0Trade-offs: The
no_overlapglobal constraint propagates via edge-finding and not-first/not-last rules, pruning far more aggressively than naΓ―ve SMT case-splits. CP is typically stronger here; SMT wins when the surrounding structure is highly propositional (e.g., large conditional dependency graphs).Example Model (Z3 Python API)
Key Techniques
1. DPLL(T) β The SMT Architecture
The SAT solver (DPLL or CDCL) finds a propositionally consistent assignment; it then calls theory-specific T-solvers to check arithmetic/array/bit-vector consistency. Conflicts discovered by the T-solver are projected back to clauses, which are fed into the SAT core as theory lemmas (T-lemmas). This tight coupling between Boolean reasoning and domain reasoning is what makes SMT powerful.
2. Eager vs. Lazy Encoding of Disjunctions
The no-overlap constraint introduces a disjunction:
s_i + d_i β€ s_j β¨ s_j + d_j β€ s_i. In eager encoding you introduce a selector Booleanb_ijand add both halves as conditional linear inequalities. In lazy mode the T-solver only instantiates clauses when needed. Lazy strategies dramatically reduce formula size for dense instances.3. Symmetry Breaking
If all machines are identical, any permutation of machine assignments yields an equivalent solution. Add a lexicographic symmetry-breaking constraint such as
m_1 = 0(pin the first task to machine 0) to eliminate half the search space immediately.Challenge Corner
References
π Yesterday's topic: Resource-Constrained Project Scheduling (RCPSP). Next time we'll look at another corner of the constraint solving world β stay tuned!
Beta Was this translation helpful? Give feedback.
All reactions