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
Class ConstantValueGenerator

    java.lang.Object
      umontreal.iro.lecuyer.contactcenters.ConstantValueGenerator

All Implemented Interfaces:
  Initializable, ValueGenerator

    public class ConstantValueGenerator

extends Object
implements ValueGenerator

Implements the `ValueGenerator` interface for a constant and possibly non-stationary value. During each period of the simulation, the generated value is constant for each contact type. When a new period begins, the constant value can be changed.

This implementation only takes contact type identifiers (`Contact.getTypeId()`) and current period (`PeriodChangeEvent.getCurrentPeriod()`) into account for generating values.

Constructor Summary
`ConstantValueGenerator(double[] vals)` Constructs a new constant stationary value generator with value `vals[k]` for contact type `k`.
`ConstantValueGenerator(int numTypes, double val)` Constructs a new constant stationary value generator supporting `numTypes` contact types, and with value `val` for each contact type.
`ConstantValueGenerator(PeriodChangeEvent pce, double[][] vals)` Constructs a new constant value generator with values `vals` and period-change event `pce`.
`ConstantValueGenerator(PeriodChangeEvent pce, int numTypes, double[] vals)` Constructs a new constant value generator with period-change event `pce`, value `vals[p]` for period `p`, and supporting `numTypes` contact types.

Method Summary
`double[][]` | `getValues()` Returns the values used by this generator.
`void` | `init()` Initializes the generator at the beginning of the simulation.
`double` | `nextDouble(Contact contact)` Returns the value of the constant corresponding to the type of `contact`, and the current period.
`void` | `setValues(double[][] vals)` Sets the values for this generator to `vals`.
`String` | `toString()`

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

Constructor Detail

### ConstantValueGenerator

    public ConstantValueGenerator(int numTypes,
                                  double val)

  Constructs a new constant stationary value generator supporting `numTypes` contact types, and with value `val` for each contact type.

  Parameters:
    `numTypes` - the number of supported contact types.
    `val` - the value that will be returned by `nextDouble(umontreal.iro.lecuyer.contactcenters.contact.Contact)`.

### ConstantValueGenerator

    public ConstantValueGenerator(double[] vals)

  Constructs a new constant stationary value generator with value `vals[k]` for contact type `k`.

  Parameters:
    `vals` - the values for each contact type.

### ConstantValueGenerator

    public ConstantValueGenerator(PeriodChangeEvent pce,
                                  int numTypes,
                                  double[] vals)

  Constructs a new constant value generator with period-change event `pce`, value `vals[p]` for period `p`, and supporting `numTypes` contact types.

  Parameters:
    `pce` - the associated period-change event.
    `numTypes` - the number of supported contact types.
    `vals` - the generated value for each period.
  Throws:
    `IllegalArgumentException` - if a value is not specified for each period.

### ConstantValueGenerator

    public ConstantValueGenerator(PeriodChangeEvent pce,
                                  double[][] vals)

  Constructs a new constant value generator with values `vals` and period-change event `pce`. The array element `vals[p][k]` gives the value for period `p`, contact type `k`.

  Parameters:
    `pce` - the associated period-change event.
    `vals` - the array of values.
  Throws:
    `IllegalArgumentException` - if an array of values is not specified for each period.

Method Detail

### getValues

    public double[][] getValues()

  Returns the values used by this generator. The format of the array is the same as in the constructor `ConstantValueGenerator(PeriodChangeEvent,double[][])`.

  Returns:
    the associated values.

### setValues

    public void setValues(double[][] vals)

  Sets the values for this generator to `vals`. This method can be used to change the number of supported contact types, but it cannot be used to change the number of periods.

  Parameters:
    `vals` - the new values for this generator.
  Throws:
    `IllegalArgumentException` - if the length of the given array is incorrect.

### nextDouble

    public double nextDouble(Contact contact)

  Returns the value of the constant corresponding to the type of `contact`, and the current period. If the contact type identifier is greater than or equal to the number of supported contact types, or a type smaller than zero, an exception is thrown.

  Specified by:
    `nextDouble` in interface `ValueGenerator`
  Parameters:
    `contact` - the contact being concerned.
  Returns:
    the generated value.

### init

    public void init()

  Description copied from interface: `ValueGenerator`
  Initializes the generator at the beginning of the simulation.

  Specified by:
    `init` in interface `Initializable`
  Specified by:
    `init` in interface `ValueGenerator`

### toString

    public String toString()

  Overrides:
    `toString` in class `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.