UNIT 2 Problem solving Methods
 
  
 
    
  
   
    
 
    
UNIT 2
Problem solving Methods – Search Strategies- Uninformed – Informed – Heuristics – Local Search Algorithms and Optimization Problems - Searching with Partial Observations – Constraint Satisfaction Problems – Constraint Propagation - Backtracking Search – Game Playing – Optimal Decisions in Games – Alpha – Beta Pruning – Stochastic Games
2.1 PROBLEM SOLVING BY SEARCH
An important aspect of intelligence is goal-based problem solving.
The solution of many problems can be described by finding a sequence of actions that lead to a desirable goal. Each action changes the state and the aim is to find the sequence of actions and states that lead from the initial (start) state to a final (goal) state.
 A well-defined problem can be described
by: Initial state
A well-defined problem can be described
by: Initial state
·      
Operator or
successor function - for any state x returns s(x), the set of states reachable
from x with one action
·       State space - all states reachable from initial by any sequence of actions
·       Path - sequence through state space
·      
Path cost - function
that assigns a cost to a path. Cost of a path is the sum of costs of individual
actions along the path
·       Goal test - test to
determine if at goal state
What is Search?
Search is
the systematic examination of states to find path from the start/root state
to the goal
state.
The set of possible states,
together with operators defining their connectivity constitute the search space.
The output of a search algorithm is a solution, that is, a path from the initial state to a state that satisfies the goal test.
Problem-solving agents
A Problem solving agent is a goal-based agent. It decide what to do by finding sequence of actions that lead to desirable states. The agent can adopt a goal and aim at satisfying it.
To illustrate the agent’s behavior, let us take an example where our agent is in the city of Arad, which is in Romania. The agent has to adopt a goal of getting to Bucharest.
Goal formulation, based on the current situation and the agent’s performance measure, is the first step in problem solving.
The agent’s task is to find out which sequence of actions will get to a goal state.
Problem
formulation is the process of deciding what actions and states to
consider given a goal.
| Example: Route
  finding problem Referring to figure On holiday in Romania : currently in 
  Arad. Flight leaves
  tomorrow from Bucharest Formulate goal: be in Bucharest Formulate problem: states: various
  cities actions: drive between cities Find
  solution: sequence of cities,
  e.g., Arad, Sibiu,
  Fagaras, Bucharest | 
| Problem formulation | 
| A problem is defined by four items: initial state
  e.g.,
  “at Arad" successor function S(x) = set
  of action-state pairs
  e.g., S(Arad) = {[Arad - >Zerind;Zerind],….} goal test, can
  be explicit, e.g., x = at Bucharest" implicit, e.g., NoDirt(x) path cost
  (additive) e.g., sum of distances, number of actions executed, etc. c(x;
  a; y) is the step
  cost, assumed to be >= 0 A solution is a sequence of actions leading from the initial state to a goal
  state. | 
| Goal formulation and
  problem formulation | 
2.2 EXAMPLE PROBLEMS
The problem solving approach has been applied to a vast array of task environments. Some best known problems are summarized below. They are distinguished as toy or real-world problems
A toy problem is intended to illustrate various problem solving methods. It can be easily used by different researchers to compare the performance of algorithms.
A real world problem
is one whose solutions people actually care about.
2.3 TOY PROBLEMS
Vacuum World Example
o        
States: The agent
is in one of two locations,
each of which might or might not contain dirt. Thus there are 2 x 22 = 8
possible world states.
o        
Initial state: Any state
can be designated as initial
state.
o        
Successor function: This generates the legal states that results
from trying the three actions
(left, right, suck). The complete state space is shown in
figure
o        
Goal Test: This tests whether
all the squares are clean.
o        
Path test: Each step costs one, so that
the path cost is the number of steps in the
path.
Vacuum World State Space
| 
 | 
| Figure 2.1 The state
  space for the
  vacuum world. Arcs denote
  actions: L = Left,
  R = Right | 
The 8-puzzle
An 8-puzzle consists of a 3x3 board with eight numbered tiles and a blank space. A tile adjacent to the balank space can slide into the space. The object is to reach the goal state, as shown in Figure 2.4
Example: The 8-puzzle
| 
 | 
| Figure 2.2 A
  typical instance of
  8-puzzle | 
The problem formulation is as follows:
o        
States :
A state description specifies the location of each of the eight tiles and the blank
in one of the nine squares.
o        
Initial state : Any state can be designated as the initial state. It can be noted that any given
goal can be reached from
exactly half of the possible initial states.
o        
Successor function
: This generates
the legal states that result from trying
the four actions(blank moves Left, Right, Up or down).
o        
Goal Test : This checks whether
the state matches
the goal configuration shown in Figure(Other goal configurations are possible)
o        
Path cost : Each step costs 1,so
the path cost is the number of steps in
the path.
The 8-puzzle belongs to the family of sliding-block puzzles, which are often used as test problems for new search algorithms in AI. This general class is known as NP-complete. The 8-puzzle has 9!/2 = 181,440 reachable states and is easily solved.
The 15 puzzle ( 4 x 4 board ) has around 1.3 trillion states, an the random instances can be solved optimally in few milli seconds by the best search algorithms.
The 24-puzzle (on a 5 x 5 board) has around 1025 states and random instances are still quite difficult to solve optimally with current machines and algorithms.
8-Queens problem
The goal of 8-queens problem is to place 8 queens on the chessboard such that no queen attacks any other.(A queen attacks any piece in the same row, column or diagonal).
Figure 2.3 shows an attempted solution that fails: the queen in the right most column is attacked by the queen at the top left.
An Incremental formulation involves operators that augments the state description, starting with an empty state. For 8-queens problem, this means each action adds a queen to the state. A complete-state formulation starts with all 8 queens on the board and move them around. In either case the path cost is of no interest because only the final state counts.
| 
 | 
