Artificial Intelligence

Similar documents
Constraint Satisfaction Problems

Constraint Satisfaction

Constraint Satisfaction Problems. Chapter 6

Constraint Satisfaction Problems

Australia Western Australia Western Territory Northern Territory Northern Australia South Australia South Tasmania Queensland Tasmania Victoria

Example: Map-Coloring. Constraint Satisfaction Problems Western Australia. Example: Map-Coloring contd. Outline. Constraint graph

Constraint Satisfaction Problems

Constraint Satisfaction Problems

Lecture 6: Constraint Satisfaction Problems (CSPs)

Constraint Satisfaction Problems. A Quick Overview (based on AIMA book slides)

Chapter 6 Constraint Satisfaction Problems

Constraint Satisfaction. AI Slides (5e) c Lin

Constraint Satisfaction Problems (CSPs)

CSE 473: Artificial Intelligence

CS 188: Artificial Intelligence Fall 2008

Announcements. CS 188: Artificial Intelligence Fall Large Scale: Problems with A* What is Search For? Example: N-Queens

CS 188: Artificial Intelligence Fall 2011

Announcements. Homework 4. Project 3. Due tonight at 11:59pm. Due 3/8 at 4:00pm

Announcements. CS 188: Artificial Intelligence Fall 2010

What is Search For? CSE 473: Artificial Intelligence. Example: N-Queens. Example: N-Queens. Example: Map-Coloring 4/7/17

CS 343: Artificial Intelligence

CS 188: Artificial Intelligence. What is Search For? Constraint Satisfaction Problems. Constraint Satisfaction Problems

What is Search For? CS 188: Artificial Intelligence. Constraint Satisfaction Problems

Constraint Satisfaction Problems

Announcements. Homework 1: Search. Project 1: Search. Midterm date and time has been set:

Space of Search Strategies. CSE 573: Artificial Intelligence. Constraint Satisfaction. Recap: Search Problem. Example: Map-Coloring 11/30/2012

10/11/2017. Constraint Satisfaction Problems II. Review: CSP Representations. Heuristic 1: Most constrained variable

CS 4100 // artificial intelligence

Constraint Satisfaction Problems

Reading: Chapter 6 (3 rd ed.); Chapter 5 (2 nd ed.) For next week: Thursday: Chapter 8

Announcements. CS 188: Artificial Intelligence Spring Today. A* Review. Consistency. A* Graph Search Gone Wrong

Announcements. CS 188: Artificial Intelligence Spring Today. Example: Map-Coloring. Example: Cryptarithmetic.

CS 188: Artificial Intelligence Spring Announcements

CS 188: Artificial Intelligence. Recap: Search

Iterative improvement algorithms. Today. Example: Travelling Salesperson Problem. Example: n-queens

CS W4701 Artificial Intelligence

Artificial Intelligence Constraint Satisfaction Problems

Foundations of Artificial Intelligence

DIT411/TIN175, Artificial Intelligence. Peter Ljunglöf. 30 January, 2018

Constraint Satisfaction Problems

Recap: Search Problem. CSE 473: Artificial Intelligence. Space of Search Strategies. Constraint Satisfaction. Example: N-Queens 4/9/2012

What is Search For? CS 188: Artificial Intelligence. Example: Map Coloring. Example: N-Queens. Example: N-Queens. Constraint Satisfaction Problems

Outline. Best-first search

CS 188: Artificial Intelligence Fall 2011

CS 188: Artificial Intelligence Spring Announcements

Spezielle Themen der Künstlichen Intelligenz

Constraint Satisfaction Problems Part 2

ARTIFICIAL INTELLIGENCE (CS 370D)

Announcements. Reminder: CSPs. Today. Example: N-Queens. Example: Map-Coloring. Introduction to Artificial Intelligence

Constraint Satisfaction Problems

Constraint Satisfaction Problems

Constraint Satisfaction Problems (CSPs) Introduction and Backtracking Search

Constraint Satisfaction Problems. slides from: Padhraic Smyth, Bryan Low, S. Russell and P. Norvig, Jean-Claude Latombe

What is Search For? CS 188: Ar)ficial Intelligence. Constraint Sa)sfac)on Problems Sep 14, 2015

Constraint Satisfaction Problems

