## Learn to Relax: Integrating Integer Linear Programming with Conflict-Driven Search

Jo Devriendt, Ambros Gleixner , Jakob Nordström *
Acknowledgement: Jan Elffers
† Lund University, Sweden

‡ Zuse Institut Berlin, Germany

* University of Copenhagen, Denmark

jo.devriendt@cs.lth.se

## Conflict-driven search for 0-1 ILP

an example-driven intro

+x+y-z \geq 0 \\ -y+z-v \geq 0 \\ -z+v-w \geq 0 \\ -x+z+w \geq 1 \\
x,y,z,v,w \mapsto \{0,1\}

## Conflict-driven Search Loop

Unit propagation

• Given 0-1 ILP program φ and current assignment α, if a constraint c ∈ φ would be falsified by assuming x=0 (resp. x=1), extend α with x=1 (resp. x=0)
• propagate until fixpoint
+x+y-z \geq 0 \\ -y+z-v \geq 0 \\ -z+v-w \geq 0 \\ -x+z+w \geq 1

currently no unit propagation

\alpha=\{\}

## Conflict-driven Search Loop

Unit propagation

Conflict?

+x+y-z \geq 0 \\ -y+z-v \geq 0 \\ -z+v-w \geq 0 \\ -x+z+w \geq 1
\alpha=\{\}
• Conflict: some constraint in φ falsified by α

## Conflict-driven Search Loop

Unit propagation

Conflict?

Decide unassigned variable

no

• Only if unit propagation did not lead to a conflict
• if no unassigned variable left, return SAT
• Resume unit propagation
+x+y-z \geq 0 \\ -y+z-v \geq 0 \\ -z+v-w \geq 0 \\ -x+z+w \geq 1
\alpha=\{\}

## Conflict-driven Search Loop

Unit propagation

Conflict?

Decide unassigned variable

no

+x+y-z \geq 0 \\ -y+z-v \geq 0 \\ -z+v-w \geq 0 \\ -x+z+w \geq 1
\alpha=\{x=0\}
• Only if unit propagation did not lead to a conflict
• if no unassigned variable left, return SAT
• Resume unit propagation

## Conflict-driven Search Loop

Unit propagation

Conflict?

Decide unassigned variable

no

+y-z \geq 0 \\ -y+z-v \geq 0 \\ -z+v-w \geq 0 \\ +z+w \geq 1
\alpha=\{x=0\}

## Conflict-driven Search Loop

Unit propagation

Conflict?

Decide unassigned variable

no

+y-z \geq 0 \\ -y+z-v \geq 0 \\ -z+v-w \geq 0 \\ +z+w \geq 1
\alpha=\{x=0\}

## Conflict-driven Search Loop

Unit propagation

Conflict?

Decide unassigned variable

no

+y-z \geq 0 \\ -y+z-v \geq 0 \\ -z+v-w \geq 0 \\ +z+w \geq 1
\alpha=\{x=0,y=1\}

## Conflict-driven Search Loop

Unit propagation

Conflict?

Decide unassigned variable

no

1-z \geq 0 \\ -1+z-v \geq 0 \\ -z+v-w \geq 0 \\ +z+w \geq 1
\alpha=\{x=0,y=1\}

## Conflict-driven Search Loop

Unit propagation

Conflict?

Decide unassigned variable

no

1-z \geq 0 \\ -1+z-v \geq 0 \\ -z+v-w \geq 0 \\ +z+w \geq 1
\alpha=\{x=0,y=1,\\z=1,v=0\}

## Conflict-driven Search Loop

Unit propagation

Conflict?

Decide unassigned variable

no

\alpha=\{x=0,y=1,\\z=1,v=0\}
0 \geq 0 \\ 0 \geq 0 \\ -1-w \geq 0 \\ +1+w \geq 1

## Conflict-driven Search Loop

Unit propagation

Conflict?

Decide unassigned variable

no

\alpha=\{x=0,y=1,\\z=1,v=0\}
0 \geq 0 \\ 0 \geq 0 \\ -1-w \geq 0 \\ +1+w \geq 1
• Conflict: some constraint in φ falsified by α

## Conflict-driven Search Loop

Unit propagation

Conflict?

Learn constraint

Decide unassigned variable

yes

no

