public class Sarsa
extends java.lang.Object
| Constructor and Description |
|---|
Sarsa(int states,
int actions,
IExplorationPolicy explorationPolicy,
boolean randomize)
Initializes a new instance of the Sarsa class.
|
| Modifier and Type | Method and Description |
|---|---|
int |
GetAction(int state)
Get next action from the specified state.
|
int |
getActions()
Amount of possible actions.
|
double |
getDiscountFactor()
Get Discount Factor
|
IExplorationPolicy |
getExplorationPolicy()
Exploration policy.
|
double |
getLearningRate()
Get learning rate
|
int |
getStates()
Amount of possible states.
|
void |
setDiscountFactor(double discountFactor)
Discount factor, [0, 1].
|
void |
setExplorationPolicy(IExplorationPolicy explorationPolicy)
Exploration policy.
|
void |
setLearningRate(double learningRate)
Learning rate, [0, 1].
|
void |
UpdateState(int previousState,
int previousAction,
double reward)
Update Q-function's value for the previous state-action pair.
|
void |
UpdateState(int previousState,
int previousAction,
double reward,
int nextState,
int nextAction)
Update Q-function's value for the previous state-action pair.
|
public Sarsa(int states,
int actions,
IExplorationPolicy explorationPolicy,
boolean randomize)
states - Amount of possible states.actions - Amount of possible actions.explorationPolicy - Exploration policy.randomize - Randomize action estimates or not.
The randomize parameter specifies if initial action estimates should be randomized
with small values or not. Randomization of action values may be useful, when greedy exploration
policies are used. In this case randomization ensures that actions of the same type are not chosen always.public int getStates()
public int getActions()
public IExplorationPolicy getExplorationPolicy()
public void setExplorationPolicy(IExplorationPolicy explorationPolicy)
explorationPolicy - Exploration policypublic double getLearningRate()
public void setLearningRate(double learningRate)
learningRate - Learning ratepublic double getDiscountFactor()
public void setDiscountFactor(double discountFactor)
discountFactor - Discount Factorpublic int GetAction(int state)
state - Current state to get an action for.public void UpdateState(int previousState,
int previousAction,
double reward,
int nextState,
int nextAction)
previousState - Current state.previousAction - Action, which lead from previous to the next state.reward - Reward value, received by taking specified action from previous state.nextState - Next state.nextAction - Next action.public void UpdateState(int previousState,
int previousAction,
double reward)
previousState - Current state.previousAction - Action, which lead from previous to the next state.reward - Reward value, received by taking specified action from previous state.
Updates Q-function's value for the previous state-action pair in
the case if the next state is terminal.