Lars Schmidt-Thieme, Information Systems and Machine Learning Lab (ISMLL), University of Hildesheim, Germany, Course on Artificial Intelligence,

Constraint satisfaction problems. CS171, Winter 2018 Introduction to Artificial Intelligence Prof. Richard Lathrop

Week 8: Constraint Satisfaction Problems

CS 771 Artificial Intelligence. Constraint Satisfaction Problem

Constraint Satisfaction Problems. Chapter 6

CONSTRAINT SATISFACTION

Announcements. CS 188: Artificial Intelligence Fall Reminder: CSPs. Today. Example: 3-SAT. Example: Boolean Satisfiability.

CS 188: Artificial Intelligence Fall 2008

Map Colouring. Constraint Satisfaction. Map Colouring. Constraint Satisfaction

Lecture 18. Questions? Monday, February 20 CS 430 Artificial Intelligence - Lecture 18 1

Artificial Intelligence, CS, Nanjing University Spring, 2018, Yang Yu. Lecture 5: Search 4.

Games and Adversarial Search II Alpha-Beta Pruning (AIMA 5.3)

Material. Thought Question. Outline For Today. Example: Map-Coloring EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS

Constraint Satisfaction Problems

Constraint Satisfaction Problems

Artificial Intelligence

Artificial Intelligence

CS 188: Artificial Intelligence

Discussion Section Week 1

CS 188: Artificial Intelligence Spring Today

Today. CS 188: Artificial Intelligence Fall Example: Boolean Satisfiability. Reminder: CSPs. Example: 3-SAT. CSPs: Queries.

Solving Problems by Searching: Constraint Satisfaction Problems

CMU-Q Lecture 7: Searching in solution space Constraint Satisfaction Problems (CSPs) Teacher: Gianni A. Di Caro

Mathematical Programming Formulations, Constraint Programming

Introduction. 2D1380 Constraint Satisfaction Problems. Outline. Outline. Earlier lectures have considered search The goal is a final state

CS 188: Artificial Intelligence. Recap Search I

Announcements. CS 188: Artificial Intelligence Spring Production Scheduling. Today. Backtracking Search Review. Production Scheduling

CS 188: Artificial Intelligence

CSE 573: Artificial Intelligence

Moving to a different formalism... SEND + MORE MONEY

Constraint Satisfaction Problems

Constraints. CSC 411: AI Fall NC State University 1 / 53. Constraints

General Methods and Search Algorithms

CS 188: Artificial Intelligence

Outline. Best-first search

Example: Map coloring

Constraint Satisfaction Problems Chapter 3, Section 7 and Chapter 4, Section 4.4 AIMA Slides cstuart Russell and Peter Norvig, 1998 Chapter 3, Section

Constraint Satisfaction Problems

Artificial Intelligence

CONSTRAINT SATISFACTION

Artificial Intelligence

CONSTRAINT SATISFACTION

AI Fundamentals: Constraints Satisfaction Problems. Maria Simi

Constraint Satisfaction Problems (CSPs)

Constraint Satisfaction. CS 486/686: Introduction to Artificial Intelligence

Transcription:

Artificial Intelligence Constraint Satisfaction Problems Marc Toussaint University of Stuttgart Winter 2015/16 (slides based on Stuart Russell s AI course)

Inference The core topic of the following lectures is Inference: Given some pieces of information on some things (observed variabes, prior, knowledge base) what is the implication (the implied information, the posterior) on other things (non-observed variables, sentence) Decision-Making and Learning can be viewed as Inference: given pieces of information: about the world/game, collected data, assumed model class, prior over model parameters make decisions about actions, classifier, model parameters, etc In this lecture: Deterministic inference in CSPs Probabilistic inference in graphical models variabels) Logic inference in propositional & FO logic 2/28

sequential decisions propositional relational deterministic sequential decision problems search BFS sequential assignment games backtracking alpha/beta pruning minimax CSP constraint propagation on trees propositional logic fwd/bwd chaining FOL MCTS UCB bandits learning probabilistic Decision Theory utilities multi-agent MDPs Reinforcement Learning MDPs dynamic programming V(s), Q(s,a) relational MDPs Active Learning graphical models ML belief propagation msg. passing HMMs FOL fwd/bwd msg. passing relational graphical models 3/28

