Package jline.util
Class PrecomputedTableFunction
java.lang.Object
jline.util.PrecomputedTableFunction
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
PrecomputedCDFunction,PrecomputedRateFunction
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
ConstructorsModifierConstructorDescriptionprotectedPrecomputedTableFunction(int numClasses, double defaultValue) Creates a new pre-computed table. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddValue(int[] state, double value) Adds a pre-computed value for a specific state given as an array.voidAdds a pre-computed value for a specific state.voidAdds 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).intGets the number of classes.protected doubleLooks up the tabulated value for a state.protected double[]lookupVector(Matrix state) Looks up the tabulated per-class value for a state.intsize()Gets the number of pre-computed values stored.toString()
-
Constructor Details
-
PrecomputedTableFunction
protected PrecomputedTableFunction(int numClasses, double defaultValue) Creates a new pre-computed table.- Parameters:
numClasses- the number of classes in the modeldefaultValue- the value to return when a state is not found
-
-
Method Details
-
addValue
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 integersvalue- the function value for this state
-
addValue
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 byPrecomputedCDFunction.apply(Matrix).- Parameters:
state- the state vector as a Matrix (1 x numClasses)value- the per-class function values for this state
-
lookup
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
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
-