question

Marc K avatar image
0 Likes"
Marc K asked Joseph Gillespie commented

Adding statistical distribution in global tables

I have processes that are variable each time they are ran. I created a Global Table to contain the time variables. If I enter a single number variable (i.e. 5 for 5 minutes) the lookup works. I needs the value to be a statically distributed (i.e. triangular(5.0, 15.0, 10.0, getstream(current))). When I input this string the Global Table does not work. Like Excel where you put an "=" sign to designate it as an expression, is there a simple way to do that in Flexsim? This way when I have my DELAY look up the table the Delay becomes variable. I know I can just have the DELAY have the expression but having the ability to modify the table is far easier than going through all DELAYS in my model.

FlexSim 19.0.1
global tables
5 |100000

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

1 Answer

·
Mischa Spelt avatar image
1 Like"
Mischa Spelt answered Joerg Vogel commented

First of all you should make sure to tell FlexSim that you want to put a script in your cell. Right click the table cell, select Assign Data, then Assign FlexScript Data (or do it on the whole column at once).

Since there will not be a current variable, you should replace the last argument with a hardcoded one such as 1 or getstream(Table("tablename")).

Now each time you request the value of the cell

Table("GlobalTable1")[1][1]

it will return a random value.

Note that you will have to be careful not to write code like this:

if(Table("GlobalTable1")[1][1] < 0.5) {
  item.RandomValue = Table("GlobalTable1")[1][1];
}

but like this, only executing the cell once:

double randomValue = Table("GlobalTable1")[1][1];
if(randomValue < 0.5) {
  item.RandomValue = randomValue;
}

Alternatively, you can just put the cell data type to String, and then instead of

Table("GlobalTable1")[1][1]

use something like

Table("GlobalTable1").executeCell(1, 1)

to execute it.

· 8
5 |100000

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

Marc K avatar image Marc K commented ·

This is what I think you are saying but it doesn't work. I get error messages. Is the Equation correct in the table cell?

0 Likes 0 ·
globaltable.png (40.6 KiB)
Marc K avatar image Marc K commented ·

Mischa, is this what I am doing wrong? I did not fully understand this statement...

"Since there will not be a current variable, you should replace the last argument with a hardcoded one such as 1 or getstream(Table("tablename"))."

0 Likes 0 ·
Joerg Vogel avatar image Joerg Vogel Marc K commented ·

you can parse parameters into the code of a table cell, if you evaluate the cell node.

1 Like 1 ·
Marc K avatar image Marc K Joerg Vogel commented ·

Jorg, what is the advantage of doing this way compared to the answer Mischa gave. I am always trying to learn.

0 Likes 0 ·
Show more comments
Show more comments
Mischa Spelt avatar image Mischa Spelt Marc K commented ·

Yes, you cannot use current there. Normally, when you use an object trigger or Process Flow activity, FlexSim will automatically add a code header with a current variable that points at the current object or attached Process Flow object. In this case there is no such default header, so current is undefined. I made that mistake too, and the error message you get is not very enlightening.

If you use triangular(5.0, 15.0, 10.0, getstream(Table("GlobalTable1"))) then it should work. If you don't want to clutter your code and hardcode the table name everywhere, you could also reserve a specific stream, say 42, and use that: triangular(5.0, 15.0, 10.0, 42).

0 Likes 0 ·
Marc K avatar image Marc K Mischa Spelt commented ·

Thank you Mischa. I knew there had to be a simpler way of getting is done.

0 Likes 0 ·

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.