Class Reward

java.lang.Object
jline.lang.reward.Reward

public class Reward extends Object
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 Details

    • queueLength

      public static RewardDescriptor queueLength(Node node)
      Queue length reward: total number of jobs at a node, over all classes.
      Parameters:
      node - the station
      Returns:
      a serializable reward descriptor
    • queueLength

      public static RewardDescriptor queueLength(Node node, JobClass jobClass)
      Queue length reward: number of jobs of a given class at a node.
      Parameters:
      node - the station
      jobClass - the job class
      Returns:
      a serializable reward descriptor
    • utilization

      public static RewardDescriptor utilization(Node node)
      Utilization reward: min(jobs, nservers) at a node, over all classes.
      Parameters:
      node - the station
      Returns:
      a serializable reward descriptor
    • utilization

      public static RewardDescriptor utilization(Node node, JobClass jobClass)
      Utilization reward: min(class jobs, nservers) at a node.
      Parameters:
      node - the station
      jobClass - the job class
      Returns:
      a serializable reward descriptor
    • blocking

      public static RewardDescriptor blocking(Node node)
      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

      public static RewardDescriptor custom(RewardFunction userFn)
      Wraps an arbitrary user reward function. The result is marked as RewardDescriptor.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