Entity Server

Serve entities

  • Library:
  • SimEvents

Description

The Entity Server block serves entities as they arrive. In a discrete-event simulation, a server stores entities for a length of time, called service time, and then attempts to output the entity. During the service period, the block is said to be serving the entity that it stores. The block can serve multiple entities simultaneously and output each entity through the output port, unless the port is blocked. When the block permits preemption, an entity in the server can depart early through a second port.

To customize actions when entities enter, complete service, exit, and are blocked or preempted by the block, enter MATLAB® code in the Entry action, Service complete action, Exit action, Blocked action, or Preempt action field of the Event actions tab. For more information, see Events and Event Actions.

Ports

Input

expand all

Input entity that carries scalar, bus, or vector data to enter the server.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | Boolean | enumerated | bus | string

Input signal port to determine service time.

Dependencies

This port is visible when Service time source is set to Signal port.

Data Types: double

Output

expand all

Output entity port for entities exiting the server.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | Boolean | enumerated | bus | string

Number of entities that have departed the block.

Dependencies

To enable this port, click the Statistics tab and select the box labeled Number of entities departed, d.

Data Types: double

Number of entities that have not yet departed the block.

Dependencies

To enable this port, click the Statistics tab and select the box labeled Number of entities in block, n.

Data Types: double

Selecting this check box outputs the value 1 for a pending entity in the block, and 0 otherwise.

Dependencies

To enable this port, select the Statistics > Pending entity in block, pe.

Data Types: double

Selecting this check box outputs the number of pending entities in the block.

Dependencies

To enable this port, select the Statistics > Number of pending entities, np.

Data Types: double

Average wait time for entities in the block.

Dependencies

To enable this port, click the Statistics tab and select the box labeled Average wait, w.

Data Types: double

Average time the server is occupied.

Dependencies

To enable this port, click the Statistics tab and select the box labeled Utilization, util.

Data Types: double

Number of preempted entities.

Dependencies

To enable this port, first click the Preemption tab, then click Statistics tab and select the box labeled Number of entities preempted, p.

Data Types: double

Number of entities that are pulled out of this block.

Dependencies

To enable this port, click the Statistics tab and select the box labeled Number of entities extracted, ex.

Data Types: double

Parameters

expand all

Specify the number of entities the block can serve simultaneously.

Programmatic Use

Block Parameter: Capacity
Type: character vector
Values: '1'| scalar
Default: '1'

Determine the source that specifies the service time.

Programmatic Use

Block Parameter: ServiceTimeSource
Type: character vector
Values: 'Dialog' | 'Signal port' | 'Attribute'| 'MATLAB action'
Default: 'Dialog'

Determine the name of the attribute that is used as the service time value.

Dependencies

This parameter is visible when Service time source is set to Attribute.

Programmatic Use

Block Parameter: ServiceTimeAttributeName
Type: character vector
Values: 'ServiceTime' | character vector
Default: 'ServiceTime'

Tunable: Yes

Dependencies

This parameter is visible when Service time source is set to Dialog.

Programmatic Use

Block Parameter: ServiceTimeValue
Type: character vector
Values: '1.0' | scalar
Default: '1.0'

Use MATLAB code to specify service time. dt specifies the service time. You can manually specify dt or use Insert pattern button to specify service time from a repeating sequence or from a distribution. For an example, see Count Simultaneous Departures from a Server.

Dependencies

This parameter is visible when Service time source is set to MATLAB action.

Programmatic Use

Block Parameter: ServiceTimeAction
Type: character vector
Values: MATLAB code
Default: 'dt = rand(1,1);'

Specify the behavior of the entity in certain events. Define the behavior in the Event action parameter. The Entry and the Exit actions are called just after the entity entry and just before entity exit. The Service complete action is called after the completion of the entity service. The Blocked action is called after an entity is blocked. The Preeempt is called after the preemption.

Programmatic Use

Block Parameter: EntryAction, ServiceCompleteAction, ExitAction, BlockedAction, PreemptAction
Type: character vector
Values: MATLAB code
Default: ''

Select this check box if you want to allow preemption of entities. Selecting this check box enables these parameters:

  • Sorting attribute name in the Preemption tab

  • Sorting direction in the Preemption tab

  • Write residual time to attribute in the Preemption tab

  • Number of entities preempted, p in the Statistics tab

For an example, see Task Preemption in a Multitasking Processor.

Programmatic Use

Block Parameter: PermitPreemptionBasedOnAttribute
Type: character vector
Values: 'on' | 'off'
Default: 'off'

Specify the name of the attribute used to determine the priority.

Dependencies

This parameter is visible when the Permit preemption based on attribute box is selected.

Programmatic Use

Block Parameter: SortingAttributeName
Type: character vector
Values: 'entity' | 'entitySys.priority' | character vector
Default: 'entity'

Specify if the entities are sorted in ascending or descending order.

  • ascending — Sorting entities with smaller key values to have a higher priority

  • descending — Sorting entities with greater key values to have a higher priority

Dependencies

This parameter is visible when the Permit preemption based on attribute box is selected.

Programmatic Use

Block Parameter: SortingDirection
Type: character vector
Values: 'Ascending' | 'Descending'
Default: 'Ascending'

Dependencies

This parameter is visible when the Permit preemption based on attribute box is selected.

Programmatic Use

Block Parameter: WriteResidualTimeToAttribute
Type: character vector
Values: 'on' | 'off'
Default: 'off'

Dependencies

This parameter is visible when the Write residual time to attribute box is selected.

Programmatic Use

Block Parameter: ResidualTimeAttributeName
Type: character vector
Values: 'ResidualTime' | character vector
Default: 'ResidualTime'

Number of entities that have departed the block.

Programmatic Use

Block Parameter: NumberEntitiesDeparted
Type: character vector
Values: 'on' | 'off'
Default: 'off'

Number of entities present in the block that are yet to depart.

Programmatic Use

Block Parameter: NumberEntitiesInBlock
Type: character vector
Values: 'on' | 'off'
Default: 'off'

Indicates whether an entity that is yet to depart is present in the block. The value is 1 for a pending entity, and 0 otherwise.

Programmatic Use

Block Parameter: PendingEntityPresentInBlock
Type: character vector
Values: 'on' | 'off'
Default: 'off'

Outputs the number of pending entities the block has served that are yet to depart.

Programmatic Use

Block Parameter: NumberEntitiesPending
Type: character vector
Values: 'on' | 'off'
Default: 'off'

Sum of the wait times for entities departed the block divided by their total number. Wait time is the duration between the Entity Server block entry and exit of an entity. For more information, seeInterpret SimEvents Models Using Statistical Analysis.

Programmatic Use

Block Parameter: AverageWait
Type: character vector
Values: 'on' | 'off'
Default: 'off'

Average time the server is occupied. The block calculates this time as the ratio of the total wait time for entities to the server capacity multiplied by the total simulation time.

Wait time is the duration between the Entity Server block entry and exit of an entity. Total wait time is the sum of the wait times for entities departed the block.

Programmatic Use

Block Parameter: Utilization
Type: character vector
Values: 'on' | 'off'
Default: 'off'

Outputs the number of preempted entities.

Dependencies

This check box appears if the Permit preemption based on attribute check box is selected.

Programmatic Use

Block Parameter: NumberEntitiesPreempted
Type: character vector
Values: 'on' | 'off'
Default: 'off'

Outputs the number of extracted entities which are pulled out from this block by the Entity Find block. If an entity is being served during the extraction, the service is terminated. If an attribute that defines the service time and it is modified by the Entity Find block, service time does not change. When an entity is extracted, Number of entities departed, d, Number of entities in block, n, Average wait, w, and Utilization, util statistics are updated accordingly. For more information about finding and extracting entities, see Find and Extract Entities in SimEvents Models.

Programmatic Use

Block Parameter: NumEntitiesExtracted
Type: character vector
Values: 'on' | 'off'
Default: 'off'

Introduced in R2016a