如何在cplex中使用随机函数

How to use the random function in cplex

我每次使用 Cplex 中的随机函数 运行 如何生成一个新的随机数,因为它只为我生成一个随机数并且每次我 [=12] 都不会改变任何东西=]吗?

在 OPL 中你可以使用 rand 函数

int v;

execute
{
  v=(new Date().getMilliseconds());
}

int sr=srand(v); // OPL random seed

execute
 {
 sr;
 writeln("OPL random seed=",sr);
 writeln(Opl.rand(10));
 }

 int inputData[i in 1..10]=rand(10);

execute
{
  writeln(inputData);
}

int inputData2[i in 1..50]=50+rand(51);

execute
{
  writeln(inputData2);
}

每次都会给出不同的结果

https://community.ibm.com/community/user/datascience/communities/community-home/digestviewer/viewthread?GroupId=5557&MID=87124&CommunityKey=ab7de0fd-6f43-47a9-8261-33578a231bb7&tab=digestviewer

中的更多内容