0% found this document useful (0 votes)
10 views13 pages

Summary CH3

Chapter Three discusses problem-solving agents that utilize search algorithms to navigate from an initial state to a goal state. It categorizes search strategies into uninformed and informed algorithms, detailing various methods such as breadth-first search, uniform-cost search, and A* search, along with their complexities and optimality conditions. Additionally, it introduces local search techniques like hill-climbing and simulated annealing, which are advantageous for optimization problems in large or continuous state spaces.

Uploaded by

Beyenech Ashiye
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)
10 views13 pages

Summary CH3

Chapter Three discusses problem-solving agents that utilize search algorithms to navigate from an initial state to a goal state. It categorizes search strategies into uninformed and informed algorithms, detailing various methods such as breadth-first search, uniform-cost search, and A* search, along with their complexities and optimality conditions. Additionally, it introduces local search techniques like hill-climbing and simulated annealing, which are advantageous for optimization problems in large or continuous state spaces.

Uploaded by

Beyenech Ashiye
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/ 13

Chapter Three

Solving Problems By Searching


This chapter describes one kind of goal-based agent called a problem-solving agent. Problem
solving agents use atomic representations, that is, states of the world are considered as wholes, with
no internal structure visible to the problem-solving algorithms. Goal-based agents that use more
advanced factored or structured representations are usually called planning agents.
 Uninformed search algorithms: algorithms that are given no information about the
problem other than its definition.
 Informed search algorithms: do quite well given some guidance on where to look for
solutions.
A problem can be defined formally by five components:
 The initial state that the agent starts in.
 A description of the possible actions available to the agent. Given a particular state s,
ACTIONS(s) returns the set of actions that can be executed in s.
 A description of what each action does; the formal name for this is the transition model,
specified by a function RESULT(s,a) that returns the state that results from doing action a in
state s. We also use the term successor to refer to any state reachable from a given state by a
single action. Together, the initial state, actions, and transition model implicitly define the
state space of the problem.
 The goal test, which determines whether a given state is a goal state.
 A path cost function that assigns a numeric cost to each path. The problem-solving agent
chooses a cost function that reflects its own performance measure. The step cost of taking
action a in state s to reach state s’ is denoted by c(s,a,s’).
 A solution to a problem is an action sequence that leads from the initial state to a goal state.
