question

Prateekq4 avatar image
0 Likes"
Prateekq4 asked Jeanette F edited

Distribution based interarrival time

Hi,

I am trying to have my source assign item label values based on a normal distribution.

So, i want the label values to occur in a normal distribution with mean 17 and s.d. 3. But i only want the values that lie between 8 and 26.

The code i used is shown below:

The problem i am facing is that some items are released with no label value. So i think what it is doing is if the value lies outside the range, it does not assign any value to that item. I want to avoid this. Please suggest a solution to ensure all items are labeled based on the specified range.


1694726598334.png

Object current = ownerobject(c);

Object item = param(1);

int port = param(2);

{ // ************* PickOption Start ************* //

/***popup:SetLabel*/

/**Set Label*/

Object involved = /** \nObject: *//***tag:object*//**/item/**/;

string labelname = /** \nLabel: *//***tag:label*//**/"Type"/**/;

int value = /** \nValue: *//***tag:value*//**/normal(17,3,getstream(current))/**/;

if (value>=8 && value<=26)

{

involved.labels.assert(labelname).value = value;

}

} // ******* PickOption End ******* //


FlexSim 22.1.4
distributions
1694726598334.png (18.3 KiB)
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

·
Jeanette F avatar image
0 Likes"
Jeanette F answered Prateekq4 commented

Hello @Prateekq4,

You just described a normal distribution.

normal(17, 3.0, getstream(current))

Normal Distribution.fsm


· 3
5 |100000

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

Prateekq4 avatar image Prateekq4 commented ·

Hi Jeanette, i accidentally uploaded the wrong code. I have uploaded the correct one now. i had actually used normal distribution in my code and want limits on it, such that no null labels are generated

0 Likes 0 ·
Prateekq4 avatar image Prateekq4 Prateekq4 commented ·
The current code is such that if there are any values outside the limits, it does not label the item.
0 Likes 0 ·
Jeanette F avatar image Jeanette F ♦♦ Prateekq4 commented ·

You want to use a while loop that makes it re-execute the distribution until the value is within the range you want.

Object current = ownerobject(c);
Object item = param(1);
int rownumber = param(2); //row number of the schedule/sequence table
{ // ************* PickOption Start ************* //
/**Set Label*/

Object involved = item;
string labelname = "Type";
Variant value = 0;

while( value < 8 || value > 26){
value = normal(17, 3.0, getstream(current));
}

involved.labels.assert(labelname).value = value;
} // ******* PickOption End ******* //

Normal Distribution_1.fsm

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.