Ok so you use a fifth way to generate random numbers : call java
Then I would change question.mod and write
execute{
var rnd = IloOplCallJava("java.util.Random", "<init>", "()");
rnd.setSeed(10+IterNum);
for (var da in allActivities) {
{
for (var i = 1; i < allActivities.size; ++i)
{
t = rnd.nextDouble();
random_time[da]=Math.round(t)*25+da.activity.duration;;
}
}
}
}
instead of what you wrote
regards
------------------------------
[Alex] [Fleischer]
[EMEA CPLEX Optimization Technical Sales]
[IBM]
------------------------------
Original Message:
Sent: Tue March 01, 2022 10:51 AM
From: Mohamed Awad
Subject: Set Seeds with Flow Control- OPL
Hi Alex,
Thanks a million for your great help. I really appreciate the time you always spend in replying for questions.
Maybe I couldn't understand your solution. In my problem, I need to run the model 5 times via the flow control model (Question_Flow.mod) which also exports the results of each iteration to a *.csv file. In Question.mod, the random numbers are generated using IloOplCallJava. I need to keep the structure of both files as it is at the same time, I want to control the random numbers generated in Question.mod by setting the seeds in Question_Flow.mod. Is that possible?
Many thanks,
Mohamed
------------------------------
Mohamed Awad
------------------------------
Original Message:
Sent: Tue March 01, 2022 02:45 AM
From: ALEX FLEISCHER
Subject: Set Seeds with Flow Control- OPL
Hi,
I want to have different random numbers for each iteration.
==> You may use srand with some dates
float d;execute{ d=new Date();}int temp=srand(ftoi(ceil(d)));execute{ temp;}int randomNumber=rand(5);execute{ writeln(randomNumber);}
will give different values for each run
whereas
float d;execute{ //d=new Date(); d=2;}int temp=srand(ftoi(ceil(d)));execute{ temp;}int randomNumber=rand(5);execute{ writeln(randomNumber);}
will always give the same value
See https://community.ibm.com/community/user/datascience/communities/community-home/digestviewer/viewthread?GroupId=5557&MID=87124&CommunityKey=ab7de0fd-6f43-47a9-8261-33578a231bb7&tab=digestviewer for all kind of random generators in OPL
------------------------------
[Alex] [Fleischer]
[EMEA CPLEX Optimization Technical Sales]
[IBM]