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.server
Class Agent

    java.lang.Object
      umontreal.iro.lecuyer.contactcenters.server.Agent

All Implemented Interfaces:
  Initializable, Named

    public class Agent

extends Object
implements Initializable, Named

Represents an individual agent in a detailed agent group.

Note: the `AgentListener` implementations are notified in the order of the list returned by `getAgentListeners()`, and an agent listener modifying the list of listeners by using `addAgentListener(AgentListener)` or `removeAgentListener(AgentListener)` could result in unpredictable behavior.

Field Summary
`protected int` | `ecType` The end-contact type associated with the contact time returned by `getContactTime(Contact)`.
`protected int` | `esType` The end-service type associated with the after-contact time returned by `getAfterContactTime(Contact)`.

Constructor Summary
`Agent()`

Method Summary
`void` | `addAgentListener(AgentListener listener)` Adds the agent listener `listener` to this object.
`void` | `clearAgentListeners()` Removes all the agent listeners registered with this agent.
`protected double` | `getAfterContactTime(Contact contact)` Generates and returns the after-contact time associated with the contact `contact`.
`ValueGenerator` | `getAfterContactTimeGenerator(int esType1)` Returns the value generator used to generate after-contact times for end-service type `esType`.
`DetailedAgentGroup` | `getAgentGroup()` Returns the detailed agent group this agent is part of, or `null` if the agent is not in a group.
`List<AgentListener>` | `getAgentListeners()` Returns an unmodifiable list containing all the agent listeners registered with this agent.
`Map<Object,Object>` | `getAttributes()` Returns the map containing the attributes for this agent.
`protected double` | `getContactTime(Contact contact)` Generates and returns the contact time associated with the contact `contact`.
`ValueGenerator` | `getContactTimeGenerator(int ecType1)` Returns the value generator used to generate contact times for end-contact type `ecType`.
`EndServiceEventDetailed` | `getEndServiceEvent()` Returns the current end-service event for this agent, or `null` if the agent is not busy.
`double` | `getFirstLoginTime()` Returns the first simulation time at which this agent was added to an agent group.
`int` | `getId()` Returns the identifier associated with this agent.
`double` | `getIdleSimTime()` Returns the last simulation time at which this agent became idle.
`double` | `getIdleTime()` Returns the time elapsed since the last moment this agent became idle.
`double` | `getLastLoginTime()` Returns the last simulation time at which this agent was added to an agent group.
`String` | `getName()` Returns the name associated with this object.
`void` | `init()` Initializes this agent for a new simulation replication.
`boolean` | `isAvailable()` Determines if the agent is available, or is serving contacts.
`boolean` | `isBusy()` Determines if this agent is busy.
`boolean` | `isGhost()` Determines if this agent is a ghost, i.e., if it was removed from an agent group before it has ended the service of a contact.
`protected void` | `notifyAdded(DetailedAgentGroup group1)`
`protected void` | `notifyAvailable(boolean avail1)`
`protected void` | `notifyBeginService(EndServiceEventDetailed es1)`
`protected void` | `notifyEndContact(EndServiceEventDetailed es1)`
`protected void` | `notifyEndService(EndServiceEventDetailed es1)`
`protected void` | `notifyInit()`
`protected void` | `notifyRemoved(DetailedAgentGroup group1)`
`void` | `removeAgentListener(AgentListener listener)` Removes the agent listener `listener` from this object.
`void` | `restore(AgentState state)` Restores the state of this agent by using the given state object `state`.
`AgentState` | `save()` Constructs and returns a token object containing the state of this agent.
`EndServiceEventDetailed` | `serve(Contact contact)` Instructs this agent to begin the service of the contact `contact`, and returns the constructed end-service event representing the service.
`void` | `setAfterContactTimeGenerator(int esType, ValueGenerator acgen)` Sets the after-contact time generator for end-service type `esType` to `acgen`.
`void` | `setAvailable(boolean avail)` Sets the availability status of this agent to `avail`.
`void` | `setContactTimeGenerator(int ecType, ValueGenerator cgen)` Sets the contact time generator for end-contact type `ecType` to `cgen`.
`void` | `setFirstLoginTime(double firstLoginTime)`
`void` | `setId(int id)` Sets the identifier of this agent to `id`.
`void` | `setIdleSimTime(double idleSimTime)`
`void` | `setLastLoginTime(double lastLoginTime)`
`void` | `setName(String n)` Sets the name of this object to `name`.
`String` | `toString()`

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

