question

Christopher S2 avatar image
1 Like"
Christopher S2 asked Matthew Gillespie commented

Exception with distribution in a global table caused by getstream(current)

Good morning,

I am using a global table to look up cycle times for my processors based on their names. This works fine. I then tried to add in a distribution into the table, by assigning the cell data type to Flexscript. I used a beta distribution:

beta(138.8, 200, 2, 10, getstream(current))

This results in the following exception, and the cycle time of the processor becomes instantaneous (or close to it).

time: 0.000000 exception: FlexScript exception: Property "dataType" accessed on invalid node. at /0

If I remove the getstream(current) and replace it with an integer, everything functions as normal.

Do I have to select a stream manually? Or am I doing something wrong in trying to use the default getstream(current) function?

FlexSim 18.2.2
global tableflexscriptflexscript exceptiondistribution parametersdatatype
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

Joerg Vogel avatar image
2 Likes"
Joerg Vogel answered Matthew Gillespie commented

"current" isn't a pointer in the scope of the method executeCell of the object you call the function. If you place a direct pointer like model() or model().find(obj name) this works.

· 5
5 |100000

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

Christopher S2 avatar image Christopher S2 commented ·

Thank you Jörg,

The below works.

beta(138.8, 200, 2, 10, getstream(model().find("ProcW3")))

Using just model() works, too, but I am worried that if I used that for every processor, they would all use the same random number stream, right? My understanding is that model() only has one stream? I tried to find documentation on this, but it is not well explained. The best I could find was this post.

0 Likes 0 ·
Matthew Gillespie avatar image Matthew Gillespie ♦♦ Christopher S2 commented ·

You should look at the documentation of the getstream command:

Returns a unique random stream associated with the object.Returns the number stored in the object's stream attribute. If the object does not yet own a stream attribute, or if its stream attribute is 0, FlexSim will assert the attribute and assign it a unique stream number. If the object passed into the function does not have object data, it will store the unique stream in a subnode. This subnode will be destroyed on model reset and reassigned during the model run as needed.Assigned streams start at stream 101 and increase as they are assigned.

So, yes, using model() would give you the same stream for every processor. Ideally you should associate each processor with its own unique stream (the point of the getstream() comand in the first place). I would suggest asking a separate question about how to pass in the processor to the distribution in the table.

Here is a post with a collection of documentation on streams in general:

https://answers.flexsim.com/questions/47022/what-representation-has-the-use-of-a-stream-in-the.html

1 Like 1 ·
Christopher S2 avatar image Christopher S2 Matthew Gillespie ♦♦ commented ·

Hi Matthew,

I did read both the documentation and the posts referenced. Hence why I asked for confirmation of my understanding, based on that documentation. Thank you for that.

I can post another question, but as it is directly related to this post, can you please provide the right syntax to pass the processor name to the getstream()? Right now I am writing an excel table that just references the row name, and then copy/pasting into the global table. This works, but I'm sure there is a more elegant solution.

Thanks,

Christopher

0 Likes 0 ·
Show more comments