| Figure 2.3
  8-queens problem | 
The first incremental formulation one might try is the following:
o  
States: Any arrangement of 0 to 8 queens
on board is a state.
o  
Initial state: No
queen on the board.
o  
Successor function: Add a queen to any
empty square.
o  
Goal Test: 8 queens are on the board, none attacked.
In this formulation, we have 64.63…57 = 3 x 1014 possible sequences to investigate.
A better formulation would prohibit placing a queen in any square that is already attacked.
o  
States :
Arrangements of n queens (
0 <= n < = 8 ),one per column in the left most columns, with no queen attacking another are states.
o  
Successor function
: Add a queen to any square
in the left most empty column such
that it is not attacked by
any other queen.
This formulation reduces the 8-queen state space from 3 x 1014 to just 2057,and solutions are easy to find.
For the 100 queens the initial formulation has roughly 10400 states whereas the improved formulation has about 1052 states. This is a huge reduction, but the improved state space is still too big for the algorithms to handle.
2.4 REAL-WORLD PROBLEMS ROUTE-FINDING PROBLEM
Route-finding problem is defined in terms of specified locations and transitions along links between them. Route-finding algorithms are used in a variety of applications, such as routing in computer networks, military operations planning, and airline travel planning systems.
2.5 AIRLINE TRAVEL PROBLEM
The airline
travel problem is specifies
as follows:
o        
States: Each is represented by a location
(e.g., an airport)
and the current time.
o        
Initial state:
This is specified by the problem.
o        
Successor
function: This returns the states resulting from taking any scheduled
flight (further specified by seat class and location),leaving later than the current time plus the within-airport transit time, from the current
airport to another.
o        
Goal Test: Are we at the destination by some prespecified time?
o        
Path cost: This depends
upon the monetary
cost, waiting time,
flight time, customs
and immigration procedures,
seat quality, time of date, type of air plane, frequent-flyer mileage
awards, and so on.
2.6 TOURING PROBLEMS
Touring problems are closely related to route-finding problems, but with an important difference. Consider for example, the problem, “Visit every city at least once” as shown in Romania map.
As with route-finding the actions correspond to trips between adjacent cities. The state space, however, is quite different.
The initial state would be “In Bucharest; visited{Bucharest}”.
A typical intermediate state would be “In Vaslui;visited {Bucharest, Urziceni,Vaslui}”. The goal test would check whether the agent is in Bucharest and all 20 cities have been
visited.
2.7 THE TRAVELLING SALESPERSON PROBLEM(TSP)
Is a touring problem in which each city must be visited exactly once. The aim is to find the shortest tour. The problem is known to be NP-hard. Enormous efforts have been expended to improve the capabilities of TSP algorithms. These algorithms are also used in tasks such as planning movements of automatic circuit-board drills and of stocking machines on shop floors.
VLSI layout
A VLSI layout problem requires positioning millions of components and connections on a chip to minimize area, minimize circuit delays, minimize stray capacitances, and maximize manufacturing yield. The layout problem is split into two parts: cell layout and channel routing.
ROBOT navigation
ROBOT navigation is a generalization of the route-finding problem. Rather than a discrete set of routes, a robot can move in a continuous space with an infinite set of possible actions and states. For a circular Robot moving on a flat surface, the space is essentially two- dimensional. When the robot has arms and legs or wheels that also must be controlled, the search space becomes multi-dimensional. Advanced techniques are required to make the search space finite.
2.8 AUTOMATIC ASSEMBLY SEQUENCING
The example includes assembly of intricate objects such as electric motors. The aim in assembly problems is to find the order in which to assemble the parts of some objects. If the wrong order is choosen, there will be no way to add some part later without undoing some work already done. Another important assembly problem is protein design, in which the goal is to find a sequence of Amino acids that will be fold into a three-dimensional protein with the right properties to cure some disease.
2.9 INTERNET SEARCHING
In recent years there has been increased demand for software robots that perform Internet searching, looking for answers to questions, for related information, or for shopping deals. The searching techniques consider internet as a graph of nodes(pages) connected by links.
Different Search Algorithm
| 
 | 
| Figure 2.4 Different Search Algorithms | 
2.10       
UNINFORMED SEARCH
STRATGES
Uninformed Search Strategies have no additional information about states beyond
that provided in the problem
definition.
called
Strategies that know whether one non goal state is “more promising” than another are
Informed search or heuristic search strategies.
There are five uninformed search strategies as given below.
o  
Breadth-first search
o  
Uniform-cost search
o  
Depth-first search
o  
Depth-limited search
o  
Iterative deepening search
Breadth-first search
o       
Breadth-first search is a simple strategy in which the
root node is expanded first, then all
successors of the root node are expanded next, then their successors, and so
on. In general, all the nodes are expanded
at a given depth in the search tree before
any nodes at the next level are expanded.
o       
Breath-first-search is implemented by calling TREE-SEARCH
with an empty fringe that is a first-in-first-out (FIFO) queue, assuring
that the nodes that are visited first will be expanded first. In otherwards,
calling TREE-SEARCH (problem, FIFO-QUEUE())
results in breadth-first-search. The FIFO queue puts all newly generated
successors at the end of the queue,
which means that Shallow nodes are expanded before deeper nodes.
| 
 | 
 | 
 | 
 | 
| Figure 2.5 Breadth-first search on a simple binary tree. At each
  stage, the node to be expanded next is indicated by a
  marker. | |||
Properties of breadth-first-search
| 
 | 
