question

Mason W avatar image
0 Likes"
Mason W asked Matthew Gillespie answered

Dempirical Table Lookup Based on Token Label

Hi all,

I'm trying to make the table lookup portion of the dempirical function dynamic based on a token label. In the example attached, depending on what token label "Table" is look up percentage from given Global Table (If token.Table == 1SKU calculate dempirical function using 1SKU Global Table, if token.Table == 2SKU use 2SKU Global Table...etc.). In the current setup there are no sub flows run. Is there a way to do this using my logic or is there a simpler way?

Thanks,

sample.fsm

FlexSim 19.1.1
global tablelabelsdempiricaldempirical distribution
sample.fsm (20.9 KiB)
5 |100000

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

Matthew Gillespie avatar image
0 Likes"
Matthew Gillespie answered

You are passing the label node into dempirical function instead of the string "1SKU" which is the label's value. I suspect you did this because the system console prints an error if you put in token.Table. This error is because the compiler doesn't know if token.Table is a string, number, or node. But the error will go away if you tell it it's a string:

dempirical(token.Table.as(string), getstream(activity))

Also the way you're concatenating the string is very round about, you don't need to make an intermediate array, you could just do something like this:

string.fromNum(token.SKUs) + "SKU"

dempiricalstring.fsm


5 |100000

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

tannerp avatar image
0 Likes"
tannerp answered

Hi @Mason W,

I think your method works, but it was having a hard time interpreting the table name as a string properly. I've updated the code a little bit and it seems to work and run sub flows now. I changed the code from this:

dempirical(token.labels["Table"], getstream(activity))

To this:

dempirical(Table(string(token.Table)),getstream(current))

Hopefully this works for you.

sample-string.fsm


sample-string.fsm (21.8 KiB)
5 |100000

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