What have we learned and what are we expected to know Overview Introduction Modelling in MiniZinc Finite Domain Constraint Solving Search Linear Programming and Network Flow Mixed Integer Programming ID: 614374
Download Presentation The PPT/PDF document "Course Summary" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Slide1
Course Summary
What have we learned and what are we expected to know?Slide2
Overview
Introduction
Modelling
in
MiniZinc
Finite Domain Constraint Solving
Search
Linear Programming and Network Flow
Mixed Integer Programming
Boolean
Satisfiability
Lazy Clause Generation
Course Summary + RevisionSlide3
ModellingSlide4
Modelling Approaches
Approaches to
modelling
traditional language and constraint-solving library
OO language with high-level library
constraint programming language
mathematical programming language
embedded domain specific language
Strengths and weaknesses
of approachesSlide5
MiniZinc Basics
Variables:
var
int
:
x
;
Parameters:
int
:
n
;
Types:
int
, float,
bool
, string, arrays + sets
Arithmetic expressions:
x
+
y
mod
z
- 3
Data files (.
dzn
)
Structure of a model (items):
include, output, variable declaration, assignment, constraint, solveSlide6
Comprehensions + Iteration
Comprehension
[
expr
|
generator1
,
generator2
… where
boolexpr
]
Iteration
forall(
generator1
,
generator2
… where
boolexpr
)(
expr
)
is equivalent to
forall([
expr
|
generator1
,
generator2
…where
boolexpr
])
Usable for any predicate/function on an array:
exists,
alldifferent
, sum, product, …Slide7
Constraints
Basic constraints:
=, <, <=
Complex combinations:
/\, \/, -> , not
Array constraints:
a[i
]
where
i
is a variable
bool2int
Constraints for sets:
union, intersect, subset, card, …
Assertions
If-then-else-
endifSlide8
Predicates + Tests
Capturing a reusable complex constraint
Global constraints:
alldifferent
, inverse, cumulative, table, regular
User-defined constraints
Question
: what is the difference between a predicate and test?Slide9
Complex Predicates
Reflection Functions:
information about array indices and variable domains
index_set
, index_set_2of3, lb,
ub
,
dom
,
lb_array
, …
Local variables:
predicate
even(var
int:x
) = let {
var
int
:
y
} in
x
= 2*
y
;
Local parameters must be initialized
No local variables
in a
negative contextSlide10
Partial Functions
Question
: What is the expected
behaviour
for
constraint
a[i
] >= 2 ->
a[i
] <= 3;
Relational semantics
partial function application leads to false at nearest enclosing Boolean contextSlide11
Modelling Considerations
Bound your variables
Write efficient loops
User global constraints where applicable
Add redundant constraints
that cause extra propagation
A dual viewpoint of the problem can help
channel the two viewpointsSlide12
Key Skills
Interpret
MiniZinc
models
understand what they mean
Write
MiniZinc
models
from an English description of the problem
including complex loops and output
understand and use the
globals
studied
write complex predicate definitionsSlide13
Finite Domain Constraint SolvingSlide14
Constraint Satisfaction Problems
CSP:
Variables
Finite Domains
Constraints
Backtracking Search
pruning using partial
satisfiabilitySlide15
Consistency
Node consistency
unary constraints:
remove invalid values
only require
one application
per constraint
Arc consistency
binary constraints
remove unsupported values
requires
fixpoint
Domain consistency
n
-ary
constraints
removes
all values
that are not part of a solution
NP-hard
for many constraintsSlide16
Bounds Consistency
Only maintain lower + upper bounds (
bounds
(Z
)
)
Relax consistency to use
reals
(
bounds
(R
)
)
More efficient
(linear propagation for
linears
)
Less pruning
Propagation Rules
inequalities to determine bounds propagation
x
=
abs(y
):
x
≥ 0,
x
≤
max(ub(y
), -
lb(y
)), y ≥ (if lb(y) ≥ -lb(x) then lb(x) else –ub(x)) y ≤ (if ub(y) ≤ lb(x) then –lb(x) else ub(x))Slide17
Propagation
Propagator
: mapping from domain to domain
correct
: does not remove solutions
checking
: answers false when all variables fixed and not solution
may not implement any notion of consistency!
Propagation solving
:
run all propagators to
fixpoint
avoid rerunning propagators that must be at
fixpoint
events,
idempotenceSlide18
Complex Constraints
Complex constraints \/ -> … are
flattened
broken into reified components
Reified constraints
:
Boolean reflects if constraint holds
e.g.
b
<->
x
<=
y
Complex constraints propagate weakly
compare
x
=
abs(y
)
with
b1 <->
x
=
y
, b2 <->
x
= -
y
, b1 \/ b2 Slide19
Global Constraints
Individual propagation algorithms
alldifferent
:
naïve: equal to decomposition but faster
domain: based on maximal matching
element
: (array access with variable index)
domain consistent
cumulative
many different propagation algorithms
timetable: compulsory parts reasoningSlide20
Optimization
Retry optimization
restart when you find a new solution
Branch and bound
add a new bound during searchSlide21
Key Skills
Define, explain, compare
consistencies, backtracking search, propagators, optimization search
Execute propagation algorithm
Create propagators for given constraint
Reason about global constraint propagationSlide22
SearchSlide23
Basic Search
Labeling
Choose a variable:
var
input_order
,
first_fail
, smallest,
max_regret
…
Choose a value:
val
indomain_min
,
indomain_random
,
indomain_median
…
Add
var
=
val
;
var
≠
val
Splitting
Choose variable:
varChoose split point: valAdd var ≤
val
;
var
>
valSlide24
Search Considerations
Which variables to search on?
Variable selection changes the search tree
Value selection reorders it: move solutions left
Complex search strategies
seq_search
: one search then another
Comparing search strategies
time, choices, fails
usually needs experimentationSlide25
Search Techniques
Restarts + Heavy tailed
behaviour
types of restart
Incomplete Search:
limits on fails, times, choices
limited discrepancy search
Autonomous Search:
dom_w_deg
impact
activitySlide26
Key Skills
Write and explain
MiniZinc
search annotations
Reason about and compare search strategies
Suggest appropriate searches for a model
Explain advanced search techniquesSlide27
Linear Programming and
Network FlowSlide28
Linear Programming
Form:
Slack variables: to make equations
Replacing unconstrained variables
Basic Feasible Solution
:
normal form illustrating a solution
Simplex algorithm
repeatedly pivot to a better solution
shadow prices
A first feasible solution
artificial variablesSlide29
Network Flow
A case where simplex solves integer problems
sources, sinks, flows
Form:
where A has one -1 and one 1 per
col
&
Σ
b
= 0Slide30
Network Simplex
Construct a feasible tree
auxiliary graph (artificial variables)
Replace one edge (pivot) that improves flow
Cycling: strong pivots by taking in direction
Too much supply
: add artificial demand (dump)Slide31
Key Skills
Define and explain the key concepts
linear program, basic feasible solution, pivot, network flow problem, network pivot, feasible tree
Put a problem into simplex form
Execute the two phase simplex algorithm
Map a problem to network flow form (where possible)
Execute the network flow algorithmSlide32
Mixed Integer ProgrammingSlide33
MIP Problems
Form:
where
x
are integer,
y
are real
Integer Programs: no
y
0-1 Integer Problems:
x
i
in {0,1
}
Modelling
in MIP
Boolean constraints
Reified
linears
alldifferent
,
element,
Slide34
Solving Mixed Integer Programs
Linear Relaxation
Branch and Bound
Choosing branching variable, fathoming
Cutting Planes methods
Generating cutting planes
Dual simplex (also for B&B)
Branch and Cut
simplification methods (preprocessing)
cutting planes (cover cuts)Slide35
Key Skills
Model and solve problems in MIP using
MiniZinc
model complex constraints using linear inequalities and 0-1 variables
Solve small MIP problems
execute branch and bound
create
Gomory
cuts
execute the dual simplex
preprocess (simplify) MIP problems
Explain the MIP solving methods Slide36
Boolean SatisfiabilitySlide37
Boolean Satisfiability
Problems
Conjunctive Normal Form (CNF)
SAT problems
3SAT, 2SAT
Resolution
U
nit resolution, unit propagation
Implication Graph
record why a new literal became true!Slide38
Solving SAT Problems
DPLL
: Davis-Putnam-
Logemann
-Loveland
backtracking search with unit propagation
Nogood
Learning
choice of
nogoods
1UIP
nogoods
Backjumping
Activity
: what participated in failure
Activity-based searchSlide39
Modelling for SAT
Boolean expressions
Modelling
integers
Cardinality constraints
BDD based representation
Binary arithmetic (adder) representation
Unary arithmetic (sorting network) representation
Sorting Networks
Pseudo-Boolean constraintsSlide40
Key Skills
Modelling
restricted problems using SAT in
MiniZinc
Explain and execute DPLL SAT solving
unit propagation
1UIP
nogood
generation
backjumping
Model cardinality constraints in SAT
Compare and contrast Boolean models.Slide41
Lazy Clause GenerationSlide42
Lazy Clause Generation
Representing integers:
bounds literals, equation literals,
domain clauses
Explaining propagation
Explaining failure
Propagation implication graph
1UIP
nogoods
BackjumpingSlide43
Lazier Clause Generation
Lazy variable generation:
array: generate equation literals on demand
list: generate both on demand
Views: a way to reduce the number of variables
map accesses/updates on views to base
var
Lazy Explanation
deletion of explanations
generating only needed explanationsSlide44
LCG + Globals
Globality
of
N
ogood
Learning
Globals
by Decomposition
advantages and disadvantages
which decomposition?
Explaining
Globals
choices in how to explain
what is the best explanation
Search
nogoods
work for all searchSlide45
Key Skills
Compare and contrast LCG with SAT and FD solving
Define explaining propagators
Execute lazy clause generation
Discuss variations on lazy clause generation
Examine issues for
globals
in LCG
decomposition, choice of propagationSlide46
Course SummarySlide47
Importance
Introduction:
LOW
Modelling
in
MiniZinc
:
CRITICAL
Finite Domain Constraint
Solving:
HIGH
Search:
MEDIUM
Linear Programming and Network
Flow:
LOW
Mixed Integer
Programming:
HIGH
Boolean
Satisfiability
:
MEDIUM
Lazy Clause
Generation:
MEDIUM
Course Summary +
Revision:
CRITICALSlide48
Exam Questions
Look at previous exams
modelling
in
Sicstus
Prolog: NO
constraint logic programming: NO
constraint solvers in general: NO
the rest YES including
modelling
questions (
MiniZinc
)
Workshop + Project Questions
Questions in Lectures
Exercises in SlidesSlide49
The Exam
My exams:
tend to be a bit long
have some hard questions
(a)
D
on’t Panic
a hard/long exam means standardization up
(
b
) Do the easiest mark/time questions first
for what you find easy
(
c
) Attend even if you think you
havent
passed project hurdle
hurdles can always be relaxed Slide50
Good Luck!