如何在 Anylogic 中生成随机 true/false 结果
How to generate random true/false result in Anylogic
我是 anylogic 的新手。我想生成随机的真假结果来控制 Select 输出中的参数。
我在源代码中使用了这个 if else 条件
if(randomTrue(0.25)){
if(randomTrue(0.5)){
agent.isOnlineRezerve = true;
}else {
agent.isOnlineRezerve = false;
}
}else{
agent.isOnlineRezerve = false;
}
我的源码输出条件是
agent.isOnlineRezerve
每次我 运行 它都会给我 1000 分中的 128 分是正确的,其余的是错误的
我每次都想得到一个不是128的数字,但是我做不到。如果你能帮上忙,我会很高兴。
AnyLogic 对随机数生成器使用固定种子,因此独立运行会产生相同的结果。要切换到随机种子:
To set up random number generator seed
In the Projects view, select the experiment you are currently working with.
Go to the Randomness section of the Properties view.
In the Random number generation group of buttons:
To set random seed, choose the Random seed (unique experiments) option.
To set fixed seed, choose the Fixed seed (reproducible experiments) option > and enter the seed value in the Seed value edit box.
来自https://anylogic.help/anylogic/stochastic/random-number-generator.html
这个问题的另一个答案是使用该函数的第二个参数,以便使用您自己的随机数生成器和您选择的种子:
randomTrue(0.5,new Random())
如果您想使用自己的种子进行单独计算
randomTrue(0.5,new Random(33))
我是 anylogic 的新手。我想生成随机的真假结果来控制 Select 输出中的参数。
我在源代码中使用了这个 if else 条件
if(randomTrue(0.25)){
if(randomTrue(0.5)){
agent.isOnlineRezerve = true;
}else {
agent.isOnlineRezerve = false;
}
}else{
agent.isOnlineRezerve = false;
}
我的源码输出条件是
agent.isOnlineRezerve
每次我 运行 它都会给我 1000 分中的 128 分是正确的,其余的是错误的
我每次都想得到一个不是128的数字,但是我做不到。如果你能帮上忙,我会很高兴。
AnyLogic 对随机数生成器使用固定种子,因此独立运行会产生相同的结果。要切换到随机种子:
To set up random number generator seed
In the Projects view, select the experiment you are currently working with.
Go to the Randomness section of the Properties view.
In the Random number generation group of buttons:
To set random seed, choose the Random seed (unique experiments) option.
To set fixed seed, choose the Fixed seed (reproducible experiments) option > and enter the seed value in the Seed value edit box.
来自https://anylogic.help/anylogic/stochastic/random-number-generator.html
这个问题的另一个答案是使用该函数的第二个参数,以便使用您自己的随机数生成器和您选择的种子:
randomTrue(0.5,new Random())
如果您想使用自己的种子进行单独计算
randomTrue(0.5,new Random(33))