Package jline.util

Class PrecomputedTableFunction

java.lang.Object
jline.util.PrecomputedTableFunction
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
PrecomputedCDFunction, PrecomputedRateFunction

public abstract class PrecomputedTableFunction extends Object implements Serializable
A pre-computed lookup table over per-class state vectors.

This is the shared storage used to convert MATLAB function handles to Java: the handle is evaluated in MATLAB over every reachable state and the resulting values are stored here, so that a call in Java is a table lookup. The state is keyed by the string "n1,n2,...,nR", where n_r is the entry of the state vector for class r.

Subclasses bind the table to a particular functional contract, since the two consumers disagree on the return type: PrecomputedCDFunction yields the dimensionless class-dependence beta as a Matrix, whereas PrecomputedRateFunction yields a scalar service rate mu(c) as a Double.

See Also:
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    PrecomputedTableFunction(int numClasses, double defaultValue)
    Creates a new pre-computed table.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addValue(int[] state, double value)
    Adds a pre-computed value for a specific state given as an array.
    void
    addValue(Matrix state, double value)
    Adds a pre-computed value for a specific state.
    void
    addValue(Matrix state, double[] value)
    Adds a pre-computed per-class value for a specific state, for a handle that returns one entry per class (as the flow-equivalent-server aggregation does, beta_r(n) = X_r(n)|n|/n_r).
    int
    Gets the number of classes.
    protected double
    lookup(Matrix state)
    Looks up the tabulated value for a state.
    protected double[]
    Looks up the tabulated per-class value for a state.
    int
    Gets the number of pre-computed values stored.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • PrecomputedTableFunction

      protected PrecomputedTableFunction(int numClasses, double defaultValue)
      Creates a new pre-computed table.
      Parameters:
      numClasses - the number of classes in the model
      defaultValue - the value to return when a state is not found
  • Method Details

    • addValue

      public void addValue(Matrix state, double value)
      Adds a pre-computed value for a specific state.
      Parameters:
      state - the state vector as a Matrix (1 x numClasses)
      value - the function value for this state
    • addValue

      public void addValue(int[] state, double value)
      Adds a pre-computed value for a specific state given as an array.
      Parameters:
      state - the state as an array of integers
      value - the function value for this state
    • addValue

      public void addValue(Matrix state, double[] value)
      Adds a pre-computed per-class value for a specific state, for a handle that returns one entry per class (as the flow-equivalent-server aggregation does, beta_r(n) = X_r(n)|n|/n_r). Storing it as a scalar would collapse the per-class resolution, so it is kept whole here and returned intact by PrecomputedCDFunction.apply(Matrix).
      Parameters:
      state - the state vector as a Matrix (1 x numClasses)
      value - the per-class function values for this state
    • lookup

      protected double lookup(Matrix state)
      Looks up the tabulated value for a state.
      Parameters:
      state - the state vector (1 x numClasses or numClasses x 1)
      Returns:
      the pre-computed value, or the default value if not found
    • lookupVector

      protected double[] lookupVector(Matrix state)
      Looks up the tabulated per-class value for a state.
      Parameters:
      state - the state vector (1 x numClasses or numClasses x 1)
      Returns:
      the per-class values, or null when the state was tabulated as a scalar (or not at all)
    • size

      public int size()
      Gets the number of pre-computed values stored.
      Returns:
      the number of pre-computed values
    • getNumClasses

      public int getNumClasses()
      Gets the number of classes.
      Returns:
      the number of classes
    • toString

      public String toString()
      Overrides:
      toString in class Object