• No results found

4.2 Distributed Framework for Fixed Agent Systems

4.3.4 Coordination

Agent Interaction and State Transfer

A state transfer is the operation of a transferable state being passed from one agent to another. After a transferable state is received, it needs to be pre-processed by the recipient before it can be used by the recipient as the root of a new local abduction. This pre-processing is captured by the following rule.

Transfer Rule (TR). Let Θt =(G, Gd), (∆, N , E , C), τ be the state received by an agent α

after a state transfer, then Θ0 =(F ∪ Gd∪ G, ∅), (∆, N , E, C), τ0 is the root state for the new

local abduction by α , where F and τ0 are obtained as follows. Let ∆new be the set of α-tagged

abducibles, i.e., {A | A ∈ ∆ and (A, S) ∈ τ and α ∈ S}, and let Nnew be the set of α-tagged

non-abducible constraints, i.e, {D | D ∈ N and (D, S) ∈ τ and α ∈ S}:

1. given an abducible A = a(~u), the set of resolvents of A with ICα is RA(ICα) = {∀~Y . ←

~

u=~v, Φ− |← Φ ∈ ICα and Φ = {a(~v)} ∪ Φ− and ~Y = vars(Φ)};

2. given a non-abducible constraint D = ∀ ~X. ← p(~u), Φ where p(~u) is its constrained non-

abducible, the set of resolvents of the non-abducible constraint with Πα is RD(Πα) =

{∀ ~X ~Y . ← ~u = ~v, Φ0, Φ | p(~v) ← Φ0 ∈ Πag and ~Y = vars(p(~v)) ∪ vars(Φ0)};

3. F is the union of all the resolvents of the α-tagged abducibles and α-tagged non-abducible

constraints, i.e., S

A∈∆newRA(ICα) ∪SD∈NnewRD(Πα);

4. τ0 is obtained by removing α from the tags τ , i.e., {(L, S) | (L, S) ∈ τ and L /∈ (∆new

Nnew)} ∪ {(L, S0) | (L, S) ∈ τ and L ∈ (∆new∪ Nnew) and S0 = S \ {α}}.

The application of this rule forces the transferable state recipient agent to perform pending checks of the state, i.e., check new assumptions (abducibles collected by others) against its

local integrity constraints (i.e., Step 1 and 3) and continue the reduction of global constraints through a non-abducible (selected by another agent) using its local background knowledge (i.e., Step 2 and 3). It also moves the goals delayed by the sender to the pending goals set (i.e., by

the definition of Θ0), so that they can be selected and reduced by the recipient agent. The

tags by the recipient agent to the abducibles or non-abducible constraints are removed after the processing (i.e., Step 4), and hence they do not need to be checked again in the future. After the processing of the state, the recipient agent can start a new local abduction with the new state independently from the sender.

Example. Recipient Agent α applies TR

Θi : given Σ = {α, β}, Πα = {p(U, V ) ← r(U ), w(V )}, ICα = {← a(Z), ¬q(Z)}

Gi = ∅ Gd i = {q(X) {β}} ∆i = {a(X){α}} Ni = {∀Y. ← p(X, Y ){α}} Ei = ∅ Ci = ∅ ⇓ Θi+1: Gi+1=            ∀Z. ← X = Z, ¬q(X), ∀Y U V. ← X = U, Y = V, r(X), w(Y ), q(X){β}            Gd i+1= ∅ ∆i+1= {a(X)∅} Ni+1= {∀Y. ← p(X, Y )∅} Ei+1= Ei Ci+1= Ci

generated by checking a(X) with ICα and ∀Y U V. ← X = U, Y = V, r(X), w(Y ) is generated by

the reduction of ∀Y. ← p(X, Y ) through p(X, Y ) using Πα. Note that the tags for the elements

in ∆i and Ni are removed.  End of example.

Agent Interaction Strategy

