SCIP - Introduction
SCIP - Introduction
Gregor Hendel
SCIP Workshop 2018, Aachen, March 6, 2018
What is SCIP?
31 active developers
• 7 running Bachelor and Master projects
• 16 running PhD projects
• 8 postdocs and professors
Careers
• 10 awards for Masters and PhD theses: MOS, EURO, GOR, DMV
• 7 former developers are now building commercial optimization software at
CPLEX, FICO Xpress, Gurobi, MOSEK, and GAMS
http://scip.zib.de
http://scip.zib.de
Definition (TSP)
Given a complete graph
G = (V , E ) and distances de for
all e ∈ E :
Find a Hamiltonian cycle (cycle
containing all nodes, tour) of
minimum length.
K8
Definition (TSP)
Given a complete graph
G = (V , E ) and distances de for
all e ∈ E :
Find a Hamiltonian cycle (cycle
containing all nodes, tour) of
minimum length.
K8
Definition (TSP)
Given a complete graph
G = (V , E ) and distances de for
all e ∈ E :
Find a Hamiltonian cycle (cycle
containing all nodes, tour) of
minimum length.
Given
• complete graph G = (V , E ) xe
Binary variables
• xe = 1 if edge e is used
K8
Given
• complete graph G = (V , E ) xe
Binary variables
• xe = 1 if edge e is used
K8
X
min de xe
e∈E
X
subject to xe = 2 ∀v ∈ V
e∈δ(v )
X
xe ≥ 2 ∀S ⊂ V , S 6= ∅
e∈δ(S)
xe ∈ {0, 1} ∀e ∈ E
Given
• complete graph G = (V , E ) xe
Binary variables
• xe = 1 if edge e is used
K8
X
min de xe
e∈E
X
subject to xe = 2 ∀v ∈ V node degree
e∈δ(v )
X
xe ≥ 2 ∀S ⊂ V , S 6= ∅
e∈δ(S)
xe ∈ {0, 1} ∀e ∈ E
Given
• complete graph G = (V , E ) xe
Binary variables
• xe = 1 if edge e is used
K8
X
min de xe
e∈E
X
subject to xe = 2 ∀v ∈ V
e∈δ(v )
X
xe ≥ 2 ∀S ⊂ V , S 6= ∅
e∈δ(S) subtour elimination
xe ∈ {0, 1} ∀e ∈ E
Given
• complete graph G = (V , E ) xe
Binary variables
• xe = 1 if edge e is used
K8
X
min de xe distance
e∈E
X
subject to xe = 2 ∀v ∈ V
e∈δ(v )
X
xe ≥ 2 ∀S ⊂ V , S 6= ∅
e∈δ(S)
xe ∈ {0, 1} ∀e ∈ E
Given
• complete graph G = (V , E )
• for each e ∈ E a distance de > 0 xv
Integer variables
• xv position of v ∈ V in tour
K8
8
Given 7 2
• complete graph G = (V , E )
• for each e ∈ E a distance de > 0 3 1
Integer variables
• xv position of v ∈ V in tour 4 6
5
min length(x1 , . . . , xn )
subject to alldifferent(x1 , . . . , xn )
xv ∈ {1, . . . , n} ∀v ∈ V
min c T x
s.t. gk (x) ≤ 0 ∀k ∈ [m]
xi ∈ Z ∀i ∈ I ⊆ [n]
xi ∈ [`i , ui ] ∀i ∈ [n]
The functions gk ∈ C 1 ([`, u], R) can be
0
100
200
10 200 300
0 200
5
0
−200
−1 1
−1
1
convex or nonconvex
s.t. zi (yi (w T xi + b) − 1 + ξi ) ≥ 0 ∀i
ξi ∈ [0, 2], zi ∈ {0, 1} ∀i
d
w ∈R , b∈R
MIP
SAT
SAT PBO
CIP
• Mixed Integer Programs
• SATisfiability problems
MIP
• Pseudo-Boolean Optimization
• Mixed Integer Nonlinear Programs SAT PBO MINLP CP
• Constraint Programming
• Constraint Integer Programming
CIP
• Mixed Integer Programs
• SATisfiability problems
MIP
• Pseudo-Boolean Optimization
• Mixed Integer Nonlinear Programs SAT PBO MINLP CP
• Constraint Programming
• Constraint Integer Programming
http://scip.zib.de
Basic Workflow
r e a d . . / c h e c k / i n s t a n c e s /MIP/ b e l l 5 . mps
optimize
write solution mysolution . sol
quit
Displaying information
Use the display ... command to enter the menu and
Changing Settings
Use the set ... command to list the settings menu.
Numerical parameters
These must be set before reading a problem.
Limits
• limits/time
• limits/nodes
• limits/gap
Randomization
• randomization/randomseedshift
• randomization/lpseed
• randomization/permutationseed
Gregor Hendel – SCIP Introduction 17/71
Different Tasks – Different Plugins
SCIP_VAR * var ;
SCIP_CALL ( // return value macro
SCIPcreateVar (
scip , // SCIP pointer
& var , // save in variable
" varname " , // pass variable name
0.0 , // lower bound
1.0 , // upper bound
length , // obj . value
SCIP_VARTYPE_BINARY , // type
TRUE , // initial
FALSE , // removable
NULL , NULL , NULL , // no callback functions
NULL // no variable data
)
);
SCIP_CALL ( SCIPaddVar ( scip , var ) ); // add var .
SCIP_CALL ( S C I P c r e a t e C o n s L i n e a r (
scip , // SCIP pointer
& cons , // save in cons
" consname " , // name
nvar , // number of variables
vars , // array of variables
vals , // array of values
2.0 , // left hand side
2.0 , // right hand side ( equation )
TRUE , // initial ?
FALSE , // separate ?
TRUE , // enforce ?
TRUE , // check ?
TRUE , // propagate ?
FALSE , // local ?
FALSE , // modifable ?
FALSE , // dynamic ?
FALSE , // removable ?
FALSE // stick at node ?
));
SCIP_CALL ( SCIPaddCons ( scip , cons ) ); // add constraint
SCIP_CALL ( SCIPreleaseCons ( scip , & cons ) ); // free cons . space
Task
s e t p r e s o l v i n g emphasis o f f
s e t p r e s o l v i n g tworowbnd maxrounds 0
s e t propa gating probing maxprerounds 0
s e t c o n s t r a i n t s components a d v a n c e d m a x p r e r o u n d s 0
Aggressive Presolving
s e t p r e s o l v i n g emphasis a g g r e s s i v e
Presolving
Pricing
Conflict analysis
Cuts
Processing
Enforce constraints
Primal heuristics
Branching
Presolving
Pricing
Conflict analysis
Cuts
Processing
Enforce constraints
Primal heuristics
Branching
Techniques
• basic rules
• depth first search (DFS)
→ early feasible solutions
• best bound search (BBS)
→ improve dual bound
• best estimate search (BES)
→ improve primal bound
Task
• combinations
• improve primal bound • BBS or BES with plunging
• keep comp. effort small • hybrid BES/BBS
• interleaved BES/BBS
• improve global dual bound
s e t n o d e s e l e c t i o n d f s s t d p r i o r i t y 1000000
Presolving
Pricing
Conflict analysis
Cuts
Processing
Enforce constraints
Primal heuristics
Branching
Presolving
Pricing
Conflict analysis
Cuts
Processing
Enforce constraints
Primal heuristics
Branching
x1 x1
Techniques
x2 x2
• constraint specific
⇒
x3 x3 • each cons handler may provide a
propagation routine
• reduced presolving (usually)
x4 x4
• dual propagation
• root reduced cost strengthening
Task
• objective function
• simplify model locally
• special structures
• improve local dual bound • variable bounds
• detect infeasibility
Presolving
Pricing
Conflict analysis
Cuts
Processing
Enforce constraints
Primal heuristics
Branching
• lp/initalgorithm, lp/resolvealgorithm
• Primal/Dual Simplex Algorithm
• Barrier w and w/o crossover
• lp/pricing
• normally LP solver specific default
• Devex
• Steepest edge
• Quick start steepest edge
• lp/threads
Slow LP performance is a blocker for the solving process and can sometimes be
manually tuned significantly.
Presolving
Pricing
Conflict analysis
Cuts
Processing
Enforce constraints
Primal heuristics
Branching
Pricing
Presolving
Pricing
Conflict analysis
Cuts
Processing
Enforce constraints
Primal heuristics
Branching
Techniques
• general cuts
• complemented MIR cuts
• Gomory mixed integer cuts
• strong Chvátal-Gomory cuts
• implied bound cuts
• reduced cost strengthening
Feasible region: (b ∈ Z+ , aj ∈ Z+ ∀ j ∈ N)
X
X BK := { x ∈ {0, 1}n : aj xj ≤ b }
j∈N
Minimal Cover: C ⊆ N
•
P
aj > b 5x1 + 6x2 + 2x3 + 2x4 ≤ 8
j∈C
P
• j∈C \{i} aj ≤ b ∀i ∈ C
Minimal cover:
C = {2, 3, 4}
Minimal Cover Inequality Minimal cover inequality:
X x2 + x3 + x4 ≤ 2
xj ≤ |C | − 1
j∈C
• separating/maxcuts, separating/maxcutsroot
• separating/maxrounds, separating/maxroundsroot
• separating/maxstallrounds, separating/maxstallroundsroot
Presolving
Pricing
Conflict analysis
Cuts
Processing
Enforce constraints
Primal heuristics
Branching
Presolving
Pricing
Conflict analysis
Cuts
Processing
Enforce constraints
Primal heuristics
Branching
Presolving
Pricing
Conflict analysis
Cuts
Processing
Enforce constraints
Primal heuristics
Branching
Presolving
Pricing
Conflict analysis
Cuts
Processing
Enforce constraints
Primal heuristics
Branching
Presolving
Pricing
Conflict analysis
Cuts
Processing
Enforce constraints
Primal heuristics
Branching
Presolving
Pricing
Conflict analysis
Cuts
Processing
Enforce constraints
Primal heuristics
Branching
Presolving
Pricing
Conflict analysis
Cuts
Processing
Enforce constraints
Primal heuristics
Branching
Presolving
Pricing
Conflict analysis
Cuts
Processing
Enforce constraints
Primal heuristics
Branching
Presolving
Pricing
Conflict analysis
Cuts
Processing
Enforce constraints
Primal heuristics
Branching
Presolving
Pricing
Conflict analysis
Cuts
Processing
Enforce constraints
Primal heuristics
Branching
Techniques
• branching on variables
• most infeasible
• least infeasible
• random branching
• strong branching
• pseudocost
• reliability
• VSIDS
Task • hybrid reliability/inference
SCIP> d i s p l a y b r a n c h i n g
Presolving
Pricing
Conflict analysis
Cuts
Processing
Enforce constraints
Primal heuristics
Branching
Techniques
• structure-based
• clique
• variable bounds
• rounding
• possibly solve final LP
• diving
• least infeasible
• guided
• objective diving
Task • objective feasibility pump
• improve primal bound • Large Neighborhood Search
• effective on average • RINS, local branching
• RENS
• guide remaining search • Adaptive LNS
• Completion of partial solutions
s e t h e u r i s t i c s feaspump f r e q −1
Important Parameters
Advice
Use emphasis settings. Do not attempt to individually tune heuristics by hand.
Presolving
Pricing
Conflict analysis
Cuts
Processing
Enforce constraints
Primal heuristics
Branching
Techniques
• Analyze:
• Propagation conflicts
• Infeasible LPs
• Bound-exceeding LPs
• Strong branching conflicts
• Detection:
Task • Cut in conflict graph
• LP: Dual ray heuristic
• Analyze infeasibility
• Use conflicts:
• Derive valid constraints
• Only for propagation
• Help to prune other nodes • As cutting planes
http://scip.zib.de
flow mcf
rlp cover
fix
odd
Reader cycle
cmir Separator
cnf sol
rapid
clique learn
probing cip sos
intto
binary trivial
redcost
ccg zpl
zero strong
implics half cg
dualfix Presolver
pseudo fracdiving intdiving
Tree Pricer
obj
linesearch
bound Impli feaspump diving
shift cations root guided
redcost diving int
fixand
infer shifting
Propa
gator cross local mutation
vbound over dins branching
restart
dfs
··· Relax coef subnlp
hybrid diving objpscost
estim actcons
diving
diving
estimate
Node
selector
SCIP Primal
Heuristic
octane
zi round oneopt
dfs pscost
veclen
Display Variable diving diving
bfs
allfull
bound strong
var
xprs bound disjunc. full
xor and strong
count
spx sos2 sols infer
cumu
sos1 ence
lative
LP Branch
relps
none clp setppc integral cost
mostinf
quadr knap
msk cpx atic sack random pscost
or linking
orbi
linear
tope
logicor
flow mcf
rlp cover
fix
odd
Reader cycle
cmir Separator
cnf sol
rapid
clique learn
probing cip sos
intto
binary trivial
redcost
ccg zpl
zero strong
implics half cg
dualfix Presolver
pseudo fracdiving intdiving
Tree Pricer
obj
linesearch
bound Impli feaspump diving
shift cations root guided
redcost diving int
fixand
infer shifting
Propa
gator cross local mutation
vbound over dins branching
restart
dfs
··· Relax coef subnlp
hybrid diving objpscost
estim actcons
diving
diving
estimate
Node
selector
SCIP Primal
Heuristic
octane
zi round oneopt
dfs pscost
veclen
Display Variable diving diving
bfs
allfull
bound strong
var
xprs bound disjunc. full
xor and strong
count
spx sos2 sols infer
cumu
sos1 ence
lative
LP Branch
relps
none clp setppc integral cost
mostinf
quadr knap
msk cpx atic sack random pscost
or linking
orbi
linear
tope
logicor
flow mcf
rlp cover
fix
odd
Reader cycle
cmir Separator
cnf sol
rapid
clique learn
probing cip sos
intto
binary trivial
redcost
ccg zpl
zero strong
implics half cg
dualfix Presolver
pseudo fracdiving intdiving
Tree Pricer
obj
linesearch
bound Impli feaspump diving
shift cations root guided
redcost diving int
fixand
infer shifting
Propa
gator cross local mutation
vbound over dins branching
restart
dfs
··· Relax coef subnlp
hybrid diving objpscost
estim actcons
diving
diving
estimate
Node
selector
SCIP Primal
Heuristic
octane
zi round oneopt
dfs pscost
veclen
Display Variable diving diving
bfs
allfull
bound strong
var
xprs bound disjunc. full
xor and strong
count
spx sos2 sols infer
cumu
sos1 ence
lative
LP Branch
relps
none clp setppc integral cost
mostinf
quadr knap
msk cpx atic sack random pscost
or linking
orbi
linear
tope
logicor
SCIP core
SCIP core
Plugins
SCIP core
Plugins
SCIP core
Plugins
flow mcf
rlp cover
fix
odd
Reader cycle
cmir Separator
cnf sol
rapid
clique learn
probing cip sos
intto
binary trivial
redcost
ccg zpl
zero strong
implics half cg
dualfix Presolver
pseudo fracdiving intdiving
Tree Pricer
obj
linesearch
bound Impli feaspump diving
shift cations root guided
redcost diving int
fixand
infer shifting
Propa
gator cross local mutation
vbound over dins branching
restart
dfs
··· Relax coef subnlp
hybrid diving objpscost
estim actcons
diving
diving
estimate
Node
selector
SCIP Primal
Heuristic
octane
zi round oneopt
dfs pscost
veclen
Display Variable diving diving
bfs
allfull
bound strong
var
xprs bound disjunc. full
xor and strong
count
spx sos2 sols infer
cumu
sos1 ence
lative
LP Branch
relps
none clp setppc integral cost
mostinf
quadr knap
msk cpx atic sack random pscost
or linking
orbi
linear
tope
logicor
allfull
bound strong
disjunc. full
strong
count
sols infer
cumu
ence
lative
Branch
indi
cator leastinf
relps
integral cost
mostinf
knap
sack random pscost
g
linear
/* start timing */
SCIP clockStart ( branchrule - > branchclock , set );
/* stop timing */
SCIPclockStop ( branchrule - > branchclock , set );
/* evaluate result */
if ( * result != SCIP_CUTOFF
&& * result != SCIP_CONSADDED
&& * result != SCIP_REDUCEDDOM
&& * result != SCIP_SEPARATED
&& * result != SCIP_BRANCHED
&& * result != SCIP_DIDNOTRUN )
{
S C I P e r rorMessage (
" branching rule <%s > returned invalid result code <%d > from LP \
solution branching \ n " ,
branchrule - > name , * result );
return S C IP _ IN VA L ID R ES UL T ;
}
Branching Rules
Constraint handlers
Functions
Result
• SCIP is constraint based
• Advantage: flexibility
• Disadvantage: limited global view
flow mcf
rlp cover
fix
odd
Reader cycle
cmir Separator
cnf sol
rapid
clique learn
probing cip sos
intto
binary trivial
redcost
ccg zpl
zero strong
implics half cg
dualfix Presolver
pseudo fracdiving intdiving
Tree Pricer
obj
linesearch
bound Impli feaspump diving
shift cations root guided
redcost diving int
fixand
infer shifting
Propa
gator cross local mutation
vbound over dins branching
restart
dfs
··· Relax coef subnlp
hybrid diving objpscost
estim actcons
diving
diving
estimate
Node
selector
SCIP Primal
Heuristic
octane
zi round oneopt
dfs pscost
veclen
Display Variable diving diving
bfs
allfull
bound strong
var
xprs bound disjunc. full
xor and strong
count
spx sos2 sols infer
cumu
sos1 ence
lative
LP Branch
relps
none clp setppc integral cost
mostinf
quadr knap
msk cpx atic sack random pscost
or linking
orbi
linear
tope
logicor
flow mcf
rlp cover
fix
odd
Reader cycle
cmir Separator
cnf sol
rapid
clique learn
probing cip sos
intto
binary trivial
redcost
ccg zpl
zero strong
implics half cg
dualfix Presolver
pseudo fracdiving intdiving
Tree Pricer
obj
linesearch
bound Impli feaspump diving
shift cations root guided
redcost diving int
fixand
infer shifting
Propa
gator cross local mutation
vbound over dins branching
restart
dfs
··· Relax coef subnlp
hybrid diving objpscost
estim actcons
diving
diving
estimate
Node
selector
SCIP Primal
Heuristic
octane
zi round oneopt
dfs pscost
veclen
Display Variable diving diving
bfs
allfull
bound strong
var
xprs bound disjunc. full
xor and strong
count
spx sos2 sols infer
cumu
sos1 ence
lative
LP Branch
relps
none clp setppc integral cost
mostinf
quadr knap
msk cpx atic sack random pscost
or linking
orbi
linear
tope
logicor
flow mcf
rlp cover
fix
odd
Reader cycle
cmir Separator
cnf sol
rapid
clique learn
probing cip sos
intto
binary default
redcost
ccg default
strong
implics default cg
dualfix Presolver
pseudo fracdiving intdiving
Tree Pricer
obj
linesearch
bound Impli feaspump diving
shift cations root guided
redcost diving int
fixand
infer shifting
Propa
gator cross local mutation
default over dins branching
default
··· Relax coef subnlp
hybrid diving objpscost
estim actcons
diving
diving
estimate
Node
selector
SCIP Primal
Heuristic
octane
default oneopt
dfs pscost
veclen
Display Variable diving diving
bfs
allfull
bound strong
var
default bound disjunc. full
default and strong
count
spx sos2 sols infer
cumu
sos1 ence
lative
LP Branch
relps
none clp setppc integral cost
mostinf
quadr knap
msk cpx atic sack random pscost
or linking
orbi
linear
tope
logicor
flow mcf
rlp cover
fix
odd
Reader cycle
cmir Separator
cnf sol
rapid
clique learn
probing cip sos
intto
binary default
redcost
tsp default
strong
implics default cg
dualfix Presolver
pseudo fracdiving intdiving
Tree Pricer
obj
linesearch
bound Impli feaspump diving
shift cations root guided
redcost diving int
fixand
infer shifting
Propa
gator local mutation
default 2-Opt
dins branching
default
··· Relax coef subnlp
hybrid diving objpscost
estim farthest diving
insert
estimate
Node
selector
SCIP Primal
Heuristic
octane
default oneopt
dfs pscost
veclen
Display Variable diving diving
bfs
allfull
bound strong
var
default bound disjunc. full
default subtour strong
count
spx sos2 sols infer
cumu
sos1 ence
lative
LP Branch
relps
none clp setppc integral cost
mostinf
quadr knap
msk cpx atic sack random pscost
or linking
orbi
linear
tope
logicor
flow mcf
rlp cover
fix
odd
Reader cycle
cmir Separator
cnf sol
rapid
clique learn
probing sos
intto csol
binary default
redcost
default coloring
col
strong
implics default cg
dualfix Presolver
pseudo fracdiving intdiving
Tree Pricer
obj
linesearch
bound Impli feaspump diving
shift cations root guided
redcost diving int
fixand
infer shifting
Propa
gator local mutation
default 2-Opt
dins branching
default
··· Relax coef subnlp
hybrid diving objpscost
estim
init diving
estimate
Node
selector
SCIP Primal
Heuristic
octane
default oneopt
dfs pscost
veclen
Display Variable diving diving
bfs
Ryan&
var bound Foster
bound disjunc. strong
default store
default Ryan&
Graph
Foster
count
spx sos2 sols infer
cumu
sos1 ence
lative
LP Branch
relps
none clp setppc integral cost
mostinf
quadr knap
msk cpx atic sack random pscost
or linking
orbi
linear
tope
logicor
flow mcf
rlp cover
fix
odd
Reader cycle
cmir Separator
cnf sol
rapid
clique learn
probing cip sos
intto
binary default
redcost
stp default
strong
implics default cg
dualfix Presolver
pseudo fracdiving intdiving
Tree Pricer
obj
linesearch
Impli feaspump diving
stp cations root guided
redcost diving int
fixand
infer shifting
Propa
gator local mutation
default local dins branching
default
··· Relax coef subnlp
hybrid diving objpscost
estim
TM diving
estimate
Node
selector
SCIP Primal
Heuristic
octane
default oneopt
dfs pscost
veclen
Display Variable diving diving
bfs
allfull
bound strong
var
default bound disjunc. full
default stp
strong
count
spx sos2 sols infer
cumu
sos1 ence
lative
LP Branch
relps
none clp setppc integral cost
mostinf
quadr knap
msk cpx atic sack random pscost
or linking
orbi
linear
tope
logicor
http://scip.zib.de
• . . . is a bag of tricks
• new tricks are introduced almost every day
• advantages of SCIP
• open source, you can see everything that happens
• hundreds of parameters to play with
• broad scope
• easily extendable