0% found this document useful (0 votes)
31 views

Constraint Satisfaction Algorithm

The document outlines three AI problem-solving techniques: agenda-driven search, constraint satisfaction, and means-ends analysis. Agenda-driven search uses an agenda of tasks to guide search. Constraint satisfaction reduces search by propagating constraints and making educated guesses. Means-ends analysis detects differences between the current and goal states and applies operators to reduce differences, setting up subgoals when needed.

Uploaded by

User Name
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views

Constraint Satisfaction Algorithm

The document outlines three AI problem-solving techniques: agenda-driven search, constraint satisfaction, and means-ends analysis. Agenda-driven search uses an agenda of tasks to guide search. Constraint satisfaction reduces search by propagating constraints and making educated guesses. Means-ends analysis detects differences between the current and goal states and applies operators to reduce differences, setting up subgoals when needed.

Uploaded by

User Name
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

OUTLINE

• Agenda Driven Search


• Constraint Satisfaction
• Means-End Analysis
Agendas
• An Agenda is a list of tasks a system could
perform.
• Associated with each task there are usually
two things:
– A list of reasons why the task is being proposed
(justification)
– Rating- representing the overall weight of
evidence suggesting that the task would be useful.
Algorithm : Agenda-Driven Search
1. Do until a goal state is reached or the agenda is empty:

(a) Choose the most promising task from the agenda. Notice that this
task can be represented in any desired form. It can be thought of
as an explicit statement of what to do next or simply as an
indication of the next node to be expanded.

(b) Execute the task by devoting to it the number of resources


determined by its importance. The important resources to
consider are time and space. Executing the task will probably
generate additional tasks (successor nodes). For each of them, do
the following:

(i) See if it is already on the agenda. If so, then see if this same reason for
doing it is already on its list of justifications. If so, ignore this current
evidence. If this justification was not already present, add it to the list. If
the task was not on the agenda, insert it.

(ii) Compute the new task’s rating, combining the evidence from all its
justifications.
Constraint Satisfaction
• Many AI problems can be viewed as problems
of constraint satisfaction.

• Can reduce substantially the amount of


search.
Constraint Satisfaction
• Operates in a space of constraint sets.

• Initial state contains the original constraints


given in the problem.

• A goal state is any state that has been


constrained “enough”.
Constraint Satisfaction
Two-step process:
1. Constraints are discovered and propagated as
far as possible.
2. If there is still not a solution, then search
begins, adding new constraints.
Constraint Satisfaction
Two kinds of rules:
1. Rules that define valid constraint
propagation.
2. Rules that suggest guesses when necessary.
A Cryptarithmetic Problem
Solving a Cryptarithmetic Problem
At each cycle, two significant things are done
• Constraints are propagated by using rules that correspond to
the properties of arithmetic.
• A value is guessed for some letter whose value is not yet
determined.
A few useful heuristics can help to select the best guess to try
first
• If there is a letter that has only two possible values and
another with six possible values, there is a better chance of
guessing right on the first than on the second.
• If there is a letter that participates in many constraints then it
is a good idea to prefer it to a letter that participates in a few.
Solving a Cryptarithmetic Problem
Initially, rules for propagating constraints generate the following
additional constraints:
• M=1, since two single digit numbers plus a carry cannot total
more than 19.
• S=8 or 9, since S+M+C3 > 9(to generate the carry) and M= 1,
S+1+C3>9, so S+C3>8and C3 is at most 1.
• O= 0, since S+M(1)+C3(<=1) must be at least 10 to generate a
carry and it can be at most 11. But M is already 1, so O must be 0.
• N= E or E+1, depending on the value of C2. But N cannot have the
same value as E. So, N=E+1 and C2 is 1.
• In order for C2 to be 1, the sum of N+R+C1 must be greater than
9, so N+R must be greater than 8.
• N+R cannot be greater than 18, even with carry in , so E cannot
be 9.
Solving a Cryptarithmetic Problem
At this point , let us assume that no more constraints can be
generated. Then, to make progress from here, we must guess.
Suppose E is assigned the value 2. (We chose to guess a value
for E because it occurs three times and thus interacts highly
with other letters.) Now the next cycle begins.
• N=3,since N=E+1.
• R=8 or 9, since R+N(3)+C1(1 or 0) = 2 or 12. But since N is
already 3, the sum of these nonnegative numbers cannot be
less than 3. Thus R+3+(0 or1) = 12 and R= 8 or 9.
• 2+D= y or 2+D =10+Y, from the sum in the rightmost column.
Solving a Cryptarithmetic Problem
Algorithm : Constraint Satisfaction
1. Propagate available constraints. To do this, first set OPEN to the set of all objects that must
have values assigned to them in a complete solution. Then do until an inconsistency is
detected or until OPEN is empty:
(a) Select an object OB from OPEN. Strengthen as much as possible the set of constraints
that apply to OB.
(b) If this set is different from the set that was assigned the last time OB was examined or if
this is the first time OB has been examined, then add to OPEN all objects that share any
constraints with OB.
(c) Remove OB from OPEN.

