Multi-Agent Planning and Diagnosis with Commonsense Reasoning

In multi-agent systems, multi-agent planning and diagnosis are two key subfields – multi-agent planning approaches identify plans for the agents to execute in order to reach their goals, and multi-agent diagnosis approaches identify root causes for faults when they occur, typically by using information from the multi-agent planning model as well as the resulting multi-agent plan. However, when a plan fails during execution, the cause can often be related to some commonsense information that is neither explicitly encoded in the planning nor diagnosis problems. As such existing diagnosis approaches fail to accurately identify the root causes in such situations. To remedy this limitation, we extend the Multi-Agent STRIPS problem (a common multi-agent planning framework) to a Commonsense Multi-Agent STRIPS model, which includes commonsense fluents and axioms that may affect the classical planning problem. We show that a solution to a (classical) Multi-Agent STRIPS problem is also a solution to the commonsense variant of the same problem. Then, we propose a decentralized multi-agent diagnosis algorithm, which uses the commonsense information to diagnose faults when they occur during execution. Finally, we demonstrate the feasibility and promise of this approach on several key multi-agent planning benchmarks.


INTRODUCTION
Multi-agent planning -the ability of a group of autonomous agents to reason about their actions and identifying sequences of actions (i.e., plans) that lead them to their goals -is a core area of AI research at the intersection of automated planning and multi-agent systems.Applications of multi-agent planning are abound, ranging from robots navigating in autonomous warehouses today [20,21,41] to autonomous vehicles navigating on roads in the future [7,32].As is the case with any application with embodied agents, failures may occur during an agent's execution.When abnormal behaviors caused by failures are observed, automated diagnosis techniques [10,33,40] are used to identify the root cause of the abnormal behavior.
However, a key assumption in both multi-agent planning methods is that the problem is fully-specified -in the sense that everything that can affect the outcomes of actions in the problem, however unlikely, is defined.For example, consider the well-known Logistics domain [22], where a set of packages need to be moved from their initial to target locations using a given fleet of vehicles such as trucks, airplanes, etc.In this domain, the drive(truck,origin,destination,city) action will successfully move truck from origin to destination if the pre-conditions that truck is at origin and both origin and destination are in city and are connected by a road are satisfied.This implicitly assumes some commonsense knowledge, typically defined as knowledge about the world that all humans are expected to know.For example, it assumed that the drive action is successful only if the truck is not broken, the road between origin and destination is not blocked, etc.
To ensure conciseness in the planning problem specification and tractability of solution approaches, it is reasonable that one models only knowledge (commonsense or otherwise) that is assumed to be relevant to the problem and ignores knowledge (much of which is commonsense) that is not relevant.However, when a plan fails during execution, the cause is often related to some factor that was not taken into consideration during the planning stage.For example, perhaps the truck failed to reach destination because the road between origin and destination is not traversable due to a flood, and the problem did not consider the possibility of a flood.As such, automated diagnosis methods need to reason about commonsense knowledge that is not explicitly encoded in the classical planning problem.
For automated diagnosis methods to perform commonsense reasoning, it must have access to commonsense knowledge that was not used in the planning stage.However, instead of explicitly representing all commonsense knowledge and providing it as input to diagnosis methods, we take a more sensible approach by considering only a subset of commonsense knowledge that may affect the planning problem.In this paper, we propose a Commonsense Multi-Agent STRIPS model, which extends the traditional Multi-Agent STRIPS model [4] by including commonsense fluents and commonsense axioms that may affect the classical planning problem.Then, with access to such commonsense knowledge, we propose commonsense multi-agent diagnosis algorithms that allow agents to collaboratively identify the root cause of abnormal behaviors in a decentralized manner.Finally, we demonstrate the feasibility and promise of this class of algorithms on several key multi-agent planning benchmarks.

BACKGROUND
We now provide some background on multi-agent STRIPS (MA-STRIPS), which we will later extend to a commonsense variant, and automated diagnosis, which we will rely on for our multi-agent diagnosis algorithm.

