How to clamp a stock in AnyLogic?

60 Views Asked by At

I want to clamp a stock between -10 and 10 in AnyLogic.

I currently use an own defined java function for this. Is there any better solution for this?

2

There are 2 best solutions below

0
Felipe On

there's a big set of distributions in anylogic

for example uniform(-10,10) will give you a random value between -10 and 10

0
Benjamin On

If you want to explore all possible random distributions, put your cursor into a code field. Then, at the top of AnyLogic, the tiny icon called "Distribution Wizard" pops up: enter image description here

Play around and it will write the correct code to apply it.