| Figure 2.6 Breadth-first-search properties | 
Time complexity for BFS
Assume every state has b successors. The root of the search tree generates b nodes at the first level, each of which generates b more nodes, for a total of b2 at the second level. Each of these generates b more nodes, yielding b3 nodes at the third level, and so on. Now suppose, that the solution is at depth d. In the worst case, we would expand all but the last node at level d, generating bd+1 - b nodes at level d+1.
Then the total number of nodes generated is b + b2 + b3 + …+ bd + ( bd+1 + b) = O(bd+1).
Every node that is generated must remain in memory, because it is either part of the fringe or is an ancestor of a fringe node. The space compleity is, therefore, the same as the time complexity
2.11 UNIFORM-COST SEARCH
Instead of expanding the shallowest node, uniform-cost search expands the node n with the lowest path cost. Uniform-cost search does not care about the number of steps a path has, but only about their total cost.
 
  
 
    
  
   
    
 
    
2.12 DEPTH-FIRST-SEARCH
Depth-first-search always expands the deepest node in the current fringe of the search tree. The progress of the search is illustrated in Figure 1.31. The search proceeds immediately to the deepest level of the search tree, where the nodes have no successors. As those nodes are expanded, they are dropped from the fringe, so then the search “backs up” to the next shallowest node that still has unexplored successors.
| 
 | 
 | 
 | 
| 
 | 
 | 
 | 
| 
 | 
 | 
 | 
| 
 | 
 | 
 | 
| Figure 2.7 Depth-first-search on a binary tree.
  Nodes that have been expanded and have node
  scendants in the fringe can be removed from the memory; these are shown in black.
  Nodes at depth 3 are assumed
  to have no successors and M is the only goal node. | ||
This strategy can be implemented by TREE-SEARCH with a last-in-first-out (LIFO) queue, also known as a stack.
Depth-first-search has very modest memory requirements. It needs to store only a single path from the root to a leaf node, along with the remaining unexpanded sibling nodes for each node on the path. Once the node has been expanded, it can be removed from the memory, as soon as its descendants have been fully explored (Refer Figure 2.7).
For a state space with a branching factor b and maximum depth m, depth-first-search requires storage of only bm + 1 nodes.
Using the same assumptions as Figure, and assuming that nodes at the same depth as the goal node have no successors, we find the depth-first-search would require 118 kilobytes instead of 10 petabytes, a factor of 10 billion times less space.
Drawback of Depth-first-search
The drawback of depth-first-search is that it can make a wrong choice and get stuck going down very long(or even infinite) path when a different choice would lead to solution near the root of the search tree. For example, depth-first-search will explore the entire left subtree even if node C is a goal node.
2.12 BACKTRACKING SEARCH
A variant of depth-first search called backtracking search uses less memory and only one successor is generated at a time rather than all successors.; Only O(m) memory is needed rather than O(bm)
DEPTH-LIMITED-SEARCH
| 
 | 
| Figure 2.8 Depth-limited-search | 
The problem of unbounded trees can be alleviated by supplying depth-first-search with a pre- determined depth limit l. That is, nodes at depth l are treated as if they have no successors. This approach is called depth-limited-search. The depth limit soves the infinite path problem.
Depth limited search will be nonoptimal if we choose l > d. Its time complexity is O(bl) and its space complete is O(bl). Depth-first-search can be viewed as a special case of depth- limited search with l = oo Sometimes, depth limits can be based on knowledge of the problem. For, example, on the map of Romania there are 20 cities. Therefore, we know that if there is a solution, it must be of length 19 at the longest, So l = 10 is a possible choice. However, it can be shown that any city can be reached from any other city in at most 9 steps. This number known as the diameter of the state space, gives us a better depth limit.
Depth-limited-search can be implemented as a simple modification to the general tree- search algorithm or to the recursive depth-first-search algorithm. The pseudocode for recursive depth- limited-search is shown in Figure.
It can be noted that the above algorithm can terminate with two kinds of failure : the standard failure value indicates no solution; the cutoffvalue indicates no solution within the depth limit. Depth-limited search = depth-first search with depth limit l,returns cut off if any path is cut off by depth limit
| function Depth-Limited-Search( problem, limit) returns a
  solution/fail/cutoff return Recursive-DLS(Make-Node(Initial-State[problem]), problem, limit) function
  Recursive- DLS(node, problem, limit) returns solution/fail/cutoff cutoff-occurred?                                                                                                       false if Goal-Test(problem,State[node]) then
  return Solution(node) else if Depth[node] = limit then
  return cutoff else for each successor in
  Expand(node, problem) do result Recursive-DLS(successor, problem, limit) if result = cutoff then cutoff_occurred?true else if result not
  = failure then return result ifcutoff_occurred? then return cutoff else return
  failure | 
| Figure 2.9 Recursive implementation of Depth-limited-search | 
2.13 ITERATIVE DEEPENING DEPTH-FIRST SEARCH
Iterative deepening search (or iterative-deepening-depth-first-search) is a general strategy often used in combination with depth-first-search, that finds the better depth limit. It does this by gradually increasing the limit – first 0,then 1,then 2, and so on – until a goal is found. This will occur when the depth limit reaches d, the depth of the shallowest goal node. The algorithm is shown in Figure.
Iterative deepening 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 non decreasing function of the depth of the node.
Figure shows the four iterations of ITERATIVE-DEEPENING_SEARCH on a binary search tree, where the solution is found on the fourth iteration.
| 
 | 
| Figure 2.10 The iterative
  deepening search algorithm, which repeatedly applies depth-limited- search with increasing limits. It terminates
  when a solution is found or if the
  depth limited search returns failure, meaning that no solution exists. | 
| 
 | 
| Figure 2.11
  Four iterations of iterative deepening search on a binary tree | 
Iterative search is not as wasteful as it might seem
| 
 | 
