Constraint Satisfaction and MEA

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 30

Constraint Satisfaction

and Means-Ends Analysis


HARSHITA SHARMA
 A constraint search does not refer to any specific search algorithm but to a
layer of complexity added to existing algorithms that limit the possible
solution set.
 Heuristic and acquired knowledge can be combined to produce the desired
result a constraint satisfaction problem is a special kind of search problem in
which states are defined by the values of a set of variables and the goal state
specifies a set of constraints that the value must obey.
 There are many problems in AI in which the goal state is not specified in the
problem and it requires to be discovered according to some specific
constraint.
 Examples of some constraint satisfaction search include design problem,
labeling graphs, robot path planning and cryptarithmatic problem etc.
 a constraint satisfaction problem (or CSP) is defined by a set of variables, X1;X2; :
: : ;Xn,
 and a set of constraints, C1;C2; : : : ;Cm.
 Each variable Xi has a nonempty domain Di of possible values.
 Each constraint Ci involves some subset of t variables and specifies the allowable
combinations of values for that subset.
 A state of the problem is defined by an assignment of values to some or all of the
variables, {Xi = vi;Xj = vj ; : : :}
 An assignment that does not violate any constraints is called a consistent or legal
assignment.
 A complete assignment is one in which every variable is mentioned, and a solution
to a CSP is a complete assignment that satisfies all the constraints. Some CSPs also
require a solution that maximizes an objectivenfunction.
 Many problems in AI can be considered as problems of constraint satisfaction,
in which the goal state satisfies a given set of constraint. constraint
satisfaction problems can be solved by using any of the search strategies.
Outline

 The general form of the constraint satisfaction procedure is as follows:


 Until a complete solution is found or until all paths have led to lead ends, do
 1. select an unexpanded node of the search graph.
 2. Apply the constraint inference rules to the selected node to generate all
possible new constraints.
 3. If the set of constraints contains a contradiction, then report that this path
is a dead end.
 4. If the set of constraints describes a complete solution then report success.
 5. If neither a constraint nor a complete solution has been found then apply
the rules to generate new partial solutions. Insert these partial solutions into
the search graph.
Algorithm
Two kinds of rules

 Rules that define the way constraints may validly be propagated.


 Rules that suggest guesses when guesses are necessary.
Example – Cryptarithmetic problem
What is to be done?

 Assign decimal digit to each of the letters in such a way that the answer to
the problem is correct to the same letter occurs more than once , it must be
assign the same digit each time . no two different letters may be assigned the
same digit.
CONSTRAINTS

 1. no two digit can be assigned to same letter.


 2. only single digit number can be assign to a letter.
 3. Assumption can be made at various levels such that they do not contradict
each other.
 4. The problem can be decomposed into secured constraints. A constraint
satisfaction approach may be used.
 5. Any of search techniques may be used.
 6. Backtracking may be performed as applicable us applied search techniques.
 7. Rule of arithmetic may be followed.
 Initial state of problem.
 D=? E=? Y=? N=? R=? O=? S=? M=? C1=? C2=?
 C1 ,C 2, C3 stands for the carry variables respectively.

 Goal State: the digits to the letters must be assigned in such a manner so that
the sum is satisfied.
Solution

 We are following the depth-first method to solve the problem.


 1. initial guess m=1 because the sum of two single digits can generate at most
a carry '1'.
 2. When n=1 o=0 or 1 because the largest single digit number added to m=1
can generate the sum of either 0 or 1 depend on the carry received from the
carry sum. By this we conclude that o=0 because m is already 1 hence we
cannot assign same digit another letter(rule no.)
 3. We have m=1 and o=0 to get o=0 we have s=8 or 9, again depending on the
carry received from the earlier sum.
 The same process can be repeated further. The problem has to be composed
into various constraints. And each constraints is to be satisfied by guessing the
possible digits that the letters can be assumed that the initial guess has been
already made . rest of the process is being shown in the form of a tree, using
depth-first search for the clear understandability of the solution process.
MEANS END ANALYSIS

 Most of the search strategies either reason forward of backward however,


often a mixture o the two directions is appropriate. Such mixed strategy
would make it possible to solve the major parts of problem first and solve the
smaller problems the arise when combining them together. Such a technique
is called "Means - Ends Analysis".
 The means -ends analysis process centers around finding the difference
between current state and goal state. The problem space of means - ends
analysis has an initial state and one or more goal state, a set of operate with
a set of preconditions their application and difference functions that
computes the difference between two state a(i) and s(j).
Steps

 1. Compute the current state s1 to a goal state s2 and computing their


difference D12.
 2. Satisfy the preconditions for some recommended operator op is selected,
then to reduce the difference D12.
 3. The operator OP is applied if possible. If not the current state is solved a
goal is created and means- ends analysis is applied recursively to reduce the
sub goal.
 4. If the sub goal is solved state is restored and work resumed on the original
problem. ( the first AI program to use means - ends analysis was the GPS
General problem solver) means- ends analysis I useful for many human
planning activities.
How MEA works?

 The means-ends analysis process can be applied recursively for a problem. It


is a strategy to control search in problem-solving. Following are the main
Steps which describes the working of MEA technique for solving a problem.
 First, evaluate the difference between Initial State and final State.
 Select the various operators which can be applied for each difference.
 Apply the operator at each difference, which reduces the difference between
the current state and goal state.
Operator Subgoaling

 In the MEA process, we detect the differences between the current state and
goal state. Once these differences occur, then we can apply an operator to
reduce the differences.
 But sometimes it is possible that an operator cannot be applied to the current
state.
 So we create the subproblem of the current state, in which operator can be
applied, such type of backward chaining in which operators are selected, and
then sub goals are set up to establish the preconditions of the operator is
called Operator Subgoaling.
Algorithm

 Let's we take Current state as CURRENT and Goal State as GOAL, then following
are the steps for the MEA algorithm.
 Step 1: Compare CURRENT to GOAL, if there are no differences between both
then return Success and Exit.
 Step 2: Else, select the most significant difference and reduce it by doing the
following steps until the success or failure occurs.
 Select a new operator O which is applicable for the current difference, and if there is no
such operator, then signal failure.
 Attempt to apply operator O to CURRENT. Make a description of two states.
i) O-Start, a state in which O?s preconditions are satisfied.
ii) O-Result, the state that would result if O were applied In O-start.
 If
(First-Part <------ MEA (CURRENT, O-START)
And
(LAST-Part <----- MEA (O-Result, GOAL), are successful, then signal Success and return
the result of combining FIRST-PART, O, and LAST-PART.
Example

 Let's take an example where we know the initial state and goal state as given
below. In this problem, we need to get the goal state by finding differences
between the initial state and goal state and applying operators.
Solution

 To solve the above problem, we will first find the differences between initial
states and goal states, and for each difference, we will generate a new state
and will apply the operators. The operators we have for this problem are:
 Move
 Delete
 Expand
 1. Evaluating the initial state: In the first step, we will evaluate the initial
state and will compare the initial and Goal state to find the differences
between both states.
 2. Applying Delete operator: As we can check the first difference is that in
goal state there is no dot symbol which is present in the initial state, so, first
we will apply the D elete operator to remove this dot
 3. Applying Move Operator: After applying the Delete operator, the new state
occurs which we will again compare with goal state. After comparing these
states, there is another difference that is the square is outside the circle, so,
we will apply the Move Operator.
 4. Applying Expand Operator: Now a new state is generated in the third
step, and we will compare this state with the goal state. After comparing the
states there is still one difference which is the size of the square, so, we will
apply Expand operator, and finally, it will generate the goal state.
END

You might also like