Multi-Agent STRIPS (MA-STRIPS)
An MA-STRIPS problem is defined by a tuple ⟨, , , {  }  ⟩, where  is a set of fluents,  is the initial state,  is the goal state, and   is the set of actions that can be performed by agent  [4].A multi-agent plan in MA-STRIPS is often assumed to be a sequence of actions ( 0 , . . .,   ) where each action   is an action of some agent  (i.e.,   ∈   ).A plan is a solution if it transitions the initial state to the goal state.A solution is optimal if it has the fewest actions among all solutions.
A multi-agent plan can also be a sequence of joint actions, if concurrent execution is allowed.We will also consider MA-STRIPS extensions in which some fluents and actions are only observable by some agents (these are called private fluents and actions).In this type of privacy-aware MA-STRIPS problems [27], a multi-agent plan comprise of a public plan that includes the actions publicly known to all agents, and set of private plans for each agent that comprise the private actions they need to perform.
Note that in MA-STRIPS, actions' effects are deterministic.Richer multi-agent planning languages that support stochastic effects and observability exists, such as Decentralized Partially Observable Markov Decision Processes (Dec-POMDPs) [3].While the theories and algorithms developed in the proposed research may carry over to such planning languages, we limit our scope to deterministic effects, which is a reasonable abstraction for many real-world problems that have been studied extensively in the automated planning and multi-agent systems communities.

Automated Diagnosis
A diagnosis problem arises when observations indicate that the system of interest is behaving abnormally.Model-based diagnosis (MBD) is a popular and principled approach for solving diagnosis problems that relies on a model characterizing the behavior of the diagnosed system.This model is referred to as the system description.A diagnosis problem in the MBD literature is commonly defined by a tuple ⟨SD, Comps, Obs⟩, where SD is the system description, Comps is a finite set of components, and Obs is a collection of observations about the system [11,12,29].The predicate  () denotes the fact that the component  ∈ Comps is "abnormal" (or defective).An MBD problem arises when the assumption that all components are healthy is inconsistent with SD and Obs (i.e., when  ∈Comps ¬ () ∪ SD ∪ Obs is inconsistent).A solution to an MBD problem is a diagnosis, which can be defined as a set of components Δ ⊆ Comps such that the assumption that these components is faulty and all other components are healthy is consistent with SD and Obs: The goal of MBD algorithms is often to identify a minimal diagnosis or preferred diagnosis in accordance to some criteria.
In the classical work introducing diagnosis from first principles, SD is a theory representing the relationship between components and state of the system and Obs consists of observations related to a single state of the system [11,12,29].However, MBD has been considered for many other, significantly richer, types of system description.For example, MBD has been considered for system descriptions that include knowledge about the components' fault modes (this is known as a strong fault model), where a diagnosis specifies not only which components are faulty but also what type of fault they exhibit [6,13,34].MBD has also been considered for discrete-event and dynamic systems, where SD and Obs encode a transition system and observations along a trajectory of the system, respectively [1,2,15,35].In this case, a diagnosis is a set of component-time pairs (, ), where  ∈ Comps and  ≥ 0, and  (, ) indicates that component  is defective (fails) from time step .Prior work also applied MBD for hybrid and distributed systems, where the system description composes of a set of variables, parameters, equations, inputs, and outputs, and observations are measurements of outputs.In such a case, a diagnosis is a fault representing the deviation of parameters from their nominal values [5].
More related to the proposed research is prior work that applied MBD to diagnose a multi-agent system [39].Typically, two types of failures have been investigated: Plan failures and coordination failures.In the former, faults occur due to failed execution of some actions in the plan.In the latter, faults occur due to disagreements of the agents on key components of their joint task.Appropriate algorithms have been proposed for each type of failures.

