Untimed Single Queue SingleUntimed Single Queue Single Server...

19
© 2009 Winton 1 Untimed Single Queue Single Untimed Single Queue Single Server Model Lock the Door Protocol Lock the Door Protocol

Transcript of Untimed Single Queue SingleUntimed Single Queue Single Server...

Page 1: Untimed Single Queue SingleUntimed Single Queue Single Server …cwinton/html/cop4300/s09/class.notes/b… ·  · 2011-03-31Untimed Single Queue SingleUntimed Single Queue Single

© 2009 Winton 1

Untimed Single Queue SingleUntimed Single Queue Single Server Model

Lock the Door ProtocolLock the Door Protocol

Page 2: Untimed Single Queue SingleUntimed Single Queue Single Server …cwinton/html/cop4300/s09/class.notes/b… ·  · 2011-03-31Untimed Single Queue SingleUntimed Single Queue Single

© 2009 Winton 2

Single Server QueueS g e Se ve Queue• Basic graphical layout for a single-server queue

model "Executive" block (in the Item.lix library)

configurable “Create" block (in the Item.lix library)for bringing items into the modelfor bringing items into the model

"Queue" block (in the Item.lix library) for receiving items in the model flow – default protocol is FIFO

"Exit" block (in the Item lix library)

"Activity" block (in the Item.lix library) ford li ti iti h f

Exit block (in the Item.lix library)for removing items from the model

“Random Number" block (in the Value.lix library)for sampling from probability distributions

modeling activities such as a server performs

• Basic setup is a timed simulation

Page 3: Untimed Single Queue SingleUntimed Single Queue Single Server …cwinton/html/cop4300/s09/class.notes/b… ·  · 2011-03-31Untimed Single Queue SingleUntimed Single Queue Single

© 2009 Winton 3

Simulation SetupSimulation SetupO ll t i h dl d i th R• Overall setup is handled via the Run … Simulation Setup…Setup tab

• Can specify a set number of time units• Can specify the global time unit to be used; Ca spec y t e g oba t e u t to be used;

e.g., “hours”• Can specify additional time unit definitions such asCan specify additional time unit definitions such as

“minutes” and “seconds”

• The Create (Item.lix) block may be ( ) yconfigured for time units such as “minutes” for the distribution being sampled fromfor the distribution being sampled from

Page 4: Untimed Single Queue SingleUntimed Single Queue Single Server …cwinton/html/cop4300/s09/class.notes/b… ·  · 2011-03-31Untimed Single Queue SingleUntimed Single Queue Single

© 2009 Winton 4

f QItems Left on Queueh h i l i h ill b• When the simulation stops there may still be

items in the Queue (Item.lix) block that have not been serviced.

• It may be important in the simulation model y pto finish serving all items still in the model– Typical protocol: "lock the door"Typical protocol: lock the door

• No more items enter the model• Items in the model finish servicete s t e ode s se v ce• Simulation doesn’t stop until all items have exited

– Some features can be added to the basic modelSome features can be added to the basic model to provide this model behavior

Page 5: Untimed Single Queue SingleUntimed Single Queue Single Server …cwinton/html/cop4300/s09/class.notes/b… ·  · 2011-03-31Untimed Single Queue SingleUntimed Single Queue Single

© 2009 Winton 5

P idi It Alt t P thProviding Items an Alternate Path• ExtendSim's Generator block (Item.lix)

continues to "push" items as long as the simulation is running– items pushed after the door is locked have to be

exited out of the model or allowed to disappear

• "Select Item Out" block (Item.lix).– value at the value input determines item path

• Item exits through one of the outputs based on the l ivalue input

• The number of item output can be set to 2 or more

Default set up is that 0 selects the top output and– Default set up is that 0 selects the top output and 1 selects the bottom

Page 6: Untimed Single Queue SingleUntimed Single Queue Single Server …cwinton/html/cop4300/s09/class.notes/b… ·  · 2011-03-31Untimed Single Queue SingleUntimed Single Queue Single

© 2009 Winton 6

P b bilit R tiProbability Routing• Use dialogue of Select

Item Out block to set it for random routingit for random routing– Set the probability

routing for the number of outputs being usedof outputs being used

