Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 20

1)Algorithm: Generate-andTest

1. Generate a possible solution. (May be a particular point in the problem space or a path from the start state.) 2. Test to see if this is actually a solution by comparing the chosen point or endpoint of the chosen path to the set of acceptable goal states. 3. If a solution has been found, quit. Else return to step 1.

2)Algorithm: Simple Hill Climbing


1. Evaluate the initial state. If it is goal state, return and quit. Else continue with the initial state as the current state. 2. Loop until a solution is found or until there are no more operators to be applied to current state: a)Select an operator that has not yet been applied to the current state and apply it to produce a new state. b) Evaluate the new state: a)if it is goal state, then return and quit. b) else if it is better than the current state, make it the current state. c) if not better than current state, continue in the loop.

3)Algorithm: Steepest-Ascent Hill Climbing 1. Evaluate the initial state.


If its a goal state, return and quit. Otherwise continue with the initial state as the current state. 2. Loop until a solution is found or until a complete iteration produces no change to current state: A) Let SUCC be a state such that any possible successor of the current state is better than SUCC. B) For each operator that applies to the current state do: a)Apply the operator and generate a new state.

b)Evaluate the new state. If goal state, return and quit. Else compare it to SUCC. If its better, set SUCC to this state. C) If the SUCC is better than current state, set current state to SUCC.

4)Algorithm: Simulated Annealing 1. Evaluate the initial state. If its a goal state, then
return and quit. Else, continue in the loop with the initial state as the current state.
2.

Initialize BEST-SO-FAR to current state.

3.

Initialize T according to the annealing schedule.


Loop until a solution is found or until there are no new operators to be applied to current state: a) Select an operator that has not yet been applied to current state and produce a new state.

4.

b) Evaluate the new state. Compute: E = (value of current) (value of new state) If the new state is a goal state, then return and quit. Else if it is better than the current state, make it the current state. Set BEST-SO-FAR to this new state. If not better than the current state, then make it the current state with probability p. c) Revise T according to annealing schedule. 5) Return BEST-SO-FAR as the answer.

5)Algorithm: Best-First Search


1. 2.

Start with OPEN containing just the initial state. Until a goal is found or there are no nodes left on OPEN do: 1. Pick the best node on OPEN. 2. Generate its successors. 3. For each successor, do: 1. If its has not been generated before, evaluate it, add it to OPEN and record its parent. 2. Else(generated already), Change the parent if this new path is better than the previous one. Update the new cost to any successors that this node already have.

6)Algorithm: A*
1.

Start with OPEN containing only the initial node. Set that nodes g=0 h = whatever it is f = h + 0 Set CLOSED to the empty list.

2. Until a goal node is found, repeat: If there are no nodes on OPEN, report failure. Else, pick the node on OPEN with lowest f value. Call it BESTNODE. Remove it from OPEN, place it on CLOSED. See if BESTNODE is the goal node. If so exit and report a solution. Else, generate the successors of BESTNODE but do not set BESTNODE to point to them yet.

A* continued..
For each SUCCESSOR , do:
a) b)

Set SUCCESSOR to point back to BESTNODE. Compute g(SUCCESSOR) = g(BESTNODE) + cost of path from BESTNODE to SUCCESSOR.

c)

If SUCCESSOR is present on OPEN already. If so call that node OLD and add it to the list of BESTNODEs successors. If the path we have just found to SUCCESSOR is cheaper than the current best path to OLD, reset the OLDs parent link to point to BESTNODE, record the new cheaper path in g(OLD) and update f(OLD).
If SUCCESSOR was not on OPEN, see if it is on CLOSED. If so, call the node on CLOSED, OLD and add OLD to the list of BESTNODEs successors. Check to see if the new path or old path is better and set the parent link , g , f appropriately. If we find a better path to OLD, we must propagate the improvement to OLDs successors. If SUCCESSOR was not already on either OPEN or CLOSED, then put it on OPEN, and add it to the list of BESTNODEs successors. Compute f(SUCCESSOR) = g(SUCCESSOR) + h(SUCCESSOR).