COMMONSENSE MULTI-AGENT STRIPS
Recall that for automated diagnosis methods to perform commonsense reasoning, it must have access to commonsense knowledge that was not used in the planning stage, but could have affected the execution of the plan.Towards that end, we propose the Commonsense MA-STRIPS (CMA-STRIPS) model, an extension of the classical MA-STRIPS model [4] that includes commonsense fluents and commonsense axioms that may affect the classical planning problem.
Before describing the CMA-STRIPS model, we first define a commonsense fluent as a fluent that is not affected by any action in the corresponding classical planning problem.More formally: , where {  }  is the set of actions in the corresponding classical MA-STRIPS problem.
In other words, these are fluents that represent aspects of the planning problem that is presumed to remain unchanged throughout the execution of the plan.For example, the commonsense variant of the logistics domain may include a fluent ¬flood-l1 representing the fact that the location 1 is not flooded.
We now define the CMA-STRIPS model, which is defined by the tuple ⟨, , , {  }  , ⟩, where ⟨, , , {  }  ⟩ is similar to its corresponding regular MA-STRIPS problem, except that they may include commonsense counterparts: •  =   ∪  is a set of fluents, where   is the set of regular fluents in the MA-STRIPS problem and   is the set of commonsense fluents.•  ⊆  and  ⊆  are the initial and goal states, which may now include commonsense fluents.•   is the set of actions that can be performed by agent , whose pre-conditions pre() of action  ∈   may now include commonsense fluents.However, by Definition 3.1, the effects eff() of action  do not include commonsense fluents.In addition, we assume that the set   might also include statements declaring that certain action of agent  can interfere or is in conflict with some actions executed by others if they were to be executed in parallel.When two actions interfere, the planning algorithm should not allow them to be executed in parallel; when two actions are in conflict and one fails then the other also fails.•  =   ∪   is a set of axioms representing the relationships between the fluents  , where   is the set of regular axioms that involve regular fluents only and   is the set of commonsense axioms that involve commonsense fluents as well.While the classical MA-STRIPS problem definition do not include regular axioms as they arguably can be compiled away, we choose to explicitly include axioms in the definition as commonsense axioms represent intuitive relationships in a concise and clear way.For example, the commonsense axiom below represents the relationship that if location 1 is flooded and it is connected with location 2 by road, then the road between the two locations is now blocked: With this problem definition in hand, we further restrict the problem definition to have the following property: Property 1.If all commonsense fluents in preconditions of actions hold in the initial state, then a solution for an MA-STRIPS problem is also a solution for the commonsense variant of the same problem.
Recall that a solution is a plan that is feasible in the planning problem and it transitions the initial state to the goal state.It is reasonable to assume that the designers of an MA-STRIPS problem have incorporated all knowledge (commonsense or otherwise) that is relevant to the planning problem.Therefore, the fluents that are in preconditions of actions and whose truth value can change during the execution of a plan must be regular fluents.All other fluents in preconditions, which are the commonsense fluents, are therefore assumed to always hold.Consequently, Property 1 holds because if an action is feasible in an MA-STRIPS problem, it must also be feasible in the corresponding Commonsense MA-STRIPS problem.As a corollary to Property 1, one can then use any MA-STRIPS planner to solve CMA-STRIPS problems.

COMMONSENSE MULTI-AGENT DIAGNOSIS
We now describe the observation function of the agents before formulating the commonsense multi-agent diagnosis problem and describing our decentralized solution approach for diagnosing the root causes of abnormal behaviors in this problem.

Observation Function of Agents
Before describing our decentralized multi-agent diagnosis approach, we must first describe the knowledge base (KB) of each agent (i.e., the fluents, actions, and axioms that it knows and can observe).As a range of possibilities exist, we assume the availability of a domaindependent mapping function: that indicates whether an agent  ∈ A knows about a fluent  ∈  , axiom  ∈ , or action  ∈   of agent .
There is a wide range of possible observation functions for agents, including: • Local Observations: On one end of the spectrum, minimally, all agents must be able to observe their own actions and the fluents that are in the preconditions and effects of those actions.In other words, for each agent  ∈ A,  (, ) =  (,  ) = 1 for all actions  ∈   and fluents  ∈ pre() ∪ eff().
Using the same Logistics domain example again, if agents have local observations only, then truck 1 can observe fluents related to its own drive(t1,l1,l2,c) action for any location pairs l1 and l2 in city c; the pre-condition at-t1-l1 indicating that the truck is at l1 and the preconditions connected-l1-l2 and ¬blocked-l1-l2 indicating that the two locations are connected by a road that is not blocked; and the effects ¬at-t1-l1 and at-t1-l2 indicating that the truck is no longer at 1 and is at 2 instead.Similarly, it can also observe fluents related to its own load(o1,t1,l1) action, which loads object 1 onto truck 1 at location 1; pre-conditions at-o1-l1 and at-t1-l1, indicating both 1 and 1 are at 1; and effects ¬at-o1-l1 and in-o1-t1, indicating that 1 is no longer at 1 but is inside 1 instead.
• Global Observations: On the other end of the spectrum, all agents have global observation and are aware of all actions and fluents in the problem.In other words, for each agent  ∈ A,  (, ) =  (,  ) = 1 for all actions  ∈   and fluents  ∈  .This assumption is valid in applications, such as automated warehouses [21,42] where there is a global observer that can communicate their observations with all agents.
In this paper, we make the most restrictive assumption and assume that all agents have local observations only.As such, our proposed diagnosis algorithm (described later) will require agents to coordinate and communicate with each other to diagnose faults that arise.Note that if agents have global observations, then diagnosing faults are trivial since all agents have complete knowledge.Finally, we also assume that an agent knows and can reason about an axiom if all the fluents in the axiom are observable to the agent.In other words, for each agent  ∈ A,  (, ) = 1 for all axioms  ∈  iff  (,  ) = 1 for all fluents  ∈  (), where  () is the set of fluents in .

