SSJ  3.3.1
Stochastic Simulation in Java
Public Member Functions | List of all members
RatioFunction Class Reference

Represents a function computing a ratio of two values. More...

Inheritance diagram for RatioFunction:
[legend]
Collaboration diagram for RatioFunction:
[legend]

Public Member Functions

 RatioFunction ()
 Constructs a new ratio function.
 
 RatioFunction (double zeroOverZero)
 Constructs a new ratio function that returns zeroOverZero for the special case of \(0/0\). More...
 
double getZeroOverZeroValue ()
 Returns the value returned by evaluate in the case where the \(0/0\) function is calculated. More...
 
void setZeroOverZeroValue (double zeroOverZero)
 Sets the value returned by evaluate for the undefined function \(0/0\) to zeroOverZero. More...
 
int getDimension ()
 Returns \(d\), the dimension of the function computed by this implementation. More...
 
double evaluate (double... x)
 Computes the function \(g(\mathbf{x})\) for the vector x. More...
 
double evaluateGradient (int i, double... x)
 Computes \(\partial g(\mathbf{x})/\partial x_i\), the derivative of \(g(\mathbf{x})\) with respect to \(x_i\). More...
 

Detailed Description

Represents a function computing a ratio of two values.

Constructor & Destructor Documentation

◆ RatioFunction()

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
zeroOverZerothe value for \(0/0\).

Member Function Documentation

◆ evaluate()

double evaluate ( double...  x)

Computes the function \(g(\mathbf{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.

Parameters
xa vector \(\mathbf{x}\).
Returns
the value of \(g(\mathbf{x})\).
Exceptions
NullPointerExceptionif x is null.
IllegalArgumentExceptionif x.length does not correspond to the dimension of this function.

Implements MultivariateFunction.

◆ evaluateGradient()

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

Computes \(\partial g(\mathbf{x})/\partial x_i\), the derivative of \(g(\mathbf{x})\) with respect to \(x_i\).

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 \(\nabla g(\mathbf{x})\).

Parameters
ithe variable to derive with respect to.
xa vector \(\mathbf{x}\).
Returns
the value of the partial derivative.
Exceptions
NullPointerExceptionif x is null.
IllegalArgumentExceptionif x.length does not correspond to the dimension of this function.
IndexOutOfBoundsExceptionif i is negative or greater than or equal to the dimension of this function.

Implements MultivariateFunction.

◆ getDimension()

int getDimension ( )

Returns \(d\), the dimension of the function computed by this implementation.

If the dimension is not fixed, this method must return a negative value.

Returns
the dimension.

Implements MultivariateFunction.

◆ getZeroOverZeroValue()

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()

void setZeroOverZeroValue ( double  zeroOverZero)

Sets the value returned by evaluate for the undefined function \(0/0\) to zeroOverZero.

See getZeroOverZeroValue for more information.

Parameters
zeroOverZerothe new value for \(0/0\).

The documentation for this class was generated from the following file: