A Second Look at Constraint Programming February 17/18, 2000.

Slides:



Advertisements
Similar presentations
Constraint Satisfaction Introduction to Artificial Intelligence COS302 Michael L. Littman Fall 2001.
Advertisements

Constraint Satisfaction Problems Russell and Norvig: Parts of Chapter 5 Slides adapted from: robotics.stanford.edu/~latombe/cs121/2004/home.htm Prof: Dekang.
Linear Programming (LP) (Chap.29)
1 Finite Constraint Domains. 2 u Constraint satisfaction problems (CSP) u A backtracking solver u Node and arc consistency u Bounds consistency u Generalized.
Linear Algebra Applications in Matlab ME 303. Special Characters and Matlab Functions.
1 Transportation problem The transportation problem seeks the determination of a minimum cost transportation plan for a single commodity from a number.
Constraint Processing and Programming Introductory Exemple Javier Larrosa.
Best-First Search: Agendas
1 Constraint-based Round Robin Tournament Planning Martin Henz National University of Singapore.
The Fundamental Property of Rational Expressions
MATH 685/ CSI 700/ OR 682 Lecture Notes
Sports Scheduling An Assessment of Various Approaches to Solving the n-Round Robin Tournament Noren De La Rosa Mallory Ratajewski.
May 2004 Minimizing travels by maximizing breaks1/32 Minimizing Travels by Maximizing Breaks in Round Robin Tournament Schedules Celso RIBEIRO UFF and.
CPSC 322, Lecture 14Slide 1 Local Search Computer Science cpsc322, Lecture 14 (Textbook Chpt 4.8) February, 3, 2010.
Symmetry as a Prelude to Implied Constraints Alan Frisch, Ian Miguel, Toby Walsh University of York.
Alan M. Frisch Artificial Intelligence Group Department of Computer Science University of York Extending the Reach of Constraint Technology through Reformulation.
Computational Methods for Management and Economics Carla Gomes
© J. Christopher Beck Lecture 20: Sports Scheduling.
Heuristics for the MTTPROADEF, February /49 Heuristics for the Mirrored Traveling Tournament Problem Celso C. RIBEIRO Sebastián URRUTIA.
Chapter 11 Systems of Equations.
Modeling the Covering Test Problem Brahim Hnich, Steven Prestwich, and Evgeny Selensky Cork Constraint Computation Center UCC Supported by SFI.
Copyright © Cengage Learning. All rights reserved. CHAPTER 11 ANALYSIS OF ALGORITHM EFFICIENCY ANALYSIS OF ALGORITHM EFFICIENCY.
Data Flow Analysis Compiler Design Nov. 8, 2005.
1 Contents college 3 en 4 Book: Appendix A.1, A.3, A.4, §3.4, §3.5, §4.1, §4.2, §4.4, §4.6 (not: §3.6 - §3.8, §4.2 - §4.3) Extra literature on resource.
Global Constraints for Lexicographic Orderings Alan Frisch, Ian Miguel (University of York) Brahim Hnich, Toby Walsh (4C) Zeynep Kiziltan (Uppsala University)
1 Combinatorial Problems in Cooperative Control: Complexity and Scalability Carla Gomes and Bart Selman Cornell University Muri Meeting March 2002.
Daniel Kroening and Ofer Strichman Decision Procedures An Algorithmic Point of View Deciding ILPs with Branch & Bound ILP References: ‘Integer Programming’
Copyright © 2009 Pearson Education, Inc. CHAPTER 9: Systems of Equations and Matrices 9.1 Systems of Equations in Two Variables 9.2 Systems of Equations.
Decision Procedures An Algorithmic Point of View
Chapter 3 – Linear Systems
Linear Systems Two or more unknown quantities that are related to each other can be described by a “system of equations”. If the equations are linear,
Slide 1 CSPs: Arc Consistency & Domain Splitting Jim Little UBC CS 322 – Search 7 October 1, 2014 Textbook §
CP Summer School Modelling for Constraint Programming Barbara Smith 1.Definitions, Viewpoints, Constraints 2.Implied Constraints, Optimization,
An Overview of Constraint Programming MSORM 2000 Tutorial November 20/21, 2000 Martin Henz, National University of Singapore.
11 Table 2.1 defines a correspondence between a set of percent scores and a set of letter grades. For each score from 0 to 100, there corresponds only.
Slide 7- 1 Copyright © 2012 Pearson Education, Inc.
Chapter 4.1 Solving Systems of Linear Equations in two variables.
Event Scheduling Using Constraint Programming November 22, 2002 Martin Henz, School of Computing, NUS
Constraint Satisfaction Problems (CSPs) CPSC 322 – CSP 1 Poole & Mackworth textbook: Sections § Lecturer: Alan Mackworth September 28, 2012.
Modelling for Constraint Programming Barbara Smith CP 2010 Doctoral Programme.
© J. Christopher Beck Lecture 21: Sports Scheduling 1.
CP Summer School Modelling for Constraint Programming Barbara Smith 2. Implied Constraints, Optimization, Dominance Rules.
Sports Scheduling Written by Kelly Easton, George Nemhauser, Michael Trick Presented by Matthew Lai.
CSCI 5582 Fall 2006 CSCI 5582 Artificial Intelligence Fall 2006 Jim Martin.
CP Summer School Modelling for Constraint Programming Barbara Smith 4. Combining Viewpoints, Modelling Advice.
CSC 423 ARTIFICIAL INTELLIGENCE Constraint Satisfaction Problems.
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns VIII Chain of Responsibility, Strategy, State.
15.053Tuesday, April 9 Branch and Bound Handouts: Lecture Notes.
Column Generation By Soumitra Pal Under the guidance of Prof. A. G. Ranade.
Scheduling with Constraint Programming February 24/25, 2000.
1 : ConsistentDependentInconsistent One solution Lines intersect No solution Lines are parallel Infinite number of solutions Coincide-Same line.
Branch-and-Cut Valid inequality: an inequality satisfied by all feasible solutions Cut: a valid inequality that is not part of the current formulation.
Chapter 5 Constraint Satisfaction Problems
Constraints and Search Toby Walsh Cork Constraint Computation Centre (4C) Logic & AR Summer School, 2002.
© J. Christopher Beck Lecture 21: IP and CP Models for Sports Scheduling.
Chapter 2) CSP solving-An overview Overview of CSP solving techniques: problem reduction, search and solution synthesis Analyses of the characteristics.
1 Constraint-based Round Robin Tournament Planning Martin Henz National University of Singapore.
CP Summer School Modelling for Constraint Programming Barbara Smith 3. Symmetry, Viewpoints.
BIL 472 SADI EVREN SEKER Constraint Satisfaction.
Copyright © Cengage Learning. All rights reserved. CHAPTER 8 RELATIONS.
10.3 Reformulation The Lex-Leader Method Shant Karakashian 1.
Constraint Programming for the Diameter Constrained Minimum Spanning Tree Problem Thiago F. Noronha Celso C. Ribeiro Andréa C. Santos.
Section 7.1 The Rectangular Coordinate System and Linear Equations in Two Variables Math in Our World.
A greedy algorithm is an algorithm that follows the problem solving heuristic of making the locally optimal choice at each stage with the hope of finding.
Scheduling with Constraint Programming
Solving Systems of Equations in Two Variables; Applications
Multi-Step Equations How to Identify Multistep Equations |Combining Terms| How to Solve Multistep Equations | Consecutive Integers.
Perturbation method, lexicographic method
Systems of Linear Equations
3. Brute Force Selection sort Brute-Force string matching
Presentation transcript:

A Second Look at Constraint Programming February 17/18, 2000

SMA HPC (c) NUS Constraint Programming2 Today  Fundamentals  Case study: ACC 97/98 Basketball  Constraint programming techniques

SMA HPC (c) NUS Constraint Programming3 Thursday/Friday  Applying constraint programming to job- shop and other scheduling problems  Evaluation of constraint programming

SMA HPC (c) NUS Constraint Programming4 Review Constraint programming is a framework for integrating three families of algorithms  Propagation algorithms  Branching algorithms  Exploration algorithms

SMA HPC (c) NUS Constraint Programming5 S E N D + M O R E = M O N E Y S  {9} E  {4..7} N  {5..8} D  {2..8} M  {1} O  {0} R  {2..8} Y  {2..8} S  {9} E  {5..7} N  {6..8} D  {2..8} M  {1} O  {0} R  {2..8} Y  {2..8} E = 4 E  4 S  {9} E  {6..7} N  {7..8} D  {2..8} M  {1} O  {0} R  {2..8} Y  {2..8} E = 5 E  5 S  {9} E  {5} N  {6} D  {7} M  {1} O  {0} R  {8} Y  {2} E = 6 E  6

SMA HPC (c) NUS Constraint Programming6 Using OPL Syntax enum Letter {S,E,N,D,M,O,R,Y}; var int l[Letter] in 0..9; solve { alldifferent(l); l[S] <> 0; l[M] <> 0; l[S]* l[E]*100 + l[N]*10 + l[D] + l[M]* l[O]*100 + l[R]*10 + l[E] = l[M]* l[O]* l[N]*100 + l[E]*10 + l[Y] }; search { forall(i in Letter ordered by increasing dsize(l[i])) tryall(v in 0..9) l[i] = v; };  All Solutions; Execution  Run