| Figure 2.12
  Iterative search is not as wasteful as it might seem | 
Properties of iterative deepening search
| 
 | 
| Figure 2.13 Properties of iterative deepening search | 
Bidirectional Search
The idea behind bidirectional search is to run two simultaneous searches – one forward from the initial state and the other backward from the goal, stopping when the two searches meet in the middle
The motivation is that bd/2 + bd/2 much less than, or in the figure, the area of the two small circles is less than the area of one big circle centered on the start and reaching to the goal.
| 
 | 
| Figure 2.14 A schematic view of a bidirectional search that is about
  to succeed, when a Branch from the Start node
  meets a Branch from the
  goal node. | 
•               
Before moving into bidirectional search
let’s first understand a few terms.
•               
Forward Search: Looking in-front of the
end from start.
•               
Backward Search: Looking from end to the start back-wards.
•               
So Bidirectional Search as the name suggests is a
combination of forwarding and backward search.
Basically, if the average branching factor going out of node / fan-out,
if fan-out is less, prefer forward search. Else if the average branching
factor is going into a node/fan in is less (i.e. fan-out is more), prefer backward search.
•               
We must traverse
the tree from the start node and the goal node and wherever they meet the path from the start node to the goal through the intersection is the optimal
solution. The BS Algorithm is
applicable when generating predecessors is easy in both forward and backward
directions and there exist only 1 or fewer goal
states.
| 
 | 
| Figure 2.15
  Comparing Uninformed Search
  Strategies | 
| 
 | 
| Figure 2.16
  Evaluation of search strategies, b is the
  branching factor; d is the
  depth of the shallowest solution; m is the
  maximum depth of the search tree; l is the depth limit. Superscript caveats are as follows: a complete if b is finite; b
  complete
  if step costs >= E for positive
  E; c optimal if step costs are all identical; d if both directions use breadth-first search. | 
2.14 SEARCHING WITH PARTIAL INFORMATION
o       
Different types of incompleteness lead to three distinct problem types:
o       
Sensorless problems
(conformant):
If the agent has no sensors at all
o       
Contingency problem: if the environment if partially observable or if action
are uncertain (adversarial)
o       
Exploration problems: When the states and actions of the environment are unknown.
o       
No sensor
o Initial State(1,2,3,4,5,6,7,8)
o       
After action [Right] the state (2,4,6,8)
o       
After action [Suck] the state (4, 8)
o       
After action [Left] the state (3,7)
o       
After action [Suck] the state (8)
o       
Answer : [Right, Suck, Left, Suck] coerce the world into state 7 without any sensor
o       
Belief State: Such state that agent belief
to be there Partial knowledge of states and actions:
–              
sensorless or conformant problem
–     
Agent may have no idea where it is;
solution (if any) is a sequence.
–              
contingency problem
–     
Percepts provide new information about current state; solution is a tree or policy;
often interleave search and execution.
–     
If uncertainty is caused by actions
of another agent: adversarial
problem
–              
exploration problem
–     
When states and actions of the environment are unknown.
| 
 | 
| Figure 2.17
  states and actions of the environment are unknown | 
| 
 | 
| Figure 2.18 states
  and actions | 
Contingency, start in {1,3}.
Murphy’s law, Suck can dirty a clean carpet. Local sensing: dirt, location only.
–     
Percept = [L,Dirty]
={1,3}
– [Suck] = {5,7}
– [Right] ={6,8}
–     
[Suck] in {6}={8}
(Success)
–                 
BUT [Suck] in {8} = failure Solution??
–     
Belief-state: no fixed action sequence guarantees
solution Relax requirement:
–     
[Suck, Right, if [R,dirty] then
Suck]
–     
Select actions based
on contingencies arising
during execution.
Time and space complexity are always considered with respect to some measure of the problem difficulty. In theoretical computer science, the typical measure is the size of the state space.
In AI, where the graph is represented implicitly by the initial state and successor function, the complexity is expressed in terms of three quantities:
b, the branching factor or maximum number of successors of any node;
d, the depth of the shallowest
goal node; and
m, the maximum length of any path in the state space.
Search-cost - typically depends upon the time complexity but can also include the term for memory usage.
Total–cost – It combines the search-cost and the path cost of the solution found.
2.15 INFORMED SEARCH AND EXPLORATION Informed (Heuristic) Search Strategies
Informed search strategy is one that uses problem-specific knowledge beyond the definition of the problem itself. It can find solutions more efficiently than uninformed strategy.
Best-first search
Best-first search is an instance of general TREE-SEARCH or GRAPH-SEARCH algorithm in which a node is selected for expansion based on an evaluation function f(n). The node with lowest evaluation is selected for expansion, because the evaluation measures the distance to the goal.
This can be implemented using a priority-queue, a data structure that will maintain the fringe in ascending order of f-values.
2.16 HEURISTIC FUNCTIONS
A heuristic function or simply a heuristic is a function that ranks alternatives in various search algorithms at each branching step basing on an available information in order to make a decision which branch is to be followed during a search.
The key
component of Best-first search algorithm is a heuristic function, denoted by h(n): h(n) = estimated cost of the cheapest path from node n
to a goal node.
For example, in Romania, one might estimate the cost of the cheapest path from Arad to Bucharest via a straight-line distance from Arad to Bucharest (Figure 2.19).
Heuristic function are the most common form in which additional knowledge is imparted to the search algorithm.
Greedy Best-first search
Greedy best-first search tries to expand the node that is closest to the goal, on the grounds that this is likely to a solution quickly.
It evaluates the nodes by using the heuristic function f(n) = h(n).
Taking the example of Route-finding problems in Romania, the goal is to reach Bucharest starting from the city Arad. We need to know the straight-line distances to Bucharest from various cities as shown in Figure. For example, the initial state is In(Arad),and the straight line distance heuristic hSLD (In(Arad)) is found to be 366.
Using the straight-line distance
heuristic hSLD, the goal state can be reached
faster.
| 
 | 