Field Detail

### ecType

    protected int ecType

  The end-contact type associated with the contact time returned by `getContactTime(Contact)`.

### esType

    protected int esType

  The end-service type associated with the after-contact time returned by `getAfterContactTime(Contact)`.

Constructor Detail

### Agent

    public Agent()

Method Detail

### getName

    public String getName()

  Description copied from interface: `Named`
  Returns the name associated with this object. If no name was set, this must return an empty string, not `null`.

  Specified by:
    `getName` in interface `Named`
  Returns:
    the name of this object.

### setName

    public void setName(String n)

  Description copied from interface: `Named`
  Sets the name of this object to `name`. The given name cannot be `null` and the implementation can throw an `UnsupportedOperationException` if the name is read-only.

  Specified by:
    `setName` in interface `Named`
  Parameters:
    `n` - the new name of the object.

### save

    public AgentState save()

  Constructs and returns a token object containing the state of this agent.

  Returns:
    the state of this agent.

### restore

    public void restore(AgentState state)

  Restores the state of this agent by using the given state object `state`.

  Parameters:
    `state` - the state of the agent.

### addAgentListener

    public void addAgentListener(AgentListener listener)

  Adds the agent listener `listener` to this object.

  Parameters:
    `listener` - the agent listener being added.
  Throws:
    `NullPointerException` - if `listener` is `null`.

### removeAgentListener

    public void removeAgentListener(AgentListener listener)

  Removes the agent listener `listener` from this object.

  Parameters:
    `listener` - the agent listener being removed.

### clearAgentListeners

    public void clearAgentListeners()

  Removes all the agent listeners registered with this agent.

### getAgentListeners

    public List<AgentListener> getAgentListeners()

  Returns an unmodifiable list containing all the agent listeners registered with this agent.

  Returns:
    the list of all registered agent listeners.

### notifyInit

    protected void notifyInit()

### notifyAvailable

    protected void notifyAvailable(boolean avail1)

### notifyAdded

    protected void notifyAdded(DetailedAgentGroup group1)

### notifyRemoved

    protected void notifyRemoved(DetailedAgentGroup group1)

### notifyBeginService

    protected void notifyBeginService(EndServiceEventDetailed es1)

### notifyEndContact

    protected void notifyEndContact(EndServiceEventDetailed es1)

### notifyEndService

    protected void notifyEndService(EndServiceEventDetailed es1)

### serve

    public EndServiceEventDetailed serve(Contact contact)

  Instructs this agent to begin the service of the contact `contact`, and returns the constructed end-service event representing the service. This method calls `getAgentGroup()``.serve (contact, this)`.

  Parameters:
    `contact` - the contact to be served.
  Returns:
    the end-service event representing the service.

### getContactTimeGenerator

    public ValueGenerator getContactTimeGenerator(int ecType1)

  Returns the value generator used to generate contact times for end-contact type `ecType`. This returns `null` if there is no value generator associated with this type of contact termination.

  Parameters:
    `ecType1` - the queried end-contact type.
  Returns:
    the value generator associated with this end-contact type.

### getAfterContactTimeGenerator

    public ValueGenerator getAfterContactTimeGenerator(int esType1)

  Returns the value generator used to generate after-contact times for end-service type `esType`. This returns `null` if there is no value generator associated with this type of service termination.

  Parameters:
    `esType1` - the queried end-service type.
  Returns:
    the value generator associated with this end-service type.

### setContactTimeGenerator

    public void setContactTimeGenerator(int ecType,
                                        ValueGenerator cgen)

  Sets the contact time generator for end-contact type `ecType` to `cgen`.

  Parameters:
    `ecType` - the affected end-contact type.
    `cgen` - the new contact time generator associated with this end-contact type.
  Throws:
    `IllegalArgumentException` - if the end-contact type is negative.

### setAfterContactTimeGenerator

    public void setAfterContactTimeGenerator(int esType,
                                             ValueGenerator acgen)

  Sets the after-contact time generator for end-service type `esType` to `acgen`.

  Parameters:
    `esType` - the modified end-service type.
    `acgen` - the new after-contact time generator associated with this end-service type.
  Throws:
    `IllegalArgumentException` - if the end-service type is negative.

