Maryam H2 avatar image
Maryam H2 asked Maryam H2 commented

How to reference to a statistical distribution in parameters table?


How can I refer to a statistical distribution in the Parameters table? and probably how can I change different parameters of a statistical distribution if I want to test the changes in the Experimenter or Optimizer?

For example, if this is a triangular distribution with TR(min, max, mode) how can I change the values for min, max, the mode in the Parameters table? Is it possible?


statistical distributionparametersreference
5 |100000 characters needed characters left characters exceeded

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

Felix Möhlmann avatar image
1 Like"
Felix Möhlmann answered Felix Möhlmann commented

The "Expression" parameter type allows you to write FlexScript as the parameter value, which will get evaluated when the parameter is called.

There is also nothing stopping you from referencing other parameters within that expression.

So you could have one parameter hold the distribution as an expression and take the values for it from others.



· 2
5 |100000 characters needed characters left characters exceeded

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

Thanks, @Felix Möhlmann for the answer?

I tried your way and have 3 questions:

What is going to be in the reference part of each of the parameters (i.e. min, max, and stream)? Also stream parameters are the same for all distributions? If the reference is blank, can I change the parameters in the Experimenter?

2. What this chunk of code does?


3. What should be in the reference section for that distribution expression?

0 Likes 0 ·
1634222996077.jpeg (599.1 KiB)

The reference is used to connect the parameter to a certain node/value in the model. To update that value when the parameter is changed. You'd use it when you have a single point in the model that uses the parameter, for example the processing time of one processor.

You don't have to enter anything into the reference field if you don't want to link the parameter to any one node. Binding the min/max/stream parameters to anything wouldn't really make sense in this case, for instance. Since they are only used to influence the distribution. The experimenter can change them regardless of a reference being set.

The "stream" could be seen as the seed of the random distribution. A different stream will lead to different results. By default, it is mostly filled in with the "getstream()" command that generates a unique stream number based on the object it is used in. This leads to better repeatability, as the numbers that are generated for any object/activity are independent of how often the distribution is used elsewhere. If you use the same stream everywhere, then adding an additional processor, for example, will have an impact on the processing times that are generated for the others during the run (it will take up some numbers that would have otherwise been used in the other objects). As such, model runs might be less comparable to each other when changes like that occur between them.

See also this post and links in the answer for more info on the stream.

I don't see any way to meaningfully vary the stream when using a parameter as a distribution like this. However, if the model run time is long enough, the variance caused by using the same stream shouldn't have a measurable impact on the results in most cases.

The code in the script window at the bottom is the other way to use a parameter in a model. Instead of connecting a single value to the parameter you can use it in multiple places to get the value of the parameter, in this case a random number according to the distribution. For example, you want to control the processing times of multiple processors with the parameter. Then you'd write "Model.parameters.distribution" in the field for the processing time of each one.

I used the script window to confirm that using other parameters in the distribution actually works as expected. When you click on the green arrow it will generate and display a new random value according to the distribution each time.

1 Like 1 ·
Maryam H2 avatar image
Maryam H2 answered Maryam H2 commented

@Felix Möhlmann Thanks for the explanation! I want to use this parameter to change a processing time in my patient flow. The eprocessing times will be read from a global table and for each label the processing times are different. The values in the global table are following statitical distributions and I want to be able to change them afterwards by changing parameters in the Experimenter as you mentioned. So in the "distribution" should I use a "Set Global Table Value" under " On Set" and define which row/column I am referring to in the global table?

· 2
5 |100000 characters needed characters left characters exceeded

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

Using the "On Set" would copy the actual text from the parameter to the global table. (Which could maybe have a another look at by the developers)

To populate a table with values generated by a distribution I have to suggestions. Both generate the values in the "On Reset" option of the tables.

1) Define the distribution in a row of the table itself (right click on column -> Assign Data -> Assign Flexscript Data)


Then use this code in the reset option.

/**Custom Code*/
Table current = param(1); //Table node

// for-loop to iterate over all rows of the table
for(int row = 1; row <= current.numRows; row++)
  // set the value in the second column to a number generated from the first column
  current[row][2] = current[row][1];

2) Only write the name of the parameter that the value should be generated from in the table (Assign String Data). In that case, you'd exchange the code in line 8 with the following.

current[row][2] = Model.parameters[current[row][1]].evaluate();

In both cases the generated values would be the same between runs, if the parameters are not changed, while the "Repeat Random Streams" under "Statistics" is activated. To generate a new set of values based on the same parameters, it would have to be deactivated.



1 Like 1 ·
1634282989585.png (24.7 KiB)
1634283378825.gif (194.1 KiB)
Maryam H2 avatar image Maryam H2 Felix Möhlmann ·

Got it, thanks a lot!

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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