SMA HPC (c) NUS Constraint Programming7 Today  Fundamentals  Case study: ACC 97/98 Basketball  Constraint programming techniques

SMA HPC (c) NUS Constraint Programming8 Fundamentals  Constraint solving  Basic constraints and propagators  Completeness of propagation

SMA HPC (c) NUS Constraint Programming9 Constraint Problems A constraint problem consists of:  number of variables: n  constraints: c 1,…,c m   n The problem is to find a = (v 1,…,v n )   n such that a  c i, for all 1  i  m

SMA HPC (c) NUS Constraint Programming10 Constraint Solving Given: a satisfiable constraint C and a new constraint C’. Constraint solving is deciding whether C  C’ is satisfiable. Example: C: n > 2 C’: a n + b n = c n

SMA HPC (c) NUS Constraint Programming11 Constraint Solving Clearly, constraint solving is not possible for general constraints. Constraint programming separates constraints into  Basic constraints: constraint solving  Non-basic constraints: propagation (incomplete)

SMA HPC (c) NUS Constraint Programming12 Basic Constraints in Constraint Programming  Basic constraints are conjunctions of constraints of the form X  S, where S is a finite set of integers.  Constraint solving is done by intersecting domains. Example: C = X  {1..10}, Y  {9..20}, C’ = X  {9..15}, Y  {14..30}.  In practice, we keep a solved form, storing the current domain of every variable.

SMA HPC (c) NUS Constraint Programming13 Basic Constraints and Propagators S  {1..9} E  {0..9} N  {0..9} D  {0..9} M  {1..9} O  {0..9} R  {0..9} Y  {0..9} all different(S,E,N,D, M,O,R,Y) 1000*S + 100*E + 10*N + D *M + 100*O + 10*R + E = 10000*M *O + 100*N + 10*E + Y

SMA HPC (c) NUS Constraint Programming14 Basic Constraints and Propagators S  {1..9} E  {0..9} N  {0..9} D  {0..9} M  {1} O  {0..9} R  {0..9} Y  {0..9} all different(S,E,N,D, M,O,R,Y) 1000*S + 100*E + 10*N + D *M + 100*O + 10*R + E = 10000*M *O + 100*N + 10*E + Y

SMA HPC (c) NUS Constraint Programming15 Basic Constraints and Propagators S  {2..9} E  {0,2..9} N  {0,2..9} D  {0,2..9} M  {1} O  {0,2..9} R  {0,2..9} Y  {0,2..9} all different(S,E,N,D, M,O,R,Y) 1000*S + 100*E + 10*N + D *M + 100*O + 10*R + E = 10000*M *O + 100*N + 10*E + Y

