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

## umontreal.iro.lecuyer.contactcenters.contact
Class RandomTypeContactFactory

    java.lang.Object
      umontreal.iro.lecuyer.contactcenters.contact.RandomTypeContactFactory

All Implemented Interfaces:
  ContactFactory

    public class RandomTypeContactFactory

extends Object
implements ContactFactory

Represents a contact factory that can create contacts of random types. Any instance of this class encapsulates an array of contact factories, and a probability of selection for each factory. Each time a new contact is needed, an internal factory is selected randomly based on the selection probabilities, and used to instantiate the contact.

Constructor Summary
`RandomTypeContactFactory(ContactFactory[] factories, double[] prob, RandomStream stream)` Constructs a random-type contact factory selecting contact factories from the array `factories`, with probabilities given by `prob`, and using the random stream `stream`.

Method Summary
`ContactFactory[]` | `getContactFactories()` Returns an array giving each internal contact factory that can be selected.
`double[]` | `getProbabilities()` Returns an array giving the probability of selection for each internal contact factory.
`RandomStream` | `getStream()` Returns the random stream used for performing the selection.
`Contact` | `newInstance()` Constructs and returns a new `Contact` object.
`void` | `setStream(RandomStream stream)` Sets the random stream for performing further selections to `stream`.

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

Constructor Detail

### RandomTypeContactFactory

    public RandomTypeContactFactory(ContactFactory[] factories,
                                    double[] prob,
                                    RandomStream stream)

  Constructs a random-type contact factory selecting contact factories from the array `factories`, with probabilities given by `prob`, and using the random stream `stream`. Contact factory `factories[k]` is selected with probability `prob[k]`, for `k=0,...,factories.length-1`. If the values in `prob` do not sum to 1, they are normalized by dividing by their sum.

  Parameters:
    `factories` - the array of contact factories.
    `prob` - the array of probabilities of selection.
    `stream` - the random stream.
  Throws:
    `NullPointerException` - if any of the above argument is `null`, or if at least one given contact factory is `null`.
    `IllegalArgumentException` - if `factories` and `prob` do not share the same length, or if `prob` contains at least one negative value.

Method Detail

### getContactFactories

    public ContactFactory[] getContactFactories()

  Returns an array giving each internal contact factory that can be selected.

  Returns:
    the array of contact factories.

### getProbabilities

    public double[] getProbabilities()

  Returns an array giving the probability of selection for each internal contact factory.

  Returns:
    the array containing probabilities of selection.

### getStream

    public RandomStream getStream()

  Returns the random stream used for performing the selection.

  Returns:
    the random stream for selection.

### setStream

    public void setStream(RandomStream stream)

  Sets the random stream for performing further selections to `stream`.

  Parameters:
    `stream` - the new random stream for selection.
  Throws:
    `NullPointerException` - if `stream` is `null`.

### newInstance

    public Contact newInstance()

  Description copied from interface: `ContactFactory`
  Constructs and returns a new `Contact` object. If a contact cannot be instantiated, a `ContactInstantiationException` is thrown.

  Specified by:
    `newInstance` in interface `ContactFactory`
  Returns:
    the new contact object.

Overview | Package | Class | Tree | Deprecated | Index | Help
| ContactCenters V. 0.9.9.
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 Richard Simard.