Package moise.oe

Class GoalInstance

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

public class GoalInstance
extends MoiseElement
implements ToXML, ToProlog
Represents an instance goal (in an instance scheme)
Author:
Jomi Fred Hubner
See Also:
Serialized Form
  • Field Details

  • Constructor Details

  • Method Details

    • getSpec

      public Goal getSpec()
    • getScheme

      public SchemeInstance getScheme()
    • setInPlan

      public void setInPlan​(PlanInstance pi)
    • setPlanToAchieve

      public void setPlanToAchieve​(PlanInstance pi) throws MoiseConsistencyException
      set the plan that achieves this goal
      Throws:
      MoiseConsistencyException
    • getPlanToAchieve

      public PlanInstance getPlanToAchieve()
    • setArgumentValue

      public void setArgumentValue​(java.lang.String arg, java.lang.Object value) throws MoiseException
      set an argument's value for this instance goal

      Example: InstanceGoal gA = sch.getGoal("a"); gA.setArgumentValue("Z", "120");

      Parameters:
      arg - the argument identification
      value - the value for this argument
      Throws:
      MoiseException - there is not such an arg id
    • getArgumentValue

      public java.lang.Object getArgumentValue​(java.lang.String arg)
    • getArgumentValues

      public java.util.Map<java.lang.String,​java.lang.Object> getArgumentValues()
      returns all this goal arguments (key=argId, value=Object)
    • setAchieved

      public void setAchieved​(OEAgent a) throws MoiseConsistencyException, MoiseCardinalityException
      sets that this goal is achieved by the agent a. only committed agents can achieve the goal. If all agents committed to the goal set it as achieved, the goal is considered as satisfied. if this goal is achieved and belongs to a plan without committed agents, check if this super goal was also achieved
      Throws:
      MoiseConsistencyException
      MoiseCardinalityException
    • setSuperAchieved

      private void setSuperAchieved()
    • setImpossible

      public void setImpossible​(OEAgent a) throws MoiseConsistencyException
      sets this goal as impossible to be achieved. if this goal belongs to a plan without committed agents, check if this super goal was also impossible
      Throws:
      MoiseConsistencyException
    • setSuperImpossible

      private void setSuperImpossible()
    • committed

      public void committed​(OEAgent a)
      adds the agent a in the set of agents committed to this goal
    • uncommitted

      public void uncommitted​(OEAgent a)
      removes the agent a in the set of agents committed to this goal
    • isEnabled

      public boolean isEnabled()
      returns true if this goal is not satisfied yet, the scheme is well formed super goal is not satisfied, super goal is not impossible,
    • checkEnabled

      private boolean checkEnabled()
      the goal is enabled in the scheme state, i.e., its pre-condition goals are satisfied.
    • isSatisfied

      public boolean isSatisfied()
      a goal is achieved if enough committed agents have set it as satisfied
    • getState

      public GoalInstance.GoalState getState()
    • isImpossible

      public boolean isImpossible()
    • isCommitted

      public boolean isCommitted()
    • hasComittedAgents

      public boolean hasComittedAgents()
    • getCommittedAgents

      public java.util.Collection<OEAgent> getCommittedAgents()
    • getAchievedAgents

      public java.util.Collection<OEAgent> getAchievedAgents()
    • hasSuperGoalInState

      public boolean hasSuperGoalInState​(GoalInstance.GoalState s)
    • 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
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class MoiseElement
    • equals

      public boolean equals​(java.lang.Object o)
      Overrides:
      equals in class MoiseElement
    • getAsProlog

      public java.lang.String getAsProlog()
      Specified by:
      getAsProlog in interface ToProlog
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class MoiseElement