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

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

christopher_s2
Not applicable
56 Views
6 Replies
Message 1 of 7

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

christopher_s2
Not applicable

[ FlexSim 18.2.2 ]

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?

Replies (6)
Message 2 of 7

joerg_vogel_HsH
Mentor
Mentor
Accepted solution

"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.

Message 3 of 7

christopher_s2
Not applicable

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
Message 4 of 7

Matthew_Gillespie
Autodesk
Autodesk

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



Matthew Gillespie
FlexSim Software Developer

Message 5 of 7

christopher_s2
Not applicable

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
Message 6 of 7

Matthew_Gillespie
Autodesk
Autodesk

It's indirectly related to this post. Your question was "Why doesn't getstream(current) work in a table". Asking "What is the right syntax to pass the processor name to a getstream() command in a table cell" is a different and more detailed question.

There is no correct syntax currently. There are a number of ways I could think of, but no one size fits all solution. Post a new question describing what you want to do how your table is set up (or post a sample model) and we'll help you come up with a solution that works for your model.



Matthew Gillespie
FlexSim Software Developer

0 Likes
Message 7 of 7

Matthew_Gillespie
Autodesk
Autodesk

The new question can be found here:

https://answers.flexsim.com/questions/57464/how-to-pass-the-processor-name-to-a-getstream-comm.html



Matthew Gillespie
FlexSim Software Developer