• From falsified constraint and reasons leading up to conflict, construct learned constraint
• implied by φ, should prevent same conflict
• Add learned constraint to φ
• learned constraint database
\alpha=\{x=0,y=1,\\z=1,v=0\}
0 \geq 0 \\ 0 \geq 0 \\ -1-w \geq 0 \\ +1+w \geq 1

## Conflict-driven Search Loop

Unit propagation

Conflict?

Learn constraint

Decide unassigned variable

yes

no

+x+y-z \geq 0 \\ -y+z-v \geq 0 \\ -z+v-w \geq 0 \\ -x+z+w \geq 1
\alpha=\{x=0,y=1,\\z=1,v=0\}
-y-w \geq 0
• From falsified constraint and reasons leading up to conflict, construct learned constraint
• implied by φ, should prevent same conflict
• Add learned constraint to φ
• learned constraint database

## Conflict-driven Search Loop

Unit propagation

Conflict?

Learn constraint

Backjump

Decide unassigned variable

yes

no

• Backtrack based on learned constraint
• Resume unit propagation
+x+y-z \geq 0 \\ -y+z-v \geq 0 \\ -z+v-w \geq 0 \\ -x+z+w \geq 1
\alpha=\{x=0,y=1,\\z=1,v=0\}
-y-w \geq 0

## Conflict-driven Search Loop

Unit propagation

Conflict?

Learn constraint

Backjump

Decide unassigned variable

yes

no

• Backtrack based on learned constraint
• Resume unit propagation
+x+y-z \geq 0 \\ -y+z-v \geq 0 \\ -z+v-w \geq 0 \\ -x+z+w \geq 1
\alpha=\{\}
-y-w \geq 0

## Conflict-driven Search Loop

Unit propagation

Conflict?

Learn constraint

Backjump

Decide unassigned variable

yes

no

+x+y-z \geq 0 \\ -y+z-v \geq 0 \\ -z+v-w \geq 0 \\ -x+z+w \geq 1
-y-w \geq 0
\alpha=\{\}

## Conflict-driven Search Loop

Unit propagation

Conflict?

Learn constraint

Backjump

Decide unassigned variable

yes

no

+x-z \geq 0 \\ +z-v \geq 0 \\ -z+v \geq 0 \\ -x+z \geq 1
\alpha=\{y=0,w=0\}
-y-w \geq 0

## Conflict-driven Search Loop

Unit propagation

Conflict?

Learn constraint

Backjump

Decide unassigned variable

yes

no

+x-z \geq 0 \\ +z-v \geq 0 \\ -z+v \geq 0 \\ -x+z \geq 1
-y-w \geq 0
\alpha=\{y=0,w=0\}

## Conflict-driven Search Loop

Unit propagation

Conflict?

Learn constraint

Backjump

Decide unassigned variable

yes

no

-y-w \geq 0
-1\geq 0 \\ 1-v \geq 0 \\ -1+v \geq 0 \\ 1 \geq 1
\alpha=\{y=0,w=0,\\x=0,z=1\}

## Conflict-driven Search Loop

Unit propagation

Conflict?

Learn constraint

Backjump

Decide unassigned variable

yes

no

-1\geq 0 \\ 1-v \geq 0 \\ -1+v \geq 0 \\ 1 \geq 1
-y-w \geq 0
\alpha=\{y=0,w=0,\\x=0,z=1\}

## Conflict-driven Search Loop

Unit propagation

Conflict?

Learn constraint

Backjump

Decide unassigned variable

yes

no

+x+y-z \geq 0 \\ -y+z-v \geq 0 \\ -z+v-w \geq 0 \\ -x+z+w \geq 1
-y-w \geq 0
0 \geq 1
\alpha=\{y=0,w=0,\\x=0,z=1\}

## Conflict-driven Search Loop

Unit propagation

Conflict?

Learn constraint

Backjump

Decide unassigned variable

yes

no

+x+y-z \geq 0 \\ -y+z-v \geq 0 \\ -z+v-w \geq 0 \\ -x+z+w \geq 1
-y-w \geq 0
0 \geq 1

UNSAT!

\alpha=\{y=0,w=0,\\x=0,z=1\}

## Conflict-driven Search Loop

Unit propagation

Conflict?

Learn constraint

Backjump

Decide unassigned variable

yes

no

