Thank you Alex, I know that CP is more suitbale for HFFS but i'm asked to do it with MIP.
Can you please check what iam doing wrong . Because cplex does'nt give me any solution
// MOD:
int nbJobs = ...;
int nbMchs = ...;
int nbOps = ...;
int M=...;
range Jobs = 1..nbJobs;
range Mchs = 1..nbMchs;
range ops = 1..nbOps;
// Mchs is used both to index machines and operation position in job
tuple Operation {
string id;
int jobId;
int pos;
int pt; // Processing time: temps de charge
int st;
};
Operation Ops[i in Jobs][k in Mchs] = ...;
string horizonstart="01/01/2020";
string duedate[i in Jobs]=...;
range horizon=0..365;
int duedateday;
execute
{
var hs=new Date(horizonstart);
var d=new Date(duedate);
duedateday=Opl.ftoi(Opl.round((d-hs)/1000/3600/24));
}
dvar int+ X[i in Jobs][j in ops][k in Mchs] in 0..1;
dvar int+ Y [i in Jobs][j in ops][i1 in Jobs][j1 in ops][k in Mchs] in 0..1;
dvar float s[i in Jobs][j in ops][k in Mchs];
dvar float c[i in Jobs][j in ops][k in Mchs];
dvar float C[i in Jobs];
dvar int+ T[i in Jobs];
minimize sum(i in Jobs) T[i];
subject to {
forall (i in Jobs, j in ops, k in Mchs) {sum (k in Mchs) X[i][j][k]==1;}
forall (i in Jobs,j in ops, k in Mchs) c[i][j][k]>= s[i][j][k]+ Ops[i][k].pt+ Ops[i][k].st- M*(1-X[i][j][k]);
forall (i in Jobs,j in ops, k in Mchs) c[i][j][k] >=s[i][j][k];
forall(i,i1 in Jobs :i>i1 ,j,j1 in ops, k in Mchs )
s[i][j][k]>= c[i1][j1][k]+Ops[i][k].st-M*(1-Y[i][j][i1][j1][k]) ;
forall (i in Jobs , k in Mchs, j in ops)
C[i]>=sum (k in Mchs ) c[i][j][k];
forall (i in Jobs )
T[i]>= C[i]-duedateday || T[i]>=0;
}
execute
{
var hs=new Date(horizonstart);
var startItvs=hs+Starttime*1000*24*3600;
writeln("The activity should start at ",new Date(startItvs));
}
//Data :
nbJobs = 3;
nbMchs = 4;
M=1000;
SheetConnection datasheet("Data bro.xlsx");
Ops from SheetRead (datasheet,"OPS");
duedate from SheetRead (datasheet,"duedate");
Here attached the data excel file.
Best regards
------------------------------
So jana
------------------------------
Original Message:
Sent: Mon November 30, 2020 06:19 AM
From: ALEX FLEISCHER
Subject: How to use duedates in opl
Hi,
if your model is scheduling why do you prefer to rely on MIP ?
Anyway the change of dates to integer work the same
string horizonstart="01/01/2020";string duedate="11/05/2020";range horizon=0..365;int duedateday;execute{ var hs=new Date(horizonstart); var d=new Date(duedate); duedateday=Opl.ftoi(Opl.round((d-hs)/1000/3600/24));}// Suppose the activity is 3 daysdvar int Completiontime;dvar int Starttime;minimize abs(Completiontime-duedateday);subject to{ Completiontime==Starttime+3; Completiontime<=duedateday;}execute{ var hs=new Date(horizonstart); var startItvs=hs+Starttime*1000*24*3600; writeln("The activity should start at ",new Date(startItvs));}/*which givesThe activity should start at 11/02/2020 00:00:00 000*/
------------------------------
[Alex] [Fleischer]
[EMEA CPLEX Optimization Technical Sales]
[IBM]
Original Message:
Sent: Mon November 30, 2020 06:00 AM
From: So jana
Subject: How to use duedates in opl
Thank you Alex for your help ,
Actually , I am using Cplex MIP i don't use CP engine . I have 46 jobs and a deadline related to each job . here are the data
job |
Duedate |
1 |
08/06/2020 |
2 |
08/06/2020 |
3 |
17/07/2020 |
4 |
10/06/2020 |
5 |
22/06/2020 |
6 |
19/06/2020 |
7 |
15/06/2020 |
8 |
15/06/2020 |
9 |
19/06/2020 |
10 |
11/06/2020 |
11 |
09/06/2020 |
12 |
09/06/2020 |
13 |
02/06/2020 |
14 |
03/06/2020 |
15 |
09/06/2020 |
16 |
08/06/2020 |
17 |
03/07/2020 |
18 |
16/07/2020 |
19 |
10/06/2020 |
20 |
16/06/2020 |
21 |
09/07/2020 |
22 |
16/06/2020 |
23 |
18/06/2020 |
24 |
03/06/2020 |
25 |
15/05/2020 |
26 |
11/06/2020 |
27 |
29/07/2020 |
28 |
28/07/2020 |
29 |
15/06/2020 |
30 |
15/06/2020 |
31 |
24/06/2020 |
32 |
22/06/2020 |
33 |
03/07/2020 |
34 |
02/07/2020 |
35 |
26/06/2020 |
36 |
22/06/2020 |
37 |
12/06/2020 |
38 |
24/07/2020 |
39 |
03/08/2020 |
40 |
01/07/2020 |
41 |
01/07/2020 |
42 |
04/08/2020 |
43 |
04/08/2020 |
44 |
10/07/2020 |
45 |
04/06/2020 |
46 |
22/06/2020 |
How can i declare my dates , knowing tat the objective function is to minimize the delay: minimize ( max (i in Jobs) (Completiontime[i]-duedate[i]) ).
------------------------------
So jana
Original Message:
Sent: Mon November 30, 2020 05:20 AM
From: ALEX FLEISCHER
Subject: How to use duedates in opl
Hi,
in OPL scripting you could use the object Date:
using CP;string horizonstart="01/01/2020";string duedate="11/05/2020";range horizon=0..365;int duedateday;execute{ var hs=new Date(horizonstart); var d=new Date(duedate); duedateday=Opl.ftoi(Opl.round((d-hs)/1000/3600/24));}// Suppose the activity is 3 daysdvar interval itvs in horizon size 3;maximize endOf(itvs);subject to{ endOf(itvs)<=duedateday;}execute{ var hs=new Date(horizonstart); var startItvs=hs+Opl.startOf(itvs)*1000*24*3600; writeln("The activity should start at ",new Date(startItvs));}/*which givesThe activity should start at 11/02/2020 00:00:00 000*/
regards
------------------------------
[Alex] [Fleischer]
[EMEA CPLEX Optimization Technical Sales]
[IBM]
Original Message:
Sent: Mon November 30, 2020 03:53 AM
From: So jana
Subject: How to use duedates in opl
Hello ;
I hope you're doing well;
I am working on a Hybrid and flexible Flow shop scheduling problem in a real company with real data .
Iam wondering how can i use duedates (ex: 11/05/2020 ) in my model . I've seen that all models use values (ex: 55,122).
How can i convert dates to values , or is it possible to declare my deadlines in OPL indates.
Thanks
------------------------------
So jana
------------------------------
#DecisionOptimization