Overview | Package | Class | Tree | Deprecated | Index | Help
| SSJ V. 2.1.1.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## umontreal.iro.lecuyer.util
Class RatioFunction

    java.lang.Object
      umontreal.iro.lecuyer.util.RatioFunction

All Implemented Interfaces:
  MultivariateFunction

    public class RatioFunction

extends Object
implements MultivariateFunction

Represents a function computing a ratio of two values.

Constructor Summary
`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
`double` | `evaluate(double... x)` Computes the function g(x) for the vector `x`.
`double` | `evaluateGradient(int i, double... x)` Computes ∂g(x)/∂xi, the derivative of g(x) with respect to xi.
`int` | `getDimension()` Returns d, the dimension of the function computed by this implementation.
`double` | `getZeroOverZeroValue()` Returns the value returned by `evaluate` in the case where the 0/0 function is calculated.
`void` | `setZeroOverZeroValue(double zeroOverZero)` Sets the value returned by `evaluate` for the undefined function 0/0 to `zeroOverZero`.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

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 the `getZeroOverZeroValue` method 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 by `evaluate` in 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 by `evaluate` for the undefined function 0/0 to `zeroOverZero`. See `getZeroOverZeroValue` for more information.

  Parameters:
    `zeroOverZero` - the new value for 0/0.

### getDimension

    public int getDimension()

  Description copied from interface: `MultivariateFunction`
  Returns 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:
    `getDimension` in interface `MultivariateFunction`
  Returns:
    the dimension.

### evaluate

    public double evaluate(double... x)

  Description copied from interface: `MultivariateFunction`
  Computes 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:
    `evaluate` in interface `MultivariateFunction`
  Parameters:
    `x` - a vector x.
  Returns:
    the value of g(x).

### evaluateGradient

    public double evaluateGradient(int i,
                                   double... x)

  Description copied from interface: `MultivariateFunction`
  Computes ∂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:
    `evaluateGradient` in interface `MultivariateFunction`
  Parameters:
    `i` - the variable to derive with respect to.
    `x` - a vector x.
  Returns:
    the value of the partial derivative.

Overview | Package | Class | Tree | Deprecated | Index | Help
| SSJ V. 2.1.1.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

To submit a bug or ask questions, send an e-mail to Pierre L'Ecuyer.