QLearner Class
Description:
A class for creating QLearner objects.
Usage:
local ML = require("ML")
local qLearner = ML.QLearner()
pack
Type: Function.
Description:
Construct a state from given hints and condition values.
Signature:
pack: function(self: QLearnerClass, hints: {integer}, values: {integer}): --[[state]] integer
Parameters:
Parameter | Type | Description |
---|---|---|
hints | {integer} | Representing the max number of possible hints. For example, if there are two conditions, and each condition has 3 possible values (0, 1, 2), then the hints array is {3, 3}. |
values | {integer} | The condition values as discrete values. |
Returns:
Return Type | Description |
---|---|
integer | The packed state value. |
unpack
Type: Function.
Description:
Deconstruct a state from given hints to get condition values.
Signature:
unpack: function(self: QLearnerClass, hints: {integer}, state: integer): {integer}
Parameters:
Parameter | Type | Description |
---|---|---|
hints | {integer} | Representing the max number of possible hints. For example, if there are two conditions, and each condition has 3 possible values (0, 1, 2), then the hints array is {3, 3}. |
state | integer | The state integer to unpack. |
Returns:
Return Type | Description |
---|---|
{integer} | The condition values as discrete values. |
__call
Type: Metamethod.
Description:
Create a new QLearner object with optional parameters for gamma, alpha, and maxQ.
Signature:
metamethod __call: function(
self: QLearnerClass,
gamma?: number --[[0.5]],
alpha?: number --[[0.5]],
maxQ?: number --[[100.0]]
): QLearner
Parameters:
Parameter | Type | Description |
---|---|---|
gamma | number | The discount factor for future rewards. Defaults to 0.5. |
alpha | number | The learning rate for updating Q-values. Defaults to 0.5. |
maxQ | number | The maximum Q-value. Defaults to 100.0. |
Returns:
Return Type | Description |
---|---|
QLearner | The newly created QLearner object. |