question

George L3 avatar image
0 Likes"
George L3 asked Regan Blackett answered

Custom IAT by hour of day using normal distribution.

Hi,

I am trying to set the inter-arrival times of objects coming out of a source, but I would like to set it using a normal distribution, not a constant value for each hour interval. I have created a global table containing the 'means' for each hour of the day. I wrote the following code, that I would like to reference the different cells in that table depending on the hour of day.

I create a double, 'hour', that gets the current hour, and would like to use it to pull from my table of means the corresponding value (using 'hour' as an index):

double hour = getmodelunit(CURRENT_HOUR_OF_DAY);

double mean = Table("ArrivalTable")[1][hour];

I have also created another table to be able to monitor the hour of day, mean and IAT throughout the simulation. When writing the code as above, the hour of the day does not update in the table throughout the simulation, but when replacing [1][hour], with say, [1][11], it works fine.

How do I reference the column of a global table using 'hour' ?

Many Thanks.


Choose One
interarrival times
· 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.

Regan Blackett avatar image Regan Blackett ♦ commented ·

Can ou share your model? If not, does your code give an error message or does it just not work as intended? Using the 'hour' variable you've created should work fine, unless the hour is 12am, in which case CURRENT_HOUR_OF_DAY will return zero and tables don't have a column 0.

1 Like 1 ·

1 Answer

Regan Blackett avatar image
1 Like"
Regan Blackett answered Regan Blackett edited

The reason it isn't doing what you think it should is because of when the code is evaluated. The Interarrival time is only evaluated once at the start of a model to find the time interval from zero until the creation of the first flowitem. Then it is evaluated again after each flowitem exits the source object. It doesn't update outside those times.

Honestly if all you need to do is create flowitems between a time range like that, the time table is probably a fine way to go. Or you could use the Data/Time Source activity in process flow and use its tokens to create your flowitems.

5 |100000

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