– Click to show probabilities on the bl k iblock icon

• For this example, 40% of the time items % o e e e swill exit out the top and otherwise out the bottombottom

Page 7: Untimed Single Queue SingleUntimed Single Queue Single Server …cwinton/html/cop4300/s09/class.notes/b… ·  · 2011-03-31Untimed Single Queue SingleUntimed Single Queue Single

© 2009 Winton 7

Use a Select Item Out BlockUse a Select Item Out Block

• When “door locked” is 0 (False) items proceed as before; when it is 1 (True), the Select Item Out block flushes

t d it t th b tt tgenerated items out the bottom connector

Page 8: Untimed Single Queue SingleUntimed Single Queue Single Server …cwinton/html/cop4300/s09/class.notes/b… ·  · 2011-03-31Untimed Single Queue SingleUntimed Single Queue Single

© 2009 Winton 8

Modify the Executive BlockModify the Executive Block• Configure the Stop simulation criteriaCo gu e t e Stop s u at o c te a

– In the Executive dialogue, specify a count value >= 1• Causes a count connector to appear on the Executive

– Serves as a “True-False” criteria• Strategy: hold the “Count" at 0 (false) until ready to stop, then

change it to 1 (true)change it to 1 (true)

Page 9: Untimed Single Queue SingleUntimed Single Queue Single Server …cwinton/html/cop4300/s09/class.notes/b… ·  · 2011-03-31Untimed Single Queue SingleUntimed Single Queue Single

© 2009 Winton 9

Establishing the Stop CriteriaEstablishing the Stop Criteria• Criteria has two conditionsCriteria has two conditions

– "door locked" – "arrivals" for service = "departures" from service

• Logical comparison and logical operations are accomplished via the Math block, the Decision bl k th E ti bl k f th V l Libblock, or the Equation block from the Value Library (Value.lix)

• Each block is configured via its dialogue• Each block is configured via its dialogue – The Math block for AND, OR, or NOT

(among others)( g )– The Decision block for the full range of

comparisons between inputs "A" and "B" ! "i b “>, >=, =, <=, <, !=, "is not a number“

– Equation block for any C-like computation

Page 10: Untimed Single Queue SingleUntimed Single Queue Single Server …cwinton/html/cop4300/s09/class.notes/b… ·  · 2011-03-31Untimed Single Queue SingleUntimed Single Queue Single

© 2009 Winton 10

Executive Block Controlecu ve oc Co o• The count input becomes 1 if the door is locked

d h b f i l l h b fand the number of arrivals equals the number of departures (i.e., all customers who arrived before h d l k d h b d)the door was locked have been served)

Note: Red ball dynamically inserted to notate which of Y/N is true

Page 11: Untimed Single Queue SingleUntimed Single Queue Single Server …cwinton/html/cop4300/s09/class.notes/b… ·  · 2011-03-31Untimed Single Queue SingleUntimed Single Queue Single

© 2009 Winton 11

Avoiding Clutter onAvoiding Clutter onExtendSim’s Model Plane

• Output connections can be named by use of a “text” label– The text label represents the output connectionThe text label represents the output connection

anywhere it is used in the model • Output connectors for arrivals departures• Output connectors for arrivals, departures,

and door locked were employed for setting h i l i i ithe simulation stop criteria

Page 12: Untimed Single Queue SingleUntimed Single Queue Single Server …cwinton/html/cop4300/s09/class.notes/b… ·  · 2011-03-31Untimed Single Queue SingleUntimed Single Queue Single

© 2009 Winton 12

Movement of Items Through an gExtendSim Simulation

• A block normally “pulls” an available item in through an input connector and makes it available at an output connector

Th it i h ld til it i ll d i t th bl k– The item is held until it is pulled into another block– Most blocks are designed to pass items through to

subsequent blocks• If an arriving item is blocked from entering a block, it is lost

from the simulation– The simulation may terminate depending on how it’s y p g

configured• Blocks such as the Queue block (Item.lix) can accept a

