CSC Modeling with FD Constraints

Slides:



Advertisements
Similar presentations
Constraint Satisfaction Problems
Advertisements

Modelling with Finite Domains u Domains and Labelling u Complex Constraints u Labelling u Different Problem Modellings u Efficiency u Using SICStus Prolog.
1 Constraint Satisfaction Problems A Quick Overview (based on AIMA book slides)
1 Finite Constraint Domains. 2 u Constraint satisfaction problems (CSP) u A backtracking solver u Node and arc consistency u Bounds consistency u Generalized.
1 Chapter 8: Modelling with Finite Domain Constraints Where we examine how modelling and controlling search interact with finite domain constraints.
Iterative Deepening A* & Constraint Satisfaction Problems Lecture Module 6.
Best-First Search: Agendas
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.
Constraint Satisfaction Problems
Chapter 5 Outline Formal definition of CSP CSP Examples
Dr Eleni Mangina – COURSE: LOGIC PROGRAMMING (during a joint degree with Fudan University in Software Engineering) DEPT. OF COMPUTER SCIENCE UCD LOGIC.
Constraint Satisfaction Problems
1 Constraint Programming: An Introduction Adapted by Cristian OLIVA from Peter Stuckey (1998) Ho Chi Minh City.
Game Trees: MiniMax strategy, Tree Evaluation, Pruning, Utility evaluation Adapted from slides of Yoonsuck Choe.
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.
Constraint Satisfaction CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
Hande ÇAKIN IES 503 TERM PROJECT CONSTRAINT SATISFACTION PROBLEMS.
Chapter 5: Constraint Satisfaction ICS 171 Fall 2006.
CSCI 5582 Fall 2006 CSCI 5582 Artificial Intelligence Fall 2006 Jim Martin.
Chapter 5 Constraint Satisfaction Problems
1 Chapter 3: Finite Constraint Domains Where we meet the simplest and yet most difficult constraints, and some clever and not so clever ways to solve them.
Problem Reduction So far we have considered search strategies for OR graph. In OR graph, several arcs indicate a variety of ways in which the original.
1 Constraint Satisfaction Problems Chapter 5 Section 1 – 3 Grand Challenge:
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 5 Team Teaching AI (created by Dewi Liliana) PTIIK Constraint Satisfaction Problems.
1 Constraint Satisfaction Problems (CSP). Announcements Second Test Wednesday, April 27.
ARTIFICIAL INTELLIGENCE (CS 461D) Dr. Abeer Mahmoud Computer science Department Princess Nora University Faculty of Computer & Information Systems.
Automatic Test Generation
Bell Work Pick up: 0.3 Notes, 0.3 Practice On your Unit 0 Notes:
Optimization Problems
CSPs: Search and Arc Consistency Computer Science cpsc322, Lecture 12
Chapter 17: Designing an Architecture
Computer Science cpsc322, Lecture 13
CSPs: Search and Arc Consistency Computer Science cpsc322, Lecture 12
Constraint Satisfaction Problems (CSPs)
Constraint Satisfaction Problems vs. Finite State Problems
Lecture 7 Constraint Satisfaction Problems
CSCI 5582 Artificial Intelligence
Rationale & Strategies Foundations of Constraint Processing
Problem Solving: Brute Force Approaches
CSPs: Search and Arc Consistency Computer Science cpsc322, Lecture 12
Computer Science cpsc322, Lecture 13
Copyright © Cengage Learning. All rights reserved.
What to do when you don’t know anything know nothing
Chapter 3: Finite Constraint Domains
Chapter 8: Modelling with Finite Domain Constraints
Coding Concepts (Basics)
Constraint Satisfaction Problems
Artificial Intelligence
Terms On The AP Physics 1 Test
Rationale & Strategies Foundations of Constraint Processing
Constraints and Search
Chapter 3: Finite Constraint Domains
Constraint satisfaction problems
Rationale & Strategies Foundations of Constraint Processing
Chap 4: Searching Techniques
Constraint Satisfaction
CS 8520: Artificial Intelligence
B-Trees.
Constraint Satisfaction Problems
Constraint satisfaction problems
Rationale & Strategies Foundations of Constraint Processing
Constraint Satisfaction Problems (CSP)
Chapter 2. Simplex method
Minimax Trees: Utility Evaluation, Tree Evaluation, Pruning
Presentation transcript:

CSC5240 - Modeling with FD Constraints Controlling Search Where we examine how modeling and controlling search interact with finite domain constraints CSC5240 - Modeling with FD Constraints