Problem Formulation
Given a plan  of an MA-STRIPS problem, a realization  of the plan is a trajectory  = ( 0 ,  1 ,  1 , . . .,   ,   ), where  0 =  is the initial (joint) state and   = ×     is the joint action of all the agents at time step .Note that   may not be a (joint) goal state as the agents may fail to reach a goal state should some of their actions fail.
An agent realization   of the realization for an agent  is the projected realization with respect to that agent: , where  0  =   is the initial state that is observable to agent  and    ∈   is the action of agent  at time step .
An action  ∈   of agent  is said to have failed in a realization of plan  if there exists a transition (, ,  ′ ) in the agent realization such that  does not satisfy the pre-conditions pre() or  ′ is inconsistent with the effects eff().Similarly, an action  ∈   of agent  is said to be faulty if there exists a transition (, ,  ′ ) such that  satisfies the pre-conditions pre(), but  ′ is still inconsistent with the effects eff().Note that all failed actions are also faulty actions, but not vice versa.Finally, all actions that are not faulty are said to be healthy.
A diagnosis for a plan  and joint observation Ω = ×  Ω  is a subset of agent actions     such that (1) there exists a realization  whose agent realizations   correspond to the observations Ω  for all agents  and (2) exactly all actions  ∈     are faulty.

MAD-DR Algorithm
We now describe our Multi-Agent Diagnosis with Decentralized Reasoning (MAD-DR) algorithm, a decentralized multi-agent algorithm that finds a commonsense multi-agent diagnosis during the execution of a multi-agent plan.Algorithm 1 shows its pseudocode for each "self" agent , where it takes as inputs the CMA-STRIPS problem , its plan   , and its set of neighboring agents   (i.e., the set of agents that it can communicate with)., , ,  = negative((⊥,  , ,  ′ , ), , , , ) 13: end if At the start, the agent initializes its sets , ,  , and  (Lines 1-4) that will be used for diagnosis (they will be described in detail later) as well as initial observable state  0  (Line 5).Then, at each time step , if the preconditions of its current action    are satisfied by its current state    , then it executes the action and transitions to the next state   +1  (Lines 7-9).If the preconditions are not satisfied or (in the case where the preconditions are satisfied) the effects of the action are not reflected in the next state (i.e., there is a discrepancy between the actual effect and expected effect in the state), then it means that the action    is faulty.Consequently, the agent starts a diagnosis process (Lines 10-20).If the action is not faulty, then the agent repeats this process and attempts to execute its actions in its plan   until it successfully reaches its goal.
Note that we assume that an agent with a faulty action will stop executing its plan after detecting and diagnosing the fault (Line 19).
We now describe the diagnosis process, which is done using answer set programming.A diagnosis is needed when an action    is faulty, which can arise due to one of the following two conditions: • Condition 1: Its preconditions are not satisfied by the current state    .• Condition 2: Its preconditions are satisfied by the current state    , but its expected effects are not reflected in the next state   +1  .In both cases, the condition can be generalized to one where there is a discrepancy in one (or more) fluent  (that is related to the preconditions/effects) in the current/next state having a value  instead of the expected value ṽ.Our MAD-DR algorithm makes use of this generalization, which we now describe.

