question

Lucas Rodrigues avatar image
0 Likes"
Lucas Rodrigues asked Jordan Johnson commented

Arrival time distribution in source change by time of day

Hello,

How i can make my source change the distribution by time of day?

Eg:

08:00h:weibull( 0.116994, 25.088053, 0.876710, getstream(current))

09:00h: beta(0.199745, 9.597606, 0.535678, 1.057751, getstream(current)))

"By Time of Day" option do not allow distributions, right?

My initial solution was to create a source for each time of day and use a Timetable to control each one.

Can someone help?

Tks!

FlexSim 21.1.4
sourcedistributionsinterarrival timesby time of dayarrival time
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

Jordan Johnson avatar image
0 Likes"
Jordan Johnson answered Jordan Johnson commented

As far as I can tell, the By Time of Day does allow expressions for each time. The code calls each value in the schedule as a function, so I think you can use that. However, I'm not sure that anything gets passed in to those functions, or that current is available. I think you'll need to change your expressions to something like:

weibull( 0.116994, 25.088053, 0.876710, param(1))

If you want to pass the stream in, you'll need to modify the code from the pickoption to pass in the stream:

if (hour >= 12)
retval = nodefunction(rank(rank(data, (hour+1) - 12),2), getstream(current));
else
retval = nodefunction(rank(rank(data, hour+1),1), getstream(current));

Alternatively, you could take a similar approach using an Object Process Flow to define a source. The attached model has both options.

SourceDemo.fsm


sourcedemo.fsm (41.5 KiB)
· 2
5 |100000

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

Lucas Rodrigues avatar image Lucas Rodrigues commented ·

Hi @Jordan Johnson

Can you tell me the difference between the "param(1)" and "gestream(current)"?

I use it by default.

0 Likes 0 ·
Jordan Johnson avatar image Jordan Johnson ♦♦ Lucas Rodrigues commented ·

In most pickoptions, current is exactly what you want to use. If you view the code of a pickoption, you'll find "current" in the section of code we call the header. It's usually defined as ownerobject(c).

If you look at the code for the "By time of day" pickoption, you'll see that current is listed in that header as well. So your question might be rephrased "why can't I use current in the function for each hour of the day?" This is a good question. The answer is that the expressions for each of the 24 hours are executed with a call to nodefunction, and they don't have a code header defined, so current isn't available like it normally is. This is a case that most pickoptions don't have, so using current is normally fine.

When you call nodefunction, you can pass in extra parameters. To access those parameters, you use param(1). So in the example code I gave you, I pass in the stream number in the call to nodefunction, and read that value by calling param(1), since I passed the stream number in nodefunction.

In your case, you could also do the following: leave the pickoption code alone (don't pass the stream number in) and write expressions like the following:

weibull( 0.116994, 25.088053, 0.876710, getstream(ownerobject(c)))

While current isn't available, c is available, and ownerobject(c) will get the same as current.

So now how have two options. You can either pass the stream number in, and read it with param(1), or you can call getstream(ownerobject(c)). Whichever makes more sense to you.

0 Likes 0 ·