Package jline.lang.reward
Class Reward
java.lang.Object
jline.lang.reward.Reward
Factory for common reward function templates.
The templates return a
RewardDescriptor, which is itself a
RewardFunction and can therefore be passed straight to
Network.setReward. Unlike a plain lambda, a descriptor records what the
reward measures, which is what makes the reward serializable to JSON.
model.setReward("QLen_Q1", Reward.queueLength(queue1));
model.setReward("QLen_Q1_C1", Reward.queueLength(queue1, class1));
model.setReward("Util_Q1", Reward.utilization(queue1));
model.setReward("Block_Q1", Reward.blocking(queue1));
The reward functions operate on a row of the aggregate state space, laid out as
[n_{1,1}, ..., n_{1,K}, n_{2,1}, ..., n_{M,K}], matching RewardFunction.- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic RewardDescriptorBlocking reward: 1 when the node holds at least as many jobs as its capacity, 0 otherwise.static RewardDescriptorcustom(RewardFunction userFn) Wraps an arbitrary user reward function.static RewardDescriptorqueueLength(Node node) Queue length reward: total number of jobs at a node, over all classes.static RewardDescriptorqueueLength(Node node, JobClass jobClass) Queue length reward: number of jobs of a given class at a node.static RewardDescriptorutilization(Node node) Utilization reward: min(jobs, nservers) at a node, over all classes.static RewardDescriptorutilization(Node node, JobClass jobClass) Utilization reward: min(class jobs, nservers) at a node.
-
Method Details
-
queueLength
Queue length reward: total number of jobs at a node, over all classes.- Parameters:
node- the station- Returns:
- a serializable reward descriptor
-
queueLength
Queue length reward: number of jobs of a given class at a node.- Parameters:
node- the stationjobClass- the job class- Returns:
- a serializable reward descriptor
-
utilization
Utilization reward: min(jobs, nservers) at a node, over all classes.- Parameters:
node- the station- Returns:
- a serializable reward descriptor
-
utilization
Utilization reward: min(class jobs, nservers) at a node.- Parameters:
node- the stationjobClass- the job class- Returns:
- a serializable reward descriptor
-
blocking
Blocking reward: 1 when the node holds at least as many jobs as its capacity, 0 otherwise.- Parameters:
node- the station- Returns:
- a serializable reward descriptor
-
custom
Wraps an arbitrary user reward function. The result is marked asRewardDescriptor.Kind.Custom, which is deliberately not serializable: an arbitrary function cannot be reproduced from JSON, so the writer warns and omits it rather than emitting a wrong reward.- Parameters:
userFn- the user reward function- Returns:
- a reward descriptor of kind Custom
-