Class RewardDescriptor

java.lang.Object
jline.lang.reward.RewardDescriptor
All Implemented Interfaces:
Serializable, RewardFunction

public class RewardDescriptor extends Object implements RewardFunction
A RewardFunction that also records what the reward measures. A RewardDescriptor delegates evaluation to the wrapped reward function, so it can be passed to Network.setReward exactly like a plain lambda, while additionally exposing the structural description (getKind(), getNode(), getJobClass()) that allows the reward to be serialized declaratively. A descriptor of kind RewardDescriptor.Kind.Custom wraps an arbitrary user function and is deliberately NOT serializable: the writer warns and omits it rather than emitting a reward it cannot reproduce on reload.
See Also:
  • Constructor Details

    • RewardDescriptor

      public RewardDescriptor(RewardDescriptor.Kind kind, Node node, JobClass jobClass, RewardFunction delegate)
      Creates a reward descriptor.
      Parameters:
      kind - structural kind of the reward
      node - node the reward refers to, or null when not node-scoped
      jobClass - job class the reward refers to, or null when not class-scoped
      delegate - the reward function actually evaluated
  • Method Details

    • compute

      public double compute(Matrix state, NetworkStruct sn)
      Description copied from interface: RewardFunction
      Compute the reward value for a given state.
      Specified by:
      compute in interface RewardFunction
      Parameters:
      state - The state vector (row from stateSpaceAggr matrix) Format: [n_{1,1}, n_{1,2}, ..., n_{M,K}] where n_{i,k} is the number of class-k jobs at station i
      sn - The NetworkStruct providing access to rates, parameters, etc.
      Returns:
      The reward value for this state
    • getKind

      public RewardDescriptor.Kind getKind()
      Returns:
      the structural kind of this reward
    • getNode

      public Node getNode()
      Returns:
      the node this reward refers to, or null when not node-scoped
    • getJobClass

      public JobClass getJobClass()
      Returns:
      the job class this reward refers to, or null when not class-scoped
    • getDelegate

      public RewardFunction getDelegate()
      Returns:
      the wrapped reward function
    • toString

      public String toString()
      Overrides:
      toString in class Object