Queue modelling

All topics specific to modeling questions in Enterprise Dynamics
EvEs0r
Posts: 11
Joined: Friday 25 May, 2012 - 11:31

Queue modelling

Post by EvEs0r »

Hey,

I am building a model for a supermarket, using Availability Controls combined with Time Schedules, to determine the different opening hours of the desks. But when a server closes, it leaves customers in the queue. Is there a way to make it so, that the server closes as soon as the queue is empty (ofcourse when the server should be down by the time schedule)?

Thanks!
MarvinH
Posts: 93
Joined: Tuesday 25 January, 2011 - 11:07
Contact:

Re: Queue modelling

Post by MarvinH »

Hello!

Can't you control the queue with the schedule, instead of the server? So when the closing time of the counter is due, close the queue in front of the counter such that no new customers can enter. Because the server is still available, the customers being present in the queue already will be taken care of anyway.

Kind regards,

Marvin
EvEs0r
Posts: 11
Joined: Friday 25 May, 2012 - 11:31

Re: Queue modelling

Post by EvEs0r »

Hi Marvin,

Thanks for your reply. It does work, only should the server also close after the last customer of the queue is processed - this will preserve the utilization of the server. Any idea how to do that?

Thanks in advance,
Yannick
MarvinH
Posts: 93
Joined: Tuesday 25 January, 2011 - 11:07
Contact:

Re: Queue modelling

Post by MarvinH »

Hello Yannick,

I am not sure how you are determining the utilization, but you can adjust your utilization by the following code OnExit of the server:

Code: Select all

If(
  And(
    { * Queue is empty * }
    Content(In(1, c)) = 0,
    { * Availability Control is "down" * }
    Att([Available], Out(2, c)) = 0
  ),
  { * Adjust the desired properties * }
  Do(
    1
  )
)
This code assumes that the queue is connected at the first input channel of the server and the central channel of the availablity control is connected to the second output channel of the server for referencing purposes.

Hope this will give you some ideas.

Kind regards,

Marvin
EvEs0r
Posts: 11
Joined: Friday 25 May, 2012 - 11:31

Re: Queue modelling

Post by EvEs0r »

Hi Marvin,

Thanks for your reply. I am trying to make it so, that when the queue is empty (and closed), that the server availability also is set to down. I have the following code on the OnExit of the server, just like yours.

I have an (second) availability control, of which the output is connected to the center of the server, and the center of the control is connected to the server third output for referencing.

Code: Select all

If(
  And(
    { * Queue is empty * }
    Content(In(1, c)) = 0,
    { * Availability Control is "down" * }
    Att([Available], Out(2, c)) = 0
  ),
  { * Adjust the desired properties * }
  Do(
    SetAtt([Available], 0, Out(3, c))
  )
)
I don't see what could be wrong about this...Do you?

Thanks!
EvEs0r
Posts: 11
Joined: Friday 25 May, 2012 - 11:31

Re: Queue modelling

Post by EvEs0r »

Another option i tried, was to connect a switch control to the availability control, which is connected to the server. When the queue is empty, and the availability of the queue is down, the switch control should be enabled; but i can't get the last part done by 4Dscript.

I tried

Code: Select all

SetAtt([OnOff], 0, Out(3, c)),
and

Code: Select all

SetAtt([Available], 0, Out(3, c)),
(The center of the switch control was connected to the 3rd output of the server.)
MarvinH
Posts: 93
Joined: Tuesday 25 January, 2011 - 11:07
Contact:

Re: Queue modelling

Post by MarvinH »

Hello!

Nice solution. However, besides setting the attribute some more has to be done to take the appropriate actions due to the attribute change.

What you should do is add the (relevant part of the) code that is on the OnUser event of the Availability Switch. Please note that everywhere "c" should be replaced by Out(3, c), as you are executing the code from the server instead of from the Availaibility Swtich itself. Further note that when you are able to take the server offline, you will be able to set the server online when the queue becomes online as well. ;)

Please let me know whether you were able to implement this solution!

Good luck!

Kind regards,

Marvin
EvEs0r
Posts: 11
Joined: Friday 25 May, 2012 - 11:31

Re: Queue modelling

Post by EvEs0r »

Hey!

Thanks for your reply! Works beautifully!

What i did is (as above) connect the Availability Control of the queue to the 2nd out of the server, and the center of the switch to the 3rd out of the server. Then on the OnExit of the server i wrote:

Code: Select all

If(
  And(
    { * Queue is empty * }
    Content(In(1, c)) = 0,
    { * Availability Control is "down" * }
    Att([Available], Out(2, c)) = 0
  ),
  { * Adjust the desired properties * }
  Do(
    SetAtt([Available], 0, Out(3, c)),
    Status(Out(3, c)) := 12,
    SetLabel([t-available], 0, Out(3, c)),
    Color(Out(3, c)) :=  ColorRed,
    OpenAllOC(Out(3, c))
  )
)
Also, I'm using the OnDown trigger of the Queue Availability Control, to put the server down immediately when there are no customers in the server and queue (The OnExit of the server wouldn't be triggered then!), So i connected the switch control to the 2nd output of the Queue Availability Control, and wrote on the OnDown trigger:

Code: Select all

If(
  And(
    { * Queue is empty * }
    Content(Out(1, c)) = 0,
    1
  ),
  { * Adjust the desired properties * }
  Do(
    SetAtt([Available], 0, Out(2, c)),
    Status(Out(2, c)) := 12,
    SetLabel([t-available], 0, Out(2, c)),
    Color(Out(2, c)) :=  ColorRed,
    OpenAllOC(Out(2, c))
  )
)
To get them back up, I wrote the following code to the OnUp trigger of the same Availability Control:

Code: Select all

If(
  And(
    { * Queue is empty * }
    Content(Out(1, c)) = 0,
    1
  ),
  { * Adjust the desired properties * }
  Do(
    SetAtt([Available], 1, Out(2, c)),
     Status(Out(2, c)) := 11,
     SetLabel([t-available], 1, Out(2, c)),
     Color(Out(2, c)) := ColorGreen,
     OpenAllOC(Out(2, c))
  )
)

Works like a charm!
MarvinH
Posts: 93
Joined: Tuesday 25 January, 2011 - 11:07
Contact:

Re: Queue modelling

Post by MarvinH »

Hello!

Well done, seems like exactly the same thing I had in mind!

Kind regards,

Marvin
EvEs0r
Posts: 11
Joined: Friday 25 May, 2012 - 11:31

Re: Queue modelling

Post by EvEs0r »

Hi!

Back again with another question! I want to write the wait times of all customers to Excel. I've got this covered with a single run, but it seems impossible to do this in an experiment? ED is trying to reopen the model every single run...Is there a solution for this?

Thanks!
Post Reply