High-Level Description. At a high level, when an agent starts a diagnosis, it first checks whether it's own action 𝑎 𝑡
is abnormal (Condition 2) or not (Condition 1).
• If it is abnormal, then it knows that its action is part of the cause of the fault.This cause is possibly incomplete because an action by a different agent may also be abnormal and is contributing to the fault.Thus, the agent needs to check if other agents also have abnormal actions that affected the next state   +1  .• If it is not abnormal, then the fault lies with a different agent.
Thus, the agent needs to check if other agents have abnormal actions that affected the current state    .To do so, the agent sends inquiry messages to its neighboring agents (e.g., agents within its communication range) asking if its neighbors know why one (or more) fluent  is having a value  instead of the expected value ṽ.
When an agent receives such a message, if it knows the reason (for example, the agent with an abnormal action knows that its effects did not materialize), then it replies with a positive answer identifying the faulty agent.If it does not know the reason, then it will propagate the inquiry to its neighboring agents.If it receives a positive answer from one of its neighboring agents, it forwards that positive answer to the agent that sent the inquiry message.If it does not know the reason and it does not have any neighboring agents other than the agent that sent the inquiry message, the agent replies with a negative answer indicating that it does not know the faulty agent.If an agent receives negative answers from all its neighboring agents, then it replies with a negative answer to the agent that sent the inquiry as well.
Under the assumption that the communication graph of the agents is a (single) connected graph (i.e., there are no disjointed subgraphs), then the inquiring agent is guaranteed to identify the faulty agent since, in the worst case, the faulty agent will reply with a positive answer to its neighboring agent, who will propagate that answer back to the original inquiring agent.For efficiency, agents that received the positive answer along the path from the faulty agent to the inquiring agent will store the faulty information (e.g., fluent  has value  instead of  ′ at time step  because of agent ).That way, if another agent inquires about the same fault, the agent can reply with the information in a positive answer immediately instead of propagating to the faulty agent and back.
Algorithm 3 query-1(( , ,  ′ , ), , , , )  add (⊥,  , ,  ′ , ) to  8: end if 9: return , , ,  Additionally, due to the decentralized nature of the algorithm, multiple agents can initiate diagnoses for different faults concurrently.Therefore, a single agent may be involved in multiple diagnoses in parallel.Further, we assume that agents will continue to execute their plans as long as their actions are not faulty.Therefore, it is possible for several faulty agents to have stopped and are either diagnosing their faults or have identified their faults, while other non-faulty agents continue to execute their plans.These two characteristics of MAD-DR differ from most existing multi-agent diagnosis algorithms, which we will further elaborate in the Related Work section (see Section 5).

