8.7. 配置随机数生成器
许多 heuristics 和 metaheuristics 依赖于伪随机数字生成器来移动选择,以解决分数绑定、根据移动接受度等问题。在解决过程中,使用相同的随机实例可以重复使用,以提高随机值的可重复性、性能和统一分布。
随机 seed 是一个数字,用于初始化伪随机数字生成器。
流程
可选:要更改随机实例的随机看到,请指定
一个随机的:<solver xmlns="https://www.optaplanner.org/xsd/solver" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://www.optaplanner.org/xsd/solver https://www.optaplanner.org/xsd/solver/solver.xsd"> <randomSeed>0</randomSeed> ... </solver>可选:要更改伪随机数字生成器实现,请为下面的解析器配置文件中列出的
randomType属性指定一个值,其中 <RANDOM_NUMBERATOR> 是一个伪随机数字生成器:<solver xmlns="https://www.optaplanner.org/xsd/solver" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://www.optaplanner.org/xsd/solver https://www.optaplanner.org/xsd/solver/solver.xsd"> <randomType><RANDOM_NUMBER_GENERATOR></randomType> ... </solver>支持以下 pseudorandom 编号生成器:
-
JDK(默认):标准随机数字生成器实施(java.util.Random) -
MERSENNE_TWISTER: Commons Math的实施随机数 -
WELL512A,WELL1024A,WELL19937A,WELL19937C,WELL44497A和WELL44497B: Random number generator by Commons Math
-
在大多数情况下,randomType 属性的值对多个数据集最佳解决方案的平均质量没有重大影响。