1. 程式人生 > >人工智慧第二章——Agent(附JADE開發包及原始碼+Agent相關PPT)

人工智慧第二章——Agent(附JADE開發包及原始碼+Agent相關PPT)

摘要

  本文會講明白1)Agent定義(及其理性);2)PEAS及環境特性;3)Agent程式的結構;4)Agent程式的部件如何運轉。

前言

接上一章——人工智慧簡介。
本章主要講Agent,也對應人工智慧定義維度中的Acting rationally (理性Agent)。

此外(劃重點):在此和大家分享JADE(Java Agent DEvelopment Framework)一個很酷的在Java上進行Agent開發的框架。你可以用這個框架很輕易的搭建一個MAS(多智慧體系統),在這些系統中,各個Agent是自治的,而且可以互相通訊,很酷誒!

大家可以去我的CSDN資源頁

下載,內附JADE安裝包,原始碼,以及官方給的一些必要的說明文件,還有一些很有意思的有關Agent系統例項。

一、Agent定義

1.1 What is an agent? (概念,定義)

定義:
  Anything that can be seen as 1) perceiving its environment through sensors 2) acting upon it through actuators. [1]

特點
  It will run in cycles of perceiving, thinking and acting.
  
例子
  拿我們人類做類比:我們的五官(五感)就是sensors,我們的身體各部分(手,足等)就是actuators。
而robotic agents靠我們給的sensors(camera,microphones 麥克風,infrared detectors 紅外探測)來感知環境,它們進行一些計算(computing/think),然後通過各種各樣的motors(馬達,發動機)/actuators來做出行動。

Agent在身邊
Now, it should be clear that the world around you is full of agents like your cell phone, vaccum cleaner, smart fridge, thermostat, camera and even yourself. (行動電話(手機),真空吸塵器,智慧冰箱,恆溫器,攝像頭,甚至你自己,都是Agent)

  這樣看來,Agent的概念確實有些廣泛…當然,我們也可以具體研究Agent in AI,這時候我們就可以把人給排查在外了。

Agent形象圖
圖一 Agent(一個很萌的形象圖)[2]

1.2 What is an intelligent agent (也叫做Rational Agents)?

定義
  An agent which acts in a way that is expected to maximize to its performance measure, given the evidence provided by what it perceived and whatever built-in knowledge it has.

如何衡量/評估Agent的理性?
  The rationality of the agent is measured by its performance measure (that defines the criterion of sucess for an agent), the prior knowledge it has, the environment it can perceive and actions it can perform.

二、Agent的PEAS特性及其環境特性

2.1 PEAS是什麼?

定義
PEAS是Agent四個特性的縮寫。
Performance, Environment, Actuators and Sensors (PEAS).

例子
自動駕駛汽車擁有以下PEAS:

  • Performance: Safety, time, legal drive, comfort.
  • Environment: Roads, other cars, pedestrians, road signs(道路標誌).
  • Actuators: Steering(轉向裝置,方向盤), accelerator, brake, signal(訊號燈), horn(喇叭).
  • Sensors: Camera, sonar(聲吶), GPS, speedometer(速度計), odometer(里程錶), accelerometer(加速劑), engine sensors, keyboard.

2.2 環境特性

  因為人們需求眾多,所以產生了各種各樣的intelligent agents,name對應的環境也有不同的型別(特性)

特性1 Fully observable and partially obeservable
  An agent’s sensors give it access to the complete state of the environment at each point in time, if fully observable, otherwise not.
  例子:chess是全域性可察的,但是poker(紙牌遊戲,你可以想成是鬥地主)不是。

特性2 Deterministic and stochastic
  The next state of the environment is completely determined by the current state and the action executed by the agent. (If the environment is deterministic except for (除了) the actions of other agents, then the environment is strategic). Stochastic environment is random in nature and cannot be completely determined. (就是說隨機環境不僅僅只是由當前agent的狀態和行動決定)
  例子:8-puzzle(九宮格)擁有一個確定性的環境,但是無人駕駛車沒有(當然啦,因為這個無人駕駛可是在大馬路上開,各種因素影響著環境)。

特性3 Static and dynamic
  The static environment is unchanged while an agent is deliberating (慎重,仔細考慮,深思熟慮). (The environment is semi-dynamic if the environment itself does not change with the passage of time (時間的流逝) but the agent’s performance score does.). A dynamic environment, on the other hand, does change.
  例子:Backgammon (西洋雙陸跳棋) has static environment and a roomba (掃地機器人) has dynamic.

特性4 Discrete and continuous
  A limited number of distinct, clearly defined perceptions and actions, constitute a discrete environment.
  E.g., checkers is an example of a discrete environment, while self-driving car evolves in a continuous one.

特性5 Single agent and Multi-agent
  An agent operating just by itself has a single agent environment. However if there are other agents involved, then it’s a multi agent environment.
  例子:Self-driving cars have multi agent environment.

三、Agent的結構,種類

3.1 Agent程式的結構

Agent = architecture + program.

所有Agent都有一樣的程式框架!具體如下:
輸入:當前感知到的資訊
輸出:行為
程式:manipulates(操作,控制) input to produce output