During local abduction, an agent can process a transferable state either by selecting a remaining goal to reduce locally, or by passing it to another agent. The decision is controlled by the agent interaction strategy that is adopted by the agent. Agent interaction strategies can be arbitrary, but have two extremes: a lazy strategy, which requires the agent to solve as many pending goals as possible before sending it out, and an eager strategy, which encourages the agent to send out state as soon as a goal is delayed, or a new abducible or a non-abducible constraint is collected. None of these strategies can guarantee optimal performance in all applications. For example, suppose in the local abduction by an agent α, there is a state with two goals p, q, where p is only defined by an agent β and q is only defined by α. In the case where p requires long computation and can succeed, but q requires little computation and will fail, then the lazy strategy will give better performance. This is because by delaying p and trying to solve q first, the state will become a failure state and no agent interaction is needed (i.e., no need for the computation of p). However, in the case where p requires little computation and will fail, but q requires long computation and can succeed, the eager strategy may do better as the agent interaction can avoid the computation of q.

In the following description of our distributed algorithm, unless stated otherwise, we will assume the lazy interaction strategy is used.

Agent Selection Strategy

After an agent decides to send out a transferable state, it needs to identify and select a state recipient. A recipient candidate for a transferable state can be an agent who defines but has not delayed a delayed goal in the state, or who tags an abducible or a non-abducible constraint

in the state. A transferable state may have several recipient candidates, and the sender agent must select one of them to send the state to. Such a decision is controlled by the agent selection strategy of the sender agent, which is often application dependent and will affect the performance of the collaboration. For example, if no agent discloses what non-abducibles are defined in its background knowledge, then the selection of a state recipient may be either randomised or through some task allocation protocols such as Auction or Contract-Nets. Otherwise, if the agents advertise all of the non-abducibles which they have definitions for in their background knowledge, then the state recipient may be decided via a Matchmaking process over the delayed goals. Furthermore, for a tagged abducible or a tagged non-abducible constraint, only those agents who have an integrity constraint containing the abducible or have a definition for the non-abducible in the local background knowledge can generate additional goals (See Rule TR). This information may be used while deciding a suitable state recipient in order to reduce the depth of agent interactions.

In the following description of our distributed algorithm, we will assume by default that no agent advertisement is available, and a uniform agent selection strategy can be adopted. This is defined as follows.

Definition 4.9 (Uniform Agent Selection Strategy). Given a global abductive frame- work

D

Σ, bFE, suppose that the agent identifiers Σ can be sorted lexicographically. Let Θ =

(G, Gd), ST , τ be a transferable state. The uniform agent selection strategy selects an agent

β ∈ Σ, such that

• request help for delayed goals: if Gd 6= ∅, and there is no delayed goal L ∈ Gd such that

hL, Σi ∈ τ (i.e., L has been delayed by every agent once), then let Ω =S

[φ∈(G∪Gd) and hφ,Si∈τ ](Σ\

S), and β is the first agent in the list obtained by lexicographically sorting Ω;

• request consistency check for abducibles and non-abducible constraints: if Gd = ∅, and

Ω =S

hφ,Si∈τS is not empty, then β is the first agent in the list obtained by lexicographi-

cally sorting Ω.

there will be no recipient candidate, and hence the transferable state can be discarded. This is intended for avoiding the situation of indefinitely asking for help. Note that discarding such states will not cause the loss of solutions during agent collaboration, because by the definition of LD1, any agent that has tagged the non-abducible also has tried tried to reduce the non- abducible using their background knowledge (and generated corresponding states).

Global Abduction and Agent Execution

Intuitively, the state transfers represent the interactions between the agents, and act as the links between local abductions performed by different agents. Thus, the overall global abductive inference can be visualised as a global abductive derivation tree, which consists of all the local

abductions by the agents (See again Figure4.1 in Section 4.3.1):

Definition 4.10 (Global Abductive Derivation Tree). Given a global abductive framework D

Σ, bFE with a safe goal selection strategy Ξ, an agent interaction strategy Υ and an agent

selection strategy Ψ, the global abductive derivation tree for a query Q is a tree where each node represents a state and each arc represents either a local inference step or a state transfer, such that:

• the root node is the initial state Θinit of Q;

• each node is obtained by the application of a local inference rule or by the application of the transfer rule.

Definition 4.11. (Successful Global Abductive Derivation) Given a global abductive derivation tree, a successful global abductive derivation is a finite path from the root of the tree to a solved state leaf node of the tree.

Since each agent computation is in fact a search process where the search space is the local abductive derivation tree, different search algorithms can be used for the agent execution, such

as depth-first and breath-first. Figure 4.2 is the pseudo-code for an example implementation

which processes the states in a depth-first fashion. Given a query, agents executing the code can collaboratively construct a global abductive derivation tree.

