course summary what have we learned and what are we expected to know?

50
Course Summary What have we learned and what are we expected to know?

Upload: leroy-gray

Post on 31-Mar-2015

216 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Course Summary What have we learned and what are we expected to know?

Course Summary

What have we learned and what are we expected to know?

Page 2: 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

Page 3: Course Summary What have we learned and what are we expected to know?

Modelling

Page 4: Course Summary What have we learned and what are we expected to know?

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

Page 5: Course Summary What have we learned and what are we expected to know?

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

Page 6: Course Summary What have we learned and what are we expected to know?

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, …

Page 7: Course Summary What have we learned and what are we expected to know?

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

Page 8: Course Summary What have we learned and what are we expected to know?

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?

Page 9: Course Summary What have we learned and what are we expected to know?

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

Page 10: Course Summary What have we learned and what are we expected to know?

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

Page 11: Course Summary What have we learned and what are we expected to know?

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

Page 12: Course Summary What have we learned and what are we expected to know?

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

Page 13: Course Summary What have we learned and what are we expected to know?

Finite Domain Constraint Solving

Page 14: Course Summary What have we learned and what are we expected to know?

Constraint Satisfaction Problems

• CSP:– Variables– Finite Domains– Constraints

• Backtracking Search– pruning using partial satisfiability

Page 15: Course Summary What have we learned and what are we expected to know?

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

Page 16: Course Summary What have we learned and what are we expected to know?

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))

Page 17: Course Summary What have we learned and what are we expected to know?

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

Page 18: Course Summary What have we learned and what are we expected to know?

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

Page 19: Course Summary What have we learned and what are we expected to know?

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

Page 20: Course Summary What have we learned and what are we expected to know?

Optimization

• Retry optimization– restart when you find a new solution

• Branch and bound– add a new bound during search

Page 21: Course Summary What have we learned and what are we expected to know?

Key Skills

• Define, explain, compare– consistencies, backtracking search, propagators,

optimization search

• Execute propagation algorithm• Create propagators for given constraint• Reason about global constraint propagation

Page 22: Course Summary What have we learned and what are we expected to know?

Search

Page 23: Course Summary What have we learned and what are we expected to know?

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

Page 24: Course Summary What have we learned and what are we expected to know?

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

Page 25: Course Summary What have we learned and what are we expected to know?

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

Page 26: Course Summary What have we learned and what are we expected to know?

Key Skills

• Write and explain MiniZinc search annotations• Reason about and compare search strategies• Suggest appropriate searches for a model• Explain advanced search techniques

Page 27: Course Summary What have we learned and what are we expected to know?

Linear Programming and Network Flow

Page 28: Course Summary What have we learned and what are we expected to know?

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

Page 29: Course Summary What have we learned and what are we expected to know?

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

Page 30: Course Summary What have we learned and what are we expected to know?

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)

Page 31: Course Summary What have we learned and what are we expected to know?

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

Page 32: Course Summary What have we learned and what are we expected to know?

Mixed Integer Programming

Page 33: Course Summary What have we learned and what are we expected to know?

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

Page 34: Course Summary What have we learned and what are we expected to know?

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)

Page 35: Course Summary What have we learned and what are we expected to know?

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

Page 36: Course Summary What have we learned and what are we expected to know?

Boolean Satisfiability

Page 37: Course Summary What have we learned and what are we expected to know?

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!

Page 38: Course Summary What have we learned and what are we expected to know?

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

Page 39: Course Summary What have we learned and what are we expected to know?

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

Page 40: Course Summary What have we learned and what are we expected to know?

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.

Page 41: Course Summary What have we learned and what are we expected to know?

Lazy Clause Generation

Page 42: Course Summary What have we learned and what are we expected to know?

Lazy Clause Generation

• Representing integers:– bounds literals, equation literals, – domain clauses

• Explaining propagation• Explaining failure• Propagation implication graph• 1UIP nogoods• Backjumping

Page 43: Course Summary What have we learned and what are we expected to know?

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

Page 44: Course Summary What have we learned and what are we expected to know?

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

Page 45: Course Summary What have we learned and what are we expected to know?

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

Page 46: Course Summary What have we learned and what are we expected to know?

Course Summary

Page 47: Course Summary What have we learned and what are we expected to know?

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

Page 48: Course Summary What have we learned and what are we expected to know?

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

Page 49: Course Summary What have we learned and what are we expected to know?

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

Page 50: Course Summary What have we learned and what are we expected to know?

Good Luck!