Solution quality is measured by the path cost function, and an optimal solution has the
lowest path cost among all solutions.
The set of all leaf nodes available for expansion at any given point is called the frontier.
Augment the TREE-SEARCH algorithm with a data structure called the explored set so that the
algorithm remembers every expanded node and avoid repeating them. Newly generated nodes that
match previously generated nodes, ones in the explored set or the frontier, can be discarded instead
of being added to the frontier.
Search algorithms’ performance are evaluated in four ways:
✔ Completeness: Is the algorithm guaranteed to find a solution when there is one?
✔ Optimality: Does the strategy find the optimal solution?
✔ Time complexity: How long does it take to find a solution?
✔ Space complexity: How much memory is needed to perform the search?
Uninformed Search
Strategies have no additional information about states beyond that provided in the problem
definition. All they can do is generate successors and distinguish a goal state from a non-goal state.
All search strategies are distinguished by the order in which nodes are expanded. Strategies that
know whether one non-goal state is ”more promising” than another are called informed search or
heuristic search strategies.
1. Breadth-first search is a simple strategy in which the root node is expanded first, then all
the successors of the root node are expanded next, then their successors, and so on. This is
achieved very simply by using a FIFO queue for the frontier. The goal test is applied to each
node when it is generated rather than when it is selected for expansion. BFS is optimal if the
path cost is a nondecreasing function of the depth of the node. The most common such
scenario is that all actions have the same cost. Imagine searching a uniform tree where every
state has b successors. Also, suppose that the solution is at depth d. Time and space
complexities are O(bd ). Lessons to be learnt from BFS: First, the memory requirements are
a bigger problem for breadth-first search than is the execution time. Second lesson is that
time is still a major factor.
2. Uniform-cost search expands the node n with the lowest path cost g(n). This is done by
storing the frontier as a priority queue ordered by g. In addition to the ordering of the queue
by path cost, there are two other significant differences from breadth-first search. The first is
that the goal test is applied to a node when it is selected for expansion rather than when it is
first generated. The reason is that the first goal node that is generated may be on a
suboptimal path. The second difference is that a test is added in case a better path is found to
a node currently on the frontier. UCS is optimal in general. Uniform-cost search does not
care about the number of steps a path has, but only about their total cost. Therefore, it will
get stuck in an infinite loop if there is a path with an infinite sequence of zero-cost actions—
for example, a sequence of NoOp actions.
3. Depth-first search always expands the deepest node in the current frontier of the search
tree. Whereas breadth-first-search uses a FIFO queue, depth-first search uses a LIFO queue.
DFS is not optimal. A depth-first tree search, on the other hand, may generate all of the
O(bm) nodes in the search tree, where m is the maximum depth of any node; this can be
much greater than the size of the state space. Note that m itself can be much larger than d
(the depth of the shallowest solution) and is infinite if the tree is unbounded. For a state
space with branching factor b and maximum depth m, depthfirst search requires storage of
only O(bm) nodes, which is DFS’s advantage over BFS. A variant of depth-first search
called backtracking search uses still less memory. In backtracking, only one successor is
generated at a time rather than all successors; each partially expanded node remembers
which successor to generate next. In this way, only O(m) memory is needed rather than
O(bm).
4. Depth-limited search nodes at depth l are treated as if they have no successors, which
solves the infinite-path problem. Its time complexity is O(b l) and its space complexity is
O(bl). Depth-first search can be viewed as a special case of depth-limited search with l = ∞.
5. Iterative deepening DFS combines the benefits of depth-first and breadth-first search. Like
depth-first search, its memory requirements are modest: O(bd) to be precise. Like breadth-
first search, it is complete when the branching factor is finite and optimal when the path cost
is a nondecreasing function of the depth of the node. Iterative deepening search may seem
wasteful because states are generated multiple times. It turns out this is not too costly. The
reason is that in a search tree with the same (or nearly the same) branching factor at each
level, most of the nodes are in the bottom level, so it does not matter much that the upper
levels are generated multiple times, which gives a time complexity of O(b d ).
6. Bidirectional search to run two simultaneous searches—one forward from the initial state
and the other backward from the goal—hoping that the two searches meet in the middle. The
d/2 d/2
motivation is that b +b is much less than b d . Bidirectional search is implemented by
replacing the goal test with a check to see whether the frontiers of the two searches intersect;
if they do, a solution has been found. The time complexity of bidirectional search using
d/2 d/2
breadth-first searches in both directions is O(b ). The space complexity is also O(b ).
We can reduce this by roughly half if one of the two searches is done by iterative deepening,
but at least one of the frontiers must be kept in memory 8 so that the intersection check can
be done. This space requirement is the most significant weakness of bidirectional search.
Comparing uninformed search strategies:
Informed Search Strategies
Most best-first algorithms include as a component of f a heuristic function, denoted h(n): h(n) =
estimated cost of the cheapest path from the state at node n to a goal state. (Notice that h(n) takes a
node as input, but, unlike g(n), it depends only on the state at that node.) If n is a goal node, then
h(n) = 0.
1. Greedy best-first search tries to expand the node that is closest to the goal, on the grounds
that this is likely to lead to a solution quickly. Thus, it evaluates nodes by using just the
heuristic function; that is, f(n) = h(n). Greedy best-first tree search is also incomplete even in
a finite state space, much like depth-first search. The worst-case time and space complexity
for the tree version is O(b m), where m is the maximum depth of the search space.
2. A∗ search: Minimizing the total estimated solution cost. It evaluates nodes by combining
g(n), the cost to reach the node, and h(n), the cost to get from the node to the goal: f(n) =
g(n) + h(n) Since g(n) gives the path cost from the start node to node n, and h(n) is the
estimated cost of the cheapest path from n to the goal, we have f(n) = estimated cost of the
cheapest solution through n Thus, if we are trying to find the cheapest solution, a reasonable
thing to try first is the node with the lowest value of g(n) + h(n). A ∗ search is both
complete and optimal.
Conditions for optimality: Admissibility and consistency The first condition we require for
optimality is that h(n) be an admissible heuristic. An admissible heuristic is one that never
overestimates the cost to reach the goal. Because g(n) is the actual cost to reach n along the
current path, and f(n) = g(n) + h(n), we have as an immediate consequence that f(n) never
overestimates the true cost of a solution along the current path through n. Admissible
heuristics are by nature optimistic because they think the cost of solving the problem is less
than it actually is. A second, slightly stronger condition called consistency (or sometimes
monotonicity) is required only for applications of A ∗ to graph search. A heuristic h(n) is
consistent if, for every node n and every successor n 0 of n generated by any action a, the
estimated cost of reaching the goal from n is no greater than the step cost of getting to n 0
plus the estimated cost of reaching the goal from n 0 : h(n) ≤ c(n, a, n0 ) + h(n 0 )
For an admissible heuristic, the inequality makes perfect sense: if there were a route from n
to G via n 0 that was cheaper than h(n), that would violate the property that h(n) is a lower
bound on the cost to reach G.
Optimality of A* the tree-search version of A∗ is optimal if h(n) is admissible, while the
graph-search version is optimal if h(n) is consistent. It follows that the sequence of nodes
expanded by A∗ using GRAPH-SEARCH is in nondecreasing order of f(n). Hence, the first
goal node selected for expansion must be an optimal solution because f is the true cost for
goal nodes (which have h = 0) and all later goal nodes will be at least as expensive. If C ∗ is
the cost of the optimal solution path, then we can say the following: ∗ A ∗ expands all
nodes with f(n) < C∗ ∗ A∗ might then expand some of the nodes right on the ”goal
contour” (where f(n) = C∗) before selecting a goal node. ∗ A∗ expands no nodes with
f(n) > C∗ No other optimal algorithm is guaranteed to expand fewer nodes than A ∗. The
catch is that, for most problems, the number of states within the goal contour search space is
still exponential in the length of the solution. The complexity of A ∗ often makes it
impractical to insist on finding an optimal solution. One can use variants of A ∗ that find
suboptimal solutions quickly, or one can sometimes design heuristics that are more accurate
but not strictly admissible. In any case, the use of a good heuristic still provides enormous
savings compared to the use of an uninformed search.
3. Memory-bounded heuristic search. The simplest way to reduce memory requirements for
A∗ is to adapt the idea of iterative deepening to the heuristic search context, resulting in the
iterative-deepening A∗ (IDA*). Recursive best-first search (RBFS) is a simple recursive
algorithm that attempts to mimic the operation of standard best-first search, but using only
linear space. RBFS is somewhat more efficient than IDA*, but still suffers from excessive
node regeneration. Like A∗ tree search, RBFS is an optimal algorithm if the heuristic
function h(n) is admissible. Its space complexity is linear in the depth of the deepest optimal
solution, but its time complexity is rather difficult to characterize: it depends both on the
accuracy of the heuristic function and on how often the best path changes as nodes are
expanded. IDA* and RBFS suffer from using too little memory. SMA* proceeds just like
A∗, expanding the best leaf until memory is full. At this point, it cannot add a new node to
the search tree without dropping an old one. SMA* always drops the worst leaf node—the
one with the highest f-value. Like RBFS, SMA* then backs up the value of the forgotten
node to its parent. In this way, the ancestor of a forgotten subtree knows the quality of the
best path in that subtree. With this information, SMA* regenerates the subtree only when all
other paths have been shown to look worse than the path it has forgotten. SMA* is complete
if there is any reachable solution—that is, if d, the depth of the shallowest goal node, is less
than the memory size (expressed in nodes). It is optimal if any optimal solution is reachable;
otherwise, it returns the best reachable solution.
Beyond Classical Search
In the above descussion we addressed a single category of problems: observable, deterministic,
known environments where the solution is a sequence of actions. In this section, when these
assumptions are relaxed are covered.
 Local search two key advantages: (1) they use very little memory—usually a constant