Detailed Description.
We now describe the pseudocode in more detail, especially the diagnoses component and the notations that we use.
When the self agent  diagnoses a fault at time step , it initializes   (), which is the set of discrepancies of the form ( , ,  ′ ) that indicates that  has the value  but should have the value  ′ , and   (), which is the set of discrepancies in   () that it knows is due to one of its actions.In other words, if the agent has an abnormal action    (Condition 2), then   () =   ().Otherwise (Condition 1),   () = ∅.The agent also updates the set of answers  it maintains.Each element in  has the form (,  , ,  ′ , ), which means that agent  is responsible for the discrepancy ( , ,  ′ ) at time step .
We write "  [ ( , ,  ′ , )]" to indicate that the self agent  sends to its neighboring agent  an inquiry on the discrepancy in the value of fluent  ( instead of  ′ ).As we assume that communication is perfect, this also means that agent  receives a message  ( , ,  ′ , ) from agent .In response to an inquiry  ( , ,  ′ , ) of agent , an agent  can reply with a message of the form " [ (,  , ,  ′ , )]" indicating that it knows that agent  is responsible for the difference in value of  at time ; or " [ (⊥,  , ,  ′ , )]" indicating that agent  and all its neighboring agents do not know which agent is responsible for it.
Agent  also maintains a list  of discrepancies and agents that are interested in learning about the causes of these discrepancies.Similarly, it also maintains a list  of failure answers received from neighboring agents and a list  of discrepancies that the agent received from neighboring agents.
When an agent receives a diagnosis message, it executes Algorithm 2. If it receives a new inquiry for the first time, then it executes the query-1 function (Algorithm 3).If the agent is the faulty agent, then it replies with a positive answer identifying itself as the faulty agent (Lines 3-4).If it does not have any neighboring agents aside from those that sent it the inquiry, then it replies with a negative answer (Lines 7-8).Otherwise, it propagates the inquiry to its neighboring agents (Lines 9-10).
If it receives a repeated (old) inquiry, then it executes the query-2 function (Algorithm 4).If the previous inquiry has been completed and the faulty agent has been identified, then the agent replies with a positive answer identifying the faulty agent.If the previous inquiry hasn't been completed, then the agent waits for that inquiry to be completed, after which the inquiring agent will receive an answer.
If it receives a positive answer, then it executes the positive function (Algorithm 5), which propagates the positive answer back to its neighboring agents that sent the inquiry for that answer.
Finally, if it receives a negative answer, then it executes the negative function (Algorithm 6).If the agent has received negative answers from all its neighboring agents (sans the neighboring agents that sent the inquiry), then it propagates the negative answer back to its neighboring agents that sent the inquiry.

