Adaptive control of MultiServer capacity/Instances

All topics on the Atoms in any Enterprise Dynamics Library.
Post Reply
Rovo
Posts: 6
Joined: Wednesday 11 April, 2012 - 10:29

Adaptive control of MultiServer capacity/Instances

Post by Rovo »

Hello,

I'm unsure if this question belongs to this part or to the 4DScript part of this forum, but I'll try with this one.

I have to simulate a supermarket and evaluate the numbers of cash-desks and trolleys needed to support the store to prevent customers from leaving as no trolleys are available. As a further required task I should include an adaptive approach to control the availability of cash desks. While using single servers and seperate queues this may be easily done with conditional control or notify router atoms, in case of a multiservice atom I have no clue on how to regulate the capacity of Multi-Service atoms, i.e: if there are less then 7 persons in queue cash desk 2 does not need to open and hence the capacity of the MultiServer may be set to 1 for this example.

My aim is to specify the maximum number of available cash desks and simulate the needed amount of cash desks for certain customer arrival rates and the impact of available trolleys to customers leaving (if more then 30 customers are waiting for a trolley a third is leaving the queue and head for an other supermarket) the store before having done their shopping.

I have attached my current model to better illustrate my approach on how to solve this. Note however that in the last 2 hours due to rush hour twice the customers arrive and that I had to integrate a further multiserver to set the capacity to 10 to only remove 10 people from the queue after changing the output-channel, as on skipping this atom the whole queue gets flushed at once resulting in all 30+ waiting customers to leave the store instead of only 10.

Thanks in advance,
Roman

PS: Is there a way to print certain variables in Textbox atoms? I currently use a generic monitor and shrink the graph part to 0 so only text will be displayed
Attachments
supermarkt4.mod
(40.96 KiB) Downloaded 389 times
MarvinH
Posts: 93
Joined: Tuesday 25 January, 2011 - 11:07
Contact:

Re: Adaptive control of MultiServer capacity/Instances

Post by MarvinH »

Dear Roman,

Thanks for your question, interesting model.

To change the capacity of the cash-desks, you can put the following code on the Entry trigger of the queue in front of the cash-desk:

Code: Select all

Do(
  Case(
    { * Determine the content of the queue, i.e. the number of waiting customers * }
    WhichIsTrue(
      Content(c) < 7,
      Content(c) < 14,
      Content(c) < 21,
      Content(c) < 28,
      True
    ),
    { * Change the capacity of the cash-desk, based on the number of waiting customers * }
    Att([Capacity], Out(1, c)) := 1,
    Att([Capacity], Out(1, c)) := 2,
    Att([Capacity], Out(1, c)) := 3,
    Att([Capacity], Out(1, c)) := 4,
    Att([Capacity], Out(1, c)) := 10
  ),
  
  { * In case there is space for another customer, open the input * }
  CreateEvent(0, Out(1, c), 2)
)
The first part of this code determines the capacity. You can add/change the conditions and values to suit your situation. The second code is used to re-evaluate the input condition of the cash-desks. In case the capacity is increased, a new client is allowed to enter immediately. In case the capacity is decreased, all customers at the cash-desks will be handled and a new customer is only allowed to enter once the number of customers is below the capacity of the cash-desk.

Note that there were some errors when I tried to open your model. These errors had to do with the way you tried to show the data in the Generic Monitors. I have changed this (as well as on the CustomerLeave sink), such that the values are stored on labels. Hope this is fine with you. Your model is attached.

Good luck with your model! In case you have any further questions, please feel free to return to this topic!

Kind regards,

Marvin
Attachments
supermarkt4_update.mod
Updated model
(41.9 KiB) Downloaded 388 times
Rovo
Posts: 6
Joined: Wednesday 11 April, 2012 - 10:29

Re: Adaptive control of MultiServer capacity/Instances

Post by Rovo »

Thank you Marvin for your quick reply - your solution works like a charm :)

In the meantime I solved the issues with printing the min/max/avg detention values using diText instead of the generic monitor (as somehow explained here: drawing-table-information-t62.html) - but I wonder why ViewWeidth always returns 0 even if I resize the atom - the only other function I have found in the visualization library is IconWeidth, but this didn't work either. I'm using the following call in the On2dDraw Eventhandler of the Sink:

Code: Select all

do (
  StandardDisplay(Name, Concat([In: ], String(Input)), Icon),
  diText(ViewWidth(c)+2, -2, Concat([Min Detention: ], string(Label([MinDetention], c))), ColorBlack, ColorWhite, 1, [Arial]),
  ...
)
Moreover I tried to add those variables to the standard display name (in the concat-function) but either I have everything in one line (which is somehow unreadable) or on adding CR, LF to the end of each variable call I'll end only with the standard "In: Input"-Ouput, so I assume multi-line names are prohibited?