| Figure 2.19 Values of hSLD -
  straight line distances to Bucharest | 
| 
 
 
 
 | 
| Figure 2.20
  progress of greedy best-first search | 
Figure shows the progress of greedy best-first search using hSLD to find a path from Arad to Bucharest. The first node to be expanded from Arad will be Sibiu, because it is closer to Bucharest than either Zerind or Timisoara. The next node to be expanded will be Fagaras, because it is closest. Fagaras in turn generates Bucharest, which is the goal.
Properties of greedy search
o       
Complete: No–can get stuck in loops,
e.g., Iasi !Neamt !Iasi !Neamt !
Complete in finite space with repeated-state checking
o       
Time: O(bm), but a good heuristic can give dramatic improvement
o       
Space: O(bm) - keeps all nodes in memory
o       
Optimal: No
Greedy best-first search is not optimal, and it is incomplete.
The worst-case time and space complexity is O(bm),where m is the maximum depth of the search space.
A* SEARCH
A* Search is the most widely used form of best-first search. The evaluation function f(n) is obtained by combining
(1)    
g(n) = the cost to reach the node, and
(2)    
h(n) = the cost to get from the node to the
goal :
f(n) = g(n) + h(n).
A* Search is both optimal and complete. A* is optimal if h(n) is an admissible heuristic. The obvious example of admissible heuristic is the straight-line distance hSLD. It cannot be an overestimate.
A* Search is optimal if h(n) is an admissible heuristic – that is, provided that h(n) never overestimates the cost to reach the goal.
An obvious example of an admissible heuristic is the straight-line distance hSLD that we used in getting to Bucharest. The progress of an A* tree search for Bucharest is shown in Figure
The values of ‘g ‘ are computed from the step costs shown in the Romania map(figure).
Also the values of hSLD are given in Figure
| 
 | 
| Figure 2.21
  A* Search | 
| 
 | 
| Figure 2.22
  Example A* Search | 
2.17 LOCAL SEARCH ALGORITHMS AND OPTIMIZATION PROBLEMS
o       
In many optimization problems, the path to the goal is irrelevant; the goal state itself is the
solution
o       
For example, in the 8-queens problem,
what matters is the final configuration of queens, not the order in which they are added.
o       
In such cases, we can use local search algorithms. They operate using a single current
state (rather than multiple
paths) and generally move only to neighbors of that state.
o       
The important applications of these class of problems are (a) integrated-circuit design,
(b) Factory-floor layout, (c) job-shop scheduling, (d) automatic programming, (e) telecommunications network optimization, (f) Vehicle routing, and (g) portfolio management.
Key advantages of Local Search Algorithms
(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.
2.18 OPTIMIZATION PROBLEMS
In addition
to finding goals, 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
To understand local search, it is better
explained using state space landscape as
shown in Figure.
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.
Local search algorithms explore this landscape. A complete local search algorithm always finds a goal if one exists; an optimal algorithm always finds a global minimum/maximum.
| 
 | 
| Figure 2.23 A one
  dimensional state space landscape in which elevation corresponds to the objective function. The aim is to
  find the global
  maximum. Hill climbing
  search modifies the current state to try to improve it, as shown by the arrow. The various topographic features are defined
  in the text | 
Hill-climbing search
The hill-climbing search algorithm as shown in figure, 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.
| function HILL-CLIMBING(
  problem) return a state that is a local
  maximum input: problem, a problem local variables: current, a node. neighbor, a node. current ←MAKE-NODE(INITIAL-STATE[problem]) loop do neighbor ← a highest valued
  successor of current if VALUE [neighbor] ≤ VALUE[current] then return STATE[current] current ←neighbor | 
| Figure 2.24 The
  hill-climbing search algorithm (steepest ascent version), which is the most basic local search technique.
  At each step the current node is replaced by
  the best neighbor; the neighbor with the highest VALUE. If the heuristic cost estimate h is used, we could find the neighbor with the
  lowest h. | 
Hill-climbing is sometimes
called greedy local search because
it grabs a good neighbor
state without thinking ahead about where to go next. Greedy algorithms
often perform quite well. Problems
with hill-climbing
Hill-climbing often gets stuck for the following reasons :
·               
Local
maxima: a local maximum is a peak that is higher than each of its
neighboring states, but lower than
the global maximum. Hill-climbing algorithms that reach the vicinity of a local maximum will be drawn
upwards towards the peak, but will then be
stuck with nowhere else to go
·               
Ridges: A ridge
is shown in Figure 2.10. Ridges results in a sequence of local maxima that is
very difficult for greedy algorithms
to navigate.
·               
Plateaux: A plateau
is an area of the state space landscape where the evaluation function is flat. It can be a flat local
maximum, from which no uphill exit exists, or a shoulder, from which
it is possible to make progress.
| 
 | 
| Figure 2.25 Illustration
  of why ridges cause difficulties for hill-climbing. The grid of states(dark circles) is superimposed on a ridge
  rising from left to right, creating
  a sequence of local maxima that are not directly connected to each
  other. From each local maximum, all the available
  options point downhill. | 
Hill-climbing variations
Ø  Stochastic hill-climbing
o  
Random selection among the uphill moves.
o  
The selection probability can vary with the steepness of the uphill move.
Ø  First-choice hill-climbing
o  
cfr. stochastic hill
climbing by generating successors randomly until a better
one is found.
Ø  Random-restart hill-climbing
o  
Tries to avoid
getting stuck in local
maxima.
Simulated annealing search
A hill-climbing algorithm that never makes “downhill” moves towards states with lower value (or higher cost) is guaranteed to be incomplete, because it can stuck on a local maximum. In contrast, a purely random walk –that is, moving to a successor choosen uniformly at random from the set of successors – is complete, but extremely inefficient.
Simulated annealing is an algorithm that combines hill-climbing with a random walk in someway that yields both efficiency and completeness.
Figure shows simulated annealing algorithm. It is quite similar to hill climbing. Instead of picking the best move, however, it picks the 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.
Simulated annealing was first used extensively to solve VLSI layout problems in the early 1980s. It has been applied widely to factory scheduling and other large-scale optimization tasks.
| 
 | 
| Figure 2.26 The simulated annealing search algorithm, a version of
  stochastic hill climbing where some downhill moves are allowed. | 
Genetic algorithms
A 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
Like beam search, Gas begin with a set of k randomly generated states, called the population. Each state, or individual, is represented as a string over a finite alphabet – most commonly, a string of 0s and 1s. For example, an 8 8-quuens state must specify the positions of 8 queens, each in a column of 8 squares, and so requires 8 x log2 8 = 24 bits.
| 
 | 
| Figure 2.27
  Genetic algorithm | 
Figure shows a population of four 8-digit strings representing 8-queen states. The production of the next generation of states is shown in Figure
In (b) each state
is rated by the evaluation function or the fitness function.
In (c),a random choice of two pairs is selected for reproduction, in accordance with the probabilities in (b).
Figure describes the algorithm that implements all these steps.
| function GENETIC_ALGORITHM( population, FITNESS-FN) return an individual input: population, a set of individuals FITNESS-FN, a function which determines the
  quality of the
  individual repeat new_population←empty set loop for ifrom 1
  to SIZE(population) do x ←RANDOM_SELECTION(population, FITNESS_FN) y ←RANDOM_SELECTION(population, FITNESS_FN) child ←REPRODUCE(x,y) if (small random probability) then child  MUTATE(child ) add child to new_population population
  ←new_population until some individual is fit
  enough or enough time has elapsed return the best individual | 
| Figure 2.28 A
  genetic algorithm. | 
2.29 CONSTRAINT SATISFACTION PROBLEMS(CSP)
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 D,of
possible values.
Each constraint Ci involves some subset of 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 objective
function.
Example for Constraint Satisfaction Problem
Figure shows the map of Australia showing each of its states and territories. We are given the task of coloring each region either red, green, or blue in such a way that the neighboring regions have the same color. To formulate this as CSP, we define the variable to be the regions
:WA,NT,Q,NSW,V,SA, and T. The domain of each variable is the set
{red,green,blue}.The constraints require neighboring regions to have distinct colors; for example, the allowable combinations for WA and NT are the pairs
{(red,green),(red,blue),(green,red),(green,blue),(blue,red),(blue,green)}.
The constraint can also be represented more succinctly as the inequality WA not = NT, provided the constraint satisfaction algorithm has some way to evaluate such expressions.) There are many possible solutions such as
{ WA = red, NT = green, Q = red, NSW = green, V = red,SA = blue,T = red}.
It is helpful to visualize a CSP as a constraint graph, as shown in Figure 2.29. The nodes of the graph corresponds to variables of the problem and the arcs correspond to constraints.
| 
 | 
| Figure 2.29 Principle
  states and territories of Australia. Coloring this map can be viewed
  as a constraint satisfaction problem. The goal is to assign colors to each region
  so that no neighboring regions have the same color. | 
| 
 
 | 
| Figure 2.30
  Mapping Problem | 
CSP can be viewed as a standard search problem as follows:
Ø   
Initial state: the empty assignment {},in
which all variables are unassigned.
Ø    Successor function: a value
can be assigned to any unassigned variable, provided that
it does not conflict with
previously assigned variables.
Ø    Goal test: the current assignment is complete.
Ø    Path cost: a constant
cost(E.g.,1) for every
step.
Every solution must be a complete assignment and therefore appears at depth n if there are n variables.
Depth first search algorithms are popular for CSPs
Varieties of CSPs
(i)                 
Discrete variables Finite domains
The simplest kind of CSP involves variables that are discrete and have finite domains. Map coloring problems are of this kind. The 8-queens problem can also be viewed as finite- domain
CSP, where the variables Q1,Q2,…..Q8 are the positions each queen in columns 1,….8 and each variable has the domain {1,2,3,4,5,6,7,8}. If the maximum domain size of any
variable in a CSP is d, then the number of possible complete assignments
is O(dn) – that is, exponential
in the number of variables. Finite domain CSPs include Boolean CSPs, whose variables can be
either true or false. Infinite domains
Discrete variables can also have infinite domains – for example, the set of integers or the set of strings. With infinite domains, it is no longer possible to describe constraints by enumerating all allowed combination of values. Instead a constraint language of algebric inequalities such as Startjob1 + 5 <= Startjob3.
(ii) CSPs with continuous domains
CSPs with continuous domains are very common in real world. For example in operation research field, the scheduling of experiments on the Hubble Telescope requires very precise timing of observations; the start and finish of each observation and manoeuvre are continuous-valued variables that must obey a variety of astronomical, precedence and power constraints. The best known category of continuous-domain CSPs is that of linear programming problems, where the constraints must be linear inequalities forming a convex region. Linear programming problems can be solved in time polynomial in the number of variables.
Varieties of constraints
(i)                 
unary constraints involve a single variable.
Example : SA # green
(ii)               
Binary constraints involve
paris of variables.
Example : SA # WA
(iii)             
Higher order constraints involve
3 or more variables. Example
:cryptarithmetic puzzles.
| S | 
| Figure 2.31 cryptarithmetic puzzles. | 
| 
 | 
