question

Mike S5 avatar image
0 Likes"
Mike S5 asked Ben Wilson commented

Calculate delay time based on array values

I'm trying to calculate a delay time based on the values in an array. For example, tokens have been batched with a mixed item type. To calculate the delay time for the batch, it would be A*X+B*Y+C where A, B, and C are constants and X and Y are the quantities of each item type. I believe the only way to accomplish this (after reading help questions for over a day on this topic) is with custom script (which is above my skill level). Is there any other way to calculate delay time based on values in a token label array?

FlexSim 20.1.1
flexsim 20.1.1
· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Ben Wilson avatar image Ben Wilson ♦♦ commented ·

Hi @Mike S5, was jason.lightfoot's answer helpful? If so, please click the red "Accept" button at the bottom of their answer. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always unaccept and comment back to reopen your question.

0 Likes 0 ·

1 Answer

·
Jason Lightfoot avatar image
2 Likes"
Jason Lightfoot answered Jason Lightfoot edited

You should be able to do it in an expression if the array lengths are fixed.

So if the mix of x and y is in an array called mix and you have global variables A,B and C the time would be:

A*mix[1]+B*mix[2]+C

If you need to, instead of 1 and 2 as indices, use "X" and "Y" then you could set up a map and then it's just:

A*mixmap["X"]+B*mixmap["Y"]+C

Setting up a map would involve scripting though, so another way would do be to define NUMX as 1 and NUMY as 2 as global macros:

#define NUMX 1
#define NUMY 2

and then use that in your regular array:

A*mix[NUMX]+B*mix[NUMY]+C

If the values of A,B and C were stored as labels on a processor, the processing time might then be:

current.A*mix[NUMX]+current.B*mix[NUMY]+current.C

and if the mix array is on the item that becomes:

current.A*item.mix[NUMX]+current.B*item.mix[NUMY]+current.C
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.