RELATED WORK
Diagnosis of multi-agent systems (MAS) has been extensively studied in various settings and under different sets of assumptions.For a comprehensive discussion of prior work in this field, see a recent survey by Kalech and Natan [19].
Early work by Micalizio et al. [24] used causal models of failures and system behavior to detect failures online and invoke a diagnosis engine to isolate their root causes.Similarly, de Jonge et al. [9] proposed to first detect which actions have failed, referred to as the primary diagnosis, and then isolate the root cause of these failures, referred to as secondary diagnosis [9].
The literature on diagnosis of MAS focused on two types of faults: coordination faults [8,17,18,30] and plan-related faults [14,25,31,36,37].The root cause of coordination faults is a conflict between the beliefs of the agents, while the root cause of plan-related faults is an agent-intrinsic reason, e.g., a mechanical failure.Our work falls under the category of plan-related faults.
Most of the existing work on diagnosing MAS assume that while the agents may not have a centralized controller, the diagnosis process is centralized [9,16,23,24,28,[36][37][38].Kalech et al. [18] addressed the problem of distributed diagnosis using a Distributed Constraint Satisfaction Problem (DisCSP) solver.However, they focused on coordination faults.Daigle et al. [8] proposed a distributed diagnosis algorithm but they assumed a small number of agents and also focused on coordination faults.Roos [30] applied a distributed reinforcement learning mechanism to respond to observed failures in multi-agent systems.Yet, their focus is on how to adapt the existing plan to overcome the failure, not on the diagnosis aspect.Also, they assumed the agents are self-interested, while in our case they are collaborative.
Researchers have proposed a distributed approach to diagnose multi-agent systems for cases where the agents are collaborative but still seek to preserve some of their information private [25].They used a combination of model-based diagnosis and DisCSP, sending partial beliefs and explanations to each other until a diagnosis is reached.An alternative approach to distributed diagnosis of MAS is based on Spectrum-Based Fault Localization (SFL) [26].While it scales well and is fairly general, unlike our proposed work, it cannot utilize knowledge about the agents plan or action models.

EXPERIMENTAL EVALUATION
We now describe our experimental evaluations.

Domains
We experiment with the logistics domain [22] and the multi-agent pathfinding (MAPF) domain [42].In the logistics domain, we consider airplanes and trucks as agents.As airplanes can fly between cities, we assume that each airplane can communicate with (and knows the existence of) all other airplanes and all trucks (and vice versa).However, as each truck can only move within the city it is in, we assume that each truck can communicate with other trucks within the same city only.In other words, trucks in different cities cannot communicate with each other.In the MAPF domain, we assume that each agent can communicate with (and knows the existence of) all other agents in the problem since it is often assumed that every agent can move within a same set of locations.We experiments with the following domains:   It is easy to see that this problem needs at least 13 steps to solve: Truck t2 needs to load objects obj21 and obj23, drive to the airport apt2, unload the two objects (5 steps); Airplane apn1 then needs to load the two objects, fly to airport apt1, and unloads them (5 steps); Truck t1 then needs to load the two objects, drive to position pos1, and unload them (5 steps).In the meantime, truck t1 can deliver the two objects obj11 and obj13 to the airport apt1.Note that because we allow agents to execution actions in parallel, some actions that are required to complete the goal can overlap.Specifically, the last step of truck t2 and the first step of airplane apn1 can be done in parallel.Similarly, the last step of airplane apn1 and the first step of truck t1 can be done in parallel.Therefore, the optimal plan length for this goal is 13.
• Multi-Agent Pathfinding (MAPF) (3 agents in a 9 × 9 gridworld): To ease the creation of situations that require diagnosis, we force the paths to the goals of all agents to intersect at the center of the grid by blocking all but the middle cell of the middle column of the grid and generate the initial and goal of every robot on opposite sides of the middle column (see Figure 2).

Implementation
The system1 is implemented using SWI-Prolog2 and clingo. 3pecifically, the environment simulator and the agent controller are written in SWI-Prolog and the computation of the state of the worlds after the execution of actions by agents, the diagnosis module, the computation of plans implemented by different clingo modules.
The environment simulator is responsible for computing the next state of the world by receiving the action occurrences from the agents and calling the clingo module that computes the next state of the world.The environment also randomly generates errors, preventing some actions to be successfully completed. 4The generated errors need to be taken into consideration in the next state computation.Naturally, there are different ways to deal with unsuccessful execution of an action, such as ignoring it and continuing with the next action; or just abandoning the execution of the plan.In this paper, we adopt the view that the latter view: Once the execution of an action by an agent is unsuccessful, then all subsequent actions will be unsuccessful.This view is influenced by the MAPF domain in which an error occurrence often means that the robot is out of order.The simulator is also responsible for providing the agents with their local observations (see Section 4.1).For example, in the logistics domain, truck t1 does not know about the existence of truck t2 and, therefore, will not know about the truth value of the fluent  (2, 2) that indicates that t2 is at pos2.
The agent controller implements the main algorithm MAD-DR and all the necessary procedures described in Section 4.3.The communication between agents is facilitated by the tipc library provided by SWI-Prolog.The agent controller is responsible for executing the agent's plan.At each step, it sends to the simulator the action that needs to be executed; the agent controller receives the observations, compares them with its hypothetical state, identifies the need for diagnoses, and communicate with other agents to identify the cause if a diagnosis is needed.
The clingo modules have been developed so that it can handle commonsense fluents.For example, the default value  of a commonsense fluent  is encoded by an the rule ℎ( , ) ←  ( ),   ( , ) and used in these modules.Abnormal situations (atoms of the form  ( , )) can be randomly generated and integrated with the error generation module of the simulator.

Experimental Results
To set up the experiments, we use a clingo module to generate valid concurrent plans for the agents.For example, Table 1 shows the plan for the three agents in the Logistics problem where '-' denotes that the agent is idle.The actions are simplified to ease the presentation.The clingo module computes the plan with the minimal horizon for all agents to achieve the goal of the problem.However, it does not optimize the individual plans, i.e., some of the agents might execute spurious actions (e.g., the airplane does not need to fly back and forth between two airports).We now describe the results of our experiments for each of our configuration domains.performs reasonable well but also leaves several interesting issues for the future.First, the question of whether SWI-Prolog is the best choice for the development of a scalable and efficient decentralized diagnosis engine needs to be evaluated.Second, as we have mentioned earlier, our assumption that the failure of an action implies failure of the agent might need to be relaxed for some applications.Third, creating CMA-STRIPS benchmarks with commonsense features and axioms is also an activity that should be conducted.

Definition 4 . 1 (
Commonsense Multi-Agent Diagnosis).A Commonsense Multi-Agent Diagnosis problem is defined by a tuple ⟨Π, , Ω⟩, where Π is a CMA-STRIPS problem,  is a solution to Π, and Ω is the observation for some realization of .A solution to the problem is a diagnosis for  and Ω.