amount; and (2) they can often find reasonable solutions in large or infinite (continuous)
state spaces for which systematic algorithms are unsuitable.
 Local search algorithms are useful for solving pure optimization problems, in which the aim
is to find the best state according to an objective function.
 State-space landscape. A landscape has both ”location” (defined by the state) and
”elevation” (defined by the value of the heuristic cost function or objective function). If
elevation corresponds to cost, then the aim is to find the lowest valley—a global minimum;
if elevation corresponds to an objective function, then the aim is to find the highest peak—a
global maximum.
A complete local search algorithm always finds a goal if one exists; an optimal algorithm always
finds a global minimum/maximum.
1. Hill-climbing search. It is simply a loop that continually moves in the direction of
increasing value—that is, uphill. It terminates when it reaches a ”peak” where no neighbor
has a higher value. Hill climbing does not look ahead beyond the immediate neighbors of
the current state. Hill climbing is sometimes called greedy local search because it grabs a
good neighbor state without thinking ahead about where to go next. It often gets stuck for
the following reasons:
✔ Local maxima.
✔ Ridges.
✔ Plateaux.
 Stochastic hill climbing chooses at random from among the uphill moves; the probability
of selection can vary with the steepness of the uphill move. This usually converges more
slowly than steepest ascent, but in some state landscapes, it finds better solutions.
 First-choice hill climbing implements stochastic hill climbing by generating successors
