Introduction to SCIPscip.zib.de/download/slides/SCIP-introduction.pdfIntroduction to SCIP Marc...
Transcript of Introduction to SCIPscip.zib.de/download/slides/SCIP-introduction.pdfIntroduction to SCIP Marc...
Introduction to SCIP
Marc PfetschZuse Institute Berlin
DFG Research Center MATHEONMathematics for key technologies
Berlin, 10/11/2007
Outline
1 SCIP Facts2 Branch-And-Cut and Constraint Programming3 SCIP Basics
SCIP PluginsProblem SpecificationPresolvingSolving
4 Further Information
2 / 60
What is SCIP?
SCIP (Solving Constraint Integer Programs) . . .. is a branch-and-cut-and-price framework,. incorporates a full-scale mixed integer programming (MIP) solver,. is also a constraint programming (CP) solver,. incorporates SAT-solving features (conflict analysis, restarts),. is free for academic purposes,. and is available in source-code!
3 / 60
Comparison of MIP-Solvers
0
1000
2000
3000
4000
Tim
ein
seco
nds
non-
com
mer
cial
com
mer
cial
SymphonylpsolveGLPKMintoCBC 1.2SCIP–CLPSCIP-SoPlexSCIP-CPLEXCPLEX 10.2
7.05x 6.99x
6.12x
4.10x
2.12x
1.06x 1.00x0.37x 0.13x
not solved 73% 81% 72% 55% 40% 16% 16% 1% 4%
. MIP-solver as fast as CPLEX 9.0
. Underlying LP-solver: treated as black box
4 / 60
SCIP History
1998 SIP – Solving Integer Programs (Alexander Martin)
10/2002 start of SCIP development (Tobias Achterberg)02/2003 first version to solve MIPs05/2003 Gomory cuts08/2003 conflict analysis03/2004 knapsack cover separator (Kati Wolter)04/2004 restarts, c-MIR cuts01/2005 feasibility pump (Timo Berthold)09/2005 first public version 0.8009/2006 version 0.9009/2007 version 1.00
5 / 60
SCIP Facts
. Approx. 220.000 lines of C code
. Main SCIP developer: Tobias Achterberg → ILOGTimo Berthold (heuristics), Kati Wolter (cuts)
. Current development: Timo Berthold, Kati Wolter, . . .
. Development together with TU Darmstadt.
. Free for academic use (as is SoPlex)
. Available at http://scip.zib.de
. ZIB Optimization Suite = SCIP + SoPlex + ZIMPLhttp://zibopt.zib.de
6 / 60
Outline
1 SCIP Facts2 Branch-And-Cut and Constraint Programming3 SCIP Basics
SCIP PluginsProblem SpecificationPresolvingSolving
4 Further Information
7 / 60
Definition: Mixed Integer Program (MIP)
min cTxs.t. Ax ≤ b
l ≤ x ≤ uxj ∈ Z j ∈ J
8 / 60
Definition: Mixed Integer Program (MIP)
min cTx
s.t. Ax ≤ bl ≤ x ≤ u
xj ∈ Z j ∈ J
8 / 60
Definition: Mixed Integer Program (MIP)
min cTxs.t. Ax ≤ b
l ≤ x ≤ uxj ∈ Z j ∈ J
8 / 60
Definition: Mixed Integer Program (MIP)
min cTxs.t. Ax ≤ b
l ≤ x ≤ u
xj ∈ Z j ∈ J
8 / 60
Definition: Mixed Integer Program (MIP)
min cTxs.t. Ax ≤ b
l ≤ x ≤ u
xj ∈ Z j ∈ J
8 / 60
Definition: Mixed Integer Program (MIP)
min cTxs.t. Ax ≤ b
l ≤ x ≤ uxj ∈ Z j ∈ J
8 / 60
Branch-And-Cut
Combination of
. Branch-and-Bound
. Cutting planes
9 / 60
Branch-And-Cut
Combination of
. Branch-and-Bound
. Cutting planes
9 / 60
Branch-And-Cut
Combination of
. Branch-and-Bound
. Cutting planes
9 / 60
Branch-And-Cut
Combination of
. Branch-and-Bound
. Cutting planes
9 / 60
Branch-And-Cut
Combination of
. Branch-and-Bound
. Cutting planes
9 / 60
Branch-And-Cut
Combination of
. Branch-and-Bound
. Cutting planes
9 / 60
Branch-And-Cut
Combination of
. Branch-and-Bound
. Cutting planes
9 / 60
Branch-And-Cut
Combination of
. Branch-and-Bound
. Cutting planes
9 / 60
Branch-And-Cut
Combination of
. Branch-and-Bound
. Cutting planes
9 / 60
Branch-And-Cut
Combination of
. Branch-and-Bound
. Cutting planes
9 / 60
Branch-And-Cut
Combination of
. Branch-and-Bound
. Cutting planes
9 / 60
Branch-And-Cut
Combination of
. Branch-and-Bound
. Cutting planes
9 / 60
Branch-And-Cut
Combination of
. Branch-and-Bound
. Cutting planes
9 / 60
Branch-And-Cut
Combination of
. Branch-and-Bound
. Cutting planes
9 / 60
Branch-And-Cut
Combination of
. Branch-and-Bound
. Cutting planes
9 / 60
Branch-And-Cut
Combination of
. Branch-and-Bound
. Cutting planes
9 / 60
Branch-And-Cut
Combination of
. Branch-and-Bound
. Cutting planes
9 / 60
Branch-And-Cut
Combination of
. Branch-and-Bound
. Cutting planes
9 / 60
Branch-And-Cut
Combination of
. Branch-and-Bound
. Cutting planes
9 / 60
Constraint Programming
Constraint Program (CP)
. Domains of variables = (finite) set
. Constraints = subsets of domain space
Easy example:. variables x and y. domains: Dx = Dy = {0, 1}. constraint: {(0, 1), (1, 0)} ⊂ Dx × Dy ⇔ x = 1− y .
Constraint Integer Program (CIP)
Fixing integer variables leaves LP.
10 / 60
Solving CPs
. Branching:I Divide into subproblems, solve recursively
. Domain Propagation:I Reductions in variables’ domains “propagate”I E.g. x1 + 2x2 ≥ 5, x1 ≤ 2 ⇒ x2 ≥ 1.5
11 / 60
Propagation Example
Alldifferent constraint:{x1, x2, x3, x4} ∈ {1, 2, 3, 4} pairwise different.
x1
x2
x3
x4
alldiff
⇒
x1
x2
x3
x4
12 / 60
Outline
1 SCIP Facts2 Branch-And-Cut and Constraint Programming3 SCIP Basics
SCIP PluginsProblem SpecificationPresolvingSolving
4 Further Information
13 / 60
Important Aspects
. SCIP is constraint basedI Advantage: flexibilityI Disadvantage: no dual representation
. A constraint knows its variables, but a variable does not know theconstraints it appears in.
. A constraint usually implements a type of inequalities, not a singleinequality.
. From CP-perspective: LP-relaxation is only an add-on! Manyconstraints do not separate inequalities at all.
14 / 60
Example: TSPTraveling Salesman problem (TSP)
Given graph G = (V , E ) and distances de , find shortest tour throughall nodes.
IP-formulation:
min∑e∈E
de xe
s.t.∑
e∈δ(v)
xe = 2 ∀ v ∈ V
∑e∈δ(S)
xe ≥ 2 ∀ S ⊂ V , S 6= ∅
xe ∈ {0, 1} ∀ e ∈ E
Example available with SCIP, including visualization.15 / 60
SCIP Stages
Init
Problem Transforming
Free Transform
Presolving
Init Solve
Solving
Free Solve
16 / 60
Outline
1 SCIP Facts2 Branch-And-Cut and Constraint Programming3 SCIP Basics
SCIP PluginsProblem SpecificationPresolvingSolving
4 Further Information
17 / 60
SCIP Interface
Main SCIP interface: plugins.
. Perform all problem specific actions.
. Each step calls user defined plugins.
. SCIP knows of plugins through “include” functions.
. Plugins may have private data.
. User defined callback functions(virtual functions in C++-interface).
. Yields modular structure.
. The MIP solver is realized through plugins.
Everything SCIP knows, it knows through plugins.
18 / 60
Types of Plugins
. Constraint handler: assures feasibility, strengthens formulation
. Separator: adds cuts, improves dual bound
. Pricer: allows dynamic generation of variables
. Heuristic: searches solutions, improves primal bound
. Branching rule: how to divide the problem?
. Node selection: which subproblem should be regarded next?
. Presolver: simplifies the problem in advance, strengthens structure
. Propagator: simplifies problem, improves dual bound locally
. Reader: reads problems from different formats
. Event handler: catches events (e.g., bound changes, new solutions)
. Display: allows modification of output
19 / 60
Default Plugins
5 presolvers5 node selection rules
14 constraint handlers8 separators8 branching rules2 propagators
23 primal heuristics
20 / 60
TSP Plugins
MIP default plugins 2-Opt Heuristic
No-Subtour Constraint Farthest Insert Heuristic
File Reader New Solution Event Handler
Search Tree LP Relaxation Presolve Management
ImplicationGraph
SolutionPool
CutPool
ConflictAnalysis
21 / 60
Outline
1 SCIP Facts2 Branch-And-Cut and Constraint Programming3 SCIP Basics
SCIP PluginsProblem SpecificationPresolvingSolving
4 Further Information
22 / 60
Problem Specification
Init
Problem Transforming
Free Transform
Presolving
Init Solve
Solving
Free Solve
23 / 60
Define Variables (TSP Example)
SCIP_VAR* var;SCIP_CALL( // return value macro
SCIPcreateVar(scip , // SCIP pointer&var , // save in variable"varname", // pass variable name0.0, // lower bound1.0, // upper boundlength , // obj. valueSCIP_VARTYPE_BINARY , // typeTRUE , // initialFALSE , // removableNULL , NULL , NULL , // no callback functionsNULL // no variable data
));SCIP_CALL( SCIPaddVar(scip , var) ); // add var.
25 / 60
TSP: Define Degree ConstraintsSCIP_CALL( SCIPcreateConsLinear(
scip , // SCIP pointer&cons , // save in cons"consname", // namenvar , // number of variablesvars , // array of variablesvals , // array of values2.0, // left hand side2.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 constraintSCIP_CALL( SCIPreleaseCons(scip , &cons) ); // free cons. space
MIPs are specified using linear constraints only (may be “upgraded”).27 / 60
Transformation
Init
Problem Transforming
Free Transform
Presolving
Init Solve
Solving
Free Solve
28 / 60
Transformation
Original problem Transformed problem
original variables
original constraints
transformed variables
transformed constraints
All variables and constraints are transformed:
. data are copied into separate memory area
. presolving and solving operate on transformed problem
. original data can only be modified in problem modification stage
29 / 60
Outline
1 SCIP Facts2 Branch-And-Cut and Constraint Programming3 SCIP Basics
SCIP PluginsProblem SpecificationPresolvingSolving
4 Further Information
30 / 60
Presolving
Init
Problem Transforming
Free Transform
Presolving
Init Solve
Solving
Free Solve
31 / 60
Presolving
init exec. presolvers exec. constraint presolving
found?yes no
. Presolvers provide global presolving (e.g. dual fixing)
. Constraint Handlers provide constraint specific presolving, e.g.:I domain tightening,I coefficient modification,I deletion of redundant constraints,I constraint upgrading.
32 / 60
Probing
Probing:. Tentatively fix binary variables to 0 and 1.. Execute domain propagation of constraints.. Try to deduce global fixings and implications.
Example: x − z ≤ 0,−y + z ≤ 0,
x + y ≤ 1
⇒ x = 0
33 / 60
Outline
1 SCIP Facts2 Branch-And-Cut and Constraint Programming3 SCIP Basics
SCIP PluginsProblem SpecificationPresolvingSolving
4 Further Information
34 / 60
Solving
Init
Problem Transforming
Free Transform
Presolving
Init Solve
Solving
Free Solve
35 / 60
Flow Chart SCIP
Start Init Presolving
Stop
Node selection
Processing
Branching
Conflict analysis
Primal heuristics
LP inf.
LP feas.IP inf.
IP feas.
36 / 60
Node Selection
. Node Selectors called in order of priority
. Choose:I child nodeI sibling nodeI leaf node stored in the tree
. two operation modes:I standard mode (default: best estimate)I memory-saving mode (default: depth first search)switching between modes is automatic
37 / 60
Branching,Conflict Analysis, and Heuristics
Start Init Presolving
Stop
Node selection
Processing
Branching
Conflict analysis
Primal heuristics
LP inf.
LP feas.IP inf.
IP feas.
→ separate talks
38 / 60
Node Solving
Start Init Presolving
Stop
Node selection
Processing
Branching
Conflict analysis
Primal heuristics
LP inf.
LP feas.IP inf.
IP feas.
39 / 60
Node Solving
Domain Propagation Solve LP
Pricing
Separation
Domain Propagation
LP Solving
Constraint Enforcement
40 / 60
TSP Example
Recall TSP IP-formulation:
min∑e∈E
de xe
s.t.∑
e∈δ(v)
xe = 2 ∀ v ∈ V
∑e∈δ(S)
xe ≥ 2 ∀ S ⊂ V , S 6= ∅
xe ∈ {0, 1} ∀ e ∈ E
Introduce no-subtour constraint: nosub(x)ensures that x does not contain a subtour.
41 / 60
TSP CP-Formulation
min∑e∈E
de xe
s.t.∑
e∈δ(v)
xe = 2 ∀ v ∈ V
nosub(x)
xe ∈ {0, 1} ∀ e ∈ E
42 / 60
TSP No-Subtour Constraint
∑e∈δ(S)
xe ≥ 2 ∀ S ⊂ V , S 6= ∅
No-Subtour Constraint Handler callback functions:. Separate: separate inequalities → added to LP
Compute Gomory-Hu tree (max-flow techniques) and check cuts.. Enforcing: separate subtour inequalities. Checking: check whether an integer solution (produced by a
heuristic) is feasible. Propagation: –. Other callbacks: (de)initialization, “locking”, transforming, printing
43 / 60
Linear Constraint Handler
linear constraints: α ≤ aTx ≤ β
. Main constraint for MIP solving
. MIP is constructed with linear constraints.
. May be upgraded to knapsack constraints, etc.
. The linear constraint handler providesI presolving methodsI separates the corresponding inequalitiesI propagates variable bounds
44 / 60
Specially Ordered Sets
Definition (Specially Ordered Set of Type 1)
In given set of variables, at most one is nonzero.
. Nonlinear constraint
. In general: no (good) inequalities (unless bounds are tight)
. Enforcing: branch to remove infeasibility:fix all variables except one to 0.
45 / 60
Domain Propagation
Domain Propagation Solve LP
Pricing
Separation
Domain Propagation
LP Solving
Constraint Enforcement
46 / 60
Domain Propagation
. Propagators provide global domain reduction methods.
. Constraint handlers provide constraint specific domain reduction:Example: knapsack 4x1 + 6x2 + 7x3 ≤ 11, x2 = 1 ⇒ x3 = 0.
. With propagation frequency f :Propagation called every f th level of the branch-and-bound tree
Similar frequencies for separation, enforcing, . . .
47 / 60
LP Solving
Domain Propagation Solve LP
Pricing
Separation
Domain Propagation
LP Solving
Constraint Enforcement
48 / 60
LP Solving
. LP-Interface LPI to various LP-solvers:SoPlex, CPLEX, XPress, CLP, . . .
. Primal or dual simplex
. Barrier with or without crossover (if supported)
. LP stability checked:resolution by changing parameters:scaling, tolerances, solving from scratch, other simplex method.
49 / 60
Pricing
Domain Propagation Solve LP
Pricing
Separation
Domain Propagation
LP Solving
Constraint Enforcement
50 / 60
Pricing
execute pricers new columns?
resolve LPyes
no
. Pricers search for new variables with negative reduced costs
. inform constraint handlers about the new variables
. LP resolved after few new columns
. Currently: partial pricing is not allowed(LP objective value has to be a lower bound.)
51 / 60
Separation
Domain Propagation Solve LP
Pricing
Separation
Domain Propagation
LP Solving
Constraint Enforcement
→ separate talk. SCIP has a built-in cut selection methodology.
52 / 60
Constraint Enforcement
Domain Propagation Solve LP
Pricing
Separation
Domain Propagation
LP Solving
Constraint Enforcement
53 / 60
Constraint Enforcement
If no separating cutting plane was found, solution can still beinfeasible for a constraint.
Enforcing is necessary for a correct implementation!
Constraint handler resolves the infeasibility by. reducing a variable’s domain,. separating a cutting plane (may use integrality),. adding a (local) constraint,. creating a branching, or. concluding that current subproblem is infeasible.
54 / 60
Outline
1 SCIP Facts2 Branch-And-Cut and Constraint Programming3 SCIP Basics
SCIP PluginsProblem SpecificationPresolvingSolving
4 Further Information
55 / 60
Implementation Hints
. SCIP has own memory handling.I Standard memory: SCIPallocMemoryArray(scip,&p,10),
SCIPfreeMemoryArray(scip,&p)I Block memory: SCIPallocBlockMemoryArray(scip,&p,10),
SCIPfreeBlockMemoryArray(scip,&p,10)I Fast buffer: SCIPallocBufferArray(scip,&p,10),
SCIPfreeBufferArray(scip,&p)
. Functions calling SCIP_RETCODE <function>() should use theSCIP_CALL() macro and should return SCIP_RETCODE.
. There are template files, e.g. cons_xxx.{c,h}.
. Only include scip/scip.h or scip/scipdefplugins.h.
56 / 60
Documentation. Constraint Integer Programming
Ph.D. dissertation of Tobias Achterberg, 2007.. SCIP – a framework to integrate Constraint and Mixed Integer
ProgrammingTobias Achterberg, ZIB-Report 04-19, 2004.
. Primal Heuristics for Mixed Integer ProgramsTimo Berthold, Diploma Thesis, TU Berlin, 2006
. Implementation of Cutting Plane Separators for Mixed IntegerProgramsKati Wolter, Diploma Thesis, TU Berlin, 2006
. http://scip.zib.deDoxygen documentation, HowTos, FAQ
. See: scip.h, pub_*.h, <plugin>.h (e.g. cons_linear.h)
57 / 60
How to Contribute?
You can/should contribute by . . .. using SCIP and report publications/projects,. sending bug-reports – better: bug-fixes,. giving feedback on documentation,. implementing plugins.
58 / 60
Future Plans
. nonlinear components/constraintsI SOS1, SOS2I indicatorsI MINLP
. exact IP (without rounding errors)
. symmetries
. counting solutions
. improved column generation support
. new heuristics/cuts
. performance improvement
. arbitrary constraints in ZIMPL → SCIP
59 / 60
Introduction to SCIP
Marc PfetschZuse Institute Berlin
DFG Research Center MATHEONMathematics for key technologies
Berlin, 10/11/2007