public abstract class GroundedAction extends java.lang.Object implements AbstractGroundedAction
GroundedAction is a high-level abstract class implementation of a AbstractGroundedAction
that is closely associated with single-agent Action definitions. The role of
a GroundedAction is to provide a reference to its corresponding Action
definition and also provide parameter assignments with which its Action should be applied.
The set of possible GroundedAction instances specifying the different possible parameter assignments
will be generated by the associated
Action.getAllApplicableGroundedActions(burlap.oomdp.core.states.State) method. See
the Action class documentation for more information on implementing parameterized
Action definitions.
AbstractGroundedAction
that are not implemented by GroundedAction:copy()AbstractGroundedAction.initParamsWithStringRep(String[]) andAbstractGroundedAction.getParametersAsString().Action with which the GroundedAction is associated
is not parameterized, then you can return the concrete class SimpleGroundedAction.
Otherwise, you will need to make your own subclass of GroundedAction and implement those methods.
Note that you can have your implementation store the parameter information anyway you like as long the copy() method
creates a version instance of your GroundedAction implementation that copies over
the parameter information. Additionally, for full support with all BURLAP tools, it should be possible to initialize
the parameters with a String array using the AbstractGroundedAction.initParamsWithStringRep(String[]) and get a String array representation
of them with the AbstractGroundedAction.getParametersAsString().
Action definition,
this class also provides a number of useful shortcut methods for evaluating the GroundedAction.
Specifically, see theexecuteIn(burlap.oomdp.core.states.State)executeIn(burlap.oomdp.singleagent.environment.Environment)getTransitions(burlap.oomdp.core.states.State) andapplicableInState(burlap.oomdp.core.states.State) Action methods providing this instance
as the set of parameters to use. Note that the getTransitions(burlap.oomdp.core.states.State) method
will throw a runtime exception if the associated Action definition does
not implement the FullActionModel interface.| Modifier and Type | Field and Description |
|---|---|
Action |
action
The action object for this grounded action
|
| Constructor and Description |
|---|
GroundedAction(Action action)
Initializes with the
Action definition with which this GroundedAction
is associated. |
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
actionName()
Returns the action name for this grounded action.
|
boolean |
applicableInState(State s) |
abstract GroundedAction |
copy()
Returns a copy of this grounded action.
|
boolean |
equals(java.lang.Object other) |
EnvironmentOutcome |
executeIn(Environment env)
Executes this grounded action in the specified
Environment. |
State |
executeIn(State s)
Executes the grounded action on a given state
|
java.util.List<TransitionProbability> |
getTransitions(State s)
Returns the full set of possible state transitions when this
GroundedAction is applied in
the given state. |
int |
hashCode() |
boolean |
isParameterized()
Returns true if this action uses parameters
|
java.lang.String |
toString() |
GroundedAction |
translateParameters(State source,
State target)
A helper method that handles action translate in case this
GroundedAction implements
AbstractObjectParameterizedGroundedAction. |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitgetParametersAsString, initParamsWithStringReppublic Action action
public GroundedAction(Action action)
Action definition with which this GroundedAction
is associated.action - the associated Action definition.public java.lang.String actionName()
actionName in interface AbstractGroundedActionpublic boolean isParameterized()
AbstractGroundedActionisParameterized in interface AbstractGroundedActionpublic java.lang.String toString()
toString in class java.lang.Objectpublic boolean applicableInState(State s)
public abstract GroundedAction copy()
AbstractGroundedActioncopy in interface AbstractGroundedActionpublic EnvironmentOutcome executeIn(Environment env)
Environment.env - the Environment in which the action is to be executed.EnvironmentOutcome specifying the outcome of this action.public State executeIn(State s)
s - the state on which to execute the actionpublic java.util.List<TransitionProbability> getTransitions(State s)
GroundedAction is applied in
the given state. If the underlying Action definition does not implement
FullActionModel, then a runtime exception will be thrown instead.s - the source state from which the transitions should be computed.List of TransitionProbability objects specifying all state transitions from the input state that have non-zero probability.public GroundedAction translateParameters(State source, State target)
GroundedAction implements
AbstractObjectParameterizedGroundedAction. Works by calling the
AbstractObjectParameterizedGroundedAction.Helper.translateParameters(burlap.oomdp.core.AbstractGroundedAction, burlap.oomdp.core.states.State, burlap.oomdp.core.states.State)
method with this object as the action to translate.
If this is a AbstractObjectParameterizedGroundedAction, then a new GroundedAction with its object parameters mapped to the object names sin the target state
is returned.source - the source state in which this GroundedAction's parameters were bound.target - the target state in which the returned GroundedAction will have its parameters bound.AbstractObjectParameterizedGroundedAction, then a new GroundedAction with its object parameters mapped to the object names sin the target statepublic int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object other)
equals in class java.lang.Object