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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GoalInstance.GoalState
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<OEAgent>
achievedAgs
protected java.util.Map<java.lang.String,java.lang.Object>
args
protected java.util.List<OEAgent>
comAgs
protected PlanInstance
inPlan
protected PlanInstance
plan
protected SchemeInstance
sch
private static long
serialVersionUID
protected Goal
spec
protected GoalInstance.GoalState
state
-
Fields inherited from class moise.common.MoiseElement
debug
-
-
Constructor Summary
Constructors Constructor Description GoalInstance(Goal sg, SchemeInstance sch)
-
Method Summary
Modifier and Type Method Description private boolean
checkEnabled()
the goal is enabled in the scheme state, i.e., its pre-condition goals are satisfied.void
committed(OEAgent a)
adds the agent a in the set of agents committed to this goalboolean
equals(java.lang.Object o)
java.util.Collection<OEAgent>
getAchievedAgents()
java.lang.Object
getArgumentValue(java.lang.String arg)
java.util.Map<java.lang.String,java.lang.Object>
getArgumentValues()
returns all this goal arguments (key=argId, value=Object)org.w3c.dom.Element
getAsDOM(org.w3c.dom.Document document)
java.lang.String
getAsProlog()
java.util.Collection<OEAgent>
getCommittedAgents()
PlanInstance
getPlanToAchieve()
SchemeInstance
getScheme()
Goal
getSpec()
GoalInstance.GoalState
getState()
static java.lang.String
getXMLTag()
boolean
hasComittedAgents()
int
hashCode()
boolean
hasSuperGoalInState(GoalInstance.GoalState s)
boolean
isCommitted()
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,boolean
isImpossible()
boolean
isSatisfied()
a goal is achieved if enough committed agents have set it as satisfiedvoid
setAchieved(OEAgent a)
sets that this goal is achieved by the agent a.void
setArgumentValue(java.lang.String arg, java.lang.Object value)
set an argument's value for this instance goalvoid
setImpossible(OEAgent a)
sets this goal as impossible to be achieved.void
setInPlan(PlanInstance pi)
void
setPlanToAchieve(PlanInstance pi)
set the plan that achieves this goalprivate void
setSuperAchieved()
private void
setSuperImpossible()
java.lang.String
toString()
void
uncommitted(OEAgent a)
removes the agent a in the set of agents committed to this goal-
Methods inherited from class moise.common.MoiseElement
compareTo, getBoolProperty, getBoolProperty, getCreationDate, getFullId, getId, getId, getOwner, getPrefix, getPrefix, getProperties, getPropertiesAsDOM, getPropertiesAsProlog, getProperty, getStrProperty, setId, setOwner, setPrefix, setPropertiesFromDOM, setProperty
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
spec
protected Goal spec
-
inPlan
protected PlanInstance inPlan
-
plan
protected PlanInstance plan
-
state
protected GoalInstance.GoalState state
-
sch
protected SchemeInstance sch
-
args
protected java.util.Map<java.lang.String,java.lang.Object> args
-
comAgs
protected java.util.List<OEAgent> comAgs
-
achievedAgs
protected java.util.List<OEAgent> achievedAgs
-
-
Constructor Detail
-
GoalInstance
public GoalInstance(Goal sg, SchemeInstance sch)
-
-
Method Detail
-
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 identificationvalue
- 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
-
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)
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classMoiseElement
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classMoiseElement
-
getAsProlog
public java.lang.String getAsProlog()
- Specified by:
getAsProlog
in interfaceToProlog
-
toString
public java.lang.String toString()
- Overrides:
toString
in classMoiseElement
-
-