question

Ismael R3 avatar image
0 Likes"
Ismael R3 asked Logan Gold commented

How to change the empirical distribution in experimenter as a variable?


Hello everyone, dear community. In my project it is necessary to insert several input distributions to see what happens, in my case I have several empirical distributions, I would like for example: In my source, I want to select the distribution between arrivals as my variable. And the scenarios would be the different empirical distributions that I have to evaluate what happens in those cases. Because of this I want to know how to solve it. Thank you very much if you know how to do it with the new update of the parameter table for version flexsim 2021. Thanks for your help

FlexSim 21.0.0
flexsim 21.0.0experimenter variableupdateexperimenter update
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

Jason Lightfoot avatar image
1 Like"
Jason Lightfoot answered Logan Gold commented

The key to this is to add a parameter as an Option type and then put text for the Empirical distribution name in the edit box BELOW the values table view - if you try to edit the table cell it will not currently accept it and will revert to numeric.

Then there are a number of ways to use this model parameter of which one is to use it to set a value somwhere in the model and another is to read the parameter directly from somewhere in the model. Both will work with scenarios in the experimenter, and with the parameters dashboard.

So for this example I created a ColorPalette and some Empirical Distributions so that we might use those in the example to change interarrival time and to set the color of the arriving items by choosing the experiment scenario.

InterArrival Distributions:

Color Distributions and Palette:

Setting Labels

The first approach puts labels on the source for us to reference in the arrival type and creation triggers:

So then the inter-arrivaltime is set to: Empirical(current.intArrivalEmp).get(getstream(current))

And the creation trigger sets the items color to:

Color.fromPalette(Empirical(current.colorEmp).get(getstream(current)),"ColorPalette1")

Note that this will work without the Model Parameters table – as it’s just reading the distribution names from the label.

To get the Model Parameters to set this via the Experimenter and on Reset. We need to add them as Options. Open the model parameters tool found in the toolbox:


Click on the arrow to the right of the value cell on the new parameter and select the Option type form the pull down which should then show this:

Now for the interarrival distribution names we need to add two options to press the + sign against Options. Click on each new value cell and enter the distibutions name BELOW the table in the edit box. Then for the reference use the sample to click on the source and choose the label “intArrivalEmp” we created (only if setting labels -see below ‘Direct Parameter Acces’s). Then rename the rows to tell FlexSim what you want shown in the experimenter view – I’ve used the same names as the distribution:

You can then rename the parameter so that you know what they are in the experimenter view:

Next set up the experimenter scnarios by checking the pararmeter you just added and adding scenarios.

Note: At the moment you need to type in the row number of the option value you want – so 1 or 2 in this case – and the value for that option will be displayed as shown.

By selecting the column you can then set the current scenario for the model when running interactively. Resetting the model will set the label value and so the source will use FastArrivals or SlowArrivals depending on the scenario chosen.

The same process goes for the empColorSetter parameter which sets the colorEmp label on the source to “RGBColors” or “ManyColors”


Direct Parameter Access

A second approach is to use the model parameters directly. In this approach the labels are not used and instead of entering the distribution names we for the parameter’s option values we enter the Empirical sampling expression which we will then evaluate from the source.

So instead of “FastArrivals” and “SlowArrivals” we’ll have Empirical("SlowArrivals").get(param(1)) and Empirical("FastArrivals").get(param(1))

There’s no need to sample or add code to the OnSet so it can be removed. I added this as a separate parameter in the model so you could see both methods in parallel and named it EmpiricalInterArrivalSampler along with the same technique for color sampler:

Then in the source inter-arrival time field the expression becomes:

Model.parameters["EmpiricalInterArrivalSampler"].evaluate(getstream(current))

And the expression for setting the item color is:

Color.fromPalette(Model.parameters["EmpiricalColorSampler"].evaluate(0),"ColorPalette1")


Model with both approaches attached so the Scenarios look like this:

Model attached in the next comment.



1608250310627.png (20.4 KiB)
1608250325090.png (48.6 KiB)
1608250344738.png (6.4 KiB)
1608250361142.png (2.1 KiB)
1608250380283.png (14.9 KiB)
1608250397689.png (12.5 KiB)
1608250411261.png (5.8 KiB)
1608250426449.png (17.5 KiB)
1608250444275.png (16.7 KiB)
1608250476659.png (12.4 KiB)
1608250491154.png (8.5 KiB)
1608250506896.png (20.5 KiB)
· 9
5 |100000

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

Jason Lightfoot avatar image Jason Lightfoot ♦♦ commented ·

The model attached.empiricalModelParameters.fsm

0 Likes 0 ·
Ismael R3 avatar image Ismael R3 commented ·
Thank you for the explanation Jason I will wait for your example!
0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦♦ Ismael R3 commented ·

@Ismael R3 Should be updated now

0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦♦ Ismael R3 commented ·
Sorry for the typo. mistakes - if I correct them I'll have to re-add all the images.
0 Likes 0 ·
Ismael R3 avatar image Ismael R3 Jason Lightfoot ♦♦ commented ·

Thank you Jason. I was trying to do the same but I have some errors. Do i make Something brong? I tried the second form because I do not have enough time to do the first one because I have severals sources . I tried to put the code that you show at the first one , but it get som errors thenI tried to call the variable just as the option that it show you in the model. Does it didnt work because of that? I do not realy found the problem. Please if you can hel I really aprreciate your example èxperimenter.fsm

0 Likes 0 ·
experimenter.fsm (548.5 KiB)
Show more comments
Dustin B avatar image Dustin B commented ·

Hi @Jason Lightfoot I am trying to do something similar, but instead of using a source I am using a create object process flow.

I've managed to figured out how to set up the options in the Parameter table, but I am not sure how to enter the "Argument" values into the Process Flow when I select the Parameter as the value. Screenshots included.
Can you help?
Thanks,
Dustin

Parameter Table with options defined as the 3 distributions
1654204988024.png
Create object qty screen with above parameter selected1654205048631.png

0 Likes 0 ·
1654204988024.png (20.3 KiB)
1654205048631.png (214.1 KiB)
Logan Gold avatar image Logan Gold ♦♦ Dustin B commented ·
Hi @Dustin B. We are happy to help, but will you please post a new question with a reference to this question? Thank you.
0 Likes 0 ·