Hello, I would like to know if there is any way to define the process time of a combiner by using Code Snippet. I attach a picture of the code where I want to define the process time with normal distribution.
Hello, I would like to know if there is any way to define the process time of a combiner by using Code Snippet. I attach a picture of the code where I want to define the process time with normal distribution.
Hi @Jon Perez, was one of Jason Lightfoot's or Iago MF's answers helpful? If so, please click the "Accept" button at the bottom of the one that best answers your question. Or if you still have questions, add a comment and we'll continue the conversation.
If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always comment back to reopen your question.
The process time value can be: a numeric single value; a string expression that is evaluated to lookup or generate a number, or multi-line code that does the same (also string).
When you say you want to "define the process time by code" it can mean two things - you can:
1) have that code as the process time expression/script to fire for each item
2) write the value/expression/script into the process time property using code (triggered elsewhere)
Of course you could be doing both of those things - trigger a script that writes an expression or script to the process time property (last example below).
Examples:
combiner.setProperty("ProcessTime", normal(10,1)); //writes a random value once to the combiner - eg. 10.5 will be used until you set another value.
combiner.setProperty("ProcessTime", "normal(10,1,getstream(ownerobject(c)))"); // writes the single line expression to be evaluated each time a process time is needed. (notice no semicolon at the end of the expression)
Lastly the code to write the script will look like this where the lines are seperated by semicolons and crucially the process time is returned by the script we supplied.
string newValue = "Object current=ownerobject(c); \ double sampletime=normal(10,1,getstream(current)); \ return sampletime;"; combiner.setProperty("ProcessTime", newValue);
Note the last two examples generate the same random samples.
Thank you! Can I add here on code snippet?
Do you want to write the value dynamically in code or do you just want it as a fixed expression (in which case you can type directly into the process time field the normal expression)?
If you want to write it dynamically then when do you want that to happen? An exit trigger will be too late for the current item for example.
Hello Jason, I want that depending of the counter to have a different process time. For example, if the counter is 10 or less, to have a normal(10,1) process time and if the counter is between 10 and 20, to have a normal(15,2) process time. Is there any way to achieve in by writing it on the oxit or entry trigger of the combiner with the code snippet?
How would I need to add that on the code of this screenshot? And if it cannot be done, how would I need to do it?
Hi, you can set value of properties with the method setProperty, for example:
Object combiner = Model.find("Combiner1"); double newValue = 50; combiner.as(Object).setProperty("ProcessTime", newValue);
If the owner of the code snippet is the combiner, you have the reference as current:
Object combiner = current;
Depending on the case, it might be sufficient for the processing time to depend on that information, so you could use a custom code in the 'Process Time' cell. In this code, you should return the value according to the conditions you desire.
I hope it helps you!
how do I have to add it to the code in order to have a normal(10,1) process time?
17 People are following this question.
FlexSim can help you understand and improve any system or process. Transform your existing data into accurate predictions.
FlexSim is a fully 3D simulation software environment. FlexSim can be used to simulate any process in any industry.
FlexSim®, FlexSim Healthcare™, Problem Solved.®, the FlexSim logo, the FlexSim X-mark, and the FlexSim Healthcare logo with stylized Caduceus mark are trademarks of FlexSim Software Products, Inc. All rights reserved.
Privacy | Do not sell or share my personal information | Cookie preferences | Report noncompliance | Terms of use | Legal | © Autodesk Inc. All rights reserved