SMA HPC (c) NUS Constraint Programming16 Basic Constraints and Propagators S  {2..9} E  {0,2..9} N  {0,2..9} D  {0,2..9} M  {1} O  {0} R  {0,2..9} Y  {0,2..9} all different(S,E,N,D, M,O,R,Y) 1000*S + 100*E + 10*N + D *M + 100*O + 10*R + E = 10000*M *O + 100*N + 10*E + Y and so on

SMA HPC (c) NUS Constraint Programming17 Basic Constraints and Propagators S  {9} E  {5..7} N  {6..8} D  {2..8} M  {1} O  {0} R  {2..8} Y  {2..8} all different(S,E,N,D, M,O,R,Y) 1000*S + 100*E + 10*N + D *M + 100*O + 10*R + E = 10000*M *O + 100*N + 10*E + Y

SMA HPC (c) NUS Constraint Programming18 Completeness of Propagation  Given: Basic constraint C and propagator P.  Propagation is complete, if for every variable x and every value v  dom c (x), there is an assignment in which x=v that satisfies C and P.  Complete propagation is also called domain-consistency or arc-consistency.

SMA HPC (c) NUS Constraint Programming19 Example: Complete All Different  C: w  {1,2,3,4} x  { 2,3,4} y  { 2,3,4} z  { 2,3,4}  P: alldifferent(w,x,y,z)

SMA HPC (c) NUS Constraint Programming20 Example: Complete All Different  C: w  {1,2,3,4} x  { 2,3,4} y  { 2,3,4} z  { 2,3,4}  P: alldifferent(w,x,y,z)  Most efficient known algorithm: O(|X| 2 d max 2 ) Regin [1994], using graph matching

SMA HPC (c) NUS Constraint Programming21 Today  Fundamentals  Case study: ACC 97/98 Basketball  Constraint programming techniques

SMA HPC (c) NUS Constraint Programming22 ACC 1997/98: A Success Story of Constraint Programming  Integer programming + enumeration, 24 hours Nemhauser, Trick: Scheduling a Major College Basketball Conference, Operations Research, 1998, 46(1)  Constraint programming, less than 1 minute. Henz: Scheduling a Major College Basketball Conference - Revisited, Operations Research, to appear

SMA HPC (c) NUS Constraint Programming23 Round Robin Tournament Planning Problems  n teams, each playing a fixed number of times r against every other team  r = 1: single, r = 2: double round robin.  Each match is home match for one and away match for the other  Dense round robin:  At each date, each team plays at most once.  The number of dates is minimal.

SMA HPC (c) NUS Constraint Programming24 The ACC 1997/98 Problem  9 teams participate in tournament  Dense double round robin:  there are 2 * 9 dates  at each date, each team plays either home, away or has a “bye”  Alternating weekday and weekend matches

SMA HPC (c) NUS Constraint Programming25 The ACC 1997/98 Problem (cont’d)  No team can play away on both last dates.  No team may have more than two away matches in a row.  No team may have more than two home matches in a row.  No team may have more than three away matches or byes in a row.  No team may have more than four home matches or byes in a row.

SMA HPC (c) NUS Constraint Programming26 The ACC 1997/98 Problem (cont’d)  Of the weekends, each team plays four at home, four away, and one bye.  Each team must have home matches or byes at least on two of the first five weekends.  Every team except FSU has a traditional rival. The rival pairs are Clem-GT, Duke-UNC, UMD- UVA and NCSt-Wake. In the last date, every team except FSU plays against its rival, unless it plays against FSU or has a bye.

SMA HPC (c) NUS Constraint Programming27 The ACC 1997/98 Problem (cont’d)  The following pairings must occur at least once in dates 11 to 18: Duke-GT, Duke-Wake, GT- UNC, UNC-Wake.  No team plays in two consecutive dates away against Duke and UNC. No team plays in three consecutive dates against Duke UNC and Wake.  UNC plays Duke in last date and date 11.  UNC plays Clem in the second date.  Duke has bye in the first date 16.