Constraint satisfaction problems (CSPs) In previous lectures we considered sequential decision problems CSPs are not sequential decision problems. However, the basic methods address them by testing sequentially decisions CSP: We have n variables x i, each with domain D i, x i D i We have K constraints C k, each of which determines the feasible configurations of a subset of variables The goal is to find a configuration X = (X 1,.., X n) of all variables that satisfies all constraints Formally C k = (I k, c k ) where I k {1,.., n} determines the subset of variables, and c k : D Ik {0, 1} determines whether a configuration x Ik D Ik of this subset of variables is feasible 4/28

Example: Map-Coloring Variables W, N, Q, E, V, S, T (E = New South Wales) Domains D i = {red, green, blue} for all variables Constraints: adjacent regions must have different colors e.g., W N, or (W, N) {(red, green), (red, blue), (green, red), (green, blue),...} 5/28

Example: Map-Coloring contd. Solutions are assignments satisfying all constraints, e.g., {W = red, N = green, Q = red, E = green, V = red, S = blue, T = green} 6/28

Constraint graph Pair-wise CSP: each constraint relates at most two variables Constraint graph: a bi-partite graph: nodes are variables, boxes are constraints In general, constraints may constrain several (or one) variables ( I k 2) c 1 c 2 N W c 9 S c 3 Q c 4 c 5 E c 6 c 8 c 7 V T 7/28

Varieties of CSPs Discrete variables: finite domains; each D i of size D i = d O(d n ) complete assignments e.g., Boolean CSPs, incl. Boolean satisfiability infinite domains (integers, strings, etc.) e.g., job scheduling, variables are start/end days for each job linear constraints solvable, nonlinear undecidable Continuous variables e.g., start/end times for Hubble Telescope observations linear constraints solvable in poly time by LP methods Real-world examples Assignment problems, e.g. who teaches what class? Timetabling problems, e.g. which class is offered when and where? Hardware configuration Transportation/Factory scheduling 8/28

Varieties of constraints Unary constraints involve a single variable, I k = 1 e.g., S green Pair-wise constraints involve pairs of variables, I k = 2 e.g., S W Higher-order constraints involve 3 or more variables, I k > 2 e.g., Sudoku 9/28

Methods for solving CSPs 10/28

Sequential assignment approach Let s start with the straightforward, dumb approach, then fix it States are defined by the values assigned so far Initial state: the empty assignment, { } Successor function: assign a value to an unassigned variable that does not conflict with current assignment fail if no feasible assignments (not fixable!) Goal test: the current assignment is complete 1) Every solution appears at depth n with n variables use depth-first search 2) b = (n l)d at depth l, hence n!d n leaves! 11/28

Backtracking sequential assignment Two variable assignment decisions are commutative, i.e., [W = red then N = green] same as [N = green then W = red] We can fix a single next variable to assign a value to at each node This does not compromise completeness (ability to find the solution) b = d and there are d n leaves Depth-first search for CSPs with single-variable assignments is called backtracking search Backtracking search is the basic uninformed algorithm for CSPs Can solve n-queens for n 25 12/28

Backtracking search function Backtracking-Search(csp) returns solution/failure return Recursive-Backtracking({ }, csp) function Recursive-Backtracking(assignment, csp) returns soln/failure if assignment is complete then return assignment var Select-Unassigned-Variable(Variables[csp], assignment, csp) for each value in Ordered-Domain-Values(var, assignment, csp) do if value is consistent with assignment given Constraints[csp] then add [var = value] to assignment result Recursive-Backtracking(assignment, csp) if result failure then return result remove [var = value] from assignment return failure 13/28

Backtracking example 14/28

Backtracking example 14/28

Backtracking example 14/28

Backtracking example 14/28

Improving backtracking efficiency Simple heuristics can give huge gains in speed: 1. Which variable should be assigned next? 2. In what order should its values be tried? 3. Can we detect inevitable failure early? 4. Can we take advantage of problem structure? 15/28

Minimum remaining values Minimum remaining values (MRV): choose the variable with the fewest legal values 16/28

Degree heuristic Tie-breaker among MRV variables Degree heuristic: choose the variable with the most constraints on remaining variables 17/28

