ContactCenters
V. 0.9.9.

umontreal.iro.lecuyer.contactcenters.msk.model
Class SegmentInfo

java.lang.Object
  extended by umontreal.iro.lecuyer.xmlbind.NamedInfo
      extended by umontreal.iro.lecuyer.contactcenters.msk.model.SegmentInfo

public class SegmentInfo
extends NamedInfo

Represents information about a user-defined segment regrouping some indexed entities such as call types, agent groups, or periods. Each segment has a name, optional user-defined properties, and a list of indices.

Segment information is extracted from a SegmentParams instance which is read from a XML file by JAXB. The method getValues() can be used to obtain the indices regrouped by the segment, while containsValue(int) tests if a specific index is contained in the segment.


Constructor Summary
SegmentInfo(SegmentParams par)
          Constructs a new segment information object from the segment parameters par.
 
Method Summary
static DoubleMatrix2D addColumnSegments(DoubleMatrix2D mat, DoubleDoubleFunction func, SegmentInfo... segments)
          Similar to DoubleDoubleFunction,SegmentInfo...), for adding extra columns to matrix mat.
static DoubleMatrix2D addRowSegments(DoubleMatrix2D mat, DoubleDoubleFunction func, boolean[] globalSegmentValues, SegmentInfo... segments)
          Constructs and returns a matrix with all the rows in mat, extra rows corresponding to the segments in segments, and an additional row representing the aggregation of all rows in the original matrix.
static DoubleMatrix2D addRowSegments(DoubleMatrix2D mat, DoubleDoubleFunction func, SegmentInfo... segments)
          Calls addRowSegments (mat, func, null, segments).
static DoubleMatrix2D addRowSegments(DoubleMatrix2D mat, int numGroups, DoubleDoubleFunction func, boolean[] globalSegmentValues1, boolean[] globalSegmentValues2, SegmentInfo[] segments1, SegmentInfo[] segments2)
          Constructs and returns a matrix with all the rows in mat, and extra rows corresponding to the segments in segments1 and segments2.
static void checkRange(int lower, int upper, SegmentInfo... segments)
          Checks that the minimal value stored in all the segments segments is greater than or equal to lower, and the maximal value is smaller than upper.
 boolean containsValue(int i)
          Tests if the index i is included in the list of values associated with this segment.
 int getMaxValue()
          Returns the maximal index in this segment.
 int getMinValue()
          Returns the minimal index in this segment.
 int getNumValues()
          Returns the number of different values in this segment.
static SegmentInfo[] getSegments(Collection<? extends SegmentParams> par)
          Converts the given collection of segment parameters into an array of segment information objects.
 int[] getValues()
          Returns the reference to an array containing the list of values in this segment.
 
Methods inherited from class umontreal.iro.lecuyer.xmlbind.NamedInfo
getName, getProperties, getStringProperties
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SegmentInfo

public SegmentInfo(SegmentParams par)
Constructs a new segment information object from the segment parameters par.

Parameters:
par - the segment parameters.
Throws:
IllegalArgumentException - if some segment parameters wre invalid.
Method Detail

getValues

public int[] getValues()
Returns the reference to an array containing the list of values in this segment. The returned array can be modified without affecting the internal array in this object.

Returns:
the list of indices.

getNumValues

public int getNumValues()
Returns the number of different values in this segment.

Returns:
the number of values.

getMinValue

public int getMinValue()
Returns the minimal index in this segment.

Returns:
the minimal index.

getMaxValue

public int getMaxValue()
Returns the maximal index in this segment.

Returns:
the maximal index.

containsValue

public boolean containsValue(int i)
Tests if the index i is included in the list of values associated with this segment. Returns true if and only if i is included in the list of values returned by getValues().

Parameters:
i - the tested index.
Returns:
the success indicator of the test.

getSegments

public static SegmentInfo[] getSegments(Collection<? extends SegmentParams> par)
Converts the given collection of segment parameters into an array of segment information objects. This method first creates an array of segment information objects whose length corresponds to the size of the given collection. It then iterates over the collection, and creates one information object for each parameter object in the collection. The constructed array is then returned.

Parameters:
par - collection of segment parameters.
Returns:
the corresponding array of segment information objects.
Throws:
IllegalArgumentException - if an error occurs during the creation of a segment information object.

checkRange

public static void checkRange(int lower,
                              int upper,
                              SegmentInfo... segments)
Checks that the minimal value stored in all the segments segments is greater than or equal to lower, and the maximal value is smaller than upper. If this condition is violated for at least one segment, an illegal-argument exception is thrown. This method is used for validating parameters when the call center model is constructed. For example, it is used to ensure that segments of inbound call types does not contain any value greater than or equal to $ \Ki$.

Parameters:
lower - the lower bound (inclusive).
upper - the upper bount (non-inclusive).
segments - the array of segments to test.
Throws:
IllegalArgumentException - if at least one segment contains an out-of-bounds value.

addRowSegments

public static DoubleMatrix2D addRowSegments(DoubleMatrix2D mat,
                                            DoubleDoubleFunction func,
                                            SegmentInfo... segments)
Calls addRowSegments (mat, func, null, segments).

Parameters:
mat - the matrix to process.
func - the function f.
segments - the segments for which rows are added in the matrix.
Returns:
the matrix with extra rows.

