1 / 21

Introduction to AgentSpeak and Jason for Programming Multi-agent Systems (1)

Introduction to AgentSpeak and Jason for Programming Multi-agent Systems (1). Dr Fuhua (Oscar) Lin SCIS Athabasca University June 19, 2009. AgentSpeak. Originally Proposed by Rao (1996) Programming language for BDI agents Elegant notation, based on logic programming

isaiah
Download Presentation

Introduction to AgentSpeak and Jason for Programming Multi-agent Systems (1)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to AgentSpeak and Jason for Programming Multi-agent Systems(1) Dr Fuhua (Oscar) Lin SCIS Athabasca University June 19, 2009

  2. AgentSpeak • Originally Proposed by Rao (1996) • Programming language for BDI agents • Elegant notation, based on logic programming • Inspired By PRS (Georgeff & Lansky), dMARS (Kinny), and BDI Logics • Abstract programming language aimed at theoretical results • Why BDI? The BDI architecture is the predominant approach to the implementation of “intelligent” or “rational” agents (Wooldridge, 2000).

  3. AgentSpeak(L) Agent • An AgentSpeak(L) agent is created by the specification of a set of base beliefs and a set of plans. • A belief atom is simply a first-order predicate in the usual notation, and belief atoms or their negations are termed belief literals • An initial set of beliefs is just a collection of ground belief atoms. A formula is called ground when it has no more uninstantiated variables.

  4. Syntax of AgentSpeak • The main language constructs of AgentSpeak are: • Beliefs • Goals • Plans • The architecture of an AgentSpeak agent has four main components: • Belief Base • Plan Library • Set of Events • Set of Intentions

  5. Agent • an agent is simply specified by • a set bs of beliefs (the agent’s initial belief base) • a set of ground (first-order) atomic formula (i.e., variables are not allowed): bs ::= at1, at2, …, atm. • a set ps of plans (the agent’s plan library): ps ::= p1, p2, …, pn • The atomic formula at of the language are predicates • at ::= P(t1, t2, …, tn) • where P is a predicate symbol, • t1 , . . . , tn are standard terms of first order logic.

  6. Plan p • p ::= te : ct <- h • te triggering event, • ct plan’s context, • h sequence of actions, goals, or belief updates; • te : ct head of the plan, conditions under which the plan can be executed • h its body. • The formula ct must be a logical consequence of the agent’s beliefs if the plan is to be considered applicable.

  7. The Concrete Syntax of AgentSpeak(L) • A triggering event te can then be the addition or the deletion of a belief from an agent’s belief base (+at and −at, respectively), or the addition or the deletion of a goal (+g and −g, respectively). • A sequence h of actions, goals, and belief updates defines the body of a plan. • We assume the agent has at its disposal a set of actions and we use a as a metavariable ranging over them. They are given as normal predicates except that an action symbol A is used instead of a predicate symbol.

  8. Beliefs • Beliefs or a belief base represent the information available to an agent (e.g. about the environment or other agents) • A collection of literals, as in traditional logic programming. • A literal is a predicate or its negation. • An example of predicates: tall(john) ------ the agent believes a particular property (“tall”) of an individual (“John”) Fact(0, 1) ------ the agent believes the factorial of 0 is 1. Fact(X, Y) ------ the agent believes the factorial of X is Y. So, when the agent starts executing, this belief is added to the agent’s belief base. • To represent the fact that a certain relationship holds between two or more objects, we can use a predicate such as: likes(john, music) Which states that John likes music. To compose predicates, we must use Terms !

  9. Types of AgentSpeak Terms in Jason--- Basics of Logic Programming (1/5) • Atom • As in Prolog, any symbol starting with a lower-case is called an atom, which is used to represent particular individuals or object; • They are the equivalent of “constants” in first-order logic. • E.g. john is an atom • Variable • A symbol starting with an uppercase letter is interpreted as a logical variable. • For example, Person is a variable. • Number and String • Are Represented as usual in programming languages • Are classified as constants terms constant Variables Person Structures staff(john, age(36)) Number 3 12, 14 String “John” Atom john box1 List [] [1, X, john]

  10. Variable instantiation • Initially variables are free or uninstantiated and once instantiated or bound to a particular value, they maintain that value throughout their scope --- in the case of AgentSpeak, we shall see that the scope is the plan in which they appear. • Variables are bound to values by unification; • A formula is called ground when it has no more uninstantiated variables. • For example, a variable Person could be bound to the atom john. • More generally, variables can be bound to a constant (i.e. an atom, a number, or a string), or to a more complex data type called structure. • Term • Is used to refer to a constant, a variable, or a structure.

  11. Structure • Structure • Is used to represent complex data, • for example, staff(“Oscar Lin”, 9892591, professor, married, wife(Yu), daughter(Sally)) • Can be used to represent the information about a member of staff in a university. • Structures start with an atom (called the functor) and are followed by a number of terms (called arguments) separated by commas and enclosed in parentheses.

  12. Predicate • facts in Prolog • Have the exactly same format as structures, e.g. like(john, music) • Difference is purely semantical • A structure is used as term to represent an individual or object. • A fact is used to represent a logical proposition --- i.e. a formula that is to be interpreted as being either true or false.

  13. arity • The number of arguments of a predicate/structure is important, and is called its arity. • A particular structure is referred to by its functor and its arity • For example, ‘staff/6’ , as it must have always exactly six different terms as arguments (otherwise it is considered a different structure altogether).

  14. List • e.g. [Spring, Winter, Summer, Fall] • A special type of structure • The Prolog syntax for lists is also used in Jason. • There are some special operators for lists in particular ‘|’ can be used to separate the first item in a list from the list of all remaining items in it.

  15. Types of AgentSpeak formula terms predicate literal belief goal Triggering event

  16. Goals • Goals g can be either achievement goals (!at) or test goals (?at). • Goals represent states of affairs the agent wants to bring (come to believe, when goals are used declaratively) g • Achievement goals: !g !write(book) • Or attempts to retrieve information from the belief base • Test goals: ?g ?publisher(P)

  17. Events • Events happen as a consequence to changes in the agent’s beliefs or goals • Changes: + addition - deletion • Events +b (belief addition) -b (belief deletion) +!g (achievement-goal addition) -!g (achievement-goal deletion) +?g (test-goal addition) -?g (test-goal deletion)

  18. Plans • An agent reacts to events by executing plans • Plans are recipes for action, representing the agent’s know-how • An AgentSpeak plan has the following general structure: trigger_event : context <- body Where • The triggering event denotes the events that the plan is meant to handle; • The context represents the circumstances in which the plan can be used; • The body is the course of action to be used to handle the event if the context is believed true at the time a plan is being chosen to handle the event.

  19. Triggering Events trigger_event : context <- body • +b ------- when the agent acquires the belief b; +started. +fact(X, Y) --- when the agent acquires the belief that the factorial of X is Y. • -b ------- (belief deletion) • +!g ------ (achievement-goal addition), whenever you acquire the goal g, or to achieve the goal g. +!print_fact(N) <- !fact(N,F); .print("Factorial of ", N, " is ", F). +!fact(N, F): N>0 <- !fact(N-1, F1); F = F1*N. +!fact(N, 1): N == 0. • -!g ------ (achievement-goal deletion) • +?g ------ (test-goal addition) • -?g ------ (test-goal deletion)

  20. Plan Context • +at and −at (in the body of a plan) represent operations for updating (u) the belief base by, respectively, adding and removing at. • The context is logical expression, typically a conjunction of literals to be checked whether they follow from the current state of belief base. • Types of literals in a plan context l --- the agent believes l is true ~l --- the agent believes l is false not l --- the agent does not believe l is true not ~l --- the agent does not believe l is false Example: +!prepare(Something) : number_of_people(N) & stock(Something, S) & S > N <- ……

  21. Body • The body is a sequence of actions and (sub) goals to achieve. • Note: this is the original AgentSpeak syntax; Jason allows other things in the context and body of plans. trigger_event : context <- body

More Related