Recalculate random()

Recalculate random()

nielsY7USN
Explorer Explorer
492 Views
6 Replies
Message 1 of 7

Recalculate random()

nielsY7USN
Explorer
Explorer

How can I recalculate random() values without manually modifying the parameter using random()?

I would have thought that "compute all" would do it but that's not the case.

 

 

0 Likes
493 Views
6 Replies
Replies (6)
Message 2 of 7

g-andresen
Consultant
Consultant

Hi,

Please share a sample file with the naming of the relevant variables

 

günther

0 Likes
Message 3 of 7

nielsY7USN
Explorer
Explorer

Example attached.

The two bars are assigned a random length when dimension is added to them and the only way I can make it change, is if I modify the BarLength parameter

Message 4 of 7

MichaelT_123
Advisor
Advisor

Hi Mr. NielsY7USN,

 

It seems that random() function receives its seed 'acquired' somehow at the opening of a document which doesn't change during the whole document session. As such the output of the function random() become deterministic, in mathematical notation random()=const.

Who knows, was this intentional on TF360 developers' side or not?

Can random() function be seeded in a more unique/random way (e.g. via the current time)? This is the open question and perhaps TF360 might have their say here.

If you for some reason want to achieve a higher level of randomness in your design ... run it via an external script without reliance of UserParameter's embedded random() function.

 

Regards

MichaelT

 

 

 

MichaelT
0 Likes
Message 5 of 7

nielsY7USN
Explorer
Explorer

Randomness is not a problem in my current design.

My problem is that the random value is only updated when I "touch" the parameter using it.

This is annoying, when I have more parameters relying on a random value - then I have to "touch" them all to get them updated - I would have expected them to update when I use the "compute all" function.

For now, I've "solved" it by adding a common, insignificant, parameter that I can "touch". However I think I'll have to dive into scripts to do it the right way...

0 Likes
Message 6 of 7

MichaelT_123
Advisor
Advisor

Hi Mr. NielsY7USN

 

... perhaps the recalculation of parameters set is done only when the parameter change is detected. It might be the rational reason for such implementation... but for random() function. I would suggest taking the problem in your own hands writing a simple custom Recalculate script. 

Utilizing userParameter.dependentParameters property and appropriately convoluting random params of interest should do the job in the structural fashion.

 

Regards

MichaelT

MichaelT
0 Likes
Message 7 of 7

troyostrander
Advocate
Advocate
Thanks for the example! That was so helpful.
0 Likes