Package moise.oe

Class OEAgent

java.lang.Object
moise.common.MoiseElement
moise.oe.OEAgent
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable, Identifiable, ToXML

public class OEAgent
extends MoiseElement
implements ToXML
Represents an agent that belongs to the OE.
Author:
Jomi Fred Hubner
See Also:
Serialized Form
  • Field Details

    • roles

      protected java.util.Map<java.lang.String,​RolePlayer> roles
    • missions

      protected java.util.Map<java.lang.String,​MissionPlayer> missions
    • oe

      protected OE oe
    • logger

      private static java.util.logging.Logger logger
    • serialVersionUID

      private static final long serialVersionUID
      See Also:
      Constant Field Values
  • Constructor Details

    • OEAgent

      protected OEAgent​(java.lang.String name)
  • Method Details

    • abort

      protected void abort() throws MoiseException
      remove the roles/missions of this agent without checking (in the case the agent leaves the society without finishing its commitments)
      Throws:
      MoiseException
    • adoptRole

      public RolePlayer adoptRole​(java.lang.String roleId, java.lang.String grId) throws MoiseConsistencyException, MoiseCardinalityException
      adds a role for an agent.

      Example: jaime.adoptRole("leader", att.getId())

      Parameters:
      roleId - the role identification (from OS)
      grId - the instance group id (from OE) where the role will be played
      Throws:
      MoiseConsistencyException - many errors: grId does not exist, the roleId does no exist in grId, the role is not compatible with other agent's role, ...
      MoiseCardinalityException - the number of roleId players already has the max value in grId
    • adoptRole

      public RolePlayer adoptRole​(java.lang.String roleId, GroupInstance gr) throws MoiseConsistencyException, MoiseCardinalityException
      adds a role for an agent.

      Example: jaime.adoptRole("leader", att)
      where jaime is an handler for an agent, "leader" is the role id, and att is the group handler.

      Parameters:
      roleId - the role identification (from OS)
      gr - the instance group object where the role will be played
      Throws:
      MoiseConsistencyException - many errors: the roleId does no exist in grId, the role is not compatible with other agent's role, ...
      MoiseCardinalityException - the number of roleId players already has the max value in gr
    • compatibilityCheck

      private void compatibilityCheck​(Role newRole, GroupInstance newRoleGr) throws MoiseConsistencyException
      Throws:
      MoiseConsistencyException
    • roleCardinalityCheck

      private void roleCardinalityCheck​(Role role, GroupInstance newRoleGr) throws MoiseCardinalityException
      Throws:
      MoiseCardinalityException
    • removeRole

      public RolePlayer removeRole​(java.lang.String roleId, java.lang.String grId) throws MoiseConsistencyException
      removes a role from an agent.

      Example: jaime.removeRole("leader", "gr_att2")
      where jaime is an handler for an agent, "leader" is the role id, and "gr_att2" is the group id.

      Parameters:
      roleId - the role identification (from OS)
      gr - the instance group id where the role will not be played anymore
      Throws:
      MoiseConsistencyException - the role is necessary for some mission, ...
    • removeRole

      public RolePlayer removeRole​(java.lang.String roleId, GroupInstance gr) throws MoiseConsistencyException
      removes a role from an agent.

      Example: jaime.removeRole("leader", att)
      where jaime is an handler for an agent, "leader" is the role id, and att is the group handler.

      Parameters:
      roleId - the role identification (from OS)
      gr - the instance group object where the role will not be played anymore
      Throws:
      MoiseConsistencyException - the role is necessary for some mission, ...
    • abortRole

      public void abortRole​(RolePlayer rp) throws MoiseConsistencyException
      removes a role of an agent without checking
      Throws:
      MoiseConsistencyException
    • removeAllRoles

      private void removeAllRoles()
      removes the roles without checking
    • getRoles

      public java.util.Collection<RolePlayer> getRoles()
      returns an Iterator for RolePlayers objects
    • playsRole

      public java.util.Collection<GroupInstance> playsRole​(java.lang.String roleId)
      returns the set of groups (class Group) where the roleId is being played
    • playsRole

      public RolePlayer playsRole​(java.lang.String roleId, GroupInstance gr)
      returns an object representing the roleId played by this agent in the group gr. returns null if roleId is not played by this agent.
    • playsRole

      public java.util.Collection<RolePlayer> playsRole​(GroupInstance gr)
      returns a collection of RolePlayer objects representing the roles this agent plays in the group gr
    • getNumberOfRoles

      public int getNumberOfRoles()
    • commitToMission

      public MissionPlayer commitToMission​(java.lang.String missionId, java.lang.String schId) throws MoiseConsistencyException, MoiseCardinalityException
      adds a mission for an agent.

      Example: gomi.commitToMission("m7", sch.getId());

      Parameters:
      missionId - the mission id (from OS)
      schId - the scheme id (from OE)
      Throws:
      MoiseConsistencyException
      MoiseCardinalityException
    • commitToMission

      public MissionPlayer commitToMission​(java.lang.String missionId, SchemeInstance sch) throws MoiseConsistencyException, MoiseCardinalityException
      adds a mission for an agent.

      Example: gomi.commitToMission("m7", sch);

      Parameters:
      missionId - the mission id (from OS)
      sch - the scheme object
      Throws:
      MoiseConsistencyException
      MoiseCardinalityException
    • removeMission

      public MissionPlayer removeMission​(java.lang.String missionId, java.lang.String schId) throws MoiseException
      removes a mission from an agent.

      Example: gomi.removeMission("m7", "sch_test4");

      Parameters:
      missionId - the mission id (from OS)
      sch - the scheme identification
      Throws:
      MoiseConsistencyException - when the agent tries to give up a mission with unsatisfied goals
      MoiseException
    • removeMission

      public MissionPlayer removeMission​(java.lang.String missionId, SchemeInstance sch) throws MoiseException
      removes a mission from an agent.

      Example: gomi.removeMission("m7", sch); or
      gomi.removeMission("test.m7", sch);
      (the mission id is prefixed by the scheme id separated by ".")

      Parameters:
      missionId - the mission id (from OS)
      sch - the scheme object
      Throws:
      MoiseConsistencyException - when the agent tries to give up a mission with unsatisfied goals
      MoiseException
    • abortMission

      public void abortMission​(java.lang.String missionId, SchemeInstance sch) throws MoiseException
      removes a mission commitment without checking
      Throws:
      MoiseException
    • getMission

      protected MissionPlayer getMission​(java.lang.String missionId, SchemeInstance sch)
      finds a mission player object for the mission "missionId" in scheme sch
    • getMission

      public MissionPlayer getMission​(java.lang.String missionId)
      finds a mission player object for the mission "missionId" in some scheme
    • checkDS

      private void checkDS​(Mission mis, SchemeInstance sch) throws MoiseConsistencyException
      checks if this agent's roles (in the scheme groups) gives him permission for the mission
      Throws:
      MoiseConsistencyException
    • missionMaxCardinalityCheck

      protected void missionMaxCardinalityCheck​(Mission mis, SchemeInstance sch) throws MoiseCardinalityException
      Throws:
      MoiseCardinalityException
    • missionMinCardinalityCheck

      protected boolean missionMinCardinalityCheck​(Mission mis, SchemeInstance sch)
    • getMissions

      public java.util.Collection<MissionPlayer> getMissions()
      returns an Iterator for MissionPlayers objects
    • removeAllMissions

      private void removeAllMissions() throws MoiseException
      removes all missions without checking
      Throws:
      MoiseException
    • getNumberOfMissions

      public int getNumberOfMissions()
    • getPossibleGoals

      public java.util.Collection<GoalInstance> getPossibleGoals()
      returns the possible global goals for this agent (see GoalInstance.isPossible method).
    • getAllMySchemes

      public java.util.Set<SchemeInstance> getAllMySchemes()
      returns a set of SCH where this agents has a mission
    • getLeafestPossibleGoal

      public GoalInstance getLeafestPossibleGoal()
      get the left first leaf possible goal in the agent's schemes
    • getLeafestPossibleGoal

      public GoalInstance getLeafestPossibleGoal​(SchemeInstance sch)
      get the left first leaf possible goal in the scheme sch
    • getLeafestPossibleGoal

      private GoalInstance getLeafestPossibleGoal​(PlanInstance p)
    • isMyGoal

      public boolean isMyGoal​(GoalInstance g, SchemeInstance sch)
      returns true if i am committed to the goal g.
    • getObligations

      public java.util.Collection<Permission> getObligations()
      returns a collection of mission i am obligated to commit to. each element in the returned collection is an Permission Object where: getRolePlayer() is the RolePlayer (rp), in this case "this" role player; getMission() is the Mission (m); and getScheme() is the Scheme instance (sch) where the rp is obligated to commit to m.
    • getPermissions

      public java.util.Collection<Permission> getPermissions()
      returns a collection of mission i am permitted to commit to. each element in the returned collection is an Permission Object where: getRolePlayer() is the RolePlayer (rp), in this case "this" role player; getMission() is the Mission (m); and getScheme() is the Scheme instance (sch) where the rp is obligated to commit to m.
    • getDeonticStatus

      public java.lang.String getDeonticStatus()
      returns a string describing this agent status regarding its obligations
    • hasLink

      public boolean hasLink​(java.lang.String type, OEAgent other)
      returns true if this agent has a role with a type link to other agent. If type = null, any kind of link can be considered.
    • setOE

      public void setOE​(OE oe)
    • getXMLTag

      public java.lang.String getXMLTag()
    • getAsDOM

      public org.w3c.dom.Element getAsDOM​(org.w3c.dom.Document document)
      Specified by:
      getAsDOM in interface ToXML