PROC receive query(Q) BEGIN

Θ0 := create initial state(Q);

process state(Θ0); // start local abduction

END PROC

PROC receive state(Θ) BEGIN

Θ0 := apply trans rule(T R, Θ);

process state(Θ0); // start local abduction

END PROC

PROC process state(Θ) BEGIN IF Θ is a solved state THEN

AN S := extract answers(Θ);

send AN S to the global query issuer4;

ELSE

// use agent interaction strategy

IF Θ is transferable state AND Θ should be sent THEN // use agent selection strategy

N ewAgent := select recipient(Θ); IF N ewAgent 6= null THEN

send Θ to N ewAgent; END IF

ELSE // local inference

// use safe goal selection strategy G := select safe goal(Θ);

LRule := applicable local rule(G); States := apply local rule(LRule, Θ);

FOREACH Θ0 IN States DO process state(Θ0); END FOREACH END IF END IF END PROC

Figure 4.2: Pseudo-code of DAREC Agent Execution

Token-controlled Coordination Protocol

So far we have seen how the agents can interact and collaborate to search for answers for a given query. However, there are still two open issues:

• (Completeness Concern) In many applications the query issuer may want a reply when no answer can be found. Thus, the query issuer also needs to know when the distributed computation has finished, i.e., the global abductive derivation tree has been searched thoroughly.

• (Performance Concern) During a local abduction several transferable states may be derived and need to be sent out according to the adopted agent interaction strategy. If all of them are sent out straightaway, then the communication channels between agents may be quickly overloaded by the “message flood”. Furthermore, since each of these states will initiate a new local abduction on the recipient agent, agents may be overloaded if they receive too many states in a short period and have to manage too many local abductions simultaneously.

To resolve these issues while allowing agents to perform concurrent computation, we propose a token-controlled coordination protocol for global abduction. Within this protocol, there is a token shared among all the agents. At any time, the token is associated with only one local abduction (of some agent). An agent is allowed to send out a transferable state only if the state belongs to one of its local abductions, and that local abduction is associated with the token. The detailed steps of the protocol are summarised as follows. We assume that each agent records three pieces of information for each local abduction it is managing – a unique ID for the local abduction, the sender of the root state, and a foreign local abduction ID understandable by the sender. We also assume that messages always arrive in order, i.e., if message A is sent to agent α before message B, then α will receive A and then B.

1. To start a global abduction, the query issuer sends a query along with a state to an agent in the system. This agent creates an initial state and starts a local abduction associated with the token.

2. During a local abduction of an agent’s, if the agent derives a transferable state that needs to be sent out, then

(a) if the local abduction has the token, then the agent sends out the transferable state with the token and the local abduction’s ID, i.e., this local abduction will no longer be associated with the token;

(b) otherwise, it buffers the transferable state;

3. Upon receiving a state with the token and a foreign local abduction ID, the recipient agent initiates a new local abduction with the token, and records the foreign local abduction ID and the state sender.

4. If an agent derives a solved state, it sends the extracted answer to the query issuer regardless if it has the token or not, and continues local abduction(s), i.e., to search for more solutions.

5. If an agent finishes a local abduction (i.e., no more states to process), then

(a) if this local abduction is associated with the token (note that this implies that there is no buffered transferable state for this local abduction), then the agent returns the token with an End Of Search (EOS) message, which contains the recorded foreign local abduction ID, to the sender agent of the (pre-processed) root state of this local abduction;

(b) otherwise, the agent waits for the token;

and in both cases the agent can continue remaining local abduction(s).

6. Upon receiving an EOS message with the token, the agent looks up the local abduction whose ID can be found in the EOS message, and

(a) if there are buffered transferable states for the local abduction, then one of them is sent out with the token (similarly to 2(a));

(b) else if there is no buffered state and the local abduction has finished (i.e., continued from 5(b)), then the agent returns an EOS message with the token to the root state sender of this local abduction (similarly to 5(a));

(c) otherwise, the agent simply associates the token back to the local abduction;

and in all cases the agent can continue remaining local abduction(s).

With this protocol and the assumption that messages arrive in order, the query issuer will know the whole global abduction has finished once it receives the EOS message from the agent it has

issued the query to. In addition, if no answer is received before the EOS message, the query can be sure that there is no global abductive answer for the query.