To further adjust the decision-variable on how to open new cash-boards, is there a slider control in ED so that I can adjust the variable at runtime without typing in the value via the 4DScript? Have only found the switch-atom (in the availability example) here.

Last issue on my mind is a visualization for the open cash-desks over a 9 hour period - at the end I'd like to have a line/bar-graph which indicates how many cash-desks have been opened at a certain point in time (x-axis time, y-axis number of opened cash-desks). Is this somehow possible in ED with predefined atoms or do I have to program it manually via 4DScript?

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

Re: Adaptive control of MultiServer capacity/Instances

Post by MarvinH »

Hello Roman,

Glad to see the model works like you expected!

Regarding your visualization question, try to use xSize(c) instead of ViewWidth(c). The ViewWidth returns the width of the entire window, the xSize only returns the width of the atom on which you are drawing, I think this is what you want.

Indeed multi-lines are not allowed within the standard display text. You could concat them behind eachother, but then you'll need to increase the size (width) of the sink.

It is possible to adjust your decision variable with a slider control. To do this, you should create a GUI with the GUI Builder in which you add a track bar component to adjust the variable. For example, your decision variable is a global variable called valDecisionVariable. With the GUI as attached, you can adjust the variable during runtime. You can open the example GUI and adjust parameters of the GUI and trackbar, such as the code to be executed and the minimum and maximum value.

Please refer to the GUI Builder help file for more info about building GUIs.

Finally it is possible to display the capacity of the desks with the Generic monitor. I have added it in the second attachment, so you can have a look at it.

Good luck!

Kind regards,

Marvin
Attachments
supermarkt4_update_v2.mod
Line graph of capacity
(80.73 KiB) Downloaded 395 times
Trackbar.gui
Example of GUI with TrackBar
(446 Bytes) Downloaded 363 times
Rovo
Posts: 6
Joined: Wednesday 11 April, 2012 - 10:29

Re: Adaptive control of MultiServer capacity/Instances

Post by Rovo »

Thank you very much, again, Marvin :)

I'll have a look at the GUI Builder

Have a nice day,
Roman
Rovo
Posts: 6
Joined: Wednesday 11 April, 2012 - 10:29

Re: Adaptive control of MultiServer capacity/Instances

Post by Rovo »

Hi Marvin,

I've implemented a small frame which actually worked (I implemented it as you've suggested). Now I extended the features a bit (well not yet implemented to be honest) and extracted the adaptive control code you provided thankfully and shifted it into the DecisionControl atom, as it makes more sense here imho.

Now I am facing 2 issues:
*) The DropDownList-Widget does not recognize a default value or I am doing something completely wrong :( I tried to set it via

Code: Select all

GuiControll([decisionStrategy], GuiSet([Text], [Linear]))
*) I shifted the adaptive control logic into the button-event OnClick() - I know its the wrong place to store the logic but I do not know where to put the code to get executed automatically in the DecisionControl atom - but I guess I have to listen to certain events but not sure on how to do it in ED. So I tested the whole thing by pushing the apply-button frequently to see if the code works.

Moreover I noticed that on disabling a GroupBox the included widgets seem to get disabled (unclickable) but do not get disabled graphically - I assume here that the GroupBox is then in sense of layers above the other controls preventing clicks on them.

Furthermore do attributes have to be defined in the atom editor first to get recognized by ED? On declaring attributes with

Code: Select all

SetAtt([someAttribute],[someValue],GuiAtom)
or

Code: Select all

Att([someAttribute], GuiAtom) := [someValue]
and not specifying them in the atom editor, ED seems to ignore them :/ In addition to that, as I used a graph-atom as parent for my frame (I only need an input-channel and the Mtbf Mttr Availability atom required an availability atom even though I deleted every reference I have found), after loading my model, the attributes of the parent get loaded due to inheritance I guess - but is there a way to prevent the loading of those attributes?

Thanks in advance,
Roman
Attachments
DecisionControl.gui
(14.2 KiB) Downloaded 392 times
supermarkt7.mod
(43.81 KiB) Downloaded 393 times
MarvinH
Posts: 93
Joined: Tuesday 25 January, 2011 - 11:07
Contact:

Re: Adaptive control of MultiServer capacity/Instances

Post by MarvinH »

Hello Roman,

