如何在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);
}
每次都会给出不同的结果
中的更多内容
我每次使用 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);
}
每次都会给出不同的结果
中的更多内容