CSC5240 - Modeling with FD Constraints Domains and Labeling New requirement: need to define the domains of variables arithmetic X :: [1,2,3,4] or X :: [1..4] non-arithmetic X :: [red, blue, yellow] multiple variables [X,Y,Z] :: [0..10] If no domain is given a default is used (say [-10000..10000] CSC5240 - Modeling with FD Constraints

CSC5240 - Modeling with FD Constraints Domains Example - 1 Goal for the smugglers knapsack problem: [W,P,C] :: [0..9], 4*W + 3*P + 2*C <= 9, 15*W + 10*P + 7*C >= 30. The constraint solver returns unknown. But how do we find a solution? Invoke a complete (backtracking) solver CSC5240 - Modeling with FD Constraints

CSC5240 - Modeling with FD Constraints Domains Example - 2 Complete solvers for FD are expensive and should not be invoked every time a new constraint is added to the constraint store Thus, most constraint solver provide only an incomplete solver When necessary, however, the complete backtracking solver for FD can be invoked explicitly by the programmer, usually in the form of built-in labeling CSC5240 - Modeling with FD Constraints

CSC5240 - Modeling with FD Constraints Labeling - 1 Built-in predicate labeling invokes the complete constraint solver labeling(Vs) takes a list of finite domain variables Vs and finds a solution [W,P,C] :: [0..9], 4*W + 3*P + 2*C <= 9, 15*W + 10*P + 7*C >= 30, labeling([W,P,C]). has solutions: CSC5240 - Modeling with FD Constraints

Constrain-and-Generate Typical form of a finite domain program variables and domains are defined constraints modeling problem are given labeling is added to invoke complete solver Minimization can be applied on labeling [W,P,C] :: [0..9], 4*W + 3*P + 2*C <= 9, 15*W + 10*P + 7*C >= 30, minimize(labeling([W,P,C]), -15*W-10*P-7*C). CSC5240 - Modeling with FD Constraints

Send+More=Money Example - 1 Cryptarithmetic problem: each digit is different and the equation holds [S,E,N,D,M,O,R,Y] :: [0..9], S != 0, M != 0, alldifferent_neq([S,E,N,D,M,O,R,Y]), 1000*S + 100*E + 10*N + D + 1000*M + 100*O + 10*R + E = 10000*M + 1000*O + 100*R + 10*E + Y, labeling([S,E,N,D,M,O,R,Y]). CSC5240 - Modeling with FD Constraints

Send+More=Money Example - 2 After domain declarations: After then alldifferent_neq adds disequations (no change) final equation: (one propagation rule) With the current domain: CSC5240 - Modeling with FD Constraints

Send+More=Money Example - 3 Hence D(M) = [1..1] Propagation continues arriving at Note: 3 variables fixed and all domains reduced Making use of the current domains of variables, labeling tries S=9. Then E=4 (this fails eventually), then E=5 which gives CSC5240 - Modeling with FD Constraints

CSC5240 - Modeling with FD Constraints Generate-and-Test Methodology without constraints: first generate a valuation and then test if it is a solution [S,E,N,D,M,O,R,Y] :: [0..9], labeling([S,E,N,D,M,O,R,Y]), S != 0, M != 0, alldifferent_neq([S,E,N,D,M,O,R,Y]), 1000*S + 100*E + 10*N + D + 1000*M + 100*O + 10*R + E = 10000*M + 1000*O + 100*R + 10*E + Y. This program requires 95671082 choices before finding the solution, and the previous required 2 CSC5240 - Modeling with FD Constraints

CSC5240 - Modeling with FD Constraints Labeling - 3 There are two choices made in labeling choice of which variable to label first choice of which value to try first Default labeling try variables in order of the given list try value in order min to max (returned by dom) We can program different strategies CSC5240 - Modeling with FD Constraints

CSC5240 - Modeling with FD Constraints Choice of Variable Variable choice effects the size of derivation tree Choose variable with smallest current domain (hence smallest possible answers) Example Labeling first tries S, M, O (need do nothing), then either E or N. Much better than Y first CSC5240 - Modeling with FD Constraints

First-Fail Labeling - 2 Application of the first-fail principle “To succeed, try first where you are most likely to fail” CSC5240 - Modeling with FD Constraints

CSC5240 - Modeling with FD Constraints First-Fail Labeling - 3 It is reasonable to assume that a variable involved in many constraints is more likely to cause failure when it is set to a value Thus another application of the first-fail principle is to label first a variable that is involved in the most number of constraints CSC5240 - Modeling with FD Constraints

CSC5240 - Modeling with FD Constraints Choice of Domain Value Value choice only effects order in which branches are explored Problem specific knowledge may lead to finding a solution faster Also important for optimization Good solutions found earlier reduce search later CSC5240 - Modeling with FD Constraints

CSC5240 - Modeling with FD Constraints N-Queens Example Q1 Q2 Q3 Q4 1 2 3 4 Problem of placing N queens on an NN chessboard so that none can take another. For large N solutions are more likely with values in the middle of variable domains CSC5240 - Modeling with FD Constraints

CSC5240 - Modeling with FD Constraints Labeling Efficiency We can use both variable and value ordering together Different number of choices for N-queens in different ranges CSC5240 - Modeling with FD Constraints

CSC5240 - Modeling with FD Constraints Domain Splitting - 1 Labeling doesn’t have to set a variable to a value---principle of least commitment Simply has to reduce the variable domains Domain splitting splits the current domain of chosen variable in half Advantage: more search space is pruned when failure is detected Disadvantage: less propagation CSC5240 - Modeling with FD Constraints

CSC5240 - Modeling with FD Constraints Domain Splitting - 3 The idea is to split recursively the domains of each variable in half until all domains are singletons. Domain splitting is better than regular labeling when the variable domains are large, and the constraints involving the variables to be labeled can gain substantial consistency information from the split domain This way, half of the variable’s domain may be eliminated CSC5240 - Modeling with FD Constraints

CSC5240 - Modeling with FD Constraints Search in MiniZinc Search order defined using the variables that appear in the output statement Search annotations allow you to specify search order There are basic search annotations and advanced ones can be defined too Read Chapter 6 of the MiniZinc tutorial CSC5240 - Modeling with FD Constraints