public class RandomPolicy extends java.lang.Object implements Policy, EnumerablePolicy
addAction(ActionType)
method
or remove or clear the actions.
Upon action selection, all applicable grounded actions for the state are generated and an action is selected uniformly randomly from them. The policy is not defined if there are no applicable actions.
Modifier and Type | Field and Description |
---|---|
protected java.util.List<ActionType> |
actionTypes
The actions from which selection is performed
|
protected java.util.Random |
rand
The random factory used to randomly select actions.
|
Constructor and Description |
---|
RandomPolicy(java.util.List<ActionType> actionTypes)
Initializes by copying all the actions references defined in the provided list into an internal action
list for this policy.
|
RandomPolicy(SADomain domain)
Initializes by copying all the primitive actions references defined for the domain into an internal action
list for this policy.
|
Modifier and Type | Method and Description |
---|---|
Action |
action(State s)
This method will return an action sampled by the policy for the given state.
|
double |
actionProb(State s,
Action a)
Returns the probability/probability density that the given action will be taken in the given state.
|
void |
addAction(ActionType actionType)
Adds an aciton to consider in selection.
|
void |
clearActions()
Clears the action list used in action selection.
|
boolean |
definedFor(State s)
Specifies whether this policy is defined for the input state.
|
java.util.Random |
getRandomGenerator()
Returns the random generator used for action selection.
|
java.util.List<ActionType> |
getSelectionActions()
Returns of the list of actions that can be randomly selected.
|
java.util.List<ActionProb> |
policyDistribution(State s)
This method will return action probability distribution defined by the policy.
|
void |
removeAction(java.lang.String actionName)
Removes an action from consideration.
|
void |
setRandomGenerator(java.util.Random rand)
Sets the random generator used for action selection.
|
protected java.util.List<ActionType> actionTypes
protected java.util.Random rand
public RandomPolicy(SADomain domain)
domain
- the domain containing all the primitive actions.public RandomPolicy(java.util.List<ActionType> actionTypes)
actionTypes
- the actions to select between.public void addAction(ActionType actionType)
actionType
- an action to consider in selectionpublic void clearActions()
public void removeAction(java.lang.String actionName)
actionName
- the name of the action to remove.public java.util.List<ActionType> getSelectionActions()
public java.util.Random getRandomGenerator()
public void setRandomGenerator(java.util.Random rand)
rand
- the random generator used for action selection.public Action action(State s)
Policy
public double actionProb(State s, Action a)
Policy
actionProb
in interface Policy
s
- the state of interesta
- the action that may be taken in the statepublic java.util.List<ActionProb> policyDistribution(State s)
EnumerablePolicy
policyDistribution
in interface EnumerablePolicy
s
- the state for which an action distribution should be returnedpublic boolean definedFor(State s)
Policy
definedFor
in interface Policy
s
- the input state to test for whether this policy is definedState
s, false otherwise.