ai.planning.propositional
Class Action

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

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

An Action is an activity that may be executable by some agent. Every Action must be an instance of some ActionType. In propositional planning the only distinction between an Action and the ActionType it instantiates is the unique label that may be given to an Action. This can be used to distinguish multiple occurrences of Actions of the same ActionType in a plan, for example.

Author:
Gerhard Wickler

Field Summary
protected  ai.krr.NamedSymbol label
          the unique label for this Action or null
protected  ActionType type
          the ActionType which this Action instantiates
 
Constructor Summary
Action(ActionType type)
           This constructor creates a new Action of the given type.
 
Method Summary
 WorldState applyIn(WorldState<ai.krr.propositions.Atom> state)
           This function computes a new WorldState that is the result of applying this Action in the given state.
protected  Action clone()
           This class does not support cloning and an Exception will be thrown if this method is called.
 boolean equals(java.lang.Object obj)
           This function compares this Action to the given Object which must be an Action.
 ActionType getActionType()
           This function returns the ActionType of this Action.
 ai.krr.NamedSymbol getLabel()
           This function returns the unique label that distinguishes this Action from other Actions of the same ActionType.
 int hashCode()
           This function returns a hash value for this action.
 boolean isApplicableIn(WorldState<ai.krr.propositions.Atom> state)
           This function tests whether this Action is applicable in the given state.
 void setLabel(ai.krr.NamedSymbol label)
           This function sets the unique label for this Action.
 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

label

protected ai.krr.NamedSymbol label
the unique label for this Action or null


type

protected final ActionType type
the ActionType which this Action instantiates

Constructor Detail

Action

public Action(ActionType type)

This constructor creates a new Action of the given type. The Action is not given a unique label at this point.

Parameters:
type - the ActionType which this Action instantiates
Method Detail

clone

protected Action clone()
                throws java.lang.CloneNotSupportedException

This class does not support cloning and an Exception will be thrown if this method is called.

Overrides:
clone in class java.lang.Object
Returns:
nothing
Throws:
java.lang.CloneNotSupportedException - will be thrown

getActionType

public final ActionType getActionType()

This function returns the ActionType of this Action.

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

isApplicableIn

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

This function tests whether this Action is applicable in the given state. It returns true iff all the Action's preconditions are satisfied in the given WolrdState.

Specified by:
isApplicableIn in interface Action<ai.krr.propositions.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 applyIn(WorldState<ai.krr.propositions.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.

Specified by:
applyIn in interface Action<ai.krr.propositions.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

setLabel

public void setLabel(ai.krr.NamedSymbol label)

This function sets the unique label for this Action. Note that no test for uniqueness is performed here. Once a label has been assigned to an Action it should not be changed.

Parameters:
label - the label to be assigned to this Action

getLabel

public ai.krr.NamedSymbol getLabel()

This function returns the unique label that distinguishes this Action from other Actions of the same ActionType.

Returns:
the unique label of this Action (may be null)

equals

public boolean equals(java.lang.Object obj)

This function compares this Action to the given Object which must be an Action. If either of the Actions has a label assigned, equality of the Actions is determined by the identity of the labels. Otherwise two Actions are equal iff they are the same Object in memory (using the == test). Note that two Actions that have the same label should also have the same ActionType.

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

hashCode

public int hashCode()

This function returns a hash value for this action. If a label has been assigned to this Action the hash code of the label is returned. Otherwise the Object-level hashCode() is used.

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 WorldState