Hi
.mod
using CP;
int nbJobs = ...;
int nbMchs = ...;
range Jobs = 0..nbJobs-1;
range Mchs = 0..nbMchs-1;
int OpDurations[j in Jobs][m in Mchs] = ...;
dvar interval itvs[j in Jobs][m in Mchs] size OpDurations[j][m];
dvar sequence mchs[m in Mchs] in all(j in Jobs) itvs[j][m] types all(j in Jobs) j;
dvar sequence jobs[j in Jobs] in all(m in Mchs) itvs[j][m];
int values[j in Jobs][m in Mchs] = ...;
execute {
cp.param.TimeLimit = 5;
}
minimize sum(j in Jobs) (max(m in Mchs) endOf(itvs[j][m]));
subject to {
forall (j in Jobs)
noOverlap(jobs[j]);
forall (m in Mchs)
noOverlap(mchs[m]);
}
execute {
writeln("sol");
for (j in Jobs)
for (m in Mchs)
write(Opl.startOf(itvs[j][m]), " ");
writeln();
}
main {
thisOplModel.generate();
var sol = new IloOplCPSolution();
for (j in thisOplModel.Jobs)
for (m in thisOplModel.Mchs)
sol.setStart(thisOplModel.itvs[j][m],thisOplModel.values[j][m]);
if (cp.solve()!=0)
thisOplModel.postProcess();
cp.setStartingPoint(sol);
cp.solve();
if (cp.solve()!=0)
thisOplModel.postProcess();
}
.dat
// OPENSHOP .DAT FILE
nbJobs = 4;
nbMchs = 4;
OpDurations = [
[34, 2, 54, 61]
[15, 89, 70, 9]
[38, 19, 28, 87]
[95, 7, 34, 29]
];
values =[];
// END OF .DAT FILE
work fine
------------------------------
ALEX FLEISCHER
------------------------------
Original Message:
Sent: Tue September 29, 2020 10:04 AM
From: Francisco Yuraszeck
Subject: I can not set a starting point for an interval dvar using CP Optimizer
Thank you Alex.
I made the following changes in my .mod file (BTW I think there is for j in thisOplModel.Jobs
instead for j in thisOplModel.jobs
):
------------------------------
Francisco Yuraszeck
Yuraszeck
Original Message:
Sent: Tue September 29, 2020 03:03 AM
From: ALEX FLEISCHER
Subject: I can not set a starting point for an interval dvar using CP Optimizer
Hi,
instead of
for j in jobs
you should rather write
for j in thisOplModel.jobs
since jobs is an object that belongs to the model.
------------------------------
ALEX FLEISCHER
Original Message:
Sent: Sat September 26, 2020 10:55 PM
From: Francisco Yuraszeck
Subject: I can not set a starting point for an interval dvar using CP Optimizer
Hello Community:
I want to set a starting point for an openshop model. In the model I have (among others) the following decision variable:
dvar interval itvs[j in Jobs][m in Mchs] size OpDurations[j][m];
Using a greedy heuristic I calculated values for the start time of every operation startOf(itvs[j in Jobs][m in Mchs])
. This value of startOf(itvs[j in Jobs][m in Mchs])
I want to use it as a starting point for continuing the search using CP solver.
Below I include the .mod and .dat file (.dat file for an instance of 4 jobs and 4 machines). The previously calculated values for startOf(itvs[j in Jobs][m in Mchs])
I want to read it from an Excel sheet (in this example in a 4x4 matrix) as detailed in .dat file.
Could you please explain to me how can I fix that?. What piece of code do I need to adjust to the .mod and/or .dat file?
Thanks in advance
F. Yuraszeck
// OPENSHOP .MOD FILEusing CP;int nbJobs = ...; int nbMchs = ...; range Jobs = 0..nbJobs-1; range Mchs = 0..nbMchs-1; int OpDurations[j in Jobs][m in Mchs] = ...; dvar interval itvs[j in Jobs][m in Mchs] size OpDurations[j][m]; dvar sequence mchs[m in Mchs] in all(j in Jobs) itvs[j][m] types all(j in Jobs) j; dvar sequence jobs[j in Jobs] in all(m in Mchs) itvs[j][m]; int values[j in Jobs][m in Mchs] = ...;execute { cp.param.TimeLimit = 5; }minimize sum(j in Jobs) (max(m in Mchs) endOf(itvs[j][m])); subject to { forall (j in Jobs) noOverlap(jobs[j]); forall (m in Mchs) noOverlap(mchs[m]); }execute { for (j in Jobs) for (m in Mchs) write(Opl.startOf(itvs[j][m]), " "); writeln();}main { thisOplModel.generate(); var sol = new IloOplCPSolution(); for (j in Jobs) for (m in Mchs) sol.setStart(thisOplModel.itvs[j][m],thisOplModel.values[j][m]); cp.solve; thisOplModel.postProcess(); cp.setStartingPoint(sol); cp.solve(); thisOplModel.postProcess(); }// OPENSHOP .DAT FILEnbJobs = 4;nbMchs = 4;OpDurations = [[34, 2, 54, 61][15, 89, 70, 9][38, 19, 28, 87][95, 7, 34, 29]];SheetConnection sheet("myExcelFile.xlsx");values from SheetRead(sheet,"'st'!B2:E5");
------------------------------
F. Yuraszeck
------------------------------
#DecisionOptimization