Package moise.oe

Class SchemeInstance

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

public class SchemeInstance
extends MoiseElement
implements ToXML
Represents the instance of one scheme Specification.
Author:
Jomi Fred Hubner
See Also:
Serialized Form
  • Field Details

    • serialVersionUID

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

      public static final java.lang.String WellFormed
      See Also:
      Constant Field Values
    • spec

      protected Scheme spec
    • root

      protected GoalInstance root
    • oe

      protected OE oe
    • players

      protected java.util.Set<MissionPlayer> players
    • groups

      protected java.util.Set<GroupInstance> groups
    • goals

      protected java.util.Map<java.lang.String,​GoalInstance> goals
    • plans

      protected java.util.Set<PlanInstance> plans
    • schCount

      private static java.util.concurrent.atomic.AtomicInteger schCount
  • Constructor Details

  • Method Details

    • rebuildHash

      public void rebuildHash()
      since serialisation of maps has a bug, we need to rebuild them after serialisation!
    • getUniqueId

      public static java.lang.String getUniqueId()
    • setOE

      protected void setOE​(OE oe)
    • getOE

      public OE getOE()
    • getRoot

      public GoalInstance getRoot()
    • getSpec

      public Scheme getSpec()
      returns the SCH specification for this SCH instance
    • addResponsibleGroup

      public void addResponsibleGroup​(java.lang.String grId) throws MoiseConsistencyException
      adds an instance group in the set of groups responsible for this SCH.

      Example: sch.addResponsibleGroup(def.getId());

      Parameters:
      grId - the group Id
      Throws:
      MoiseConsistencyException - the grIs does not exist in the OE
    • addResponsibleGroup

      public void addResponsibleGroup​(GroupInstance g) throws MoiseConsistencyException
      adds an instance group in the set of groups responsible for this SCH.

      Example: sch.addResponsibleGroup(def);

      Parameters:
      g - the group object
      Throws:
      MoiseConsistencyException - the group is not well formed
    • remResponsibleGroup

      public void remResponsibleGroup​(java.lang.String grId) throws MoiseConsistencyException
      removes an instance group in the set of groups responsible for this SCH.

      Example: sch.remResponsibleGroup("gr_def22");

      Parameters:
      grId - the group id
      Throws:
      MoiseConsistencyException - no agent of group g can be committed to missions in this scheme
    • remResponsibleGroup

      public void remResponsibleGroup​(GroupInstance g) throws MoiseConsistencyException
      removes an instance group in the set of groups responsible for this SCH.

      Example: sch.remResponsibleGroup(def);

      Parameters:
      g - the group object
      Throws:
      MoiseConsistencyException - no agent of group g can be committed to missions in this scheme
    • getResponsibleGroups

      public java.util.Collection<GroupInstance> getResponsibleGroups()
      returns a collection of groups that are responsible for this scheme
    • abort

      public void abort() throws MoiseException
      remove all commitments without checking goal state
      Throws:
      MoiseException
    • wellFormedStatus

      public java.lang.String wellFormedStatus()
      returns "ok" (SchemeInstance.WellFormed) if the sch is well formed, otherwise returns the problems' description
    • isWellFormed

      public boolean isWellFormed()
      returns true if the sch is well formed
    • isCommitable

      public boolean isCommitable()
      returns true if this scheme's root goal is neither achieved nor impossible
    • addPlayer

      protected void addPlayer​(MissionPlayer mp)
      adds a mission player for this SCH
    • removePlayer

      protected void removePlayer​(MissionPlayer mp) throws MoiseException
      removes a mission player from this scheme (no checks are done)
      Throws:
      MoiseException
    • getPlayers

      public java.util.Collection<MissionPlayer> getPlayers()
    • isPlayer

      public boolean isPlayer​(OEAgent ag)
    • getPlayers

      public java.util.Collection<OEAgent> getPlayers​(java.lang.String missionId)
      returns the OEAgents committed to the missionId in this scheme (if missionId is null, return all agents)
    • getAgents

      public java.util.Collection<OEAgent> getAgents()
      gets all agents participating in this scheme
    • getPlayersQty

      public int getPlayersQty()
      returns the total number of players in this sch
    • getPlayersQty

      public int getPlayersQty​(java.lang.String missionId)
      returns the number of missionId players in this scheme
    • getGoal

      public GoalInstance getGoal​(java.lang.String goalId)
    • getGoal

      public GoalInstance getGoal​(Goal gs)
    • getGoals

      public java.util.Collection<GoalInstance> getGoals()
    • getXMLTag

      public static java.lang.String getXMLTag()
    • getAsDOM

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