Solve Your Problem Faster - by changing the model

Slides:



Advertisements
Similar presentations
Constraint Satisfaction Problems
Advertisements

Artificial Intelligence 15. Constraint Satisfaction Problems
Case study 3: orthogonal Latin squares Modelled by Barbara Smith.
ISN Workshop September 2003 Constraint Programming in Practice: Scheduling a Rehearsal Barbara Smith.
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 Introduction to Artificial Intelligence COS302 Michael L. Littman Fall 2001.
1 Constraint Satisfaction Problems A Quick Overview (based on AIMA book slides)
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.
Exploiting Symmetry in Planning Maria Fox Durham Planning Group University of Durham, UK.
MBD and CSP Meir Kalech Partially based on slides of Jia You and Brian Williams.
Artificial Intelligence Constraint satisfaction problems Fall 2008 professor: Luigi Ceccaroni.
BackTracking Algorithms
Constraint Satisfaction problems (CSP)
Techniques for Dealing with Hard Problems Backtrack: –Systematically enumerates all potential solutions by continually trying to extend a partial solution.
Constraint Processing and Programming Introductory Exemple Javier Larrosa.
Best-First Search: Agendas
Transforming and Refining Abstract Constraint Specifications Alan Frisch, Brahim Hnich*, Ian Miguel, Barbara Smith, and Toby Walsh *Cork Constraint Computation.
Maths of Constraint Satisfaction, Oxford, March 2006 Constraint Programming Models for Graceful Graphs Barbara Smith.
4 Feb 2004CS Constraint Satisfaction1 Constraint Satisfaction Problems Chapter 5 Section 1 – 3.
Constraint Logic Programming Ryan Kinworthy. Overview Introduction Logic Programming LP as a constraint programming language Constraint Logic Programming.
Ryan Kinworthy 2/26/20031 Chapter 7- Local Search part 1 Ryan Kinworthy CSCE Advanced Constraint Processing.
Constraint Satisfaction Problems
CGRASS A System for Transforming Constraint Satisfaction Problems Alan Frisch, Ian Miguel (York) Toby Walsh (Cork)
Chapter 5 Outline Formal definition of CSP CSP Examples
Constraint Satisfaction Not all problems are solved by a sequential series of steps. How do we solve other types of problems?
Constraint Satisfaction Problems
1 Constraint Programming: An Introduction Adapted by Cristian OLIVA from Peter Stuckey (1998) Ho Chi Minh City.
Decision Procedures An Algorithmic Point of View
Tractable Symmetry Breaking Using Restricted Search Trees Colva M. Roney-Dougal, Ian P. Gent, Tom Kelsey, Steve Linton Presented by: Shant Karakashian.
CP Summer School Modelling for Constraint Programming Barbara Smith 1.Definitions, Viewpoints, Constraints 2.Implied Constraints, Optimization,
Modelling for Constraint Programming Barbara Smith CP 2010 Doctoral Programme.
Constraint Satisfaction Problems Chapter 6. Review Agent, Environment, State Agent as search problem Uninformed search strategies Informed (heuristic.
Chapter 5 Section 1 – 3 1.  Constraint Satisfaction Problems (CSP)  Backtracking search for CSPs  Local search for CSPs 2.
CP Summer School Modelling for Constraint Programming Barbara Smith 2. Implied Constraints, Optimization, Dominance Rules.
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.
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.
CSE 589 Part VI. Reading Skiena, Sections 5.5 and 6.8 CLR, chapter 37.
15.053Tuesday, April 9 Branch and Bound Handouts: Lecture Notes.
Chapter 5 Constraint Satisfaction Problems
CP Summer School Modelling for Constraint Programming Barbara Smith 3. Symmetry, Viewpoints.
Maximum Density Still Life Symmetries and Lazy Clause Generation Geoffrey Chu, Maria Garcia de la Banda, Chris Mears, Peter J. Stuckey.
CHAPTER 5 SECTION 1 – 3 4 Feb 2004 CS Constraint Satisfaction 1 Constraint Satisfaction Problems.
Constraint Satisfaction Problems University of Berkeley, USA
1. 2 Outline of Ch 4 Best-first search Greedy best-first search A * search Heuristics Functions Local search algorithms Hill-climbing search Simulated.
Chapter 13 Backtracking Introduction The 3-coloring problem
Chapter 5 Team Teaching AI (created by Dewi Liliana) PTIIK Constraint Satisfaction Problems.
1 CSC 384 Lecture Slides (c) , C. Boutilier and P. Poupart CSC384: Lecture 16  Last time Searching a Graphplan for a plan, and relaxed plan heuristics.
1 Constraint Satisfaction Problems (CSP). Announcements Second Test Wednesday, April 27.
CSG3F3/ Desain dan Analisis Algoritma
CSPs: Search and Arc Consistency Computer Science cpsc322, Lecture 12
CSPs: Search and Arc Consistency Computer Science cpsc322, Lecture 12
Constraint Satisfaction Problems Lecture # 14, 15 & 16
Instructor: Vincent Conitzer
Computer Science cpsc322, Lecture 14
CSPs: Search and Arc Consistency Computer Science cpsc322, Lecture 12
Constraint Satisfaction Problems
Artificial Intelligence
Constraints and Search
Constraint satisfaction problems
Constraint Satisfaction Problems. A Quick Overview
Constraint Satisfaction
CS 8520: Artificial Intelligence
Constraint Satisfaction Problems
Constraint satisfaction problems
Presentation transcript:

Solve Your Problem Faster - by changing the model Barbara Smith

Background Assumptions A constraint programming tool providing: a systematic search algorithm combined with constraint propagation a set of pre-defined constraints A problem that can be represented as a finite domain constraint satisfaction or optimization problem Caveat: the experiences described are based on ILOG Solver ERCIM/CologNet Workshop

ERCIM/CologNet Workshop What do I mean by Faster? e.g.`Peaceable Armies of Queens’ problem place m black & m white queens on a chessboard so that the black queens don’t attack the white queens, and maximize m Optimal solution for an 11 x 11 board: ERCIM/CologNet Workshop

ERCIM/CologNet Workshop Results for 8 x 8 board Backtracks to find optimal prove optimality Time (sec.) Basic model 5270 12,002,608 2100 Eliminate symmetry 5270 938,652 240 New model 4676 478,012 72 Variable order-ing heuristic 2973 44,276 12 Just changing the model makes a huge difference to the time to solve the problem ERCIM/CologNet Workshop

ERCIM/CologNet Workshop What are the options? Given a CSP representation of the problem: if there is symmetry in the CSP, eliminate it find a related representation to use instead/as well add variables – to express different aspects of the problem add constraints to relate new variables to old to prune dead-ends earlier change the search strategy (other possibilities won’t be considered) ERCIM/CologNet Workshop

ERCIM/CologNet Workshop Symmetry in the CSP A symmetry transforms any (full or partial) assignment into another so that consistency/inconsistency is preserved Symmetry causes wasted search effort: after exploring choices that don’t lead to a solution, symmetrically equivalent choices will be explored Especially difficult if there is no solution, or if all solutions are wanted, or in optimization problems ERCIM/CologNet Workshop

Symmetry Breaking During Search (SBDS) See Gent & Smith, ECAI’2000 A = set of assignments made so far var = val var != val + g(var!= val) for any unbroken symmetry g, i.e. if g(A) is (or will be) true On backtracking to a choice point, add symmetry breaking constraints to the 2nd branch explored ERCIM/CologNet Workshop

Symmetries of ‘armies of queens’ Variable s[i,j] represents the square i, j The values are b, w or e (black, white or empty) 7 chess board symmetries: x (horizontal reflection), y, d1, d2, r90, r180, r270 + bw (swap black & white queens) + 7 combinations x(s[i,j]=v)  s[n-i+1,j]=v bw(s[i,j] = v)  s[i,j] = v’ , (v’ = b if v = w, w if v = b, e if v = e ) bw_x(s[i,j]=v)  s[n-i+1,j]=v’ , etc. 15 symmetry functions are needed in all each takes a constraint as input, e.g. s[i,j]=v, and returns the symmetric constraint, e.g. s[i,j] = v’ ERCIM/CologNet Workshop

Armies of Queens – 8 x 8 Board s[1,1]=w s[1,1] != w d1: s[1,1]!=w bw_x: s[8,1]!=b, etc. x: s[8,1]!=w bw: s[1,1]!=b r90: s[1,8]!=w s[1,2]=w s[1,2] != w All symmetries swapping colours now broken on this branch x: if s[8,1]=w then s[8,2]!=w , etc. ERCIM/CologNet Workshop

ERCIM/CologNet Workshop Results for 8 x 8 board Fails to find optimal Fails to prove optimality Time (sec.) Basic model 5270 12,002,608 2100 Eliminate symmetry 5270 938,652 240 ERCIM/CologNet Workshop

Optimizing SONET Rings See Sherali & Smith*, ‘Improving Discrete Model Representations via Symmetry Considerations’ (*no relation) Transmission over optical fibre networks Known traffic demands between pairs of client nodes A node is installed on a SONET ring using an ADM (add-drop multiplexer) If there is traffic demand between 2 nodes, there must be a ring that they are both on Rings have capacity limits (number of ADMs, i.e. nodes, & traffic) Satisfy demands using the minimum number of ADMs ERCIM/CologNet Workshop

Example & Optimal Solution Up to 7 rings, maximum capacity 5 ADMs Ignore traffic capacity (for now) ERCIM/CologNet Workshop

ERCIM/CologNet Workshop A CSP Model Variables: xij = 1 if node i is on ring j At most 5 nodes on any ring: If there is a demand between nodes k and l : Minimize ERCIM/CologNet Workshop

Symmetry in the SONET CSP The rings are indistinguishable (only numbered for the purposes of the CSP model) We can eliminate the symmetry using SBDS just by describing all transpositions of pairs of rings: e.g. r12(x[i,j] = v)  x[i,2]=v if j =1 x[i,1]=v if j =2 x[i,j]=v otherwise That’s all – we can forget about symmetry (e.g. when choosing the variable ordering) ERCIM/CologNet Workshop

Three Alternative Models Whether a given node is on a given ring: xij = 1 if node i is on ring j Which ring(s) each node is on: Ni = set of rings node i is on Which nodes are on each ring Rj = set of nodes on ring j In principle, any of these 3 sets of variables could be the basis of a complete CSP model ERCIM/CologNet Workshop

Dual Models from Boolean Variables Given a CSP with Boolean variables xijkl… we can form a new set of variables with one less subscript: e.g. xijkl… = 1 corresponds to yjkl… = i (an integer variable) or i  Yjkl… (a set variable), depending on whether one or several possible values i are associated with each combination of j,k,l,… if the Boolean variables have n subscripts, we can derive n sets of dual variables ERCIM/CologNet Workshop

ERCIM/CologNet Workshop Which Model to Choose? We don’t need to choose just one set of variables – we can use them all at once We then need new channelling constraints to link the sets of variables: (xij = 1) = (i  Rj) = (j  Ni) (see Cheng, Choi, Lee & Wu, Constraints, 1999) But we should not combine all 3 complete models Adding variables & channelling constraints doesn’t cost much – duplicated constraints do ERCIM/CologNet Workshop

ERCIM/CologNet Workshop Why add more variables? Express each problem constraint in whichever way is easiest /most natural/ propagates best e.g. gives better results than (Often easiest /most natural/ propagates best are the same thing) We can observe effects of search on different aspects of the model, & express them develop implied constraints, search strategies, etc. ERCIM/CologNet Workshop

Possible Variables in the SONET Problem Whether a given node is on a given ring  Which ring(s) each node is on  Which nodes are on each ring  How many nodes are on each ring  How many rings each node is on  The total number of nodes on all rings  The total of the number of rings each node is on  Which demand pairs are on each ring Which ring(s) each demand pair is on How many rings are used ……… ERCIM/CologNet Workshop

Choosing the Search Variables We need to choose a set of variables such that an assignment to each one, satisfying the constraints, is a complete solution to the problem Assume we pass the search variables to the search algorithm in a list or array the order determines a static variable ordering ERCIM/CologNet Workshop

ERCIM/CologNet Workshop Possible Choices Use just one set of variables, e.g. xij – the others are just for constraint propagation Use two (or more) sets of variables (of the same type) e.g. Rj ,Ni interleave them in a sensible (static) order or use a dynamic ordering applied to both sets of variables Use an incomplete set of variables first, to reduce the search space before assigning a complete set e.g. decide how many rings each node is on (search variables |Ni|) and then which rings each node is on (xij ) All three possibilities are useful – the first will be used in the SONET problem (and later the third) ERCIM/CologNet Workshop

ERCIM/CologNet Workshop Implied Constraints Constraints which can be derived from the existing constraints, and so don’t eliminate any solutions We only want useful implied constraints: they reduce search: i.e. at some point during search, a partial assignment must be tried which is inconsistent with the implied constraint but would otherwise not fail immediately they reduce running time – the overhead of propagating extra constraints must be less than the savings in search ERCIM/CologNet Workshop

How to Find Useful Implied Constraints Identify obviously wrong partial assignments that may/do occur during search Try to predict them by contemplation/intuition Observe the search in progress Having many variables in the model enables observing/thinking about many possible aspects of the search But we still need to check empirically that new constraints do reduce both search and running time ERCIM/CologNet Workshop

Implied Constraints: SONET A node with degree in the demand graph > 4 must be on more than 1 ring (|Ni| > 1) If a pair of connected nodes have more than 3 neighbours in total, at least one of the pair must be on more than 1 ring (|Nk|+|Nl| > 2) ERCIM/CologNet Workshop

Optimality Constraints In optimizing, if we know that for any solution with a particular characteristic, there must be another solution at least as good, we can add constraints forbidding it e.g. no ring should have just one node on it any two rings must have more than 5 nodes in total (otherwise we could merge them) Derive these in the same way as implied constraints ERCIM/CologNet Workshop

Variable Ordering Heuristics Armies of Queens: Place a white queen next where it will attack fewest additional squares SONET problem: add a node to a ring with spare capacity; choose the node connected to most nodes already on the ring; of those, the node connected to most nodes still to be placed ERCIM/CologNet Workshop

Finding a Good Solution v. Proving Optimality Armies of Queens the heuristic finds an optimal solution for every case where this is known but… it’s hopeless for proving optimality the `anti-heuristic’ (place a white queen where it will attack most additional squares) is much better! ERCIM/CologNet Workshop

Finding a Good Solution v. Proving Optimality: SONET The heuristic finds near-optimal solutions quite quickly, but is no good for proving optimality How could we prove this solution is optimal: {2,3,4,9,12}, {1,3,7,8,10}, {4,5,6,7,10}, {1,8,11,12,13} ? e.g. show that we cannot reduce the number of times that any of 3, 4, 7, 8, 12 appear without having another node appear twice instead Introduce variables ni = |Ni| i.e. the number of rings that node i is on  Two-stage search: find a good solution, then start search again, assigning ni variables first and then xij variables ERCIM/CologNet Workshop

ERCIM/CologNet Workshop What do I mean by Faster? The basic model (just the xij variables, no symmetry-breaking) can only solve small problems (7 nodes, 8 demand pairs) The final model can solve the problems in the Sherali & Smith paper (13 nodes, 24 demand pairs) 3 full sets of variables + others SBDS implied constraints variable ordering heuristic two-stage search process ERCIM/CologNet Workshop

ERCIM/CologNet Workshop Some Advice Eliminate symmetry Use lots of variables, with channelling constraints But don’t express the same problem constraints twice Add constraints that make explicit what you know about satisfying/optimal solutions But only if they reduce search and running time Learn from solving the problem by hand and observing the search If finding good solutions is easy and proving optimality is hard, consider using a different strategies for each stage ERCIM/CologNet Workshop

ERCIM/CologNet Workshop Conclusions Can we list “10 Steps to Successful Modelling”? New problems still often lead to new ideas about modelling But some patterns do recur frequently e.g. models representing dual viewpoints We are beginning to automate some aspects of modelling e.g. symmetry, implied constraints Still a long way to go before building a good model of a problem is straightforward e.g. we often can’t tell if model A is better than model B without trying them both More research is still needed... ERCIM/CologNet Workshop

ERCIM/CologNet Workshop Selected References Symmetry Breaking During Search in Constraint Programming, I. P. Gent and B. M. Smith, Proceedings ECAI'2000, pp. 599-603, 2000. Models and Symmetry Breaking for `Peaceable Armies of Queens’, K.E Petrie, B. M. Smith & I. P. Gent, APES Report APES-50-2002, May 2002. Improving Discrete Model Representations via Symmetry Considerations, H. D. Sherali & J. C. Smith, Man.Sci. (47) pp. 1396-1407, 2001. Increasing Constraint Propagation by Redundant Modeling: an Experience Report, B. M. W. Cheng, K. M. F. Choi, J. H. M. Lee & J. C. K. Wu, Constraints (4) pp. 167-192, 1999.   ERCIM/CologNet Workshop