Least constraining value Given a variable, choose the least constraining value: the one that rules out the fewest values in the remaining variables Combining these heuristics makes 1000 queens feasible 18/28

Constraint propagation After each decision (assigning a value to one variable) we can compute what are the remaining feasible values for all other variables. Initially, every variable has the full domain D i. Constraint propagation reduces these domains, deleting entries that are inconsistent with the new decision. These dependencies are recursive: Deleting a value from the domain of one variable might imply infeasibility of some value of another variable contraint propagation. We update domains until they re all consistent with the constraints. This is Inference 19/28

Constraint propagation Example of just 1-step propagation : N and S cannot both be blue! Idea: propagate the implied constraints serveral steps further Generally, this is called constraint propagation 20/28

Arc consistency (=constraint propagation for pair-wise constraints) Simplest form of propagation makes each arc consistent X Y is consistent iff for every value x of X there is some allowed y 21/28

Arc consistency (=constraint propagation for pair-wise constraints) Simplest form of propagation makes each arc consistent X Y is consistent iff for every value x of X there is some allowed y 21/28

Arc consistency (=constraint propagation for pair-wise constraints) Simplest form of propagation makes each arc consistent X Y is consistent iff for every value x of X there is some allowed y If X loses a value, neighbors of X need to be rechecked 21/28

Arc consistency (=constraint propagation for pair-wise constraints) Simplest form of propagation makes each arc consistent X Y is consistent iff for every value x of X there is some allowed y If X loses a value, neighbors of X need to be rechecked Arc consistency detects failure earlier than forward checking Can be run as a preprocessor or after each assignment 21/28

Arc consistency algorithm constraints) (for pair-wise function AC-3( csp) returns the CSP, possibly with reduced domains inputs: csp, a pair-wise CSP with variables {X 1, X 2,..., X n} local variables: queue, a queue of arcs, initially all the arcs in csp while queue is not empty do (X i, X j ) Remove-First(queue) if Remove-Inconsistent-Values(X i, X j ) then for each X k in Neighbors[X i ] do add (X k, X i ) to queue function Remove-Inconsistent-Values( X i, X j ) returns true iff Dom[X i ] changed changed false for each x in Domain[X i ] do if no value y in Domain[X j ] allows (x,y) to satisfy the constraint X i X j then delete x from Domain[X i ]; changed true return changed O(n 2 d 3 ), can be reduced to O(n 2 d 2 ) 22/28

Constraint propagation See textbook for details for non-pair-wise constraints Very closely related to message passing in probabilistic models In practice: design approximate constraint propagation for specific problem E.g.: Sudoku: If X i is assigned, delete this value from all peers 23/28

Problem structure c 1 c 2 N W c 9 S c 3 Q c 4 c 5 E c 6 c 8 c 7 V Tasmania and mainland are independent subproblems Identifiable as connected components of constraint graph T 24/28

Tree-structured CSPs Theorem: if the constraint graph has no loops, the CSP can be solved in O(n d 2 ) time Compare to general CSPs, where worst-case time is O(d n ) This property also applies to logical and probabilistic reasoning! 25/28

Algorithm for tree-structured CSPs 1. Choose a variable as root, order variables from root to leaves such that every node s parent precedes it in the ordering 2. For j from n down to 2, apply RemoveInconsistent(P arent(x j ), X j ) This is backward constraint propagation 3. For j from 1 to n, assign X j consistently with P arent(x j ) This is forward sequential assignment (trivial backtracking) 26/28

Nearly tree-structured CSPs Conditioning: instantiate a variable, prune its neighbors domains Cutset conditioning: instantiate (in all ways) a set of variables such that the remaining constraint graph is a tree Cutset size c runtime O(d c (n c)d 2 ), very fast for small c 27/28

Summary CSPs are a fundamental kind of problem: finding a feasible configuration of n variables the set of constraints defines the (graph) structure of the problem Sequential assignment approach Backtracking = depth-first search with one variable assigned per node Variable ordering and value selection heuristics help significantly Constraint propagation (e.g., arc consistency) does additional work to constrain values and detect inconsistencies The CSP representation allows analysis of problem structure Tree-structured CSPs can be solved in linear time If after assigning some variables, the remaining structure is a tree linear time feasibility check by tree CSP 28/28