d)

e)

7) Algorithm: Problem Reduction


1. 2.

Initialize the graph to the starting node. Loop Until the starting node is labeled SOLVED or until its cost is above FUTILITY:
1. Traverse the graph, starting at the initial node and following the current best path, and accumulate the set of nodes that are on that path and have not yet been expanded or labeled as solved. Pick one of these unexpanded nodes and expand it. If there are no successors, assign FUTILITY as the value of this node. Otherwise, add the successors to the graph and compute f for each of them. If f=0, mark node as SOLVED.

2.

3) Change the f estimate of the newly expanded node to reflect the new information provided by its successors. Propagate this change backward through the graph. If any node contains a successor arc whose descendants are all solved, label the node itself as SOLVED. At each node that is visited while going up the graph, decide which of its successor arcs is the most promising and mark it as part of the current best path. This may cause the current best path to change.

8)Algorithm: AO*
1) 2)

Let GRAPH consist only of the node representing the initial state (INIT). Compute h(INIT). Until INIT is labeled SOLVED or until INITs h value > FUTILITY, repeat: 1) Trace the labeled arcs from INIT and select for expansion one of the as yet unexpanded nodes that occurs on this path. (NODE). 2) Generate the successors of NODE. If there are none, then f(NODE)=FUTILITY(ie. not solvable) . If there are successors, then for each SUCCESSOR (that is not an ancestor of NODE) do the following: 1) Add SUCCESSOR to GRAPH. 2) If SUCCESSOR is a terminal node, label it SOLVED and assign h=0. 3) If SUCCESSOR is not a terminal node , compute h.

2.3) Propagate the newly discovered information up the graph by doing the following: Let S be a set of nodes that have been labeled SOLVED or whose h values have been changed. Until S is empty: 1) If possible, select from S, a node , whose descendants in

GRAPH doesnt occur in S. If there is no such node, select any node from S. Call this node CURRENT, remove it from S. 2) Compute the cost of each arc emerging from CURRENT. Assign CURRENTs new h value the minimum of the cost of arcs emerging from it. 3) Mark the best path out of CURRENT by marking the arc that had the minimum cost(prev. step) 4) Mark CURRENT, SOLVED if all the nodes connected to it are solved. 5) If CURRENT is SOLVED or if the cost of CURRENT was just changed , add all of the ancestors of CURRENT to S.

9)Algorithm: Constraint Satisfaction 1) Propagate available constraints. To do this, first set OPEN to
the set of all objects that must have values assigned to them in a complete solution. Then do until an inconsistency is detected or until OPEN is empty:
1) 2)
3)
2)
3)

Select an object OB from OPEN. Strengthen its constraints. If this set is different from the set assigned last time when OB was examined, then add to OPEN all objects that share any constraint with OB Remove OB from OPEN.

If the union of the constraints discovered above defines a solution, then quit and report the solution. If the union of the constraints discovered above defines a contradiction, then return failure. If neither of the above occurs, then it is necessary to make a guess at something inorder to proceed. To do this, loop until a solution is found or all possible solutions have been eliminated:
1) 2) Select an object whose value is not yet determined and select a way to strengthen its constraints. Recursively invoke constraint satisfaction with the current set of constraints augmented by the strengthening constraint.(4.1)

4)

10)Algorithm: Means-Ends Analysis(CURRENT,GOAL)


1) 2)

Compare CURRENT to GOAL. If there is no difference between them then return. Otherwise, select the most important difference and reduce it by doing the following until success or failure is signaled: 1) Select an untried operator O that is applicable to the current difference. If there are no such operators, then signal failure. 2) Attempt to apply O to CURRENT. Generate descriptions of two states: O-START(state in which the Os preconditions are satisfied) O-RESULT(the state that would result if O were applied in O-START). If (FIRST-PARTMEA(O-CURRENT, O-START)) and (LAST-PARTMEA(O-RESULT,GOAL)) are successful, then signal success and return the result of concatenating FIRST-PART, O, AND LAST-PART.

