Package MAKBPInterpreter.interpreter
Class MAKBPInterpreter
- java.lang.Object
-
- MAKBPInterpreter.interpreter.MAKBPInterpreter
-
public class MAKBPInterpreter extends java.lang.Object
Represents a Multi-Agent Knowledge-Based Program interpreter. We can pass a default structure, collections of agents and objects, and an association of permissions to initialize this. We can iterate through the publicAnnoucement method to run the deduction system. We can check if all agents know that are all in the real world.
-
-
Constructor Summary
Constructors Constructor Description MAKBPInterpreter(java.util.Set<Agent> agents, KripkeStructure structure, java.util.Map<Agent,java.util.Set<Agent>> permissions, java.util.Map<Action,java.util.List<java.lang.Object>> objects)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Map<Agent,java.lang.Object>
executeAction(java.util.Map<Agent,Action> actions)
Executes retrieving actions.java.util.Map<Agent,Action>
getAssociatedAction(java.util.Collection<Agent> agents, KripkeWorld pointedWorld)
Gets the associated action for each agent of theagents
argument by retrieving its associated Kripke structure and thepointedWorld
.java.util.Map<Action,java.util.List<java.lang.Object>>
getObjects()
Gets the objects associated to actions.java.util.Map<Agent,java.util.Set<Agent>>
getPermissions()
Gets the permissions.java.util.Map<Agent,KripkeStructure>
getStructures()
Gets the Kripke structures of the agents.boolean
isFinished()
Check if the interpreter is terminated.boolean
isFinished(KripkeWorld realWorld)
Check if the interpreter is terminated.void
publicAnnouncement(java.util.Collection<Agent> agents, Formula formula)
Announcement of a formula to a collection of agents.void
publicAnnouncement(java.util.List<Agent> agents, java.util.List<Formula> formulas)
Announcement of associated formulas to agents.void
publicAnnouncement(java.util.Map<Agent,Formula> formulas)
Announcement of associated formulas to agents.void
publicAnnouncement(Agent agent, Formula formula)
Announcement of a formula to an agent.java.util.Map<Agent,Formula>
reasoning(java.util.Collection<Agent> agents, java.util.Map<Agent,Formula> observations)
Returns a map of agents and formulas in function of observations and agents programs knowledge for agents.java.util.Map<Agent,Formula>
reasoning(java.util.Collection<Agent> agents, java.util.Map<Agent,Formula> observations, java.util.Map<Agent,java.util.Set<Agent>> permissions)
Returns a map of agents and formulas in function of observations and observations knowledge for agents via permissions.Formula
reasoning(Agent agent, java.util.Map<Agent,Formula> observations)
Returns a formula in function of observations and agents programs knowledge for an agent.Formula
reasoning(Agent agent, java.util.Map<Agent,Formula> observations, java.util.Map<Agent,java.util.Set<Agent>> permissions)
Returns a formula in function of observations and observations knowledge for agents via permissions.java.util.Map<Agent,Formula>
reverseEngineering(java.util.Map<Agent,Action> actions)
Gets modal logic formulas for each retrieved action.
-
-
-
Constructor Detail
-
MAKBPInterpreter
public MAKBPInterpreter(java.util.Set<Agent> agents, KripkeStructure structure, java.util.Map<Agent,java.util.Set<Agent>> permissions, java.util.Map<Action,java.util.List<java.lang.Object>> objects)
Constructor.- Parameters:
agents
- set of agentsstructure
- default structure to copy for each agentspermissions
- agent programs knowledge for each agentobjects
- lists of objects to pass for action execution
-
-
Method Detail
-
publicAnnouncement
public void publicAnnouncement(java.util.List<Agent> agents, java.util.List<Formula> formulas) throws java.lang.Exception
Announcement of associated formulas to agents. Specification to announce formulas to agents in one method.- Parameters:
agents
- list of agents who received announcementformulas
- list of formula to announce- Throws:
java.lang.Exception
- thrown when the list sizes are not equals or by the Kripke structure in case of error
-
publicAnnouncement
public void publicAnnouncement(java.util.Map<Agent,Formula> formulas) throws java.lang.Exception
Announcement of associated formulas to agents. Specification to announce formula to agent via a map.- Parameters:
formulas
- map of formula to announce to a related agent- Throws:
java.lang.Exception
- thrown when the list sizes are not equals or by the Kripke structure in case of error
-
publicAnnouncement
public void publicAnnouncement(java.util.Collection<Agent> agents, Formula formula) throws java.lang.Exception
Announcement of a formula to a collection of agents. Specification to announce one formula to multiple agents.- Parameters:
agents
- collection of agents who received announcementformula
- formula to announce- Throws:
java.lang.Exception
- thrown by the Kripke structure in case of error
-
publicAnnouncement
public void publicAnnouncement(Agent agent, Formula formula) throws java.lang.Exception
Announcement of a formula to an agent.- Parameters:
agent
- agent who received announcementformula
- formula to announce- Throws:
java.lang.Exception
- thrown by the Kripke structure in case of error
-
getAssociatedAction
public java.util.Map<Agent,Action> getAssociatedAction(java.util.Collection<Agent> agents, KripkeWorld pointedWorld) throws java.lang.Exception
Gets the associated action for each agent of theagents
argument by retrieving its associated Kripke structure and thepointedWorld
.- Parameters:
agents
- collection of agents to get actionspointedWorld
- pointed world in the Kripke structure to retrieve actions- Returns:
- map of agents and actions
- Throws:
java.lang.Exception
- throws when the formula not supported evaluate operation or expected object not given
-
executeAction
public java.util.Map<Agent,java.lang.Object> executeAction(java.util.Map<Agent,Action> actions) throws java.lang.Exception
Executes retrieving actions.- Parameters:
actions
- actions to execute- Returns:
- returned objects of the actions executions
- Throws:
java.lang.Exception
- thrown when an actions no longer exists inobjects
attribute or when an action received illegal arguments, objects cannot be processed, etc
-
reverseEngineering
public java.util.Map<Agent,Formula> reverseEngineering(java.util.Map<Agent,Action> actions)
Gets modal logic formulas for each retrieved action.- Parameters:
actions
- retrieved actions- Returns:
- modal logic formulas
-
reasoning
public Formula reasoning(Agent agent, java.util.Map<Agent,Formula> observations)
Returns a formula in function of observations and agents programs knowledge for an agent.- Parameters:
agent
- reasoning agentobservations
- observations- Returns:
- deducted formula
- See Also:
reasoning(Agent, Map, Map)
-
reasoning
public Formula reasoning(Agent agent, java.util.Map<Agent,Formula> observations, java.util.Map<Agent,java.util.Set<Agent>> permissions)
Returns a formula in function of observations and observations knowledge for agents via permissions.- Parameters:
agent
- reasoning agentobservations
- observationspermissions
- map to know if an agent can see another agent- Returns:
- deducted formula
-
reasoning
public java.util.Map<Agent,Formula> reasoning(java.util.Collection<Agent> agents, java.util.Map<Agent,Formula> observations)
Returns a map of agents and formulas in function of observations and agents programs knowledge for agents.- Parameters:
agents
- reasoning agentsobservations
- observations- Returns:
- deducted formulas
- See Also:
reasoning(Collection, Map, Map)
-
reasoning
public java.util.Map<Agent,Formula> reasoning(java.util.Collection<Agent> agents, java.util.Map<Agent,Formula> observations, java.util.Map<Agent,java.util.Set<Agent>> permissions)
Returns a map of agents and formulas in function of observations and observations knowledge for agents via permissions.- Parameters:
agents
- reasoning agentsobservations
- observations- Returns:
- deducted formulas
-
getPermissions
public java.util.Map<Agent,java.util.Set<Agent>> getPermissions()
Gets the permissions.- Returns:
- permissions object
-
getObjects
public java.util.Map<Action,java.util.List<java.lang.Object>> getObjects()
Gets the objects associated to actions.- Returns:
- objects map
-
getStructures
public java.util.Map<Agent,KripkeStructure> getStructures()
Gets the Kripke structures of the agents.- Returns:
- structures map
-
isFinished
public boolean isFinished(KripkeWorld realWorld) throws KripkeStructureInvalidRuntimeException, NoKripkeWorldPossibleException
Check if the interpreter is terminated.- Parameters:
realWorld
- the real world or pointed world- Returns:
- boolean representing the end of the interpreter
- Throws:
KripkeStructureInvalidRuntimeException
- thrown when the real world has been deleted (so no convergence to it)NoKripkeWorldPossibleException
- thrown when no world are in a structure (impossible, need one real world)
-
isFinished
public boolean isFinished() throws NoKripkeWorldPossibleException
Check if the interpreter is terminated.- Returns:
- boolean representing the end of the interpreter
- Throws:
NoKripkeWorldPossibleException
- thrown when no world are in a structure (impossible, need one real world)
-
-