Skip to content

add_payload

Tushar Semwal edited this page Oct 15, 2017 · 2 revisions

Syntax:

add_payload(Agent_name, PredList) 

Agent_name: <atom+> AddList: <atom list +>

Adds the list of predicates PredList whose clauses need to be carried by the specified agent as it migrates.

Description:

add_payload/2 add the payload to the agent. The payload predicate should have guid as one of the argument.

For instance,
ability(guid,X):-
print(X).

Here ability(guid,X) is a payload having arity 2 with guid as the first argument. Thus when command add_payload/2 is invoked, the guid is replaced with the actual identifier/name of the agent. AddList is list of predicate name and arity as [(<predicatename1>,<number of arity>),(<predicatename2>,<number of arity>),…].

Example:

Let square_coordinate/2 and point/1 be predicates defined as follows:

?- square_coordinate(0,0).
?- square_coordinate(0,10).
?- square_coordinate(10,10).
?- square_coordinate(10,0).
?- point(1).

Suppose the payload to be carried by an agent are the clauses for square_coordinate/2 and point/1. The following add_payload predicate ensures that the clauses for the above two predicates are carried with the agent named myagent as and when it migrates to another platform.

add_payload(myagent, [(square_coordinate,2), (point,1)]).

Note that the second argument is a list comprising a tuple that contains the name of the predicate and its arity. Thus in a generalized way, we can define the add_payload predicate as follows:

add_payload(AgentName, [(<predicate1>,<Arity>), (<predicate1>,<Arity>), …]).

CAUTION: All predicates within the PredList have to be declared dynamic.

Clone this wiki locally