ix.ip2
Class Ip2ModelManager

java.lang.Object
  extended by ix.icore.AbstractAnnotatedObject
      extended by ix.util.context.ContextAnnotatedObject
          extended by ix.icore.process.AbstractPMM
              extended by ix.ip2.Ip2ModelManager
All Implemented Interfaces:
Annotated, ProcessModelManager, java.io.Serializable
Direct Known Subclasses:
IPlanModelManager

public class Ip2ModelManager
extends AbstractPMM

See Also:
Serialized Form

Nested Class Summary
protected  class Ip2ModelManager.BindingSentinel
          A sentinel that lets an activity become complete when all the variables in its effects have values.
 
Nested classes/interfaces inherited from class ix.icore.process.AbstractPMM
AbstractPMM.Sentinel
 
Field Summary
protected  AdviceManager adviceManager
           
 boolean computeStatus
           
protected  java.lang.Object computeSupportCode
           
protected  ConstraintAssociator constraintAssociator
           
protected  Ip2 ip2
           
protected  ContextMultiMap nodeFilterConstraints
           
protected  LLQueue<ActivityItem> nodes
           
protected  ContextMultiMap nodeTimeConstraints
           
protected  LLQueue otherConstraints
           
protected  ContextMultiMap otherNodeConstraints
           
protected static Symbol S_COMPUTE_SUPPORT_CODE
           
static Symbol S_CONDITION
           
static Symbol S_EFFECT
           
static Symbol S_WORLD_STATE
           
protected  LLQueue sentinels
           
protected  TimePointNet tpnm
           
protected  ContextHashMap varEnv
           
protected  VariableManager variableManager
           
protected  Ip2WorldStateManager worldStateCM
           
 
Fields inherited from class ix.icore.AbstractAnnotatedObject
annotationListeners, annotations
 
Constructor Summary
Ip2ModelManager(Ip2 ip2)
           
 
Method Summary
 void addConstraint(Constrainer c)
           
 void addConstraint(java.util.Map idToItemMap, Constrainer c)
           
 void addConstraint(PNode node, Constraint c)
           
 void addConstraintManager(ConstraintManager cm)
           
 MatchChoice addMatchChoice(java.util.List envs)
           
 void addNode(PNode node)
           
 void addNodesBefore(PNode at, java.util.List addList)
           
 void addOrderingsAsTimeConstraints(PNode node, ix.icore.domain.ListOfOrdering orderings)
           
 void addSentinel(AbstractPMM.Sentinel r)
           
 void addVariable(Variable v)
           
 void applyEnv(MatchEnv env)
           
 void beginUndoableTransaction(java.lang.String note)
           
 void bindVariables(java.util.Map bindings)
          Assigns values to Variables.
 void clear()
           
 void deleteConstraint(Constraint c)
           
protected  void deleteEffect(PatternAssignment pv)
           
 void endUndoableTransaction(java.lang.String note)
           
 void evalAtBegin(PNodeEnd ne, java.util.List<Constraint> constraints)
           
 void evalAtEnd(PNodeEnd ne, java.util.List<Constraint> constraints)
           
 java.util.List evalFilters(ix.icore.domain.ListOfConstraint conds, MatchEnv env)
           
 void executeRefinementEffects(Refinement r, MatchEnv env)
          Applies the world-state effects specified by the refinement, changing the current world state.
 Refinement fillInRefinement(Refinement r, MatchEnv env)
          Returns a copy of the refinement in which each ItemVar that appears in the refinement is replaced the value, if any, that it has in the MatchEnv.
protected  void forcedBindings(MatchEnv forced)
           
 AdviceManager getAdviceManager()
           
protected  java.lang.Object getAnyNewComputeSupportCode()
           
 ComputeInterpreter getComputeInterpreter()
           
 java.util.List<ConstraintManager> getConstraintManagers(Constraint c)
           
 Ip2 getIp2()
           
 ix.icore.domain.ListOfConstraint getNodeConditions(PNode node)
           
 java.util.List getNodeEffects(PNode node)
           
 java.util.List<PNodeEnd> getNodeEnds()
           
 ix.icore.domain.ListOfConstraint getNodeFilters(PNode node)
           
 java.util.List<ActivityItem> getNodes()
           
 java.util.List<Constraint> getNodeTimeConstraints(PNode node)
           
 java.util.List getOtherConstraints()
           
 java.util.List<Constraint> getOtherNodeConstraints(PNode node)
           
 Plan getPlan()
           
protected  java.util.List getSentinels()
           
 TimePointNet getTPNManager()
           
 java.util.List<UndoAction> getUndoTrail()
           
 java.util.Map getVarEnv()
           
 Variable getVariable(java.lang.Object name)
           
 VariableManager getVariableManager()
           
 java.util.Map getWorldStateMap()
           
 java.lang.Object getWorldStateValue(LList pattern)
           
protected  void handleCompletion(PNode node)
           
protected  void handleEffects(java.util.List effects)
           
 void handleEffects(PNode node, java.util.List effects)
           
 void linkAfter(PNodeEnd to, PNodeEnd from)
           
 void linkBefore(PNodeEnd from, PNodeEnd to)
           
 void loadAnyNewComputeSupportCode()
           
 void logBindings(java.util.Map bindings)
           
protected  AdviceManager makeAdviceManager()
           
protected  ComputeInterpreter makeComputeInterpreter()
           
protected  TimePointNet makeTPNManager()
           
protected  VariableManager makeVariableManager()
           
protected  Ip2WorldStateManager makeWorldStateManager()
           
 void markUndoPoint(java.lang.String note)
           
 long nextMark()
           
protected  void postProcessInstalledPlan(PlanInstaller pi)
           
 java.util.List reevaluateFilters(ix.icore.domain.ListOfConstraint conds)
           
 void removeNode(PNode node)
           
 void removeSentinel(AbstractPMM.Sentinel r)
           
 void reset()
           
 java.util.List satisfyRefinementPreconditions(Activity act, Refinement r)
          Returns a list of MatchEnvs containing one env for each way in which all of the refinement's preconditions can be satisfied by the curent world state.
 void saveUndoAction(UndoAction un)
           
 void setAnnotation(java.lang.Object key, java.lang.Object value)
           
 void setPlan(Plan plan)
           
 void setWorldStateMap(java.util.Map m)
           
 void statusChanged(PNode node)
          Called by a node when its status changes.
 ix.icore.domain.ListOfConstraint testFilters(ix.icore.domain.ListOfConstraint conds, MatchEnv env)
           
 void undo()
           
 void undo(java.lang.String noteToMatch)
           
 void undoableTransaction(java.lang.String note, java.lang.Runnable r)
          Packages an undoable transaction as one method call.
 boolean undoIsEnabled()
           
 void walkNodeChildren(ActivityItem item, Proc walker)
           
 void walkNodeEnds(Proc p)
           
 void walkNodes(Proc p)
           
 void walkTopNodes(Proc walker)
           
 
Methods inherited from class ix.icore.process.AbstractPMM
addConstraints, addConstraints, addProcessStatusListener, fireNewBindings, fireStateChange, fireStateDeletion, fireStatusUpdate, getConstraintManager, getConstraintManager, putVariablesInPattern, registerConstraintManager, runSentinels
 
Methods inherited from class ix.util.context.ContextAnnotatedObject
annMap, clearAnnotationsCompletely, makeAnnMap, setAnnotations
 
Methods inherited from class ix.icore.AbstractAnnotatedObject
addAnnotationListener, clearAnnotations, fireSetAnnotation, getAnnotation, getAnnotations, getComments, removeAnnotation, setComments, takeAnnotations
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface ix.icore.Annotated
addAnnotationListener, clearAnnotations, fireSetAnnotation, getAnnotation, getAnnotations, removeAnnotation, setAnnotations, takeAnnotations
 

Field Detail

S_WORLD_STATE

public static final Symbol S_WORLD_STATE

S_CONDITION

public static final Symbol S_CONDITION

S_EFFECT

public static final Symbol S_EFFECT

S_COMPUTE_SUPPORT_CODE

protected static final Symbol S_COMPUTE_SUPPORT_CODE

ip2

protected Ip2 ip2

nodes

protected LLQueue<ActivityItem> nodes

varEnv

protected ContextHashMap varEnv

sentinels

protected LLQueue sentinels

constraintAssociator

protected ConstraintAssociator constraintAssociator

variableManager

protected VariableManager variableManager

worldStateCM

protected Ip2WorldStateManager worldStateCM

tpnm

protected TimePointNet tpnm

adviceManager

protected AdviceManager adviceManager

otherConstraints

protected LLQueue otherConstraints

nodeFilterConstraints

protected ContextMultiMap nodeFilterConstraints

nodeTimeConstraints

protected ContextMultiMap nodeTimeConstraints

otherNodeConstraints

protected ContextMultiMap otherNodeConstraints

computeSupportCode

protected java.lang.Object computeSupportCode

computeStatus

public boolean computeStatus
Constructor Detail

Ip2ModelManager

public Ip2ModelManager(Ip2 ip2)
Method Detail

reset

public void reset()

clear

public void clear()

getIp2

public Ip2 getIp2()

getVariableManager

public VariableManager getVariableManager()

makeVariableManager

protected VariableManager makeVariableManager()

makeWorldStateManager

protected Ip2WorldStateManager makeWorldStateManager()

makeTPNManager

protected TimePointNet makeTPNManager()

getTPNManager

public TimePointNet getTPNManager()

makeAdviceManager

protected AdviceManager makeAdviceManager()

getAdviceManager

public AdviceManager getAdviceManager()

makeComputeInterpreter

protected ComputeInterpreter makeComputeInterpreter()

getComputeInterpreter

public ComputeInterpreter getComputeInterpreter()

addConstraintManager

public void addConstraintManager(ConstraintManager cm)

getConstraintManagers

public java.util.List<ConstraintManager> getConstraintManagers(Constraint c)

addVariable

public void addVariable(Variable v)

getVariable

public Variable getVariable(java.lang.Object name)

getVarEnv

public java.util.Map getVarEnv()

addNode

public void addNode(PNode node)

removeNode

public void removeNode(PNode node)

addNodesBefore

public void addNodesBefore(PNode at,
                           java.util.List addList)

getNodes

public java.util.List<ActivityItem> getNodes()

nextMark

public long nextMark()

walkNodes

public void walkNodes(Proc p)

walkTopNodes

public void walkTopNodes(Proc walker)

walkNodeChildren

public void walkNodeChildren(ActivityItem item,
                             Proc walker)

walkNodeEnds

public void walkNodeEnds(Proc p)

getNodeEnds

public java.util.List<PNodeEnd> getNodeEnds()

bindVariables

public void bindVariables(java.util.Map bindings)
Assigns values to Variables. Assignments must go through this method rather than directly calling Variable.setValue(Object).

See Also:
Variable

forcedBindings

protected void forcedBindings(MatchEnv forced)

applyEnv

public void applyEnv(MatchEnv env)

logBindings

public void logBindings(java.util.Map bindings)

addConstraint

public void addConstraint(Constrainer c)

addConstraint

public void addConstraint(java.util.Map idToItemMap,
                          Constrainer c)

addConstraint

public void addConstraint(PNode node,
                          Constraint c)

evalAtBegin

public void evalAtBegin(PNodeEnd ne,
                        java.util.List<Constraint> constraints)

evalAtEnd

public void evalAtEnd(PNodeEnd ne,
                      java.util.List<Constraint> constraints)

linkBefore

public void linkBefore(PNodeEnd from,
                       PNodeEnd to)

linkAfter

public void linkAfter(PNodeEnd to,
                      PNodeEnd from)

addOrderingsAsTimeConstraints

public void addOrderingsAsTimeConstraints(PNode node,
                                          ix.icore.domain.ListOfOrdering orderings)

deleteConstraint

public void deleteConstraint(Constraint c)

getNodeConditions

public ix.icore.domain.ListOfConstraint getNodeConditions(PNode node)

getNodeFilters

public ix.icore.domain.ListOfConstraint getNodeFilters(PNode node)

getNodeEffects

public java.util.List getNodeEffects(PNode node)

getNodeTimeConstraints

public java.util.List<Constraint> getNodeTimeConstraints(PNode node)

getOtherNodeConstraints

public java.util.List<Constraint> getOtherNodeConstraints(PNode node)

getOtherConstraints

public java.util.List getOtherConstraints()

getWorldStateMap

public java.util.Map getWorldStateMap()

setWorldStateMap

public void setWorldStateMap(java.util.Map m)

getWorldStateValue

public java.lang.Object getWorldStateValue(LList pattern)