continuing stream of input items (up to some user controlled g p ( plimit)

• The Create block (Item.lix), unlike most other model blocks, always “pushes” items out from its output connector, whetheralways pushes items out from its output connector, whether or not they are pulled by another block

Page 13: Untimed Single Queue SingleUntimed Single Queue Single Server …cwinton/html/cop4300/s09/class.notes/b… ·  · 2011-03-31Untimed Single Queue SingleUntimed Single Queue Single

© 2009 Winton 13

ArrivalsArrivalsTh t t t f th i f ti bl k b• The output connector of the information block can be expanded to include an output for the count of the number of items that have passed through the blockof items that have passed through the block– Enables counting the number of items allowed into the model

before locking the door

Page 14: Untimed Single Queue SingleUntimed Single Queue Single Server …cwinton/html/cop4300/s09/class.notes/b… ·  · 2011-03-31Untimed Single Queue SingleUntimed Single Queue Single

© 2009 Winton 14

DeparturesDepartures• There are 3 kinds of departures from the modelThere are 3 kinds of departures from the model

– Items served and departing before doors lockedIt d d d t d ft d l k d– Items served and departed after doors locked

– Items arriving after doors locked are flushed

Notes: when the Activity period ends, the item is pulled through the Select Item Out block passing through either the upper or lower output. The item output for an Exit block can be expanded to as many item exits as desired. Regardless, the top output gives the total number of departures.

Page 15: Untimed Single Queue SingleUntimed Single Queue Single Server …cwinton/html/cop4300/s09/class.notes/b… ·  · 2011-03-31Untimed Single Queue SingleUntimed Single Queue Single

© 2009 Winton 15

door locked

• Locking the door requires– a block that can signal when a given time

is reached • This is the function of the Pulse block

(Value.lix). a block that can change from 0 to 1 when– a block that can change from 0 to 1 when signaled

• The switch obtained via the Model• The switch obtained via the Model … Controls tab can do this

• So can the Constant block (Value.lix)( )

Page 16: Untimed Single Queue SingleUntimed Single Queue Single Server …cwinton/html/cop4300/s09/class.notes/b… ·  · 2011-03-31Untimed Single Queue SingleUntimed Single Queue Single

© 2009 Winton 16

Pulse Block

• In its dialogue it can be set to “pulse” aIn its dialogue it can be set to pulse a True value (1) at specified time intervals and False (0) otherwiseand False (0) otherwise.

• An option is to have it “pulse” a True value (1) at the beginning of the simulation run

Page 17: Untimed Single Queue SingleUntimed Single Queue Single Server …cwinton/html/cop4300/s09/class.notes/b… ·  · 2011-03-31Untimed Single Queue SingleUntimed Single Queue Single

© 2009 Winton 17

Constant Block and Switch

• Switch– Pulsing the left input (or clicking on it) causes switch output to be 0.– Pulsing the right input (or clicking on it) causes switch output to be 1.

C t t bl k (V l li )• Constant block (Value.lix) – If the hold input is not connected, the block outputs the constant

specified in its dialogue plus the value at its input, if any– Whenever the hold input is 0 (false), the block output value remains

unchanged, regardless of changes to the input– When the hold input is 1 (true), the input value is added to the currentWhen the hold input is 1 (true), the input value is added to the current

value producing the output for the block• If the hold input returns to 0, the most recent output value of the block is

retained as the outputp

Page 18: Untimed Single Queue SingleUntimed Single Queue Single Server …cwinton/html/cop4300/s09/class.notes/b… ·  · 2011-03-31Untimed Single Queue SingleUntimed Single Queue Single

© 2009 Winton 18

Generating door locked Signalg g• The Pulse block is set to pulse when

it’s time to close the doors and theit s time to close the doors and the Constant block is set to capture the value (1) of the pulse when it occurs

• The System Variable block (V l li ) is set to o tp t the(Value.lix) is set to output the current simulation Time, which at time 0 sets the switch back to 0 if it was left at 1

• The Constant block output will id th door locked i lprovide the door locked signal

unless the user activates the switch before time has expiredp

Page 19: Untimed Single Queue SingleUntimed Single Queue Single Server …cwinton/html/cop4300/s09/class.notes/b… ·  · 2011-03-31Untimed Single Queue SingleUntimed Single Queue Single

© 2009 Winton 19

Implemented ModelImplemented Model• Model configuration data, time, max queue length, arrival

d d t d t l d t th d l land departure data are cloned onto the model plane