### init

    public void init()

  Initializes this agent for a new simulation replication.

  Specified by:
    `init` in interface `Initializable`

### isAvailable

    public boolean isAvailable()

  Determines if the agent is available, or is serving contacts.

  Returns:
    the availability status of this agent.

### setAvailable

    public void setAvailable(boolean avail)

  Sets the availability status of this agent to `avail`. If this method is called with `true`, the agent will be capable of processing new contacts (the default). Otherwise, it will not receive new contacts. This does not affect the contact being served by this agent if it is busy.

  Parameters:
    `avail` - the new availability status of this agent.

### isGhost

    public boolean isGhost()

  Determines if this agent is a ghost, i.e., if it was removed from an agent group before it has ended the service of a contact.

  Returns:
    `true` if the agent is a ghost agent, `false` otherwise.

### isBusy

    public boolean isBusy()

  Determines if this agent is busy.

  Returns:
    the agent's busyness indicator.

### getEndServiceEvent

    public EndServiceEventDetailed getEndServiceEvent()

  Returns the current end-service event for this agent, or `null` if the agent is not busy.

  Returns:
    the current end-service event, or `null`.

### getIdleSimTime

    public double getIdleSimTime()

  Returns the last simulation time at which this agent became idle.

  Returns:
    the simulation idle time of this agent.
  Throws:
    `IllegalStateException` - if this agent is not idle.

### getIdleTime

    public double getIdleTime()

  Returns the time elapsed since the last moment this agent became idle. This corresponds to the current simulation time minus the result of `getIdleSimTime()`.

  Returns:
    the agent's idle time.

### setIdleSimTime

    public void setIdleSimTime(double idleSimTime)

### getFirstLoginTime

    public double getFirstLoginTime()

  Returns the first simulation time at which this agent was added to an agent group.

  Returns:
    the agent's first login time.

### setFirstLoginTime

    public void setFirstLoginTime(double firstLoginTime)

### getLastLoginTime

    public double getLastLoginTime()

  Returns the last simulation time at which this agent was added to an agent group.

  Returns:
    the agent's last login time.

### setLastLoginTime

    public void setLastLoginTime(double lastLoginTime)

### getAgentGroup

    public DetailedAgentGroup getAgentGroup()

  Returns the detailed agent group this agent is part of, or `null` if the agent is not in a group.

  Returns:
    the parent agent group.

### getContactTime

    protected double getContactTime(Contact contact)

  Generates and returns the contact time associated with the contact `contact`. The method returns the generated value and can store an end-contact type indicator in the protected field `ecType` if the default value of 0 is not appropriate. If this returns `Double.NaN`, the contact time will be generated by the parent agent group.

  By default, a `MinValueGenerator` is used. For each end-contact type c with an associated value generator, a contact time Cc is generated. The scheduled contact time is Cc* = {Cc}, and the end-contact type is c*.

  Parameters:
    `contact` - the contact being served.
  Returns:
    the generated contact time.

### getAfterContactTime

    protected double getAfterContactTime(Contact contact)

  Generates and returns the after-contact time associated with the contact `contact`. The method returns the generated value and can store an end-service type indicator in the protected field `esType` if the default value of 0 is not appropriate. If this returns `Double.NaN`, the after-contact time will be generated by the parent agent group.

  By default, a `MinValueGenerator` is used. For each end-service type c with an associated value generator, an after-contact time Cc is generated. The scheduled after-contact time is Cc* = {Cc}, and the end-service type is c*.

  Parameters:
    `contact` - the contact being served.
  Returns:
    the generated after-contact time.

### getId

    public int getId()

  Returns the identifier associated with this agent. This identifier, which defaults to `-1`, can be used as an index in routers.

  Returns:
    the identifier associated with this agent.

### setId

    public void setId(int id)

  Sets the identifier of this agent to `id`. Once this identifier is set to a positive or 0 value, it cannot be changed anymore.

  Parameters:
    `id` - the new identifier associated with the agent.
  Throws:
    `IllegalStateException` - if the identifier was already set.

### getAttributes

    public Map<Object,Object> getAttributes()

  Returns the map containing the attributes for this agent. Attributes can be used to add user-defined information to agent objects at runtime, without creating a subclass. However, for maximal efficiency, it is recommended to create a subclass of `Agent` instead of using attributes.

  Returns:
    the map containing the attributes for this object.

### 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.