| Figure 2.32
  Cryptarithmetic puzzles-Solution | 
| 
 | 
| Figure 2.33
  Numerical Solution | 
Backtracking Search for CSPs
The term backtracking search is used for depth-first search that chooses values for one variable at a time and backtracks when a variable has no legal values left to assign. The algorithm is shown in figure
| 
 | 
| Figure 2.34 A simple backtracking algorithm for constraint
  satisfaction problem. The algorithm
  is modeled on the recursive depth-first search | 
| 
 | 
| Figure 2.34 Part of the search tree generated by simple backtracking
  for the map- coloring problem | 
| 
 | 
| Figure
  2.35 Part of search tree generated by simple backtracking for the map coloring problem. | 
Forward checking
One way to make better use of constraints during search is called forward checking. Whenever a variable X is assigned, the forward checking process looks at each unassigned variable Y that is connected to X by a constraint and deletes from Y ’s domain any value that is inconsistent with the value chosen for X. Figure 5.6 shows the progress of a map-coloring search with forward checking.
| 
 | 
| Figure 2.36 The progress of a map-coloring search
  with forward checking. WA = red is assigned first; then forward
  checking deletes red from the
  domains of the neighboring
  variables NT and SA. After Q = green, green is deleted from the domain of NT,
  SA, and NSW. After V = blue, blue, is deleted from the domains of NSW and SA,
  leaving SA with no legal
  values. | 
Constraint propagation
Although forward checking detects many inconsistencies, it does not detect all of them.
Constraint propagation is the general term for propagating the implications of a constraint on one variable onto other variables.
Arc Consistency
| 
 | 
| Figure 2.37 Arc Consistency | 
| 
 | 
| Figure 2.38
  Arc Consistency –CSP | 
k-Consistency
Local Search for CSPs
 
  
 
    
  
   
    
 
    
The Structure of Problems Problem
Structure
 
  
 
    
  
   
    
 
    
Independent Subproblems
| 
 | 
| Figure 2.39 Independent Subproblems | 
Tree-Structured CSPs
| 
 | 
| Figure 2.40
  Tree-Structured CSPs | 
2.30 ADVERSARIAL SEARCH
Competitive environments, in which the agent’s goals are in conflict, give rise to
adversarial search problems – often known as games.
Games
Mathematical Game Theory, a branch of economics, views any multiagent environment as a game provided that the impact of each agent on the other is
“significant”, regardless of whether the agents are cooperative or competitive. In, AI, “games” are deterministic,
turn-taking, two-player, zero-sum games of perfect information. This means deterministic, fully observable environments in which there are two agents whose actions must alternate and in which
the utility values at
the end of the game are always
equal and opposite. For example, if one player
wins the game of chess(+1),the other player necessarily loses(-1). It is this opposition between the agents’ utility functions that makes the situation adversarial.
Formal Definition of Game
We will consider games with two players, whom we will call MAX and MIN. MAX moves first, and then they take turns moving until the game is over. At the end of the game, points are awarded to the winning player and penalties are given to the loser. A game can be formally defined as a search problem with the following components:
o       
The initial state, which includes
the board position and identifies the
player to move.
o       
A successor
function, which returns
a list of (move, state) pairs,
each indicating a legal move
and the resulting state.
o       
A terminal test,
which describes when the game is over. States where the game has ended are called
terminal states.
o       
A utility
function (also called an objective function or payoff function), which give
a numeric value for the terminal states.
In chess, the outcome is a win, loss, or draw, with values+1,-1, or 0. he
payoffs in backgammon range from +192
to -192.
Game Tree
The initial state and legal moves for each side define the game tree for the game. Figure 2.18 shows the part of the game tree for tic-tac-toe (noughts and crosses). From the initial state, MAX has nine possible moves. Play alternates between MAX’s placing an X and MIN’s placing a 0 until we reach leaf nodes corresponding to the terminal states such that one player has three in a row or all the squares are filled. He number on each leaf node indicates the utility value of the terminal state from the point of view of MAX; high values are assumed to be good for MAX and bad for MIN. It is the MAX’s job to use the search tree (particularly the utility of terminal states) to determine the best move.
| 
 | 
| Figure 2.41 A partial search tree. The top node is
  the initial state, and MAX move first,
  placing an X in an empty square. | 
Optimal Decisions in Games
In normal search problem, the optimal solution would be a sequence of move leading to a goal state – a terminal state that is a win. In a game, on the other hand, MIN has something
to say about it, MAX therefore must find a contingent strategy, which specifies MAX’s move in the initial state, then MAX’s moves in the states resulting from every possible response by MIN, then MAX’s moves in the states resulting from every possible response by MIN those moves, and so on. An optimal strategy leads to outcomes at least as good as any other strategy when one is playing an infallible opponent.
| 
 | 
| Figure 2.42
  Optimal Decisions in Games | 
| 
 | 
| Figure 2.43 MAX-VALUE
  and MIN-VALUE | 
| 
 | 
| Figure 2.44 An algorithm
  for calculating minimax decisions. It returns the action corresponding to the best possible move,
  that is, the move that leads to the outcome
  with the best utility, under the assumption that the opponent plays to
  minimize utility. The functions
  MAX-VALUE and MIN-VALUE go through the whole game tree, all the way
  to the leaves, to determine the backed-up value of a
  state. | 
