ai-kuliah-3

download ai-kuliah-3

of 14

Transcript of ai-kuliah-3

  • 7/28/2019 ai-kuliah-3

    1/14

    1

    Bab 2

    Intelligent Agents [Russel and Norvig, Chapter 2]

    Apa yang dimaksud dengan Agent

    o Agen (Agents) dapat dianggap sebagai segala sesuatu yang menerima dan merasakankeadaan mengenai lingkungannya melalui sensor sensor yang dimilikinya dan melakukanaction terhadap lingkungannya tersebut dengan memanfaatkan effectors yang dimilikinya.

    o Analogi dapat dilihat pada human agents yang memiliki mata, telinga dan bagian tubuh

    lainnya sebagai sensor dan tangan, kaki dsb sebagai effector.o Robotic agent menggunakan kamera dan infrared range finder sebagai sensor dan

    motor sebagai effector.o Software agent memanfaatkan encoded bit string untuk menentukan keadaan

    lingkungannya [percepts] dan action yang dilakukan.

    Bentuk generik dari Agents dapat dilihat pada gambar diatas.

    Bagaimana suatu agen melakukan suatu action.

    Rational agent adalah agen yang melakukan hal yang benar, dengan manfaat yang dapatdirasakan oleh lingkungannya.

    Keberhasilan suatu agent untuk suatu tujuan tertentu ditentukan melalui pengukuranperformance yang dicapai oleh agent tersebut.

    Pengukuran performance atau tingkat keberhasilan suatu agents ditentukan oleh1. Bagaimana (How) menentukan kriteria keberhasilan dari agent.2. Bilamana (When) evaluasi keberhasilan tersebut dilakukan.

    Rational Agents = Map from percept sequences into Actions.Performance measure = criteria for determining the quality of agents.

    AGENT

    Effectors

    Sensors

    Environment

    Percepts

    Actions

  • 7/28/2019 ai-kuliah-3

    2/14

    2

    Misalnya: for diagnosis agents # of successful diagnoses/day,

    for vacuum cleaner dirt collected/day.So, the definition of rational agents for each percept sequence, choose action that maximizes

    expected value of performance measure, given only built in knowledge and perceptsequence.

    Perlu dibedakan antara Rational Agent dan Omniscience Agent.1. Rational agent lebih menekankan pada keberhasilan yang diharapkan

    berdasarkan pada kondisi lingkungan yang dihadapinya2. Omniscience Agent adalah agent yang mengetahui dengan pasti tentang hasil

    yang harus diperoleh dan berusaha untuk mencapainya dari action yangdilakukan.

    Avoiding Omniscience: performance criterion should not require predicting futureperfectly.

    Rational agent tergantung pada 4 hal yaitu:1. Pengukuran performance (menentukan tingkat keberhasilan agents)

    2. Percept sequence (urutan hal yang dialami hingga saat tertentu)3. Hal apa saja tentang lingkungannya yang diketahuinya.4. Action apa saja yang dapat dilakukan oleh agents tersebut.

    For each possible percept sequence, an ideal rational agent should do whatever action isexpected to maximize its performance measure, on the basis of the evidence provided by thepercept sequence and what ever built-in knowledge the agent has.

    Blok Diagram Intelligent Agent

    Contoh Aplikasi Inteligent Agent

    1. Delivery Robot

  • 7/28/2019 ai-kuliah-3

    3/14

    3

    Task yang harus dilakukan:

    Berpindah ke suatu lokasi tertentu [Move self to location L]

    Memindahkan object A dari suatu lokasi ke lokasi lain [Move A from L1 to L2]

    Menemukan dimana lokasi benda A

    dll

    Suatu Autonomous Delivery robot memiliki:

    Goal : when and where to deliver what; trade-off antara acting quickly and actingsafely.

    Percepts:images from camera, sonar, laser range finders, instructions fromkeyboards, dst

    Operations:translate, rotate, pick-up, put-down, look-at, dst Proses Reasoning (Sub)Tasks yang terlibat antara lain:

    Find a path between locations

    Plan how to carry out multiple tasks

    Make assumptions about Russ's location

    Make tradeoffs under uncertainty: should it go near the stairs?

    Proses Learning yang terjadi:

    which actions are useful and when

    which objects are where

    how its actions affect its position

    2. Diagnostic AssistantTask yang harus dilakukan suatu Diagnostic Assistant

    Menentukan apa yang terjadi jika[ What should happen if . . .]

    Menetukan mengapa sesuatu tdk bekerja [Something doesn't work. Why?]

    Menentukan test terbaik untuk menentukan suatu fault.

    Dll

  • 7/28/2019 ai-kuliah-3

    4/14

    4

    Suatu Diagnostic Assistant memiliki:

    Goals:identify fault, decide which tests to perform, fix device, explain treatment,tradeoffs between fixing vs replacing components

    Percepts:symptoms of device/patient, results of tests

    Operations:ask further diagnostic questions (order tests), provide treatment

    Reasoning (Sub)Tasks Plan tests / treatments to address problems

    Derive possible causes for symptoms; rule out other causes

    Reason about uncertainties/ambiguities given symptoms

    Trade off alternate courses of action

    Learning

    Association between symptoms and faults

    Effects of treatments

    Accuracy of tests

    3. Infobot

    Infobot interacts with an information environment dan memiliki tugas:

    takes in high-level, perhaps informal, queries finds relevant information

    and presents information in meaningful way

    Suatu Infobot memiliki:

    Goals: get requested information; tradeoffs between volume and quality ofinformation vs expense involved; explain (non) answer

  • 7/28/2019 ai-kuliah-3

    5/14

    5

    Percepts: information at current site; what links are available; load on variousconnections

    Operations: initiate search; report results; ask for refinement/confirmation

    Reasoning (Sub)Tasks Derive implicit information

    Reach appropriate conclusions even if knowledge is insuffcient/conicting

    Infer (default) where to find information

    Tradeoff between information quality and cost

    Learning

    User preferences

    Information sources

    Speed of servers

    Dari 3 contoh diatas dapat disimpulkan bahwa common task suatu

    intelligent agent adalah sbb:

    1. Percept/Operation:

    Sense (visual, acoustic, . . . )

    Communicate (Natural language, Program, Spec)

    Move (\arms", \legs", . . . )

    Order (Natural language, instruction, . . . )

    Explain (Natural language, . . . )

    2. Reasoning:

    Answer queries

    Plan (paths, activities, . . . )

    Make assumptions / guesses

    Deal with tradeoffs

    3. Adapting/LearningPerform more tasks; perform task better; . . . faster

    Update model of world, user, dll.

    Update model of agent itself

    Update distribution of tasks

    What is involved in intelligence?

    1. Ability to interact with real world

    speech recognition, understanding, and synthesis

    image understanding (computer vision)

    2. Reason

    modelling external world

    problem solving, planning, decision making ability to deal with unexpected problems, uncertainties

    3. Learning/AdaptationWe are continuously learning and adapting and want systems that adapt to us

    Contoh intelligent agent lainnya seperti pada tabel berikut:

  • 7/28/2019 ai-kuliah-3

    6/14

    6

    Note: PAGE (Percepts, Actions, Goals, Environment)

    Basic Action Policy dari suatu Intelligent Agent Maping from percept sequences to actions.

    Agent programming: designing and implementing good policies.

    Types of Policy1. Reflex (respond immediately to percept)

    Tables

    Rules

    with State (Memory)2. Goal-based (act to achieve a goal)

    3. Utility-based (try to maximize \happiness")

    Implementing Agents using Tables

    Contoh: Tic Tac Toe

    Program 1.

    Data structures :A nine element vector representing the board, where the elements of the vector correspond tothe board positions as follows:

  • 7/28/2019 ai-kuliah-3

    7/14

    7

    1 2 3

    4 5 67 8 9

    An element contains the value :0 if the corresponding square is blank1 if the filled with an X2 if it is filled with an O

    Move_table : vector of 39

    ( 19.683 ) elements, each element is a nine element vector.

    Algorithm :1. View the vector board as a base three number. And convert to decimal.

    Ex :

    O X

    The board above in the condition 2 1 0 0 0 0 0 0 0 3 2 30

    + 1 31

    = 5

    2. Use the number above as an index into Movetable and access the vector storedthere.

    3. The vector selected in step 2 represents the way the board will look after the movethat should be made, so set board to that vector.

    Problem for program 11. Even the problem is very efficient in time, it takes a lot of space to store the table2. You have to do a lot of work to enter the vector to the table3. Step 2 is prone of error4. To extend the game into 3 dimensions, we have to start from the scratch again.

    Problem with table approach

    Should keep entire history of percepts.

    Memory Space: For chess, requires 35100

    entries

    Design Diffculty: Designer must anticipate how agent should respond to everypossible percept sequence.

    Avoiding Intractably Large Tables

    Many cells in table are identical.

    Markov Environments: Eg: In Chess, only current board position matters;independent of all previous percepts. . . .Irrelevant Percepts:Eg: If car in front of you slows down, you should brake;color/model of car, music on radio, temperature, dll are all irrelevant.

    Summarizing Percept Sequence:Use state" yaitu synopsis of percept history

    state + current percept identic dengan kondisi Markov diatas

  • 7/28/2019 ai-kuliah-3

    8/14

    8

    Compact Representation: Implement Agents using Rules Rules express regularities in the table, Misalnya: if car-in-front-is-braking then initiate-

    braking

    This rule only needs only last percept, jadi ignores all irrelevant percepts

    simple reflex agent

    Program 2

    Data structures :A nine element vector representing the board, where the elements of the vector correspond tothe board positions as follows :

    1 2 3

    4 5 6

    7 8 9

    An element contains the value :2 if the corresponding square is blank3 if the filled with an X5 if it is filled with an O

    Turn :An integer indicating which move of the game is about to be played, 1 indicates the first move,

    9 the last move.

    Algorithm :There are 3 subprocedures

    Make2 This procedure returns 5 if the center square of the board is blank, that is,Board[5] = 2 , otherwise, this function returns any blank non corner square (2, 4, 6 or 8 ).

  • 7/28/2019 ai-kuliah-3

    9/14

    9

    Posswin(p) this procedures returns 0 if playerp cant win on his next move, otherwise itreturns the number of the square that constitutes a winning move.

    By checking the value of every row, every column or every diagonal, thefunction will enable the program both to win or block the opponents win.If the value is 18 ( 3 x 3 x 2 ) then X can win, if the value is 50 ( 5 x 5 x 2 )then O can win.If the procedure find a winning row, determine which element is blank, andthen return the number of that square.

    Go(n) This procedure set Board[n] to 3 if Turn is odd or 5 if Turn is even, then itincrements Turn by 1

    (note : the algorithm has a built in strategy, it makes the odd numbered moves if it is playing Xand even numbered moves if it playing O.)

    The strategy for each turn is as follows:

    Turn Rules

    1 Go(1)

    2 if Board[5] = 2 then Go(5) else Go(1)

    3 if Board[9] = 2 then Go(9) else Go(3)

    4 if Posswin(X) is not 0 then Go(Posswin(X)) else Go(Make2)

    5 if Posswin(X) is not 0 then Go(Posswin(X)) else if Posswin(O) is not 0 thenGo(Posswin(O)) else if Board[7] = 2 then Go(7) else Go(3)

    6 if Posswin(O) is not 0 then Go(Posswin(O)) else if Posswin(X) is not 0 thenGo(Posswin(X)) else Go(Make2)

    7 if Posswin(X) is not 0 then Go(Posswin(X)) else if Posswin(O) is not 0 thenGo(Posswin(O)) else go anywhere that is blank

    8 if Posswin(O) is not 0 then Go(Posswin(O)) else if Posswin(X) is not 0 thenGo(Posswin(X)) else go anywhere that is blank

    9 Same as Turn = 7

    Note :

    1. Since Turn = 4 the program will be able to block the opponents win2. The program needs time more than program 1 because it has to check several conditionbefore it moves but it saves a lot of space

    3. We can not generalize any of the program knowledge, only for 3 by 3 tic tac toe game

    Summarizing Percept SequenceMay require > 1 percept to understand situation, can use state" to help encode situation

  • 7/28/2019 ai-kuliah-3

    10/14

    10

    Eg: distinguish BRAKE from TURN signalrequires several percepts. . .but can summarize as \car signalling turn" state

    Use this state when interpreting next percepts

    reflex agent with state

    Program 3Data structures :A nine element vector representing the board, where the elements of the vector correspond tothe board positions as follows :

    8 3 4

    1 5 9

    6 7 2

    Board position is arranged as a Magic Square. (all the rows, columns, diagonals sum is 15)

    We can simplify the process of checking for a possible win

    We mark the board as moves are made and also we keep a list of the squares in whicheach player has played

    To check for a possible win of one player, we consider each pair of squares owned by theplayer, compute the difference betwen 15 and the sum of two squares.

  • 7/28/2019 ai-kuliah-3

    11/14

    11

    If the difference (+) and (> 9) then not colinier and ignored it else if the difference is equalto blank, a move there will produce a win

    No player own move the 4 squares at a time, so fewer square is examine compare with

    program 2. So, the way of representation give an impact on the effesiency of the program

    Compute Action Dynamically Why pre-compute entire table? Instead. . .

    Have agent compute desired action, rather than look it up. (Tradeoff: reduce space,but increase CPU time)

    Compute paths, select best, take action that leads to best situation

    Note table is NOT explicitly pre-computed.

    Program 4

    Data structures :

    Board Position :A structure containing 9 element vector representing the board,a list of board positions that could result from the next move,a number representing an estimate of how likely the board position is to leadto an ultimate win for the player to move.

    Algorithm :

    Called : Minimax ProcedureLook ahead various sequence of moves in order to find a sequence that leads to a win. Thismeans to maximixe the likelihood of winning while the opponent will try to mininmize thelikelihood.To decide on the next move :

    Look ahead at the board positions that result from each possible move.

    Decide which position is best by doing the following steps for each of the board position1. see if it is a win

    2. if so call it the best and give the highest possible rating3. otherwise, consider all the moves the opponent could make next and see which ofthem is worst for us.

    Make the move that lead to that position

    Assign the rating of that best move to current position

  • 7/28/2019 ai-kuliah-3

    12/14

    12

    Problems with Computing Action Dynamically

    Search space may be exponentially large:

    Choosing the best action may be computationally intractable.

    World may change while we are searching:

    In dynamic environment, agent must act promptly.

    It may not have time to consider all possible action sequences.

    Knowledge of world may be incomplete or wrong:

    Agent may not be able to accurately predict the future.

    But this approach is still usually best option. . .

    Problems with Reflex AgentOnly single response for each situation maka only for achieving single goal dan Designermust anticipate, for each situation, which action is best for achieving goal

    Goal-Based Agents

    Generate possible sequences of actions

    Predict resulting states

    Assess goals in each resulting state

    Choose an action that achieves goal

  • 7/28/2019 ai-kuliah-3

    13/14

    13

    Note: can reprogram agent simply by changing goals

    Utility-Based Agents

    While goals are qualitative, (eg, get to destination)

    may want to make quantitative comparisons of actions. (eg, quicker, safer, morereliable paths)

    Important for making tradeoffs (speed vs safety), the likelihood of success againstimportance of goal

    Environments

    Best agent design depends on:+ performance measure (goal, utility, . . .)+ complexity of its environment

  • 7/28/2019 ai-kuliah-3

    14/14

    14

    Sifat sifat Environment

    Accessible:Percepts determine state

    policy based on current percept

    no need for (internal) state

    Deterministic:Actions cause deterministic changes.

    Simpler model of action effects (If env. also accessible, everything is certainty)

    Episodic:Performance measured on short sequence of actions (then start over)

    No long-term issues.

    Static:World doesn't change while agent is thinking.

    Allows lots of computing per decision

    Discrete:Percepts, actions are discrete. Easier to interpret percepts & to evaluate actions

    Comments on Environments

    Known:(by designer/agent)

    Environment can be modeled

    Agent does not need to adapt

    Most real situations appear non-deterministic as complex, inaccessible, and/or stochastic

    Hardest: Inaccessible, Nonepisodic, Dynamic, Continuous (Unknown)

    Beberapa contoh kondisi environment: