ai.planning.strips
Class Action

java.lang.Object
  extended by ai.planning.strips.Action
All Implemented Interfaces:
Action<ai.krr.fol.Atom>

public class Action
extends java.lang.Object
implements Action<ai.krr.fol.Atom>

An Action is an activity that may be executable by some agent. Every Action must be a fully ground instance of some ActionType, i.e. all the parameters are mapped to objects in the domain. A unique id is given to an Action to distinguish multiple occurrences of Actions of the same ActionType in a plan.

Author:
Gerhard Wickler

Field Summary
protected  ActionType actionType
          the ActionType which this Action instantiates
protected  Grounding params
          the mapping of parameter variables (from the type) to domain objects
 
Constructor Summary
Action(ActionType type, Grounding g, boolean allowComplements)
           This constructor creates a new Action of the given type.
Action(ActionType type, java.util.List<ai.krr.fol.Constant> params, boolean allowComplements)
           This constructor creates a new Action of the given type.
 
Method Summary
protected  java.lang.String addrString()
           This function returns a String that corresponds to the address of this Object in memory.
 WorldState applyIn(WorldState state)
           This function computes a new WorldState that is the result of applying this Action in the given state.
 WorldState<ai.krr.fol.Atom> applyIn(WorldState<ai.krr.fol.Atom> state)
           This function computes a new WorldState that is the result of applying this Action in the given state.
 Action clone()
           This function returns an equal copy of this action.
 boolean equals(Action other)
           
 boolean equals(java.lang.Object obj)
           This function tests whether this and the given action are equal.
 ActionType getActionType()
           This function returns the ActionType of this Action.
 ai.krr.fol.Atom[] getNegativeEffects()
           This function returns the negative effects associated with this Action.
 ai.krr.fol.Atom[] getNegativePreconditions()
           This function returns the negative preconditions associated with this Action.
 ai.krr.fol.Atom[] getPositiveEffects()
           This function returns the positive effects associated with this Action.
 ai.krr.fol.Atom[] getPositivePreconditions()
           This function returns the positive preconditions associated with this Action.
 int hashCode()
           This function returns a hash value for this action.
 boolean isApplicableIn(WorldState state)
           This function tests whether this Action is applicable in the given state.
 boolean isApplicableIn(WorldState<ai.krr.fol.Atom> state)
           This function tests whether this Action is applicable in the given state.
 java.lang.String toString()
           This function creates a String representation for this ActionType.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

actionType

protected ActionType actionType
the ActionType which this Action instantiates


params

protected Grounding params
the mapping of parameter variables (from the type) to domain objects

Constructor Detail

Action

public Action(ActionType type,
              java.util.List<ai.krr.fol.Constant> params,
              boolean allowComplements)

This constructor creates a new Action of the given type. The Action is automatically given a unique id. The parameters are instantiated in the given order.

The final parameter determines whether an Action may have inconsistent effects. However, this is only tested with an assertion!

Parameters:
type - the ActionType which this Action instantiates
params - the objects used by this Action
allowComplements - whether complementary effects are permitted

Action

public Action(ActionType type,
              Grounding g,
              boolean allowComplements)

This constructor creates a new Action of the given type. The Action is automatically given a unique id. The parameters are instantiated using the given Grounding.

The final parameter determines whether an Action may have inconsistent effects. However, this is only tested with an assertion!

Parameters:
type - the ActionType which this Action instantiates
g - the grounding of the parameters defined in the type
allowComplements - whether complementary effects are permitted
Method Detail

clone

public Action clone()

This function returns an equal copy of this action. Note that the clone will have a different id.

Overrides:
clone in class java.lang.Object
Returns:
an equal copy of this Action

isApplicableIn

public boolean isApplicableIn(WorldState<ai.krr.fol.Atom> state)

This function tests whether this Action is applicable in the given state. It returns true iff all the Action's positive preconditions are entailed by the given WolrdState and the negative preconditions are falsified by the given WolrdState.

Specified by:
isApplicableIn in interface Action<ai.krr.fol.Atom>
Parameters:
state - the WorldState in which applicability is to be tested
Returns:
whether applying this Action in the given state results in a well-defined state

applyIn

public WorldState<ai.krr.fol.Atom> applyIn(WorldState<ai.krr.fol.Atom> state)

This function computes a new WorldState that is the result of applying this Action in the given state. The Action should be applicable or the result of this function may not be as expected. If assertions are switched on, applicability will be tested. The resulting WorldState is computed by first removing all the negative effects of the given Action from this state and then adding all the positive effects. This order is only relevant if this action may have inconsistent effects.

Specified by:
applyIn in interface Action<ai.krr.fol.Atom>
Parameters:
state - the WorldState in which this Action to be applied
Returns:
a new WorldState that is the result of the state transition function applied to the WorldState

getActionType

public ActionType getActionType()

This function returns the ActionType of this Action.

Specified by:
getActionType in interface Action<ai.krr.fol.Atom>
Returns:
the ActionType instantiated by this Action

getNegativePreconditions

public ai.krr.fol.Atom[] getNegativePreconditions()

This function returns the negative preconditions associated with this Action. These are taken from the ActionType of this Action and instantiated using the Grounding of this Action.

Returns:
the fully ground negative preconditions of this Action

getPositivePreconditions

public ai.krr.fol.Atom[] getPositivePreconditions()

This function returns the positive preconditions associated with this Action. These are taken from the ActionType of this Action and instantiated using the Grounding of this Action.

Returns:
the fully ground positive preconditions of this Action

getNegativeEffects

public ai.krr.fol.Atom[] getNegativeEffects()

This function returns the negative effects associated with this Action. These are taken from the ActionType of this Action and instantiated using the Grounding of this Action.

Returns:
the fully ground negative effects of this Action

getPositiveEffects

public ai.krr.fol.Atom[] getPositiveEffects()

This function returns the positive effects associated with this Action. These are taken from the ActionType of this Action and instantiated using the Grounding of this Action.

Returns:
the fully ground positive effects of this Action

isApplicableIn

public boolean isApplicableIn(WorldState state)

This function tests whether this Action is applicable in the given state. It returns true iff all the Action's positive preconditions are entailed by the given WolrdState and the negative preconditions are falsified by the given WolrdState.

Parameters:
state - the WorldState in which applicability is to be tested
Returns:
whether applying this Action in the given state results in a well-defined state

applyIn

public WorldState applyIn(WorldState state)

This function computes a new WorldState that is the result of applying this Action in the given state. The Action should be applicable or the result of this function may not be as expected. If assertions are switched on, applicability will be tested. The resulting WorldState is computed by first removing all the negative effects of the given Action from this state and then adding all the positive effects. This order is only relevant if this action may have inconsistent effects.

Parameters:
state - the WorldState in which this Action to be applied
Returns:
a new WorldState that is the result of the state transition function applied to the WorldState

addrString

protected java.lang.String addrString()

This function returns a String that corresponds to the address of this Object in memory. Thus, this String should be unique to this Action. The returned String will begin with the character '@' followed by a hexadecimal number.

String a unique String for this Action


equals

public boolean equals(java.lang.Object obj)

This function tests whether this and the given action are equal. This is true iff the unique ids of the two Actions are the same or iff they are the same Object.

Overrides:
equals in class java.lang.Object
Parameters:
obj - the Object this Action is compared to
Returns:
whether the two Actions are the same

equals

public boolean equals(Action other)

hashCode

public int hashCode()

This function returns a hash value for this action.

Overrides:
hashCode in class java.lang.Object
Returns:
an integer that can be used for hashing

toString

public java.lang.String toString()

This function creates a String representation for this ActionType.

Overrides:
toString in class java.lang.Object
Returns:
the String representing this Action