I'm trying to write script for a Source's Trigger-on-Creation field, such that a product's label is assigned based on a uniform(0,1) draw. Here's my pseudo-code that's not a working 4DScript:
Case((x=uniform(0,1)),
(x<=0.3, setlabel([JobType],1,i)),
(x>0.3 & x<=0.8, setlabel([JobType],2,i)),
(x>0.8,setlabel([JobType],3,i))
)
I know this isn't right, but I hope it communicates my intent. Once the product's label is set, I will use another 4DS in the Send-To field to route it to the appropriate server. FYI, this is implementing the Job-Shop example in Section 2.7 of 4th ed. of Averill Law's Simulation Modeling and Analysis. It's the final thing that I need to do to illustrate this example using ED.
Random Product Label Assignment at Source Creation
Re: Random Product Label Assignment at Source Creation
Hi Terril,
You can use this:
Regards,
Bart
You can use this:
Code: Select all
Do(
var([valX], vbValue),
valX := Uniform(0, 1),
Case(
WhichIsTrue(
valX <= 0.3,
valX <= 0.8,
valX > 0.8
),
SetLabel([JobType], 1, i),
SetLabel([JobType], 2, i),
SetLabel([JobType], 3, i)
)
)
Bart
Re: Random Product Label Assignment at Source Creation
Thanks; I'll try this. One correction, though: The second case needs to include an "and" condition, i.e. Val >0.3 & <= 0.8. I'll try combining two conditions, but so far, I haven't yet got the syntax correct.
Thanks again.
-TH
Thanks again.
-TH
Re: Random Product Label Assignment at Source Creation
I'm still having difficulties implementing the Law's Job Shop example. So I've created and attached a simplified version for debugging.
After implementing Bart's 4DScript in the Source Trigger-on-Creation Field, the model "kind of" functions, sending a small number of products through some of the time (after reset) but not always. Then it stalls out as though deadlocked.
I believe that I've correctly connected everything, since if I randomly send products to the 3 queues/servers, then they roughly converge to equal utilizations. But somehow, I'm still not routing as desired according to the probabilities in the Source Trigger-on-Creation's case/label assignments and Send-To script.
I'm not sure it's a misunderstanding of 4DScript, the "Central Channel", referencing, or a combination of many things that's stopping me.
I appreciate any further help that you can provide.
After implementing Bart's 4DScript in the Source Trigger-on-Creation Field, the model "kind of" functions, sending a small number of products through some of the time (after reset) but not always. Then it stalls out as though deadlocked.
I believe that I've correctly connected everything, since if I randomly send products to the 3 queues/servers, then they roughly converge to equal utilizations. But somehow, I'm still not routing as desired according to the probabilities in the Source Trigger-on-Creation's case/label assignments and Send-To script.
I'm not sure it's a misunderstanding of 4DScript, the "Central Channel", referencing, or a combination of many things that's stopping me.
I appreciate any further help that you can provide.
Re: Random Product Label Assignment at Source Creation
I think I figured out my problem: It had to do with the conditional statements' syntax. Here's what works in the Source's Trigger-On-Creation script:
Do(
var([valX], vbValue),
valX := Uniform(0, 1),
Case(
WhichIsTrue(
<=(valX,0.3),
&(>(valX,0.3),<=(valX,0.8)),
>(valX,0.8)
),
SetLabel([JobType], 1, i),
SetLabel([JobType], 2, i),
SetLabel([JobType], 3, i)
)
)
On to next challenge!
Do(
var([valX], vbValue),
valX := Uniform(0, 1),
Case(
WhichIsTrue(
<=(valX,0.3),
&(>(valX,0.3),<=(valX,0.8)),
>(valX,0.8)
),
SetLabel([JobType], 1, i),
SetLabel([JobType], 2, i),
SetLabel([JobType], 3, i)
)
)
On to next challenge!