Anylogic:为每个资源使用独立的RandomNumberGenerator。

huangapple go评论129阅读模式
英文:

Anylogic: Use individual RandomNumberGenerator for each ressource

问题

我们正在模拟一个由六台串联的机器组成的生产链。对于所有这些机器,我们都需要不同分布的故障时间等信息。

我正在寻找一种为每个使用的资源实现单独的随机数生成器(RNG)的方法。我们需要六个不同的随机数生成器。不幸的是,我们难以理解如何实现和使用它。Anylogic文档并没有提供很多帮助或解释。它提到了使用Java的Random类。

示例中提到:triangular( 5, 10, 25, myRNG ) - 如何实现myRNG?它是一个对象还是一个数字?

英文:

We are working on a simulation of a production chain of six machines connected in a series. For all of them, we need failure times etc. which are distributed differently.

I am looking for a way to implement an individual RNG for each of the resources used. We need six different RNGs. Unfortunately, we struggle to understand how to implement and use this. Anylogic docu does not really help/explain. It says something about using the Java Random Class.

The example says: triangular( 5, 10, 25, myRNG ) - how to implement myRNG and is it an object or a number?

答案1

得分: 1

你在问题中提到的myRNG必须是Random类的实例或Random类的子类的实例。

Random是一个Java类,您可以自由使用它。要生成该类的实例,您需要执行以下操作:

Random rand = new Random();

或者您可以直接在您的分布中使用它:

triangular(5, 10, 25, new Random())

现在,子类是另一个类,与Random类不同,但继承其所有属性。要创建一个子类,您需要自己做,并且要全面学习Java。作为新手,我不明白您为什么会需要它。

如果您想要6个不同的随机数生成器,我猜您可以在您的随机类中使用种子,以便您可以定义和索引每个种子的状态,然后执行以下操作:

triangular(5, 10, 25, new Random(seeds.get(index)))

假设您有一个称为seeds的集合,其中存储了您想要使用的所有种子。

英文:

The myRNG that you state in your question has to be an instance of the class Random or of a subclass of Random.

Random is a Java class that you can freely use. To generate an instance of that class you would need to do
Random rand=new Random();
or you can use it directly in your distribution:

triangular( 5, 10, 25, new Random() ) 

Now a subclass is another class, different than the Random class, but inherits all of its properties. To create a subclass, you need to do it by yourself and learn Java in general and as a newbie I don't see why you would need it.

If you want 6 different RNG, i guess you would be ok with seeds in your random class so you can define and index that states each one of your seeds and do

triangular( 5, 10, 25, new Random(seeds.get(index)) ) 

assuming you have a collection called seeds that stores all the seeds you want to use.

huangapple
  • 本文由 发表于 2020年8月16日 19:16:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/63436196.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定