• Learning constraints pushes search forward
• Thousands of conflicts per second
• Highly optimized unit propagation
• First proposed for Boolean satisfiability [MS96,BS97,MMZZ01]
• Generalized to pseudo-Boolean solving [CK05,SS06,LP10,EN18]
• many variations possible

here be dragons
(different from MIP)

## Another look at our example...

+x+y-z \geq 0 \\ -y+z-v \geq 0 \\ -z+v-w \geq 0 \\ -x+z+w \geq 1 \\
x,y,z,v,w \mapsto \{0,1\}
• It's rationally infeasible!
• Could be solved without search
• In practice: conflict-driven search even reaches timeout on certain rationally infeasible programs
• unit propagation is local
• wrong constraints are learned

our work

## Linear Programming (LP) solver

• Input:
• LP relaxation of φ
• variable bounds α
• objective function
• Output: either
• optimal rational solution
• Farkas multipliers
• define a positive linear combination of constraints in φ, falsified by α

## Conflict-driven search loop

with LP solver call

Unit Propagation

Conflict?

Backjump

Decide unassigned variable

no

Rational infeasibility?

Query LP solver

yes

no

Learn constraint

Extract Farkas multipliers

yes

Learn Farkas constraint

## Rational infeasibility example

\textcolor{red}{+a}+x+y-z \geq 0 \\ \textcolor{red}{+b}-y+z-v \geq 0 \\ -z+v-w \geq 0 \\ -x+z+w \geq 1 \\ \textcolor{red}{+a-b \geq 0}
\alpha=\{a=0,b=0\}
\times\textcolor{red}{1}\\ \times\textcolor{red}{1}\\ \times\textcolor{red}{1}\\ \times\textcolor{red}{1}\\ \times\textcolor{red}{0}\\
+a+b\geq 1

Farkas multipliers

• LP solvers are slow compared to conflict-driven search loop
• limit calls to LP solver
• limit LP solver running time
• deterministic measure: balance #conflicts in conflict-driven solver to #pivots in LP solver
• LP solver uses inexact floating point arithmetic
• learned constraint must be implied by φ
• recalculate Farkas constraint with exact arithmetic
• verify Farkas constraint is still conflicting
• post-process Farkas constraint to eliminate noise

## Two technical hurdles

• Every once in a while, run LP solver to completion at root
• use (optimal) rational solution as value heuristic
• generate Gomory cuts
• add to both LP solver and learned constraint set
• Generate "deep" Gomory cuts from internal search nodes
• valid at root node, so safe to add as learned constraint
• Add learned constraints as cuts to the LP solver

## Further ideas

• PB solver RoundingSat [EN18]
• Strong ILP constraint learning
• Performed well in past PB competitions
• LP solver SoPlex [ZIB]
• SCIP's native LP solver
• State-of-the-art open source

[PBCOMP]

[PBCOMP]

[PBCOMP]

[PBCOMP]

[MIPLIB]

[MIPLIB]

[P04]

[P04]

## Summary

Conflict-driven search for 0-1 ILPs

• Generates cuts from search conflicts
• Does not always find short refutations for rational infeasibility
• Allows sound & efficient integration with LP solver
• Is further improved by value heuristic & Gomory cut generation

Experiments indicate best of both worlds

• But don't forget to switch off cut generation for decision problems

[MS96] GRASP - a new search algorithm for satisfiability - Marques-Silva, Sakallah

[BS97] Using CSP lookback techniques to solve real-world SAT instances - Bayardo, Schrag

[MMZZ97] Chaff: Engineering an efficient SAT solver - Moskewicz, Madigan, Zhao, Zhang

[P04] Where are the hard knapsack problems? - Pisinger

[CK05] A fast pseudo-Boolean constraint solver - Chai, Kuehlmann

[SS06] Pueblo: A hybrid pseudo-Boolean SAT solver - Sheini, Sakallah

[LP10] The Sat4j library, release 2.2 - Le Berre, Parrain

[EN18] Divide and conquer: Towards faster pseudo-boolean solving - Elffers, Nordström

[ZIB] SoPlex - soplex.zib.de

[PBCOMP] Latest PB competition - www.cril.univ-artois.fr/PB16/

[MIPLIB] The Mixed Integer Programming Library - miplib.zib.de

By krr

• 40