Class QLearningAgent<S,A>
java.lang.Object
org.episteme.natural.computing.ai.rl.QLearningAgent<S,A>
- Type Parameters:
S- The type of the state (must properly implement equals/hashCode).A- The type of the action.
A generic Q-Learning agent implementation.
Learns a policy mapping states to actions to maximize cumulative reward.
- Since:
- 1.0
- Author:
- Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionchooseAction(S state) Chooses an action based on the current state using an epsilon-greedy policy.getBestAction(S state) Returns the best action for a given state (exploitation).doubleGets the maximum Q-value for a given state.voidUpdates the Q-value for a state-action pair based on the received reward and next state.voidvoidsetDiscountFactor(double gamma) voidsetExplorationRate(double epsilon) voidsetLearningRate(double alpha)
-
Constructor Details
-
QLearningAgent
-
-
Method Details
-
chooseAction
-
learn
Updates the Q-value for a state-action pair based on the received reward and next state. Q(s, a) = Q(s, a) + alpha * (reward + gamma * max(Q(s', a')) - Q(s, a))- Parameters:
state- The previous state.action- The action taken.reward- The reward received.nextState- The new state arrived at.
-
learn
-
getBestAction
-
getMaxQ
Gets the maximum Q-value for a given state. -
setLearningRate
public void setLearningRate(double alpha) -
setDiscountFactor
public void setDiscountFactor(double gamma) -
setExplorationRate
public void setExplorationRate(double epsilon)
-