View
217
Download
1
Category
Tags:
Preview:
Citation preview
Course Summary
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• Boolean Satisfiability• Lazy Clause Generation• Course Summary + Revision
Modelling
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 approaches
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, solve
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, …
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-endif
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?
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 context
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 context
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 viewpoints
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 definitions
Finite Domain Constraint Solving
Constraint Satisfaction Problems
• CSP:– Variables– Finite Domains– Constraints
• Backtracking Search– pruning using partial satisfiability
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 constraints
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))
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, idempotence
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
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 reasoning
Optimization
• Retry optimization– restart when you find a new solution
• Branch and bound– add a new bound during search
Key Skills
• Define, explain, compare– consistencies, backtracking search, propagators,
optimization search
• Execute propagation algorithm• Create propagators for given constraint• Reason about global constraint propagation
Search
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: var– Choose split point: val– Add var ≤ val ; var > val
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 experimentation
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– activity
Key Skills
• Write and explain MiniZinc search annotations• Reason about and compare search strategies• Suggest appropriate searches for a model• Explain advanced search techniques
Linear Programming and Network Flow
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 variables
€
max cv x subject to A
v x ≤ b
Network Flow
• A case where simplex solves integer problems• sources, sinks, flows• Form:
where A has one -1 and one 1 per col & Σ b = 0
minimize cx= cijxij∑
subject to
Ax=b,
xij ≥0
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)
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 algorithm
Mixed Integer Programming
MIP Problems
• Form:
where x are integer, y are real• Integer Programs: no y• 0-1 Integer Problems: xi in {0,1}
• Modelling in MIP– Boolean constraints– Reified linears– alldifferent, element,
€
max cv x subject to A
v x + B
v y ≤ b
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)
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
Boolean Satisfiability
Boolean Satisfiability Problems
• Conjunctive Normal Form (CNF)• SAT problems
– 3SAT, 2SAT
• Resolution• Unit resolution, unit propagation• Implication Graph
– record why a new literal became true!
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 search
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 constraints
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.
Lazy Clause Generation
Lazy Clause Generation
• Representing integers:– bounds literals, equation literals, – domain clauses
• Explaining propagation• Explaining failure• Propagation implication graph• 1UIP nogoods• Backjumping
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 explanations
LCG + Globals
• Globality of Nogood 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 search
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 propagation
Course Summary
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: CRITICAL
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 Slides
The Exam
• My exams:– tend to be a bit long– have some hard questions
(a) Don’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
Good Luck!
Recommended