DCS Lecture how to solve it Patrick Prosser. Put a different number in each circle (1 to 8) such that adjacent circles cannot take consecutive numbers.

Slides:



Advertisements
Similar presentations
Constraint Satisfaction Problems
Advertisements

Analysis of Algorithms
Vehicle Routing & Job Shop Scheduling: Whats the Difference? ICAPS03, June 13, 2003 J. Christopher Beck, Patrick Prosser, & Evgeny Selensky Dept. of Computing.
Slides by Peter van Beek Edited by Patrick Prosser.
Non-Binary Constraint Satisfaction Toby Walsh Cork Constraint Computation Center.
Non-binary Constraints Toby Walsh
Constraint Programming Peter van Beek University of Waterloo.
Constraint Satisfaction Patrick Prosser. An Example, Exam Timetabling Someone timetables the exams We have a number of courses to examine how many? Dept.
Traffic assignment.
University of Toronto Mechanical & Industrial Engineering An Introduction to Constraint Programming J. Christopher Beck Dept. of Mechanical & Industrial.
CS1022 Computer Programming & Principles
Local Search Jim Little UBC CS 322 – CSP October 3, 2014 Textbook §4.8
CPSC 322, Lecture 14Slide 1 Local Search Computer Science cpsc322, Lecture 14 (Textbook Chpt 4.8) Oct, 5, 2012.
Constraint Satisfaction Problems (Chapter 6). What is search for? Assumptions: single agent, deterministic, fully observable, discrete environment Search.
Constraint Satisfaction Problems
1 Today’s class Interleaving backtracking and consistency checking Variable-ordering heuristics Value-ordering heuristics Intelligent backtracking Marie.
Constraint Satisfaction Problems
Constraint Satisfaction Introduction to Artificial Intelligence COS302 Michael L. Littman Fall 2001.
Lecture 11 Last Time: Local Search, Constraint Satisfaction Problems Today: More on CSPs.
1 Constraint Satisfaction Problems. 2 Intro Example: 8-Queens Generate-and-test: 8 8 combinations.
© J. Christopher Beck Lecture 17: Tabu Search.
Constraint Processing and Programming Introductory Exemple Javier Larrosa.
Crew Scheduling Housos Efthymios, Professor Computer Systems Laboratory (CSL) Electrical & Computer Engineering University of Patras.
© J. Christopher Beck Lecture 15: CP Search.
Solving Problems with Constraints Karen E. Petrie.
CPSC 322, Lecture 4Slide 1 Search: Intro Computer Science cpsc322, Lecture 4 (Textbook Chpt ) January, 12, 2009.
Maths of Constraint Satisfaction, Oxford, March 2006 Constraint Programming Models for Graceful Graphs Barbara Smith.
CPSC 322, Lecture 12Slide 1 CSPs: Search and Arc Consistency Computer Science cpsc322, Lecture 12 (Textbook Chpt ) January, 29, 2010.
A game of logic where the player must assign the numbers 1..9 to cells on a 9x9 grid. The placement of the numbers must be such that every number must.
© J. Christopher Beck Lecture 11: Constraint Programming 1.
Two Discrete Optimization Problems Problem: The Transportation Problem.
Constraint Programming for Supply Chain Management J. Christopher Beck Cork Constraint Computation Centre (4C) SCM Information Day, Nov.
CP Summer School Modelling for Constraint Programming Barbara Smith 1.Definitions, Viewpoints, Constraints 2.Implied Constraints, Optimization,
Introduction to Job Shop Scheduling Problem Qianjun Xu Oct. 30, 2001.
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.
© J. Christopher Beck Lecture 13: Modeling in Constraint Programming.
15 July 2005Edward Tsang (Copyright)1 Constraint Satisfaction and Optimization Professor Edward Tsang University of Essex URL:
Decision Diagrams for Sequencing and Scheduling Andre Augusto Cire Joint work with David Bergman, Willem-Jan van Hoeve, and John Hooker Tepper School of.
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.
Sudoku Solver Comparison A comparative analysis of algorithms for solving Sudoku.
CSC 423 ARTIFICIAL INTELLIGENCE Constraint Satisfaction Problems.
CSE 589 Part VI. Reading Skiena, Sections 5.5 and 6.8 CLR, chapter 37.
Main MenuExercise Set 1Exercise Set 2 Interactive Exercises Set 1 Exercise 1.1 Exercise 1.2 Exercise 1.3.
Relations And Functions. A relation is a set of ordered pairs {(2,3), (-1,5), (4,-2), (9,9), (0,-6)} This is a relation The domain is the set of all x.
Constraints and Search Toby Walsh Cork Constraint Computation Centre (4C) Logic & AR Summer School, 2002.
Graph Theory. A branch of math in which graphs are used to solve a problem. It is unlike a Cartesian graph that we used throughout our younger years of.
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.
© 2010 Pearson Prentice Hall. All rights reserved. CHAPTER 15 Graph Theory.
Lecture 11: 9.4 Connectivity Paths in Undirected & Directed Graphs Graph Isomorphisms Counting Paths between Vertices 9.5 Euler and Hamilton Paths Euler.
8puzzle in CP initial state goal state A trivial example.
BIL 472 SADI EVREN SEKER Constraint Satisfaction.
© J. Christopher Beck Lecture 16: Local Search.
Warm Up What algebraic equation shows the sentence four plus a number divided by six is equal to the product of twelve and the same number?
Tabu Search Applications Outlines: 1.Application of Tabu Search 2.Our Project with Tabu Search: EACIIT analytics.
Alternative Search Formulations and Applications
CSPs: Search and Arc Consistency Computer Science cpsc322, Lecture 12
Introduction to Data Structures and Algorithms
CSPs: Search and Arc Consistency Computer Science cpsc322, Lecture 12
Constraint Satisfaction Problems Lecture # 14, 15 & 16
Lecture 7 Constraint Satisfaction Problems
Introduction (with applications) ADT & terminology
CSPs: Search and Arc Consistency Computer Science cpsc322, Lecture 12
and 2 units to the left of point B. Count down 5 units from point B
Lecture 9: Tabu Search © J. Christopher Beck 2005.
at Glasgow (and Strathclyde till mid April)
Constraint satisfaction problems
Algorithms Lecture # 27 Dr. Sohail Aslam.
Constraint Satisfaction Problems
Constraint satisfaction problems
Presentation transcript:

DCS Lecture how to solve it Patrick Prosser

Put a different number in each circle (1 to 8) such that adjacent circles cannot take consecutive numbers Your Challenge

56 Put a different number in each circle (1 to 8) such that adjacent circles cannot take consecutive numbers Thats illegal, okay?

3 3 Put a different number in each circle (1 to 8) such that adjacent circles cannot take consecutive numbers Thats illegal, okay?

The Puzzle Place numbers 1 through 8 on nodes –Each number appears exactly once ? ? ? ? ? ? ?? –No connected nodes have consecutive numbers You have 4 minutes!

How do we solve it? Bill Gates asks … how do we solve it?

Heuristic Search Which nodes are hardest to number? ? ? ? ? ? ? ?? Heuristic: a rule of thumb

Heuristic Search ? ? ? ? ? ? ??

? ? ? ? ? ? ?? Which are the least constraining values to use?

Heuristic Search ? 1 ? ? 8 ? ?? Values 1 and 8

Heuristic Search ? 1 ? ? 8 ? ?? Values 1 and 8 Symmetry means we dont need to consider: 8 1

Inference/propagation We can now eliminate many values for other nodes ? 1 ? ? 8 ? ?? Inference/propagation: reasoning

Inference/propagation ? 1 ? ? 8 ? ?? {1,2,3,4,5,6,7,8}

Inference/propagation ? 1 ? ? 8 ? ?? {2,3,4,5,6,7}

Inference/propagation ? 1 ? ? 8 ? ?? {3,4,5,6}

Inference/propagation ? 1 ? ? 8 ? ?? {3,4,5,6} By symmetry {3,4,5,6}

Inference/propagation ? 1 ? ? 8 ? ?? {3,4,5,6} {1,2,3,4,5,6,7,8}

Inference/propagation ? 1 ? ? 8 ? ?? {3,4,5,6} {2,3,4,5,6,7}

Inference/propagation ? 1 ? ? 8 ? ?? {3,4,5,6}

Inference/propagation ? 1 ? ? 8 ? ?? {3,4,5,6} By symmetry {3,4,5,6}

Inference/propagation ? 1 ? ? 8 ? ?? {3,4,5,6} {3,4,5,6,7} {3,4,5,6} {2,3,4,5,6}