3)

Difference table: (Shows which operator is


appropriate)
Push Carry Move Object Move Robot Clear Object Get Object on Object Get Arm empty Be holding Object * * * * * * * * Walk Pickup Putdown Place

Robots Operators:
Operator PUSH(obj,loc) Preconditions Results at(robot,obj) ^ large(obj) at(obj,loc) ^ ^ clear(obj) ^ armempty at(robot,loc)

CARRY(obj,loc)s

at(robot,obj) ^ small(obj)
none at(robot,obj) holding(obj) at(robot,obj2) ^ holding(obj1)

At(obj,loc) ^ at(robot,loc)
at(robot,loc) holding(obj) holding(obj) on(obj1,obj2)

WALK(loc) PICKUP(obj) PUTDOWN(obj) PLACE(obj1,obj2)

11)Algorithm: Minimax(Position, Depth, Player)


1)

If DEEP-ENOUGH(Position,Depth),then return the structure VALUE=STATIC(Position,Player); PATH=nil . This indicates that there is no path from this node and that its value is that determined by the static evaluation function. Otherwise, generate one more ply of the tree by calling the function MOVE-GEN(Position,Player) and setting SUCCESSORS to the list it returns. If SUCCESSORS is empty, then there are no moves to be made, so return the same structure that would have been returned if DEEP-ENOUGH had returned true. If SUCCESSORS is not empty, then examine each element in turn and keep track of the best one:

2)

3)

4)

Initialize BEST-SCORE to the minimum value that STATIC can return. It will be updated to reflect the best score that can be achieved by the element of SUCCESSORS. For each element SUCC of SUCCESSORS, do the following: a) Set RESULT-SUCC to MINIMAX(SUCC,Depth+1,OPPOSITE(Player)) b) Set NEW-VALUE to VALUE(RESULT-SUCC). c) If NEW-VALUE > BEST-SCORE, then we have found a successor that is better than any that have been examined so far. Record this:
a) b) Set BEST-SCORE to NEW-VALUE The best known path is now from CURRENT to SUCC and then on to the appropriate path down from SUCC as determined by the recursive call to MINIMAX. So set BEST-PATH to the result of attaching SUCC to the front of PATH(RESULT-SUCC).

5) Now that all the successors have been examined, we know the value of Position as well as which path to take from it. So return the structure VALUE = BEST-SCORE

12)Algorithm: Minimax-A-B(Position, Depth, Player, Use-Thresh, Pass-Thresh)


1)

If DEEP-ENOUGH(Position,Depth),then return the structure VALUE=STATIC(Position,Player); PATH=nil . Otherwise, generate one more ply of the tree by calling the function MOVE-GEN(Position,Player) and setting SUCCESSORS to the list it returns. If SUCCESSORS is empty, then there are no moves to be made, so return the same structure that would have been returned if DEEP-ENOUGH had returned true.

2)

3)

4)

If SUCCESSORS is not empty, then examine each element in turn and keep track of the best one:

For each element SUCC of SUCCESSORS, do the following: a) Set RESULT-SUCC to MINIMAX-A-B (SUCC,Depth+1,OPPOSITE(Player), -Pass-Thresh, -UseThresh) b) Set NEW-VALUE to VALUE(RESULT-SUCC). c) If NEW-VALUE >Pass-Thresh , then we have found a successor that is better than any that have been examined so far. Record this:
a) b) Set Pass-Thresh to NEW-VALUE The best known path is now from CURRENT to SUCC and then on to the appropriate path down from SUCC as determined by the recursive call to MINIMAX-A-B. So set BEST-PATH to the result of attaching SUCC to the front of PATH(RESULT-SUCC).

d) If Pass-Thresh (current best value) is not better than Use-Thresh, then we should stop examining this branch. But both thresholds and values have been inverted. So if Pass-Thresh>= Use-Thresh, then return immediately with the value. VALUE = Pass-Thresh PATH= BEST-PATH 5) Return the structure VALUE = Pass-Thresh

You might also like