Download presentation
Presentation is loading. Please wait.
Published byMatthew Weaver Modified over 9 years ago
1
1 PAGE of designing an agent Problem types Search Strategies PAGE of designing an agent Problem types Search Strategies
2
2 Words and Terms problem solving strategies search state environment action deterministic Accessible breadth-first search depth-first search Vacuum-cleaning
3
3 Words and Terms problem solving strategies search state environment action deterministic Accessible breadth-first search depth-first search Vacuum-cleaning Words and Terms problem solving 問題解決 strategies 方法 search 探索 state 状態 environment 環境 action 行動 deterministic 決定論的な Accessible 入手しやすい、利用でき る breadth-first search 幅優先探索 depth-first search 深さ優先探索 Vacuum-cleaning 掃除機
4
4 agent PAGE: Percepts, Actions, Goals, Environment Percepts Actions Goals Environmenttraffic light, other traffic, pedestrians, in Japan steer, accelerate, brake safely to destination cameras, speedometer, GPS, sonar Fig 1. The taxi driver agent and its PAGE description environment percepts actions Sensors: eyes, camera, … Effectors: hands, motors, … Fig1. A generic agent diagram e.g.
5
5 Percepts Actions Goals Environment A grid of squares that may have obstacles (wall or furniture), dirt, or may be open space (having nothing) go forward, turn right by 90 o , turn left by 90 o, suck up dirt, and turn off clean up the room touch sensor, photo sensor, infrared sensor Fig 2. The Vacuum-cleaning agent and its PAGE description More e.g.: Vacuum-clearning Agent Notes: Touch sensor is to check if the machine has bumped into something. Photo sensor is to check if there is dirt there. Infrared sensor is to check if the agent is in its home location.
6
6 Problem types Deterministic, accessible => single-state problem ( 単一状態問題 ) The agent sensors give it enough information to tell exactly which state it is in. technique search Deterministic, inaccessible => multiple-state problem ( 多重状態問題 ) The agent knows all the effects of its actions but has limited access to the world state so that it must reason about sets of states that it might get to. technique search + reasoning Nondeterministic, inaccessible => Contingency problem ( 偶発的問題 ) There is no fixed action sequence that guarantees a solution to the problem. It must sensors during execution. solution is a tree or policy, not a single sequence of actions. techniques: interleave search (dynamically acquire information) + execution Unknown state space => exploration problem ( 探索問題 ) The agent must experiment, gradually discovering what its actions do and what sorts of states exist. techniques: experiment + discovery knowledge more less
7
7 Define a problem A problem is defined by four items: initial state: The world initial state. operators: A set of possible actions. goal-test: To check if it reaches goal state or states. path-cost-fucntion: It is the sum of cost of the individual actions along the path, which is from one state to another. Notes: State space is the set of all states reachable from the initial state by any sequence of actions. Solution is a path (a sequence of operators) from the initial state to a state that satisfies the goal test. How to find a solution? search
8
8 Some examples - e.g. 1 Can you write a Java program that can find a solution, i.e. path from the initial state to the goal state? The 8-puzzle 5 1 4 2 8 37 6 12 5 4 3 67 8 Start stateGoal state state: the location of each of the eight tiles in one of the nine squares. operators: blank tile moves left, right, up, or down. goal-test: state matches the goal state. path-cost-fucntion: each step costs 1so the total cost is the length of the path.
9
9 Some examples – e.g. 2 Can you write a Java program that can find a solution, i.e. path from any initial state to the goal state? The vacuum world: 2 squares state: one of the eight states above. operators: move left, move right, suck. goal-test: no dirt left in any square. path-cost-fucntion: each action costs 1. vacuum dirt 2468 1357
10
10 Breadth-first search ( 幅優先探索 ) The breadth-first search algorithm searches a state space by constructing a hierarchical tree structure consisting of a set of nodes and links. The algorithm defines a way to move through the tree structure, examining the value at nodes. From the start, it looks at each node one edge away. Then it moves out from those nodes to all two edges away from the start. This continues until either the goal node is found or the entire tree is searched. The algorithm follows: 1.Create a queue and add the first node to it. 2.Loop: -If the queue is empty, quit. -Remove the first node from the queue. -If the node contains the goal state, then exit with the node as the solution. -For each child of the current node: add the new state to the back of the queue. 幅優先探索アルゴリズムはノードやリンクからなる階層的なツリー構造を構成することにより、状態空間を検 索します。 アルゴリズムはツリー構造を通して移動すると定義されています。スタートからそれぞれのノードを見ます。 それからスタートから繋がっている二つのノードへと移動する。ゴールノードが見つかるか、すべてのツリー が探索されるまでこの操作を続けます。 ※ある階層をすべて調べ、それが終わるとひとつ深い階層をすべて調べることを繰り返す。
11
11 An example of breadth-first search: Rochester Wausau Milwaukee Rochester Dubuque Rockford Chicago GrandForks Fargo Sioux St.Cloud Bemidji Duluth InternationalFalls Minneapolis GreenBay Wausau Madison LaCrosse [Rochester]->[Sioux Falls, Minneapolis, LaCrosse, Dubuque]->[Minneapolis, LaCrosse, Dubuque, Frago, Rochester]-> [LaCrosse, Dubuque, Frago, Rochester, St.Cloud, Duluth, Wausau, LaCrosse, Rochester]->……(after 5 goal test and expansion) -> [Wausau, LaCrosse, Rochester, Minneapolis, GreenBay, ……] Finally, we get to Wausau, the goal test succeeds.
12
12 public SearchNode breadthFirstSearch(SearchNode initialNode, Object goalState) { Vector queue = new Vector() ; queue.addElement(initialNode) ; initialNode.setTested(true) ; // test each node once while (queue.size()> 0) { SearchNode testNode = (SearchNode)queue.firstElement() ; queue.removeElementAt(0) ; testNode.trace() ; if (testNode.state.equals(goalState)) return testNode ; // found it if (!testNode.expanded) { testNode.expand(queue,SearchNode.BACK) ; } return null ; } A demo Source code for your reference
13
13 Depth-first search( 深さ優先探索 ) The algorithm follows: 1.Create a queue and add the first node to it. 2.Loop: -If the queue is empty, quit. -Remove the first node from the queue. -If the node contains the goal state, then exit with the node as the solution. -For each child of the current node: add the new state to the front of the queue. 深さ優先探索アルゴリズムは木の最初のノードから、目的のノードが見つかるか行き止まりまで深く下がって いきます スタートか根ノードから始まり、ずっと下ったところの葉ノードまで探索する。もしゴールノードが見つから なかったら引き返し、次のまだ通っていないツリーを葉に到達するまで探す。 Root node : ツリー構造の頂点にあるノード leaf node : ツリー構造の最底辺にあるノード ※ 深く進んでいき、行き止まったら引き返して、また深く進みながらゴール目指す The depth-first algorithm follows a single branch of the tree down as many levels as possible until we either reach a solution or a dead end. It searches from the start or root node all the way down to a leaf node. If it does not find the goal node, it backtracks up the tree and searches down the next untested path until it reaches the next leaf.
14
14 An example of depth-first search: Rochester Wausau Milwaukee Rochester Dubuque Rockford Chicago GrandForks Fargo Sioux St.Cloud Bemidji Duluth InternationalFalls Minneapolis GreenBay Wausau Madison LaCrosse [Rochester]->[Dubuque, LaCrosse, Minneapolis, Sioux Falls]->[Rockford, LaCrosse, Rochester,LaCrosse, Minneapolis, Sioux Falls]-> …… (after 3 goal test and expansion) -> [GreenBay, Madison, Chicago, Rockford, Chicago, Madison, Dubuque, LaCrosse, Rochester,LaCrosse, Minneapolis, Sioux Falls] We remove GreenBay and add Milwaukee, LaCrosse, and Wausau to the queue in that order. Finally, we get to Wausau, at the front of the queue and the goal test succeeds.
15
15 public SearchNode depthFirstSearch(SearchNode initialNode, Object goalState) { Vector queue = new Vector() ; queue.addElement(initialNode) ; initialNode.setTested(true) ; // test each node once while (queue.size()> 0) { SearchNode testNode = (SearchNode)queue.firstElement() ; queue.removeElementAt(0) ; testNode.trace() ; // display trace information if (testNode.state.equals(goalState)) return testNode ; // found it if (!testNode.expanded) { testNode.expand(queue,SearchNode.FRONT); } return null ; } A demo Source code for your reference
16
16 Quiz 問題解決と探索とは何か?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.