Inference/propagation ? 1 ? ? 8 ? ?? {3,4,5,6} {3,4,5,6,7} {3,4,5,6} {2,3,4,5,6} Value 2 and 7 are left in just one nodes domain

Inference/propagation ? 1 ? ? 8 ? 27 {3,4,5,6} {3,4,5,6,7} {3,4,5,6} {2,3,4,5,6} And propagate …

Inference/propagation ? 1 ? ? 8 ? 27 {3,4,5} {3,4,5,6,7} {3,4,5} {3,4,5,6} {2,3,4,5,6} And propagate …

Inference/propagation ? 1 ? ? 8 ? 27 {3,4,5} {3,4,5,6,7} {3,4,5} {4,5,6} {2,3,4,5,6} And propagate …

Inference/propagation ? 1 ? ? 8 ? 27 {3,4,5} {4,5,6} Guess a value, but be prepared to backtrack … Backtrack?

Inference/propagation 3 1 ? ? 8 ? 27 {3,4,5} {4,5,6} Guess a value, but be prepared to backtrack …

Inference/propagation 3 1 ? ? 8 ? 27 {3,4,5} {4,5,6} And propagate …

Inference/propagation 3 1 ? ? 8 ? 27 {4,5} {5,6} {4,5,6} And propagate …

Inference/propagation 3 1 ? ? 8 ? 27 {4,5} {5,6} {4,5,6} Guess another value …

Inference/propagation 3 1 ? 5 8 ? 27 {4,5} {4,5,6} Guess another value …

Inference/propagation 3 1 ? 5 8 ? 27 {4,5} {4,5,6} And propagate …

Inference/propagation 3 1 ? 5 8 ? 27 {4} {4,6} And propagate …

Inference/propagation ? 27 {4} {4,6} One node has only a single value left …

Inference/propagation {6}

Solution!

How does a computer solve it? Bill Gates says … how does a computer solve it?

Variable, v i for each node Domain of {1, …, 8} Constraints –All values used Alldifferent(v 1 v 2 v 3 v 4 v 5 v 6 v 7 v 8 ) –No consecutive numbers for adjoining nodes |v 1 - v 2 | > 1 |v 1 - v 3 | > 1 … ? ? ? ? ? ? ?? A Constraint Satisfaction Problem

How we might input the problem to a program Viewing the problem as a graph with 8 vertices and 17 edges

Graph Theory?

8 vertices, 17 edges vertex 0 is adjacent to vertex 1 vertex 3 is adjacent to vertex Our Problem as a Graph

Computer scientists count from zero By the way, Bill Gates says …

A Java (Constraint) Program to solve our problem

Read in the name of the input file

Make a Problem and attach variables to it Note: variables represent our vertices

Constrain all variables take different values

Read in edges and constrain corresponding variables/vertices non-consecutive

Solve the problem! Using constraint propagation and backtracking search

Print out the number of solutions

Why have you read in the puzzle as a file? Bill Gates wants to know …

So that we can be more general

This technology is called constraint programming

Constraint programming Model problem by specifying constraints on acceptable solutions –define variables and domains –post constraints on these variables Solve model –choose algorithm incremental assignment / backtracking search complete assignments / stochastic search –design heuristics It is used for solving the following kinds of problems

Crew scheduling (airlines) Railway timetabling Factory/production scheduling Vehicle routing problems Network design problems Design of locks and keys Spatial layout workforce management … Some sample problems that use constraint programming

BT workforce management

Constraints are everywhere! No meetings before 10am Network traffic < 100 Gbytes/sec PCB width < 21cm Salary > 45k Euros …

A Commercial Reality First-tier software vendors use CP technology

You know, were doing something on this! Bill Gates is watching …

So, how do YOU solve it?

Learn to program a computer, learn a bit of discrete maths, algorithmics, learn about hardware, security and data protection, computer graphics, information management, project management, interactive systems, computer networks, operating systems, professional issues, software engineering, machine learning, bioinformatics, grid computing … and of course constraint programming! Computing Science at Glasgow

Constraint Programming An Introduction by example with help from Toby Walsh, Chris Beck, Barbara Smith, Peter van Beek, Edward Tsang,... That was a 4 th year lecture …

Thats all for now folks