randomly until one is generated that is better than the current state. This is a good strategy
when a state has many (e.g., thousands) of successors.
 Random-restart hill climbing conducts a series of hill-climbing searches from randomly
generated initial states, until a goal is found. It is trivially complete with probability
approaching 1, because it will eventually generate a goal state as the initial state. If each hill-
climbing search has a probability p of success, then the expected number of restarts required
is 1/p.
2. Simulated annealing solution is to start by shaking hard (i.e., at a high temperature) and
then gradually reduce the intensity of the shaking (i.e., lower the temperature). The
innermost loop of the simulated-annealing algorithm is quite similar to hill climbing. Instead
of picking the best move, however, it picks a random move. If the move improves the
situation, it is always accepted. Otherwise, the algorithm accepts the move with some
probability less than 1. The probability decreases exponentially with the ”badness” of the
move—the amount ∆E by which the evaluation is worsened. The probability also decreases
as the ”temperature” T goes down: ”bad” moves are more likely to be allowed at the start
when T is high, and they become more unlikely as T decreases. If the schedule lowers T
slowly enough, the algorithm will find a global optimum with probability approaching 1.
3. Local beam search keeps track of k states rather than just one. It begins with k randomly
generated states. At each step, all the successors of all k states are generated. If any one is a
goal, the algorithm halts. Otherwise, it selects the k best successors from the complete list
and repeats. In a local beam search, useful information is passed among the parallel search
threads.
4. Genetic algorithm (or GA) is a variant of stochastic beam search in which successor
states are generated by combining two parent states rather than by modifying a single state.
GAs begin with a set of k randomly generated states, called the population. Each state is
rated by the objective function, or (in GA terminology) the fitness function. A fitness
function should return higher values for better states. Then two pairs are selected at random
for reproduction, in accordance with the probability in previous step. For each pair to be
mated, a crossover point is chosen randomly from the positions in the string. Then offspring
themselves are created by crossing over the parent strings at the crossover point. It is often
the case that the population is quite diverse early on in the process, so crossover (like
simulated annealing) frequently takes large steps in the state space early in the search
process and smaller steps later on when most individuals are quite similar. Finally each
location is subject to random mutation with a small independent probability.
An optimization problem is constrained if solutions must satisfy some hard constraints on the values
of the variables.
Searching with Nondeterministic Actions. Solutions for nondeterministic problems can contain
nested if–then–else statements; this means that they are trees rather than sequences. In a
deterministic environment, the only branching is introduced by the agent’s own choices in each
state. We call these nodes OR nodes. In a nondeterministic environment, branching is also
introduced by the environment’s choice of outcome for each action. We call these nodes AND
nodes. A solution for an AND–OR search problem is a subtree that (1) has a goal node at every leaf,
(2) specifies one action at each of its OR nodes, and (3) includes every outcome branch at each of
its AND nodes.
Searching with Partial Observations. To solve sensorless problems, we search in the space of
belief states rather than physical states. Suppose the underlying physical problem P is defined by
ACT IONSP , RESULTP , GOAL − T ESTP , and ST EP − COSTP . Then we can define the
corresponding sensorless problem as follows:
✔ Belief states: The entire belief-state space contains every possible set of physical states. If P
has N states, then the sensorless problem has up to 2 N states, although many may be
unreachable from the initial state.
✔ Initial state: Typically the set of all states in P , although in some cases the agent will have
more knowledge than this.
✔ Actions: This is slightly tricky. Suppose the agent is in belief state b = s1, s2, but ACT
IONSP (s1) 6= ACT IONSP (s2); then the agent is unsure of which actions are legal. It can
either take and union of the actions or the intersection.
✔ Transition model: The agent doesn’t know which state in the belief state is the right one; so
as far as it knows, it might get to any of the states resulting from applying the action to one
of the physical states in the belief state.
✔ Goal test: The agent wants a plan that is sure to work, which means that a belief state
satisfies the goal only if all the physical states in it satisfy GOAL− T ESTP .
✔ Path cost: This is also tricky. If the same action can have different costs in different states,
then the cost of taking an action in a given belief state could be one of several values.
The preceding definitions enable the automatic construction of the belief-state problem formulation
from the definition of the underlying physical problem. Once this is done, we can apply any of the
search algorithms.
• Online search. Online search is a good idea in dynamic or semidynamic domains—domains
where there is a penalty for sitting around and computing too long. Online search is a necessary idea
for unknown environments, where the agent does not know what states exist or what its actions do.
In this state of ignorance, the agent faces an exploration problem and must use its actions as
experiments in order to learn enough to make deliberation worthwhile. We stipulate that the agent
knows only the following:
✔ ACT IONS(s), which returns a list of actions allowed in state s
✔ The step-cost function c(s, a, s0 )—note that this cannot be used until the agent knows that s
0 is the outcome
✔ GOAL − T EST(s)
Note in particular that the agent cannot determine RESULT(s, a) except by actually being in s and
doing a. Typically, the agent’s objective is to reach a goal state while minimizing cost. The cost is
the total path cost of the path that the agent actually travels. It is common to compare this cost with
the path cost of the path the agent would follow if it knew the search space in advance—that is, the
actual shortest path. In the language of online algorithms, this is called the competitive ratio; we
would like it to be as small as possible. No algorithm can avoid dead ends in all state spaces. No
bounded competitive ratio can be guaranteed if there are paths of unbounded cost.
Adversarial Search
A game can be formally defined as a kind of search problem with the following elements:
✔ S0: The initial state, which specifies how the game is set up at the start.
✔ PLAY ER(s): Defines which player has the move in a state.
✔ ACTIONS(s): Returns the set of legal moves in a state.
✔ RESULT(s, a): The transition model, which defines the result of a move.
✔ TERMINAL−TEST(s): A terminal test, which is true when the game is over and false
otherwise. States where the game has ended are called terminal states.
✔ UTILITY (s, p): A utility function (also called an objective function or payoff function),
defines the final numeric value for a game that ends in terminal state s for a player p. In
chess, the outcome is a win, loss, or draw, with values +1, 0, or 1/2 . Some games have a
wider variety of possible outcomes. A zero-sum game is (confusingly) defined as one where
the total payoff to all players is the same for every instance of the game. Chess is zero-sum
because every game has payoff of either 0 + 1, 1 + 0 or 1/2 + 1/2. ”Constant-sum” would
have been a better term, but zero-sum is traditional and makes sense if you imagine each
player is charged an entry fee of 1/2.
• Given a choice, MAX prefers to move to a state of maximum value, whereas MIN prefers a state
of minimum value. The minimax algorithm performs a complete depth-first exploration of the game
tree. If the maximum depth of the tree is m and there are b legal moves at each point, then the time
complexity of the minimax algorithm is O(b m). The space complexity is O(bm) for an algorithm
that generates all actions at once, or O(m) for an algorithm that generates actions one at a time.
1. Alpha-Beta Pruning The problem with minimax search is that the number of game states it
has to examine is exponential in the depth of the tree. When applied to a standard minimax
tree, it returns the same move as minimax would, but prunes away branches that cannot
possibly influence the final decision. Minimax search is depth-first, so at any one time we
just have to consider the nodes along a single path in the tree. Alpha–beta pruning gets its
name from the following two parameters that describe bounds on the backed-up values that
appear anywhere along the path:
✔ α = the value of the best (i.e., highest-value) choice we have found so far at
any choice point along the path for MAX.
✔ β = the value of the best (i.e., lowest-value) choice we have found so far at
any choice point along the path for MIN.
The effectiveness of alpha–beta pruning is highly dependent on the order in which the states
are examined. This suggests that it might be worthwhile to try to examine first the
successors that are likely to be best. If this can be done, then it turns out that alpha–beta
m/2
needs to examine only O(b ) nodes to pick the best move, instead of O(b m) for minimax.
Alpha–beta can solve a tree roughly twice as deep as minimax in the same amount of time.
If successors are examined in random order rather than best-first, the total number of nodes
examined will be roughly O(b 3m/4 ) for moderate b.
Evaluation functions should order the terminal states in the same way as the true utility
function: states that are wins must evaluate better than draws, which in turn must be better
than losses. Otherwise, an agent using the evaluation function might err even if it can see
ahead all the way to the end of the game. Second, the computation must not take too long!
(The whole point is to search faster.) Third, for nonterminal states, the evaluation function
should be strongly correlated with the actual chances of winning. Most evaluation functions
work by calculating various features of the state. The features, taken together, define various
categories or equivalence classes of states: the states in each category have the same values
for all the features. The evaluation function should be applied only to positions that are
quiescent—that is, unlikely to exhibit wild swings in value in the near future.
2. Stochastic games. Positions do not have definite minimax values. Instead, we can only
calculate the expected value of a position: the average over all possible outcomes of the
chance nodes. As with minimax, the obvious approximation to make with expectiminimax is
to cut the search off at some point and apply an evaluation function to each leaf. One might
think that evaluation functions for games such as backgammon should be just like evaluation
functions for chess—they just need to give higher scores to better positions. But in fact, the
presence of chance nodes means that one has to be more careful about what the evaluation
values mean. If the program knew in advance all the dice rolls that would occur for the rest
of the game, solving a game with dice would be just like solving a game without dice, which
minimax does in O(bm) time, where b is the branching factor and m is the maximum depth of
the game tree. Because expectiminimax is also considering all the possible dice-roll
sequences, it will take O(bmnm), where n is the number of distinct rolls.
Partially observable games. Given a current belief state, one may ask, ”Can I win the
game?” For a partially observable game, the notion of a strategy is altered; instead of
specifying a move to make for each possible move the opponent might make, we need a
move for every possible percept sequence that might be received. In addition to guaranteed
checkmates, Kriegspiel admits an entirely new concept that makes no sense in fully
observable games: probabilistic checkmate. Such checkmates are still required to work in
every board state in the belief state; they are probabilistic with respect to randomization of
the winning player’s moves.
Constraint Satisfaction Problems
• A constraint satisfaction problem consists of three components, X, D, and C:
✔ X is a set of variables, {X1, ..., Xn}.
✔ D is a set of domains, {D1, ..., Dn}, one for each variable.
✔ C is a set of constraints that specify allowable combinations of values.
Each domain Di consists of a set of allowable values, {v1, ..., vk} for variable Xi . Each constraint
Ci consists of a pair < scope, rel >, where scope is a tuple of variables that participate in the
constraint and rel is a relation that defines the values that those variables can take on. A relation can
be represented as an explicit list of all tuples of values that satisfy the constraint, or as an abstract
relation that supports two operations: testing if a tuple is a member of the relation and enumerating
the members of the relation.
• To solve a CSP, we need to define a state space and the notion of a solution. Each state in a CSP 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 assigned, and a solution to a CSP is a
consistent, complete assignment. A partial assignment is one that assigns values to only some of the
variables.
• Why formulate a problem as a CSP? One reason is that the CSPs yield a natural representation for
a wide variety of problems; if you already have a CSP-solving system, it is often easier to solve a
problem using it than to design a custom solution using another search technique. In addition, CSP
solvers can be faster than state-space searchers because the CSP solver can quickly eliminate large
swatches of the search space. With CSPs, once we find out that a partial assignment is not a
solution, we can immediately discard further refinements of the partial assignment. Furthermore, we
can see why the assignment is not a solution—we see which variables violate a constraint—so we
can focus attention on the variables that matter. As a result, many problems that are intractable for
regular state-space search can be solved quickly when formulated as a CSP.
• Constraint hypergraph. constraints can be represented in a constraint hypergraph. A hypergraph
consists of ordinary nodes (the circles in the figure) and hypernodes (the squares), which represent
n-ary constraints.
• Preference constraints indicates which solutions are preferred, such problems are called constraint
optimization problem, or COP.
• Constraint propagation. In regular state-space search, an algorithm can do only one thing: search.
In CSPs there is a choice: an algorithm can search (choose a new variable assignment from several
possibilities) or do a specific type of inference called constraint propagation: using the constraints to
reduce the number of legal values for a variable, which in turn can reduce the legal values for
another variable, and so on.
• Node consistency. A single variable (corresponding to a node in the CSP network) is
nodeconsistent if all the values in the variable’s domain satisfy the variable’s unary constraints.
• Arc consistency. A variable in a CSP is arc-consistent if every value in its domain satisfies the
variable’s binary constraints. More formally, Xi is arc-consistent with respect to another variable Xj
if for every value in the current domain Di there is some value in the domain Dj that satisfies the
binary constraint on the arc (Xi , Xj ).
• Path consistency. A two-variable set {Xi , Xj} is path-consistent with respect to a third variable
Xm if, for every assignment {Xi = a, Xj = b} consistent with the constraints on {Xi , Xj}, there is
an assignment to Xm that satisfies the constraints on {Xi , Xm} and {Xm, Xj}. This 16 is called
path consistency because one can think of it as looking at a path from Xi to Xj with Xm in the
middle.
• K-consistency. A CSP is k-consistent if, for any set of k − 1 variables and for any consistent
assignment to those variables, a consistent value can always be assigned to any kth variable. 1-
consistency says that, given the empty set, we can make any set of one variable consistent: this is
what we called node consistency. 2-consistency is the same as arc consistency. For binary constraint
networks, 3-consistency is the same as path consistency.
• Commutativity. A problem is commutative if the order of application of any given set of actions
has no effect on the outcome. CSPs are commutative because when assigning values to variables,
we reach the same partial assignment regardless of order. Therefore, we need only consider a single
variable at each node in the search tree.
• Backtracking search. The term backtracking search is used for a depth-first search that chooses
values for one variable at a time and backtracks when a variable has no legal values left to assign. It
repeatedly chooses an unassigned variable, and then tries all values in the domain of that variable in
turn, trying to find a solution. If an inconsistency is detected, then BACKTRACK returns failure,
causing the previous call to try another value.
• Variable and value ordering. Intuitive idea—choosing the variable with the fewest ”legal” values
—is called the minimum-remaining-values (MRV) heuristic. The MRV heuristic doesn’t help at all
in choosing the first region to color in Australia, because initially every region has three legal
colors. In this case, the degree heuristic comes in handy. It attempts to reduce the branching factor
on future choices by selecting the variable that is involved in the largest number of constraints on
other unassigned variables. Once a variable has been selected, the algorithm must decide on the
order in which to examine its values. For this, the leastconstraining-value heuristic can be effective
in some cases. It prefers the value that rules out the fewest choices for the neighboring variables in
the constraint graph.
• Local search for CSPs. Local search algorithms turn out to be effective in solving many CSPs.
They use a complete-state formulation: the initial state assigns a value to every variable, and the
search changes the value of one variable at a time. In choosing a new value for a variable, the most
obvious heuristic is to select the value that results in the minimum number of conflicts with other
variables—the min-conflicts heuristic. Roughly speaking, n-queens is easy for local search because
solutions are densely distributed throughout the state space.

You might also like