23.08.2015 Views

Here - Agents Lab - University of Nottingham

Here - Agents Lab - University of Nottingham

Here - Agents Lab - University of Nottingham

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Node 1registryNode 2registryProc BProc CmailboxProc AprocessdictionaryFig. 1. An Erlang multi-node systemis automatically unregistered when the associated process terminates. Messagepassing between processes in different nodes is transparent when pids are used,i.e., there is no syntactical difference between sending a message to a process inthe same node, or to a remote node. However, the node must be specified whensending messages using registered names, as the pid registry is local to a node.A unique feature <strong>of</strong> Erlang that greatly facilitates building fault-tolerantsystems is that processes can be “linked together” in order to detect and recoverfrom abnormal process termination. If a process P 1 is linked to another processP 2 , and P 2 terminates with a fault, process P 1 is automatically informed <strong>of</strong> thefailure <strong>of</strong> P 2 . It is possible to create links to processes at remote nodes.As an integral part <strong>of</strong> Erlang, the OTP library provides a number <strong>of</strong> veryfrequently used design patterns (behaviours in Erlang terminology) for implementingrobust distributed and concurrent systems. The most important OTPdesign patterns are generic servers that implement client/server architectures,and supervisors, to build robust systems. Other OTP design patterns implement,for instance, a publish-subscribe mechanism, and a finite state machine.3 Implementing Jason in ErlangThis section describes the implementation <strong>of</strong> a subset <strong>of</strong> Jason in Erlang.3.1 A simple running example in JasonTo illustrate the implementation <strong>of</strong> Jason in Erlang, we use the example in Fig. 2,which illustrates the main syntactical elements <strong>of</strong> the Jason language.This somewhat artificially programmed agent is a counter, which prints amessage when finished. The initial beliefs <strong>of</strong> the agent are (a), representing that10

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!