loadAnyNewComputeSupportCode

public void loadAnyNewComputeSupportCode()

getAnyNewComputeSupportCode

protected java.lang.Object getAnyNewComputeSupportCode()

setAnnotation

public void setAnnotation(java.lang.Object key,
                          java.lang.Object value)
Specified by:
setAnnotation in interface Annotated
Overrides:
setAnnotation in class AbstractAnnotatedObject

undoIsEnabled

public boolean undoIsEnabled()

undo

public void undo()

undo

public void undo(java.lang.String noteToMatch)

getUndoTrail

public java.util.List<UndoAction> getUndoTrail()

markUndoPoint

public void markUndoPoint(java.lang.String note)

saveUndoAction

public void saveUndoAction(UndoAction un)

undoableTransaction

public void undoableTransaction(java.lang.String note,
                                java.lang.Runnable r)
Packages an undoable transaction as one method call.

An alternative is to write a try-finally "by hand". It should look like this:

  Ip2ModelManager mm = ...;
  ...

  mm.beginUndoableTransaction("Note");
  try {
      ... undoable operations ...
  }
  finally {
      mm.endUndoableTransaction("Note");
  }
 
Note that the call to beginUndoableTransaction must be directly before the "try".


beginUndoableTransaction

public void beginUndoableTransaction(java.lang.String note)

endUndoableTransaction

public void endUndoableTransaction(java.lang.String note)

evalFilters

public java.util.List evalFilters(ix.icore.domain.ListOfConstraint conds,
                                  MatchEnv env)

testFilters

public ix.icore.domain.ListOfConstraint testFilters(ix.icore.domain.ListOfConstraint conds,
                                                    MatchEnv env)

reevaluateFilters

public java.util.List reevaluateFilters(ix.icore.domain.ListOfConstraint conds)

addMatchChoice

public MatchChoice addMatchChoice(java.util.List envs)

statusChanged

public void statusChanged(PNode node)
Description copied from interface: ProcessModelManager
Called by a node when its status changes.


handleCompletion

protected void handleCompletion(PNode node)

handleEffects

public void handleEffects(PNode node,
                          java.util.List effects)

handleEffects

protected void handleEffects(java.util.List effects)

deleteEffect

protected void deleteEffect(PatternAssignment pv)

satisfyRefinementPreconditions

public java.util.List satisfyRefinementPreconditions(Activity act,
                                                     Refinement r)
Returns a list of MatchEnvs containing one env for each way in which all of the refinement's preconditions can be satisfied by the curent world state. The preconditions are the world-state condition constraints, and the compute constraints, listed in the refinement. Each MatchEnv will also contain any bindings obtained by matching the activity's pattern to to the refinement's. Note that the list will be empty if the preconditions could not be satisfied.

Returns:
null if the refinement's pattern does not match the activity's; otherwise, a possibly empty list of MatchEnvs as described above.

fillInRefinement

public Refinement fillInRefinement(Refinement r,
                                   MatchEnv env)
Returns a copy of the refinement in which each ItemVar that appears in the refinement is replaced the value, if any, that it has in the MatchEnv.

Throws:
MissingValuesException - if any variables in the refinement did not have values.

executeRefinementEffects

public void executeRefinementEffects(Refinement r,
                                     MatchEnv env)
Applies the world-state effects specified by the refinement, changing the current world state. The MatchEnv should be one that satisfies the refinement's preconditions, such as one obtained by calling satisfyRefinementPreconditions(Activity, Refinement). All variables in the refinement should have been replaced by values as specified by the MatchEnv. That can be done by calling fillInRefinement(Refinement, MatchEnv) on the original refinement as obtained from a domain.

In addition to changing the world state, this method will assign values to any Variables listed in the MatchEnv.


getPlan

public Plan getPlan()

setPlan

public void setPlan(Plan plan)

postProcessInstalledPlan

protected void postProcessInstalledPlan(PlanInstaller pi)

addSentinel

public void addSentinel(AbstractPMM.Sentinel r)
Specified by:
addSentinel in class AbstractPMM

removeSentinel

public void removeSentinel(AbstractPMM.Sentinel r)
Specified by:
removeSentinel in class AbstractPMM

getSentinels

protected java.util.List getSentinels()
Specified by:
getSentinels in class AbstractPMM