addRowSegments

public static DoubleMatrix2D addRowSegments(DoubleMatrix2D mat,
                                            DoubleDoubleFunction func,
                                            boolean[] globalSegmentValues,
                                            SegmentInfo... segments)
Constructs and returns a matrix with all the rows in mat, extra rows corresponding to the segments in segments, and an additional row representing the aggregation of all rows in the original matrix. Let mat be a a×b matrix. If a≤1, the method returns mat unchanged. Otherwise, it creates a new matrix M with a + s + 1 rows and b columns, where s is the length of the segments array. Let mi, j be the element in mat at position (i, j), for i = 0,…, a - 1 and j = 0,…, b - 1, and let Mi, j be an element in the resulting matrix, with i = 0,…, a + s, and j = 0,…, b - 1. Then, for any j = 0,…, b - 1,

Mi, j = {$\displaystyle \begin{array}{ll}
f(0,m_{i,j}) &\mbox{ for }i=0,\ldots,a-1,\\  f_{l=0}^{a-1}
m_{l,j}s_{i-a,l}&\mbox{ for }i=a,\ldots,a+s, \end{array}$.

where

fi=abxisi = {$\displaystyle \begin{array}{ll} f(f_{i=a}^{b-1} x_is_i, x_b) &
\mbox{ if }a<b\...
... x_a) & \mbox{ if }a=b\mbox{ and }s_a=1,\\  0 & \mbox{
otherwise}. \end{array}$.

Here, f : $ \RR^{2}_{}$$ \RR$ is a function, and sr, i = 1 if index i is included in the rth segment, and 0 otherwise. For r = 0,…, s - 1, sr, i is determined using the containsValue(int) method of segments[r] while ss, i is 1 if and only if globalSegmentValues[i] is true. If globalSegmentValues is null, ss, i is set to 1 for all i in the last row.

Usually, func which represents f is set to Functions.plus, or Functions.max. In the former case, f (x, y) = x + y, and Mi, j is

$\displaystyle \htsum_{{l=0}}^{{a-1}}$ml, jsi-a, l.

Parameters:
mat - the matrix to process.
func - the function f.
globalSegmentValues - determines which rows are summed up in the global segment.
segments - the segments for which rows are added in the matrix.
Returns:
the matrix with extra rows.

addRowSegments

public static DoubleMatrix2D addRowSegments(DoubleMatrix2D mat,
                                            int numGroups,
                                            DoubleDoubleFunction func,
                                            boolean[] globalSegmentValues1,
                                            boolean[] globalSegmentValues2,
                                            SegmentInfo[] segments1,
                                            SegmentInfo[] segments2)
Constructs and returns a matrix with all the rows in mat, and extra rows corresponding to the segments in segments1 and segments2. Let mat be a (a*cb matrix. If a*c≤1, the method returns mat unchanged. Otherwise, it creates a new matrix M with (a + s1 +1)(c + s2 + 1) rows and b columns, where s1 and s2 are the lengths of the segments1 and segments2 arrays, respectively. Let mi, j, p be element at row i*c + j and column p in mat, with i = 0,…, a - 1 and j = 0,…, c - 1, and p = 0,…, b - 1. Also let Mi, j, p be element at row i*(c + s2 - 1) + j and column p in M, with i = 0,…, a + s1, and j = 0,…, c + s2. Then,

Mi, j, p = {$\displaystyle \begin{array}{ll}
f(0,m_{i,j,p}) &\mbox{ if }i<a\mbox{ and }j < ...
...^{c-1}m_{l_1,l_2,p}s_{2,j-c,l_2})s_{1,i-a,l_1}&
\mbox{ otherwise}. \end{array}$.

Here, sd, r, i is 1 if and only if segment r in dimension d contains element i, for d = 1, 2. In particular, s1, r, i, for r = 0,…, s1 - 1, is determined using segments1[r] while s2, r, i, for r = 0,…, s2 - 1, is set using segments2[r]. The variables s1, s1, i and s2, s2, i are set using globalSegmentValues1[i] and textttglobalSegmentValues2[i] respectively, or 1 if the corresponding array is null. The definition of fi=abxisi is the same as in method addRowSegments(DoubleMatrix2D,DoubleDoubleFunction,boolean[],SegmentInfo...).

Parameters:
mat - the matrix to process.
numGroups - the value of c, a being determined using mat.
func - the function f.
globalSegmentValues1 - determines which rows are summed up in the global segment for the first dimension.
globalSegmentValues2 - determines which rows are summed up in the global segment for the second dimension.
segments1 - the segments for which rows are added in the matrix, for the first dimension.
segments2 - the segments for which rows are added in the matrix, for the second dimension.
Returns:
the matrix with extra rows.

addColumnSegments

public static DoubleMatrix2D addColumnSegments(DoubleMatrix2D mat,
                                               DoubleDoubleFunction func,
                                               SegmentInfo... segments)
Similar to DoubleDoubleFunction,SegmentInfo...), for adding extra columns to matrix mat.

Parameters:
mat - the matrix to process.
func - the function f.
segments - the segments for which rows are added in the matrix.
Returns:
the matrix with extra rows.

ContactCenters
V. 0.9.9.

To submit a bug or ask questions, send an e-mail to Richard Simard.