AgentsAuthor(s): Francisco Bueno.
An agent is an active module which has a main execution thread. Simultaneously (i.e., in concurrent execution with the main thread), the agent receives messages from other agents, which trigger the execution of a predicate by the name of the message. Messages can also be sent to other agents, by calling the predicate by the name of the message in the context of the receiver agent (see ::/2 below). Agents are identified by name. The name of an agent is usually the name of its (main) file, but this depends on the protocol used (see protocol/1 below).
A simple agent that sends inform messages and at the same time receives them from other agents, answering back ok, will look like:
:- agent(simple,[inform/2,ok/1]). :- protocol('actmods/filebased'). agent :- repeat, display('Agent id:message?- '), read(Agent:Mess), Agent::inform(Mess), fail. inform(Agent,Mess):- display(Agent), display(' has sent: ', display(Mess), nl, Agent::ok. ok(_Agent).
Usage and interface
Documentation on new declarations
Usage: :- protocol(Protocol).
- Description: Protocol is the prefix to a library path where an active module rendezvous protocol can be found.
Documentation on multifiles
The predicate is multifile.
- Description: (protocol defined) publishes the agent's Address.
Documentation on internals
- Description: (protocol defined) gives the Address of Agent.
Other informationThis package is intended as a sample of how to program agents in Ciao, based on active modules. It probably lacks many features that an agent might need. In particular, it lacks language-independence: it is thought for multi-agent systems where all agents are programmed in Ciao.
You are welcome to add any feature that you may be missing!
A platform is an active module which holds connection addresses of agents in a multi-agent system. A protocol is provided which enables the use of platforms: agent/platformbased. A suitable platform must be up and running when agents which run under this protocol are started up. The host id and port number (IP address/socket number) of the platform must then be given as arguments to the agents executables. The protocol also allows to give an agent name to the agent upon start-up. A module suitable for a platform can be found in library(actmods/examples/webbased_server/webbased_server).
Known bugs and planned improvements
- Currently, the agent has to be compiled explicitely as an active module. The same protocol than in the agent source code must be used for this. Automatic compilation is not working.
- It seems that there are running-ahead problems with threads that prevent to correctly publish agent addresses, sometimes.