• No results found

AINN ICT4101 FS

N/A
N/A
Protected

Academic year: 2020

Share "AINN ICT4101 FS"

Copied!
34
0
0

Loading.... (view fulltext now)

Full text

(1)

Constraint Satisfaction

Problems

(2)

Outline

n 

Constraint Satisfaction Problems (CSP)

n 

Backtracking search for CSPs

(3)

Constraint satisfaction problems (CSPs)

n 

Standard search problem:

n  state is a "black box“ – any data structure that supports successor

function, heuristic function, and goal test

n 

CSP:

n  state is defined by variables Xi with values from domain Di

n  goal test is a set of constraints specifying allowable combinations of

values for subsets of variables

n 

Simple example of a

formal representation language

(4)

Example: Map-Coloring

n  Variables WA, NT, Q, NSW, V, SA, T

n  Domains Di = {red,green,blue}

n  Constraints: adjacent regions must have different colors

n  e.g., WA ≠ NT, or (WA,NT) in {(red,green),(red,blue),(green,red),

(5)

Example: Map-Coloring

n 

Solutions

are

complete

and

consistent

assignments,

(6)

Constraint graph

n 

Binary CSP:

each constraint relates two variables

(7)

Varieties of CSPs

n 

Discrete variables

n  finite domains:

n  n variables, domain size d à O(dn) complete assignments

n  e.g., Boolean CSPs, incl.~Boolean satisfiability (NP-complete)

n  infinite domains:

n  integers, strings, etc.

n  e.g., job scheduling, variables are start/end days for each job

n  need a constraint language, e.g., StartJob1 + 5 ≤ StartJob3

n 

Continuous variables

n  e.g., start/end times for Hubble Space Telescope observations

(8)

Varieties of constraints

n 

Unary

constraints involve a single variable,

n 

e.g., SA

green

n 

Binary

constraints involve pairs of variables,

n 

e.g., SA

WA

n 

Higher-order

constraints involve 3 or more

variables,

(9)

Example: Cryptarithmetic

n 

Variables

:

F T U W

R O X

1

X

2

X

3

n 

Domains

: {

0,1,2,3,4,5,6,7,8,9

}

n 

Constraints

:

Alldiff (F,T,U,W,R,O)

n  O + O = R + 10 · X1

(10)

Real-world CSPs

n 

Assignment problems

n 

e.g., who teaches what class

n 

Timetabling problems

n 

e.g., which class is offered when and where?

n 

Transportation scheduling

n 

Factory scheduling

n 

Notice that many world problems involve

(11)

Standard search formulation (incremental)

Let's start with the straightforward approach, then fix it

States are defined by the values assigned so far

n  Initial state: the empty assignment { }

n  Successor function: assign a value to an unassigned variable that does

not conflict with current assignment

à fail if no legal assignments

n  Goal test: the current assignment is complete

1.  This is the same for all CSPs

2.  Every solution appears at depth n with n variables

à use depth-first search

3.  Path is irrelevant, so can also use complete-state formulation

(12)

Backtracking search

n  Variable assignments are commutative}, i.e.,

[ WA = red then NT = green ] same as [ NT = green then WA = red ]

n  Only need to consider assignments to a single variable at each node

à b = d and there are $d^n$ leaves

n  Depth-first search for CSPs with single-variable assignments is called

backtracking search

n  Backtracking search is the basic uninformed algorithm for CSPs

(13)
(14)
(15)
(16)
(17)
(18)

Improving backtracking efficiency

n 

General-purpose

methods can give huge

gains in speed:

n 

Which variable should be assigned next?

n 

In what order should its values be tried?

(19)

Most constrained variable

n 

Most constrained variable:

choose the variable with the fewest legal values

n 

a.k.a.

minimum remaining values (MRV)

(20)

Most constraining variable

n 

Tie-breaker among most constrained

variables

n 

Most constraining variable:

n 

choose the variable with the most constraints on

(21)

Least constraining value

n 

Given a variable, choose the least

constraining value:

n 

the one that rules out the fewest values in the

remaining variables

n 

Combining these heuristics makes 1000

(22)

Forward checking

n 

Idea

:

(23)

Forward checking

n 

Idea

:

(24)

Forward checking

n 

Idea

:

(25)

Forward checking

n 

Idea

:

(26)

Constraint propagation

n 

Forward checking propagates information from assigned to

unassigned variables, but doesn't provide early detection for

all failures:

n 

NT and SA cannot both be blue!

(27)

Arc consistency

n 

Simplest form of propagation makes each arc

consistent

n 

X

à

Y

is consistent iff

(28)

Arc consistency

n 

Simplest form of propagation makes each arc

consistent

n 

X

à

Y

is consistent iff

(29)

Arc consistency

n 

Simplest form of propagation makes each arc

consistent

n 

X

à

Y

is consistent iff

for every value x of X there is some allowed y

(30)

Arc consistency

n 

Simplest form of propagation makes each arc

consistent

n 

X

à

Y

is consistent iff

for every value x of X there is some allowed y

n 

If

X

loses a value, neighbors of

X

need to be rechecked

n 

Arc consistency detects failure earlier than forward checking

(31)

Arc consistency algorithm AC-3

(32)

Local search for CSPs

n 

Hill-climbing, simulated annealing typically work with

"complete" states, i.e., all variables assigned

n 

To apply to CSPs:

n  allow states with unsatisfied constraints n  operators reassign variable values

n 

Variable selection: randomly select any conflicted variable

n 

Value selection by

min-conflicts

heuristic:

n  choose value that violates the fewest constraints

(33)

Example: 4-Queens

n 

States

: 4 queens in 4 columns (4

4

= 256 states)

n 

Actions

: move queen in column

n 

Goal test

: no attacks

n 

Evaluation

:

h(n)

= number of attacks

n 

Given random initial state, can solve

n

-queens in almost

(34)

Summary

n  CSPs are a special kind of problem:

n  states defined by values of a fixed set of variables

n  goal test defined by constraints on variable values

n  Backtracking = depth-first search with one variable assigned per node

n  Variable ordering and value selection heuristics help significantly

n  Forward checking prevents assignments that guarantee later failure

n  Constraint propagation (e.g., arc consistency) does additional work to

constrain values and detect inconsistencies

References

Related documents

The compounds 2,5,8 showed inhibition against nuclear , ligand and kinase receptors .The synthesised derivatives were also evaluated for anti bacterial

Select video format (avi, mp4, mpg) which is required to enhance. Divide video into frames and audio. Then decide quality frames and degraded frames. Next to enhance degraded

Target noise curves for existing and future detectors [65] : advanced LIGO at design sensitivity (aLIGO); LIGO Voyager; Einstein Telescope (two proposed configurations, ET-B and

The modified version was piloted (procedure and duration) in individual face-to-face cog- nitive interviews with two physicians, two pediatricians and four osteopaths. It took 8 to

AHS: Ambulatory Healthcare Services; CCM: Chronic Care Model; HAAD: Health Authority Abu Dhabi; PHC: Primary Health Care; SEHA: Abu Dhabi Health Services Company; UAE: United

Results: The ratio of drug sales and institution revenues at primary healthcare institutions was 42.99% in the treatment group, which was significantly lower than the control

At the point of discharge, pharmacists offered eligible patients a TFU service with a verbal description. All con- sented patients were referred to the structured pharma- cist

The hotspot E17K mutation in the PH domain of AKT1 occurs in approximately 0.6–2% of human NSCLC patients. However, its role in the development of lung cancer