The minimax Algorithm
The minimax algorithm computes the minimax decision from the current state. It uses a simple recursive computation of the minimax values of each successor state, directly implementing the defining equations. The recursion proceeds all the way down to the leaves of the tree, and then the minimax values are backed up through the tree as the recursion unwinds. For example in Figure 2.19,the algorithm first recourses down to the three bottom left nodes, and uses the utility function on them to discover that their values are 3, 12, and 8 respectively. Then it takes the minimum of these values, 3, and returns it as the backed-up value of node B. A similar process gives the backed up values of 2 for C and 2 for D. Finally, we take the maximum of 3, 2, and 2 to get the backed-up value of 3 at the root node. 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(bm). The space complexity is O(bm) for an algorithm that generates successors at once.
Alpha-Beta Pruning
The problem with minimax search is that the number of game states it has to examine is exponential in the number of moves. Unfortunately, we can’t eliminate the exponent, but
we can effectively cut it in half. By performing pruning, we can eliminate large part of the tree from consideration. We can apply the technique known as alpha beta pruning, when applied to a minimax tree, it returns the same move as minimax would, but prunes away branches that cannot possibly influence the final decision.
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:
o   
α : the value of the best (i.e., highest-value) choice we have found so far at any choice
point along the path of MAX.
o   
β: the value of best (i.e., lowest-value) choice we have found so far at any choice
point along the path of MIN.
Alpha Beta search updates the values of α and β as it goes along and prunes the remaining branches at anode(i.e., terminates the recursive call) as soon as the value of the current node is known to be worse than the current α and β value for MAX and MIN, respectively. The complete algorithm is given in Figure. The effectiveness of alpha-beta pruning is highly dependent on the order in which the successors are examined. It might be worthwhile to try to examine first the successors that are likely to be the best. In such case, it turns out that alpha-beta needs to examine only O(bd/2) nodes to pick the best move, instead of O(bd) for minimax. This means that the effective branching factor becomes sqrt(b) instead of b – for chess,6 instead of 35. Put an other way alpha-beta cab look ahead roughly twice as far as minimax in the same amount of time.
 
  
 
    
  
   
    
 
    
| 
 | 
| Figure 2.45 The alpha
  beta search algorithm. These routines are the same
  as the minimax routines in figure 2.20,except
  for the two lines in each of MIN-VALUE and MAX-VALUE that maintain α and β | 
Key points in Alpha-beta Pruning
·               
Alpha: Alpha is the best choice or the highest
value that we have found
at any instance along the path
of Maximizer. The initial value for alpha
is – ∞.
·               
Beta: Beta is the best choice or the lowest value that
we have found at any instance along the path
of Minimizer. The initial value for alpha is + ∞.
·               
The condition for Alpha-beta Pruning
is that α >= β.
·               
Each node has to keep track of its alpha and beta
values. Alpha can be updated only when it’s MAX’s turn and, similarly, beta can be updated only when it’s MIN’s chance.
·               
MAX will update only alpha values and MIN player will update only beta values.
·               
The node values will be passed to upper nodes instead
of values of alpha and beta during
go into reverse of tree.
·               
Alpha and Beta values only be passed
to child nodes.
Working of Alpha-beta Pruning
1.             
We will first start with the initial move. We will
initially define the alpha and beta values as the worst case i.e. α = -∞ and β= +∞. We will prune the node only when alpha
becomes greater than or equal
to beta.
| 
 | 
| Figure 2.46
  Step 1 Alpha-beta Pruning | 
2.             
Since the initial value of alpha is less than beta so
we didn’t prune it. Now it’s turn for MAX.
So, at node D, value of alpha will be calculated. The value of alpha at node D will be max (2, 3). So, value of alpha at node D will be 3.
3.             
Now the next move will be on node B and its turn for
MIN now. So, at node B, the value of alpha beta will be min (3, ∞). So, at node B values
will be alpha= – ∞ and beta will
be 3.
| 
 | 
| Figure 2.47
  Step 2 Alpha-beta Pruning | 
In the next step, algorithms traverse the next successor of Node B which is node E, and the values of α= -∞, and β= 3 will also be passed.
4.             
Now it’s turn for MAX. So, at node E we will look for
MAX. The current value of alpha at E
is – ∞ and it will be compared with 5. So, MAX (- ∞, 5) will be 5. So, at node E,
alpha = 5, Beta = 5. Now as we can see that alpha
is greater than beta which is satisfying
the pruning condition so we can prune the right successor of node E and algorithm
will not be traversed and the value at node E
will be 5.
| 
 | 
| Figure 2.48
  Step 3 Alpha-beta Pruning | 
6.             
In the next step the algorithm again comes to node A
from node B. At node A alpha will be
changed to maximum value as MAX (- ∞, 3). So now the value of alpha and beta at node A will be (3, + ∞)
respectively and will be transferred to node C. These same values will be
transferred to node F.
7.             
At node F the value of alpha will be compared to the
left branch which is 0. So, MAX (0,
3) will be 3 and then compared with the right child which is 1, and MAX (3,1) =
3 still α remains 3, but the
node value of F will become 1.
| 
 | 
| Figure 2.49
  Step 4 Alpha-beta Pruning | 
8.             
Now node F will return
the node value 1 to C and will compare
to beta value
at C. Now its turn for
MIN. So, MIN (+ ∞, 1) will be 1. Now at node C, α= 3, and β= 1 and alpha is greater than beta which again
satisfies the pruning condition. So, the next successor of node C i.e.
G will be pruned
and the algorithm didn’t
compute the entire subtree
G.
| 
 | 
| Figure 2.50
  Step 5 Alpha-beta Pruning | 
Now, C will return the node value to A and the best value of A will be MAX (1, 3) will be 3.
| 
 | 
| Figure 2.51
  Step 6 Alpha-beta Pruning | 
The above represented tree is the final tree which is showing the nodes which are computed and the nodes which are not computed. So, for this example the optimal value of the maximizer will be 3.




































































 
Comments
Post a Comment