Class RatioFunction
- java.lang.Object
-
- umontreal.iro.lecuyer.util.RatioFunction
-
- All Implemented Interfaces:
- MultivariateFunction
public class RatioFunction extends java.lang.Object implements MultivariateFunction
Represents a function computing a ratio of two values.
-
-
Constructor Summary
Constructors Constructor and Description RatioFunction()Constructs a new ratio function.RatioFunction(double zeroOverZero)Constructs a new ratio function that returns zeroOverZero for the special case of 0/0.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description doubleevaluate(double... x)Computes the function g(x) for the vector x.doubleevaluateGradient(int i, double... x)Computes ∂g(x)/∂xi, the derivative of g(x) with respect to xi.intgetDimension()Returns d, the dimension of the function computed by this implementation.doublegetZeroOverZeroValue()Returns the value returned byevaluatein the case where the 0/0 function is calculated.voidsetZeroOverZeroValue(double zeroOverZero)Sets the value returned byevaluatefor the undefined function 0/0 to zeroOverZero.
-
-
-
Constructor Detail
-
RatioFunction
public RatioFunction()
Constructs a new ratio function.
-
RatioFunction
public RatioFunction(double zeroOverZero)
Constructs a new ratio function that returns zeroOverZero for the special case of 0/0. See thegetZeroOverZeroValuemethod for more information. The default value of zeroOverZero is Double.NaN.- Parameters:
zeroOverZero- the value for 0/0.
-
-
Method Detail
-
getZeroOverZeroValue
public double getZeroOverZeroValue()
Returns the value returned byevaluatein the case where the 0/0 function is calculated. The default value for 0/0 is Double.NaN.Generally, 0/0 is undefined, and therefore associated with the Double.NaN constant, meaning not-a-number. However, in certain applications, it can be defined differently to accomodate some special cases. For exemple, in a queueing system, if there are no arrivals, no customers are served, lost, queued, etc. As a result, many performance measures of interest turn out to be 0/0. Specifically, the loss probability, i.e., the ratio of lost customers over the number of arrivals, should be 0 if there is no arrival; in this case, 0/0 means 0. On the other hand, the service level, i.e., the fraction of customers waiting less than a fixed threshold, could be fixed to 1 if there is no arrival.
- Returns:
- the value for 0/0.
-
setZeroOverZeroValue
public void setZeroOverZeroValue(double zeroOverZero)
Sets the value returned byevaluatefor the undefined function 0/0 to zeroOverZero. SeegetZeroOverZeroValuefor more information.- Parameters:
zeroOverZero- the new value for 0/0.
-
getDimension
public int getDimension()
Description copied from interface:MultivariateFunctionReturns d, the dimension of the function computed by this implementation. If the dimension is not fixed, this method must return a negative value.- Specified by:
getDimensionin interfaceMultivariateFunction- Returns:
- the dimension.
-
evaluate
public double evaluate(double... x)
Description copied from interface:MultivariateFunctionComputes the function g(x) for the vector x. The length of the given array must correspond to the dimension of this function. The method must compute and return the result of the function without modifying the elements in x since the array can be reused for further computation.- Specified by:
evaluatein interfaceMultivariateFunction- Parameters:
x- a vector x.- Returns:
- the value of g(x).
-
evaluateGradient
public double evaluateGradient(int i, double... x)Description copied from interface:MultivariateFunctionComputes ∂g(x)/∂xi, the derivative of g(x) with respect to xi. The length of the given array must correspond to the dimension of this function. The method must compute and return the result of the derivative without modifying the elements in x since the array can be reused for further computations, e.g., the gradient ∇g(x).- Specified by:
evaluateGradientin interfaceMultivariateFunction- Parameters:
i- the variable to derive with respect to.x- a vector x.- Returns:
- the value of the partial derivative.
-
-
DMelt 3.0 © DataMelt by jWork.ORG