SimpSolver class.
SimpSolver overview
The simplifying solver extends the base solver with preprocessing capabilities:SimpSolver is a drop-in replacement for Solver. All base functionality remains available.Variable elimination
Variable elimination removes variables by bounded resolution, potentially simplifying the formula.How it works
For a variablex appearing in clauses:
- Compute all resolvents between positive and negative occurrences
- If total clauses decrease (or increase within bounds), eliminate
x - Replace all clauses containing
xwith resolvents - Store elimination information for model reconstruction
Eliminated variables are automatically reconstructed in the model if a solution is found.
Enabling variable elimination
Master switch for variable eliminationCommand-line:
-elim or -no-elimElimination parameters
Maximum resolvent clause lengthRange: Command-line:
-1 (no limit) or positive integerVariables producing resolvents longer than this are not eliminated.-cl-lim=20Allowed clause count increaseNumber of additional clauses elimination may produce.Command-line:
-grow=0Subsumption check size limitRange: Command-line:
-1 (no limit) or positive integerSkip subsumption checks against clauses larger than this.-sub-lim=1000Calling elimination explicitly
Perform variable elimination
- Returns
falseif formula becomes unsatisfiable turn_off_elim: Disable elimination for future calls- Automatically called by
solve()unless disabled
Asymmetric branching
Asymmetric branching strengthens clauses by removing literals that are implied by the remaining literals.Enable asymmetric branchingCommand-line:
-asymm or -no-asymmExample
Given clause(a ∨ b ∨ c) and formula implying (¬a ∧ ¬b) → ¬c:
Asymmetric branching detects that c is implied by ¬a ∧ ¬b, so the clause can be strengthened to (a ∨ b), removing c.
Subsumption and self-subsuming resolution
Subsumption removes redundant clauses:- Subsumption: Clause
C₁subsumesC₂ifC₁ ⊆ C₂. ThenC₂is redundant. - Self-subsuming resolution: Strengthen clauses by resolution when result subsumes original.
Check if clauses are already impliedCommand-line:
-rcheck or -no-rcheckFreezing variables
Prevent specific variables from being eliminated:Freeze or unfreeze a variable
v: Variable to freezeb:trueto freeze,falseto unfreeze- Frozen variables are never eliminated
Alternative freeze interface
Preprocessing workflow
Typical preprocessing workflow withSimpSolver:
Controlling solve-time simplification
Control whethersolve() performs simplification:
Solve with simplification control
do_simp: Perform simplification before solvingturn_off_simp: Disable simplification for future calls
Exporting simplified formulas
Export the simplified formula to DIMACS format:Output file for simplified formulaIf specified, simplified formula is written in DIMACS format after preprocessing.Command-line:
-dimacs=output.cnfStatistics
Track preprocessing effectiveness:- eliminated_vars
- asymm_lits
- merges
Number of variables eliminated through bounded resolution.
Best practices
Use SimpSolver
Always prefer
SimpSolver over Solver unless you have specific reasons not to preprocess.Freeze outputs
Freeze output or interface variables to keep them in the model.
Tune clause limit
Adjust
clause_lim based on problem structure. Lower for bounded growth, higher for aggressive elimination.Disable for incremental
Turn off simplification (
turn_off_simp=true) when using incremental solving.Advanced: Checking elimination status
Check if a variable was eliminatedReturns
true if variable v was eliminated during preprocessing.Performance considerations
Preprocessing is a tradeoff: it takes time upfront but can dramatically reduce solving time.
When preprocessing helps
- Structured problems: Industrial instances with many equivalences
- Large formulas: Problems where size reduction is significant
- Hard instances: When solving time dominates preprocessing time
When to skip preprocessing
- Easy problems: Quick solves where preprocessing overhead isn’t worth it
- Incremental solving: Adding clauses repeatedly makes preprocessing ineffective
- Real-time constraints: When preprocessing time is unacceptable
Garbage collection
Preprocessing can generate memory fragmentation. Control garbage collection:GC trigger threshold during simplificationCommand-line:
-simp-gc-frac=0.5Related topics
Configuration
All solver configuration options
Performance
Optimize for speed