2. If the union of the constraints discovered above defines a solution, then quit and report the
solution.
3. If the union of the constraints discovered above defines a contradiction, then return failure.
4. If neither of the above occurs, then it is necessary to make a guess at something in order to
proceed. To do this, loop until a solution is found or all possible solutions have been
eliminated:
(a) Select an object whose value is not yet determined and select a way of strengthening the
constraints on that object.
(b) Recursively invoke constraint satisfaction with the current set of constraints augmented by
the strengthening constraint just selected.
Means-Ends Analysis
• Process centers around the detection of difference between
the current state and the goal state.
• An operator that can reduce the difference must be found.
• If that operator cannot be applied to the current state. Set up
a sub problem of getting to a state in which it can be applied.
This process is known as operator subgoaling.
• The first AI program to exploit means-ends analysis was the
General Problem Solver (GPS) motivated by the observation
that people often use this technique when they solve
problems.
Means-Ends Analysis

• Means-ends analysis relies on a set of rules that can


transform one problem state into another.
• They are represented as a left side that describes the
conditions that must be met for the rule to be applicable
(preconditions) and a right side that describes those aspects
of the problem state that will be changed by the application
of the rule.
• Difference table indexes the rules by the difference that they
can be used to reduce.
A Robot’s Operators

• Consider a simple household robot domain. The available


operators are given, along with their preconditions and
results.
Robot operation
• Suppose that the robot in this domain were given the
problem of moving a desk with two things on it from one
room to another.
• The objects on top must also be moved. The main difference
between the start state and the goal state would be the
location of the desk.
• To reduce this difference, either PUSH or CARRY could be
chosen.
• If CARRY is chosen first, its precondition must be met.
• This results in two more differences that must be reduced:
the location of the robot and the size of the desk.
Robot operation
• The location of the robot can be handled by applying WALK, but
there are no operators that can change the size of an object. So
this path leads to a dead-end.
• Following the other branch, we attempt to apply PUSH.
• PUSH has four preconditions, two of which produce differences
between the start and the goal states: the robot must be at the
desk, and the desk must be clear.
• Since the desk is already large, and the robot’s arm is empty,
those two preconditions can be ignored.
• The robot can be brought to the correct location by using WALK.
And the surface of the desk can be cleared by two uses of PICKUP.
But after one PICKUP, an attempt to do the second results in
another difference- the arm must be empty. PUSHDOWN can be
used to reduce that difference.
Robot operation
• Once PUSH is performed, the problem state is close to the
goal state, but not quite. The objects must be placed back on
the desk.
• PLACE will put them there. But it cannot be applied
immediately. Another difference must be eliminated, since
the robot must be holding the objects.
• The final difference between C and E can be reduced by using
WALK to get the robot back to the objects, followed by
PICKUP and CARRY.
A Difference Table
The Progress of the Means-Ends Analysis
Methods
Algorithm : Means-Ends Analysis
1. Compare CURRENT to GOAL. If there are no differences between them then return.

2. Otherwise, select the most important difference and reduce it by doing the following until
success or failure is signaled:

(a) Select yet untried operator O that is applicable to the current difference. If there are no such
operators, then signal failure.

(b) Attempt to apply O to CURRENT. Generate descriptions of two states: O-START, a state in
which O’s preconditions are satisfied and O-RESULT, the state that would result if O were
applied in O-START.

(c) If
(FIRST-PART ← MEA(CURRENT, O-START))
and
(LAST-PART ← MEA(O-RESULT, GOAL))
are successful, then signal success and return the result of concatenating
FIRST-PART, O, and LAST-PART.

You might also like