CP2014: Teaching CP. Context Final Year 120 credits (1 credit approx 10 hours) 30 credit project 4 modules in semester 1 4 modules in semester 2.

Slides:



Advertisements
Similar presentations
I am Patrick Prosser I am a senior lecturer at Glasgow I teach algorithms & data structures in java I am a member of the algorithms group the apes (distributed,
Advertisements

1D Bin Packing (or “CP? Who cares?”)
Levels of Consistency Node Consistency (NC) Arc-consistency (AC) Path Consistency (PC) Generalised arc-consistency (GAC) Bounds consistency Inverse Path.
Slides by Peter van Beek Edited by Patrick Prosser.
Non-Binary Constraint Satisfaction Toby Walsh Cork Constraint Computation Center.
Constraint Satisfaction Patrick Prosser. An Example, Exam Timetabling Someone timetables the exams We have a number of courses to examine how many? Dept.
University of Toronto Mechanical & Industrial Engineering An Introduction to Constraint Programming J. Christopher Beck Dept. of Mechanical & Industrial.
This lecture topic (two lectures) Chapter 6.1 – 6.4, except 6.3.3
1 Finite Constraint Domains. 2 u Constraint satisfaction problems (CSP) u A backtracking solver u Node and arc consistency u Bounds consistency u Generalized.
ICS-271:Notes 5: 1 Lecture 5: Constraint Satisfaction Problems ICS 271 Fall 2008.
Artificial Intelligence Constraint satisfaction problems Fall 2008 professor: Luigi Ceccaroni.
Reducibility Class of problems A can be reduced to the class of problems B Take any instance of problem A Show how you can construct an instance of problem.
© J. Christopher Beck Lecture 15: CP Search.
CPM!. Just do it! JChoco We jumped in, and took it for a spin Some counting problems Meeting scheduling problem … you got your hands dirty.
Backtracking COP Backtracking  Backtracking is a technique used to solve problems with a large search space, by systematically trying and eliminating.
4 Feb 2004CS Constraint Satisfaction1 Constraint Satisfaction Problems Chapter 5 Section 1 – 3.
Constraint Satisfaction CSE 473 University of Washington.
CPSC 322, Lecture 14Slide 1 Local Search Computer Science cpsc322, Lecture 14 (Textbook Chpt 4.8) February, 4, 2009.
Constraint Satisfaction Problems
© J. Christopher Beck Lecture 11: Constraint Programming 1.
Chapter 5 Outline Formal definition of CSP CSP Examples
Global Constraints for Lexicographic Orderings Alan Frisch, Ian Miguel (University of York) Brahim Hnich, Toby Walsh (4C) Zeynep Kiziltan (Uppsala University)
Constraint Satisfaction Problems
CP Summer School Modelling for Constraint Programming Barbara Smith 1.Definitions, Viewpoints, Constraints 2.Implied Constraints, Optimization,
A simple assessed exercise Ciaran McCreesh & Patrick Prosser + 21.
Specialised (user defined) constraints in JChoco 2 examples: max and subtour elimination.
Artificial Intelligence CS482, CS682, MW 1 – 2:15, SEM 201, MS 227 Prerequisites: 302, 365 Instructor: Sushil Louis,
Constrainedness Including slides from Toby Walsh.
Local Search CPSC 322 – CSP 5 Textbook §4.8 February 7, 2011.
I am Patrick Prosser I am a senior lecturer at Glasgow (and Strathclyde till mid April) I teach algorithms & data structures in java I am a member of.
Teaching CP in Scotland 02/09/ how you attract students to your CP course - how do you keep them interested - goals/aims of your course - course.
© J. Christopher Beck Lecture 13: Modeling in Constraint Programming.
Magic square An example of how to represent a problem An idea from Chris Beck.
Computer Science CPSC 322 Lecture 13 Arc Consistency (4.5, 4.6 ) Slide 1.
A talk with 3 titles By Patrick Prosser Research … how not to do it LDS revisited (aka Chinese whispers) Yet Another Flawed Talk by Patrick Prosser.
Searching by Constraint CMSC Artificial Intelligence January 24, 2008.
Hande ÇAKIN IES 503 TERM PROJECT CONSTRAINT SATISFACTION PROBLEMS.
Artificial Intelligence CS482, CS682, MW 1 – 2:15, SEM 201, MS 227 Prerequisites: 302, 365 Instructor: Sushil Louis,
Chapter 5: Constraint Satisfaction ICS 171 Fall 2006.
lds revisited (aka chinese whispers) Send reinforcements. We’re going to advance.
Review Test1. Robotics & Future Technology Future of Intelligent Systems / Ray Kurzweil futurist Ray Kurzweil / A Long Bet A Long Bet / Robot Soccer.
An Introduction to Artificial Intelligence Lecture 5: Constraint Satisfaction Problems Ramin Halavati In which we see how treating.
CP Summer School Modelling for Constraint Programming Barbara Smith 3. Symmetry, Viewpoints.
CHAPTER 5 SECTION 1 – 3 4 Feb 2004 CS Constraint Satisfaction 1 Constraint Satisfaction Problems.
Arc Consistency CPSC 322 – CSP 3 Textbook § 4.5 February 2, 2011.
Put a different number in each circle (1 to 8) such that adjacent circles cannot take consecutive numbers.
1. 2 Outline of Ch 4 Best-first search Greedy best-first search A * search Heuristics Functions Local search algorithms Hill-climbing search Simulated.
Eliminating non- binary constraints Toby Walsh Cork Constraint Computation Center.
Chapter 5 Team Teaching AI (created by Dewi Liliana) PTIIK Constraint Satisfaction Problems.
Constraint Propagation Artificial Intelligence CMSC January 22, 2002.
Domain Splitting, Local Search CPSC 322 – CSP 4 Textbook §4.6, §4.8 February 4, 2011.
An Introduction to Constraint Programming in JChoco.
Where are the hard problems?. Remember Graph Colouring? Remember 3Col?
1 Constraint Satisfaction Problems (CSP). Announcements Second Test Wednesday, April 27.
543 cbj fans can’t be wrong.
Constraint Satisfaction
CS 188: Artificial Intelligence
Computer Science cpsc322, Lecture 14
CSP Search Techniques Backtracking Forward checking
Number partitioning.
Constraints and Search
at Glasgow (and Strathclyde till mid April)
Artificial Intelligence
The N-Queens Problem Search The N-Queens Problem Most slides from Milos Hauskrecht.
Domain Splitting CPSC 322 – CSP 4 Textbook §4.6 February 4, 2011.
Constraint Satisfaction
Constraint Satisfaction Problems
Constraint Satisfaction Problems (CSP)
Presentation transcript:

CP2014: Teaching CP

Context Final Year 120 credits (1 credit approx 10 hours) 30 credit project 4 modules in semester 1 4 modules in semester 2 A module is 10 credits 1 compulsory module on Prof Issues Students select 4 modules from 8 in each semester There is competition between staff for students Students make choice after 2 nd week First lectures have to be as attractive as possible CP(M) 30 lectures 1 short assessed exercise (5%) 1 long(ish) assessed exercise (15%) Exam (80%) Students are motivated by “marks” 

How not to do it

Course outline Lecture 1

Variables and constraints, and how to represent themLecture 2

Backtracking search, implementation Lectures 3 to 5

A bit on heuristics Lecture 6

A wee bit of theory (levels of consistency etc) Lecture 7

A tiny wee bit more theory (dual and hidden variables) Lecture 8

Ready to write our 1 st constraint program Week 4

Wooooosh!

… how I do it now

Lecture 1

Stolen: BMS, TW, JCB

Lecture 1 Handed out on paper, given 8 minutes, discussion …

Lecture 2 Just do it!

How many dominos are there? Lecture 2

How many dominos are there? How many pairs of numbers are there of the form 0 ≤ x ≤ y ≤ 6 Lecture 2

Compile & Run Lecture 2

Stolen: BMS Lecture 2

Compile & Run Lecture 2

An exam question from AF2 Lecture 2

Compile & Run Lecture 2

1 st observations & questions How do you know “How not to do it”? Why are you using choco (jchoco I call it)? Do you steal everything? do you tell the students you deal in stolen goods? have you no sense of shame? You get students to use technology they don’t understand! We would NEVER EVER do that! You write code in the lecture? Edit compile AND run? what if something goes wrong? You’d look stupid, right? You put all of the code on the web?

CPM!

search

Opening up the hood: part 1, search So how does CP work? BT: Chronological BackTracking Thrashing! FC: forward checking Thrashing! CBJ: Conflict-directed BackJumping Thrashing!

consistency

Opening up the hood: part 2, arc-consistency So how does CP work? Arc-consistency Definition (aka 2-consistency) Covered Consistency Algorithms AC3 AC4/6/2001 AC5 Is AC a decision procedure?

modelling

We modelled some problems number partitioning jobshop scheduling magic square n-queens bin packing knight’s tour Ramsey number Orthogonal Latin Squares Crystal Maze graph colouring m-queens Talent Scheduling Crossword Puzzle

What are the decision variables? Are there any symmetries? Is there a variable/value ordering heuristic? Is there another model? We modelled some problems How does search go? Redundant constraints? Dual or Hidden Variable encoding?

phase transition phenomena

Where are the hard problems? Constrainedness? Who cares? In optimisation, as a heuristic, in solving problems

heuristics

Variable and value ordering heuristics Static, topological properties Fail-first, and it’s realisation Constrainedness Dual viewpoint heuristics Promise Regret Domain Specific (example JSSP slack-based, Warnsdorff)

specialised constraints

max sub-tour elimination Knight’s tour … the glass box

local search

Search againLocal search (aka neighbourhood search) HC, SA, TS, GLS, GA, ACO, … Why we need them Problems in using them incompleteness, move operators, evaluation/fitness functions, tuning parameters, Problems in using them in CP aka meta-heuristics

Search againLimited Discrepancy Search lds motivation for LDS when might we use it? when should we not use it?

change of representation

dual and hidden variable encoding change of representation

Levels of consistency

Node Consistency (NC) Arc-consistency (AC) Path Consistency (PC) Generalised arc-consistency (GAC) Bounds consistency Inverse Path Consistency (IPC aka PIC) Singleton Arc-consistency (SAC) … and others consistency

Mechanics of choco

CP for a design problem Using CP as an intelligent data base Not solving a problem, but using CP as an “active” representation Explanations via quickXplain

theory csp and it’s complexity search (bt, fc, cbj, …) thrashing arc-consistency levels of consistency heuristics local search & lds dual & hidden variables sat phase transition phenomena & constrainedness summary

practice number partitioning jobshop scheduling magic square n-queens bin packing knight’s tour Talent SchedulingOrthogonal Latin Squares Crystal Maze graph colouring Modelling & Solving Problemssummary

practice variables (enumerated/bound/setsVar) and their domains constraints (neq, allDiff, ifOnlyIf, …) decision variables what propagation might take place size of the encoding/model (how it scales with problem size) heuristics (dynamic/static, variable/value) size of the search/state space how search goes (example was knight’s tour) alternative models (dual? hidden? values as variables?) optimisation (with maximise/minimise, seqn of decision problems) dealing with conflicts (soft constraints & penalties) symmetry breaking (ramsey, bin packing, …) redundant constraints (magic square, MOLS …) what will make problems hard to solve and what will make them easy? Modelling & Solving Problemssummary

Rhythm Once we are up to speed, an ideal week goes like this lecture on new theory a new problem Model and solve “Performance CP” Consider alternative models Symmetry breaking When do problems get hard

Where are the really hard problems

The usual stuff int x = 3; int y = 5; int z = Math.max(x,y);

Where are the really hard problems The usual stuff int x = 3; int y = 5; int z = Math.max(x,y); Our stuff Model model = new CPModel(); IntegerVariable x = makeIntVar(“x”,0,3); IntegerVariable y = makeIntVar(“y”,0,5); IntegerVariable z = makeIntVar(“z”,0,4); model.addConstraint(eq(z,max(x,y)));

Where are the really hard problems The usual stuff int x = 3; int y = 5; int z = Math.max(x,y); Our stuff Model model = new CPModel(); IntegerVariable x = makeIntVar(“x”,0,3); IntegerVariable y = makeIntVar(“y”,0,5); IntegerVariable z = makeIntVar(“z”,0,4); model.addConstraint(eq(z,max(x,y))); Breaking the mental model of variables in a programming language

Where are the really hard problems The usual stuff int x = 3; int y = 5; int z = Math.max(x,y); Our stuff Model model = new CPModel(); IntegerVariable x = makeIntVar(“x”,0,3); IntegerVariable y = makeIntVar(“y”,0,5); IntegerVariable z = makeIntVar(“z”,0,4); model.addConstraint(eq(z,max(x,y))); Post x > 0 and propagate Post z > 0 and propagate Post z < 3 and propagate

Where are the really hard problems Almost anything to do with implication is mind blowing (or maybe I am a bad teacher)

Where are the really hard problems arrays

Where are the really hard problems arrays Pick off the ith row: easy

Where are the really hard problems arrays Pick off the diagonal: easy

Where are the really hard problems arrays Pick off the ith column: hard

Where are the really hard problems arrays Pick off the diagonal: hard

Where are the really hard problems Code comprehension

Where are the really hard problems Code comprehension Given n, what does f1 return? Suggest a name for f1.

Where are the really hard problems Code comprehension Given n and r, what does f2 return? Suggest a name for f2?

Assessed exercises

1 st exercise is sudoku (5%) To get them to download and use choco

1D Sudoku!

Read in 9 rows of 9 numbers Jeez. If I knew it was this hard I never would have attempted it

The floggings will continue until morale improves

Assessed exercises Exercise 2 (15%) has been Car sequencing Talent scheduling Meeting Scheduling Maximum Clique

Assessed exercises Exercise 2 (15%) has been Car sequencing Talent scheduling Meeting Scheduling Maximum Clique I think that was the best

So?

Jump in!

Steal

You can’t teach it all

The hard bits might not be where you expect them to be.

Have fun

… and remember, your students are not just your students CP(M)