Nice GUI so far!
Rovo wrote:The DropDownList-Widget does not recognize a default value or I am doing something completely wrong :(
It's better to set the text of the combobox by updating the ItemIndex, instead of setting the text. So in your case, you can compare the attribute of the DecisionControl with [Linear] or [Exponential Smoothing], and set the ItemIndex of the combobox afterwards by using:

Code: Select all

GuiControl([decisionStrategy], GuiSet([ItemIndex], 1 {or 2})),
Rovo wrote:I know its the wrong place to store the logic but I do not know where to put the code to get executed automatically in the DecisionControl atom - but I guess I have to listen to certain events but not sure on how to do it in ED.
Your implementation of evaluating the code at clicking of the button is an option. If you want to control the behavior within the simulation itself, please indicate when/where you want the code to be evaluated. This way I can help you finding the relevant events. One option is to evaluate the code within an event of the DecisionControl itself. Put the code OnEvent, and create an event at reset of the DecisionControl after for example 5 seconds. Then at the event evaluate your code and create an event after 5 seconds again. This way, your code gets executed every 5 seconds during the entire simulation.
Rovo wrote:Moreover I noticed that on disabling a GroupBox the included widgets seem to get disabled (unclickable) but do not get disabled graphically - I assume here that the GroupBox is then in sense of layers above the other controls preventing clicks on them.
Indeed disabling a Groupbox disables all elements within the GroupBox. If you don't want to see the elements, simply set Visible of the group box to False.
Rovo wrote:Furthermore do attributes have to be defined in the atom editor first to get recognized by ED?
Indeed attributes have to be declared in the atom tree before a value can be assigned to it. You can also create attributes by code, for example:

Code: Select all

If(
  Not(Attribute_Exists(GuiAtom, [decisionStrategy])),
  CreateAttributes(1, [decisionStrategy], GuiAtom)
)
Undeclared attributes always return zero.
Rovo wrote:In addition to that, as I used a graph-atom as parent for my frame (I only need an input-channel and the Mtbf Mttr Availability atom required an availability atom even though I deleted every reference I have found), after loading my model, the attributes of the parent get loaded due to inheritance I guess - but is there a way to prevent the loading of those attributes?
It is not completely clear what you try to accomplish or what problems you run into. Indeed, when you load a model, all attributes of the mother of the atoms are loaded first. The values of these attributes are not loaded however. In case you want to add new attributes, just leave the original ones to it and create the new attributes below the attributes already present at your atom. That way changes to the mother of the atom do not affect your model. I do not understand your remark:
Rovo wrote:I only need an input-channel and the Mtbf Mttr Availability atom required an availability atom even though I deleted every reference I have found
Please feel free to reformulate your question.

Kind regards,

Marvin
Rovo
Posts: 6
Joined: Wednesday 11 April, 2012 - 10:29

Re: Adaptive control of MultiServer capacity/Instances

Post by Rovo »

Thank you again Marvin for your valuable input :)

The handling of the adaptive control logic works fine within the OnEvent-Method!

Concerning the disabling of a GroupBox-Element I meant that on disabling a GroupBox all contained elements are not clickable (as intended) but they do not get greyish like if you disable them manually (which I do to visualize that they are disabled) - not much of a problem though

With my starter knowledge in ED and 4DScript I didn't knew how to add channels to a newly created atom (channels tab in the atom editor is the solution therefore), so I took an existing atom (like in the example wizard) which had only one input channel. My intention here was that the DecisionController should control the connected atom via its info-channel, like the availability control. Graph-atom therefore was the first atom I found which only had one input-channel :D After finding the channels tab in the atom editor (never gone through all the tabs to be honest), I was to lazy to start the atom/frame from scratch so that I do not have the inherited attributes.

Hava a nice day/evening,
Roman
Rovo
Posts: 6
Joined: Wednesday 11 April, 2012 - 10:29

Re: Adaptive control of MultiServer capacity/Instances

Post by Rovo »

hello again,

I have nearly finished implementing my model (result is attached), but is there any possibility to check the input in the table like for editboxes in the edit_OnChange()-method? I only found a table_OnSelectCell()-method or is there an Update-event after an input? I'd like to guarantee that firstly all inputs are values and not strings and secoundly that they are greater then the values from preceding Cells

Thanks,
Roman
Attachments
Supermarket.zip
(14.74 KiB) Downloaded 413 times
MarvinH
Posts: 93
Joined: Tuesday 25 January, 2011 - 11:07
Contact:

Re: Adaptive control of MultiServer capacity/Instances

Post by MarvinH »

Hello Roman,

On the Table component there is an OnExit control. In this control you can put your code to be evaluated for all cells. Note that this code is only executed when another component than the Table is selected (e.g. a button), i.e. the code is not executed when different cells within the same table are selected. So OnExit, check all values for all cells and further check the relations between the cells, as you described before.

Further I think you might like the function "IsNumeric", for the evaluation of the cells within the table.

Kind regards,

Marvin
Post Reply