Select shortest queue from branch object

331 views
Skip to first unread message

Giorgio Perperoglou

unread,
May 26, 2015, 1:04:23 PM5/26/15
to jaamsi...@googlegroups.com

Hello, I'd like to ask how can we make our entities go from the branch to the shortest available queue
Let's say for example,after the branch we have 3 queues(with their servers) and we want to send it to the less crowded
I've seen an example here named "Queue Selection Example"
but when i type on the input editor on the "choice" the formula indexOfMin(.....) and then i press enter it disappears
Am I typing wrong the formula or it's something else? Which exactly is the structure of the formula?
Thank you!

Harry King

unread,
May 26, 2015, 1:55:27 PM5/26/15
to jaamsi...@googlegroups.com
Giorgio,

The entry for the Choice keyword is an "expression". The syntax for expressions is described on page 86 of the user manual.

If you can't get your expression to work, please post the exact text that you have entered unsuccessfully. Also attach a copy of your input file for reference.

Harry

Harry King

unread,
May 26, 2015, 2:12:09 PM5/26/15
to jaamsi...@googlegroups.com
Giorgio,

I notice that the indexOfMin function is not documented in the manual. This function takes a list of numbers and returns the index number for the one that has the smallest value. For example, 'indexOfMin(5, 3, 4)' returns 2 because the second input (3) is the smallest value. There is also an indexOfMax function. I'll add this information to the next release of the manual.

Harry

Giorgio Perperoglou

unread,
Jun 3, 2015, 4:19:16 PM6/3/15
to jaamsi...@googlegroups.com
  Hello Harry and thank you for the response
  OK now,i found how the "indexOfMin" works but i'd like to ask something
  I attach an example here (example1)
  In the example we have 4 servers with their corresponding queues
  by running the example the entities don't go to the next available server but to the next available queue starting with the 1st,then the 2nd etc.
  In this way,for example,if the server 1 is working (containing an entity), the next entity will go to the queue1 instead of the server 2
  Only if the queue 1 has one entity,the next entity will go to the server 2 (the same of course is happening with the next components,queue2-server3,queue3-server4)
  Actually the priority is Server1>Queue1>Server2>Queue2>Server3>Queue3>Server4>Queue4 instead of Server1>Server2>Server3>Server4>Queue1>Queue2>Queue3>Queue4
  Is there something we can do to fix it?
  Thank you for your time,
      Giorgio
example1.cfg

Harry King

unread,
Jun 3, 2015, 5:26:44 PM6/3/15
to jaamsi...@googlegroups.com
Giorgio,

The solution is to include information about each Server in the expression for Choice. The following expression adds 1 to the length of each queue when its server is working:

'indexOfMin( [Queue1].QueueLength+([Server1].Working?1:0), [Queue2].QueueLength+([Server2].Working?1:0), [Queue3].QueueLength+([Server3].Working?1:0), [Queue4].QueueLength+([Server4].Working?1:0))'

The attached input files includes this change.

Harry

example1 - HK.cfg

Giorgio Perperoglou

unread,
Jun 4, 2015, 7:50:29 PM6/4/15
to jaamsi...@googlegroups.com
  Great,thank you, this helped a lot!
  Giorgio

Connor Beddow

unread,
Feb 7, 2022, 6:57:19 AM2/7/22
to Jaamsim Users Discussion Group
Why may I ask does the next component list order have to be in the same order as the list of values in the expression array (within the input builder for choice) for this to work.

For example if next component list for branch is Queue1, Queue2, Queue3. but in the expression I was to write 'indexOfMin([Queue2].QueueLength+([Server2].Working?1:0), [Queue1].QueueLength+([Server1].Working?1:0),[Queue3].QueueLength+([Server3].Working?1:0) the formula no longer works as it should, I have tired multiple variations to this forumal using MinCol, Min etc but they all suffer the same issue when the NextComponentList is out of order with the expression array in the input builder the formulas no longer work. 

Regards

Connor

Harry King

unread,
Feb 7, 2022, 12:18:43 PM2/7/22
to Jaamsim Users Discussion Group
Connor,

Please don't reuse an old forum post in this way. Start a new one!

Regarding your input to the Choice keyword, the expression you give seemed to work okay when I tried it myself. However, I did have to add a closing bracket and single quote. The correct expression is:

'indexOfMin([Queue2].QueueLength+([Server2].Working?1:0), [Queue1].QueueLength+([Server1].Working?1:0), [Queue3].QueueLength+([Server3].Working?1:0))'

If those changes don't solve your problem, please attach to your next post a simple example model that demonstrates the issue.

Harry

Reply all
Reply to author
Forward
0 new messages