2APL (A Practical Agent Programming Language) is a modular BDI-based programming language that supports the development of multi-agent systems. 2APL provides a rich set of programming constructs allowing direct implementation of concepts such as beliefs, declarative goals, actions, plans, events, and reasoning rules. The reasoning rules allow run-time selection and generation of plans based on declarative goals, received events and messages, and failed plans. 2APL can be used to implement muti-agent systems consisting of software agents with reactive as well as pro-active behaviours.
2APL provides programming constructs to specify both multi-agent systems and individual agents. Multi-agent systems are specified in terms of individual agents and the environments with which they interact. Individual agents are specified in terms of the following ingredients.Beliefs: It implements an agent's initial information about its environments and other agents with which it interacts. An agent's beliefs may change during its execution.
Goals: It implements an agent's initial objectives. Each objective denote a state the agent desires to achieve. A goal will be removed as soon as it is achieved. Different goals may not be achievable at the same time as they may denote conflicting states.
Basic Actions: 2APL provides different types of actions, among which,
Belief Update Action is to update an agent's beliefs.
Communication Action is to pass a message to another agent.
External Action is to interact with an environment.
Abstract Action is to encapsulation a plan by a single action.
Belief Test Action is to query an agent’s beliefs.
Goal Test Action is to query an agent's goals.
Adopt Goal Action is to add a goal to an agent’s goals.
Drop Goal Action is to remove a goal from an agent’s goals.
Plans: A plan consists of basic actions composed by operators such as sequence, conditional choice, conditional iteration, and a unary operator to identify (region of) plans that should be executed atomically, i.e., the actions should not be interleaved with the actions of other plans of the agent.
Reasoning Rules: Three types of (practical) reasoning rules are provided to implement the generation of plans. The rules have a belief condition indicating when the rule can be applied.
Planning Goal Rule is to generate a plan to achieve a goal.
Procedural Rule is to generate a plan to react to either an event (received from environment) or a message (received from an agent). This rule can also be used to relate an abstract action to the plan it encapsulate.
Plan Repair Rule is to generate a plan to replace a failed plan.
Modules: A 2APL agent’s program can be developed in separate modules. Each module encapsulates cognitive components such as beliefs, goals, plans, and reasoning rules. In practice, a 2APL module can be used to program a specific functionality, such as a role or an agent profile. A programmer can perform a wide range of operations on modules, e.g., creating a module instance, updating it, executing it, and testing its state.
Environments: A 2APL environment can be implemented as a Java object. The methods of such an object correspond to agents' external actions. The body of a method implements the effect of the corresponding action.
The 2APL Platform and its corresponding Eclipse plug-in editor are developed to facilitate the development and execution of multi-agent programs. The execution of an individual 2APL agent program is realized by a cyclic sense-reason-act process, called the deliberation process. The execution of a 2APL multi-agent program is the parallel executions of the involved individual agent programs.