SMA HPC (c) NUS Constraint Programming28 The ACC 1997/98 Problem (cont’d)  Wake does not play home in date 17.  Wake has a bye in the first date.  Clem, Duke, UMD and Wake do not play away in the last date.  Clem, FSU, GT and Wake do not play away in the fist date.  Neither FSU nor NCSt have a bye in the last date.  UNC does not have a bye in the first date.

SMA HPC (c) NUS Constraint Programming29 Nemhauser/Trick Solution  Enumerate home/away/bye patterns  explicit enumeration (very fast)  Compute pattern sets  integer programming (below 1 minute)  Compute abstract schedules  integer programming (several minutes)  Compute concrete schedules  explicit enumeration (approx. 24 hours) Schreuder, Combinatorial Aspects of Construction of Competition Dutch Football Leagues, Discr. Appl. Math, 35: , 1992.

SMA HPC (c) NUS Constraint Programming30 Modeling ACC 97/98 as Constraint Satisfaction Problem Variables  9 * 18 variables taking values from {0,1} that express which team plays home when. Example: H UNC, 5 =1 means UNC plays home on date 5.  away, bye similar, e.g. A UNC, 5 or B UNC, 5  9 * 18 variables taking values from {0,1,...,9} that express against which team which other team plays. Example:  UNC, 5 =1 means UNC plays team 1 (Clem) on date 5

SMA HPC (c) NUS Constraint Programming31 Modeling ACC 97/97 as Constraint Satisfaction Problem (cont’d) Constraints Example: No team plays away on both last dates. A Clem,17 + A Clem,18 < 2, A Duke,17 + A Duke,18 < 2,... All constraints can be easily formalized in this manner.

SMA HPC (c) NUS Constraint Programming32 First Step: Back to Nemhauser/Trick!  Constraint programming for generating all patterns.  CSP representation straightforward.  computing time below 1 second (Pentium II, 233MHz)  Constraint programming for generating all pattern sets.  CSP representation straightforward.  computing time 3.1 seconds

SMA HPC (c) NUS Constraint Programming33 Back to Schreuder  Constraint programming for abstract schedules  Introduce variable matrix for “abstract opponents” similar to  in naïve model  there are many abstract schedules  runtime over 20 minutes  Constraint programming for concrete schedules  model somewhat complicated, using two levels of the “element” constraint  runtime several minutes

SMA HPC (c) NUS Constraint Programming34 Cain’s Model  Alternative to last two phases of Nemhauser/Trick  Assign teams to patterns in a given pattern set.  Assign opponent teams for each team and date. W.O. Cain, Jr, The computer-assisted heuristic approach used to schedule the major league baseball clubs, Optimal Strategies in Sports, North-Holland, 1977

35 Dates Pattern 1H A B A H B Pattern 2B H A B A H Pattern 3A B H H B A Cain 1977 Schreuder 1992 Dates DynamoH A B A H B SpartaB H A B A H Vitesse A B H H B A Dates Team 1 3H 2A B 3A 2H B Team 2 B 1H 3A B 1A 3H Team 3 1A B 2H 1H B 2A Dates DynamoVH SA B VA SH B SpartaB DH VA B DA VH Vitesse DA B VH DH B VA

SMA HPC (c) NUS Constraint Programming36 Cain’s Model in CP: main idea  Remember: matrices H, A, B represent patterns and matrix  represents opponents  Given: matrices H, A, B of 0/1 values representing given pattern set.  Vector p of variables ranging from 1 to n; p GT identifies the pattern for team GT.  Team GT plays according to pattern indicated by p on date 2: H p GT,2 = H GT,2  Implemented: element(p GT,H 2, H GT,2 )

SMA HPC (c) NUS Constraint Programming37 Using Cain’s Model in CP  Model for Cain simpler than model for Schreuder  Runtimes:  patterns to teams: 33 seconds  opponent team assignment: 20.7 seconds  overall runtime for all 179 solutions: 57.1 seconds

SMA HPC (c) NUS Constraint Programming38 Friar Tuck  Constraint programming tool for sport scheduling, ACC 97/98 just one instance  Convenient entry of constraints through GUI  Friar Tuck is distributed under GPL  Friar Tuck 1.1 available for Unix and Windows 95/98 ( )  Implementation language: Oz using Mozart (see

SMA HPC (c) NUS Constraint Programming39 Today  Fundamentals  Case study: ACC 97/98 Basketball  Constraint programming techniques

SMA HPC (c) NUS Constraint Programming40 Constraint Programming Techniques  Symmetry Breaking  Redundant Constraints  Global Constraints

SMA HPC (c) NUS Constraint Programming41 Symmetry Breaking Often, the most efficient model admits many different solutions that are essentially the same (“symmetric” to each other). Symmetry breaking tries to improve the performance of search by eliminating such symmetries.

SMA HPC (c) NUS Constraint Programming42 Redundant Constraints  Pruning of original model is often not sufficient  Adding redundant constraints sometimes helps

SMA HPC (c) NUS Constraint Programming43 Example: Grocery Puzzle A kid goes into a grocery store and buys four items. The cashier charges $7.11, the kid pays and is about to leave when the cashier calls the kid back, and says “Hold on, I multiplied the four items instead of adding them; I’ll try again… Gosh, with adding them the price still comes to $7.11”! What were the prices of the four items?

SMA HPC (c) NUS Constraint Programming44 Model for Grocery Puzzle  Variables A, B, C, D represent prices of items in cents.  Constraints:  A + B + C + D = 711  A * B * C * D = 711 * 100 * 100 * 100

SMA HPC (c) NUS Constraint Programming45 Additional Constraints B  C  D 79 is prime factor of 711. Thus without loss of generality: A divisible by 79  Redundant constraint  Symmetries

SMA HPC (c) NUS Constraint Programming46 Solution to Grocery Puzzle Grocery plus Redundancy Grocery plus Redundancy plus Symmetry

SMA HPC (c) NUS Constraint Programming47 Example: Fractions Find distinct non-zero digits such that the following equation holds: A D G + + = 1 B C E F H I

SMA HPC (c) NUS Constraint Programming48 Model for Fractions  One variable for each letter, similar to MONEY  Constraint A*E*F*H*I + D*B*C*H*I + G*B*C*E*F = B*C*E*F*H*I

SMA HPC (c) NUS Constraint Programming49 Additional Constraints A D G  B C E F H I A 3 *  1 B C G 3 *  1 H I  Symmetries  Redundant constraints

SMA HPC (c) NUS Constraint Programming50  Constraint A*E*F*H*I + D*B*C*H*I + G*B*C*E*F = B*C*E*F*H*I  Symmetries A*E*F >= D*B*C D*H*I >= G*E*F  Redundant Constraints 3*A >= B*C 3*G =< H*I Fractions plus Symmetries Fractions plus Symmetries plus Redundancies

SMA HPC (c) NUS Constraint Programming51 Redundant Constraints Adding redundant constraints sometimes results in dramatic performance improvements.

SMA HPC (c) NUS Constraint Programming52 Performance of Symmetry Breaking  All solution search: Symmetry breaking usually improves performance; often dramatically  One solution search: Symmetry breaking may or may not improve performance

SMA HPC (c) NUS Constraint Programming53 “Global” Constraints: Euler Tour range ChessBoard 1..64; {ChessBoard} Knightmove[ i in ChessBoard] = { j | j in ChessBoard :... }; var ChessBoard jump[ChessBoard]; solve { forall(p in ChessBoard) jump[p] in Knightmove[p]; circuit(jump); forall(p in ChessBoard) sum(c in Knightmove[p]) (jump[c] = p) = 1; }; Euler

SMA HPC (c) NUS Constraint Programming54 Today  Fundamentals  Case study: ACC 97/98 Basketball  Constraint programming techniques

SMA HPC (c) NUS Constraint Programming55 Thursday/Friday  Applying constraint programming to job- shop and other scheduling problems  Evaluation of constraint programming