3.2 Agent分類

  從Agent能夠處理的任務複雜度和智慧程度來分類,Agent可以分為四類,而這四類都可以概括為Learning Agents。

1)Simple reflex agents

  在做出行動時,僅僅只基於當前狀態,忽略歷史(過去的)感知資訊。
  They can only work if the environment is fully observable, or the correct action is based on what is perceived currently.

這裡寫圖片描述
2)Model-based reflex agents

  Agents keep track of partially observable environments. These have an internal state depending on perception history. The environment/ world is modeled based on how it evolves independently from the agent, and how the agent actions affects the world.(保留了部分可觀察環境的蹤跡(一些資訊,路徑之類的吧),整個environment/world在此基礎上建模)

這裡寫圖片描述
3)Goal-based agents

  This is an improvement over model based agents, and used in cases where knowing the current state of the environment is not enough. Agents combine the provided goal information with the environment model, to chose the actions which achieve that goal.

這裡寫圖片描述

  該類agent是在model-based agent上的改進,適用於“光知道當前狀態還不夠(做出決定,行動)”的情況。其中,agent在做決定的時候考慮了goal information。

  這讓我想起了搜尋演算法。

4)Utility-based agents

  An improvement over goal based agents, helpful when achieving the desired goal is not enough. We might need to consider a cost. For example, we may look for quicker, safer, cheaper trip to reach a destination. This is denoted by a utility function. A utility agent will chose the action that maximizes the expected utility.

  這讓我想起了搜尋演算法中更加複雜的情況(考慮一些其他的cost)。

這裡寫圖片描述

5)Learning Agents
Learning element: responsible for making improvements.
Performance element: responsible for selecting external actions. It is what we considered as agent so far.
Critic: How well is the agent is doing w.r.t. a fixed performance standard.
Problem generator: allows the agent to explore.

四、Agent程式的部件如何運轉

  由於前面討論的四類都可以歸為learning agent,所以這裡討論learning agent中的部件如何運轉。

4.1 各部件功能

  • 執行部件即前面考慮的整個Agent,接受感知,選擇動作。
  • 學習部件根據評判部件的反饋評價Agent做得如何,從而確定如何修改執行部件。
  • 評判部件根據效能標準告知學習部件Agent的執行情況。當“將軍”發生了,評判部件告知學習部件:好事情發生了
    (效能標準是固定的,Agent不應該修改效能標準來適應自己的行為)
  • 問題生成器可向執行部件建議探索性行動,短期內可能是次優的行動,但長遠而言可能是更好的行動

4.2 例子

自動駕駛

  • 執行部件:使用執行部件在公路上行駛。執行部件包含選擇駕駛行動的全部知識和過程集合。
  • 評判部件:觀察評價世界,告知學習部件。不打轉向燈變道,聽到後車喇叭聲。
  • 學習部件:制定修改規則。如果是不好的行動,如何修改執行部件。
  • 問題生成器:例如提議在不同路面試驗一下剎車效果。

4.3 Agent各部件如何工作

  Agent程式包含回答以下問題的部件:1)當前狀態;2)當前應該採取的行動;3行動後果。

如何表示狀態及其轉換?
  沿著複雜度和表達能力增長的軸線有三種表示:原子表示、要素化表示、結構化表示。

這裡寫圖片描述
1)Atomic representation 原子表示

  The state is stored as black box, i.e. without any internal structure.

例子:
  For example, for Roomba(a robotic vaccum cleaner), the internal state is a patch already vaccumed, you don’t have to know anything else. As depicted in the image, such representation works for model and goal based agents and used in various AI algorithms such as search problems and adversarial games.

2)Factored Representation 要素化表示

  The state, in this representation, is no longer a black box. It now has attribute-value pairs, also known as variables that can contain a value.

例子
  For example, while finding a route, you have a GPS location and amount of gas in the tank. This adds a constraint to the problem. As depicted in the image, such representation works for goal based agents and used in various AI algorithms such as constraint satisfaction and bayesian networks.

3)Structured Representation 結構化表示

  In this representation, we have relationships between the variables/ factored states. This induces(引起 cause) logic in the AI algorithms.
  
例子
  For example, in natural language processing, the states are whether the statement contains a reference to a person and whether the adjective in that statement represents that person. The relation in these states will decide, whether the statement was a sarcastic one. This is high level Artificial Intelligence, used in algorithms like first order logic, knowledge-based learning and natural language understanding. [1]

五、資源

依舊是一些ppt,我看了之後感覺還挺有用的,這裡分享給大家,有空可以去我的CSDN資源頁下載,如果沒有積分,也可以直接評論留言,我發給你。

本次分享的資源包含兩個PPT檔案:
1)Techniques in Artificial Intelligence (對Ai進行定義,描述世界模型Agent結構,一些例項等)
2)Intelligent Agents: Introduction(對Agent,甚至是整個AI人工智慧都有一個比較全面的介紹,可以一看)

六、總結

又搞了一下午。2個小時左右吧。由於時間關係,有時候不得不忽略一些細節,如有疑問請評論留言。

參考文獻