Original Message:
Sent: Tue January 19, 2021 03:43 AM
From: Petr Vilím
Subject: CP flowshop
Hello,
it seems the code should be:
execute{var hs=new Date(horizonstart);for (var o in Operations) writeln("Operation ", o, " starts at ", new Date(hs + itvs[o].start*1000*24*3600));}
This code assumes that duration is given in days.
Regards, Petr
------------------------------
Petr Vilím
IBM
Original Message:
Sent: Thu January 14, 2021 04:33 AM
From: So jana
Subject: CP flowshop
Hi peter;
Here are my .mod and .dat file so you can con see what happens
Best regards
------------------------------
So jana
Original Message:
Sent: Thu January 14, 2021 04:20 AM
From: Petr Vilím
Subject: CP flowshop
Hello,
hard to answer without knowing the input values. I suggest to print them (just for debugging) so we can see what happens:
execute
{
writeln(horizonstart);
var hs=new Date(horizonstart);
writeln(hs);
writeln(Opl.itvs.start);
var startItvs=hs+Opl.itvs.start*1000*24*3600;
writeln("The activity should start at ",new Date(startItvs));
}
You can find documentation for Date in the script here: https://www.ibm.com/support/knowledgecenter/cs/SSSA5P_20.1.0/ilog.odms.ide.help/OPL_Studio/opllangref/topics/opl_langref_script_values_dates.html
In particular Date constructor takes number of milliseconds since January 1, 1970. Operator + should also use number of milliseconds, the code looks like counting number of days though (1000*24*3600). So maybe it can be enough to remove "*1000*24*3600".
Regards, Petr
------------------------------
Petr Vilím
IBM
Original Message:
Sent: Thu January 14, 2021 03:37 AM
From: So jana
Subject: CP flowshop
Hello David;
I tried this, but i don't know what iam doing wrong:
execute
{
var hs=new Date(horizonstart);
var startItvs=hs+Opl.itvs.start*1000*24*3600;
writeln("The activity should start at ",new Date(startItvs));
}
I get this when i run the model:
The activity should start at -2147483645/-2147483648/-2147483648 ...
the result i want to get is:The activity should start a tmm/dd/yyyy hh:mm
Thank you
------------------------------
So jana
Original Message:
Sent: Sun January 10, 2021 09:41 AM
From: David Gravot
Subject: CP flowshop
Hello
This API is only available in model, not in Opl Script. Use directly itvs.start instead
You can have a look at the examples provided in the distribution , and also the documentation
David
------------------------------
David Gravot
Original Message:
Sent: Fri January 08, 2021 01:56 PM
From: So jana
Subject: CP flowshop
I tried this to translate dates, but i get this message when i run the model :'
Script execution error: No OPL function "startOf (dvar interval [Operations])" 23>] ".
To translate Date time to model time:
string horizonstart="05/11/2020";
execute {
for(var d in DueDates) {
var hs=new Date(horizonstart);
var temp=new Date(d.duedate);
var duedateday=Opl.ftoi(Opl.round((temp-hs)/1000/3600/24));
duedateint[d.jobid]=duedateday;
}
model time----> date time
execute
{
var hs=new Date(horizonstart);
var startItvs=hs+Opl.startOf(itvs)*1000*24*3600;
writeln("The activity should start at ",new Date(startItvs));
}
Can you please check what iam doing wrong .
Best regards
------------------------------
So jana
Original Message:
Sent: Fri January 08, 2021 06:10 AM
From: Philippe Laborie
Subject: CP flowshop
1. Yes, nothing changes in the model except that Machines will be declared as string:
tuple Operation {
key int opid;
key string jobid;
string mch; // Machine, operation id
int pt; // Processing time
int st; // Setup time
};
...
{string} Mchs = { o.mch | o in Operations };
2. You should have a look at the documentation of dates in OPL: here. If you decide to use time value 0 as start date (06/07/2020) in your model, don't forget to remove 06/07/2020 from the due dates when computing the "model" due dates. I suggest you have two functions for date_time / model_time_unit translation : one to translate date_time to model_time_unit and the other for the reverse translation.
------------------------------
Philippe Laborie
Original Message:
Sent: Fri January 08, 2021 05:16 AM
From: So jana
Subject: CP flowshop
Thank you Philippe for your explanations now i absorb it .I have to ask about two other other things:
1.Can i use a string for mchs in the tuple Operation. as in the Excel file, if yes how can i use it in dvar sequence mchs[m in Mchs] in all(o in Operations : o.mch == m) itvs[o].
2.I am also wondering how i can express the result in this way :
(start date and start time ) (completion date at completion time) (MM/DD/YYYY at HH:SS) , knowing that the horizon start is (06/07/2020)
------------------------------
So jana
Original Message:
Sent: Thu January 07, 2021 11:19 AM
From: Philippe Laborie
Subject: CP flowshop
You have to be more precise. What do you mean by "it doesn't give me any result even after almost 2 hours!". What happens? Do you have a log of the search or some error messages to share with us?
There is clearly a problem with this line of your code:
dvar interval itvs[j in Jobs][o in Mchs] size (Ops[j].pt+Ops[j].st);
Because on the left side (j in Jobs) j is an index of the jobs (in 0..nbJobs-1) whereas on the right side it is used to index Ops which is indexed on 1..nbOps. So Ops[0] does not exist.
As your flow shop problem is not rectangular (the number of operations is not the same for each jobs), you cannot use a 2-D array for operations itvs, you need to index them with a tuple set.
There is also some potential ambiguity in your data because the table that gives the due date of jobs is indexed by numbers (job 1, job 2, ...) whereas in the first table, jobs are identified by ids (OFB2001618, OFB2001619, ...) ...
I tried to fixed manually these problems in the two attached files (the data file is not in Excel but directly as an OPL data file).
------------------------------
Philippe Laborie
Original Message:
Sent: Wed January 06, 2021 03:42 PM
From: So jana
Subject: CP flowshop
Hi Philippe and Christiane,
Thank you for your answer;
Iam new to cplex , i don't master it, so i really appereciate your help .
i made the requested changes but when i run the model it doesn't give me any result even after almost 2 hours!
If you have any idea how to make it solvable, I will really appreciate that!
Best regards
------------------------------
So jana
Original Message:
Sent: Wed January 06, 2021 09:55 AM
From: Christiane Bracchi
Subject: CP flowshop
Hello,
In addition to these modeling tips from my colleague Philippe, I would like to draw your attention to possible problems reading dates in excel.
The constructor of "Date" requires a string which follows a strict format "MM/DD/YYYY".
The string returned by SheetRead depends on your local settings.
You may check your "Regional format data", the "Short date" format should match the format required by the constructor of Date.
I hope this helps.
------------------------------
Christiane Bracchi
Original Message:
Sent: Wed January 06, 2021 08:53 AM
From: Philippe Laborie
Subject: CP flowshop
Hi, could you explain what you mean by "i get some results that seems to me incoherent" ?
I noticed 3 strange things in the model:
1) The interval variables representing the operations are defined without specifying any length (duration) so the engine consider the length is unconstrained (domain is [0,+oo)) and thus for instance it can be 0 for all operations:
dvar interval itvs[j in Jobs][o in Mchs] ;
2) You say that you minimise the tardiness but the model minimizes the makespan.
3) If you want to post constraints that the tardiness (delay of last operation of the jobs j compared to duedateint[j]) should be 0, I think your constraint is wrong. Instead of:
forall (j in Jobs, o in 0..nbMchs-2)
endOf(itvs[j][o]) <= duedateint[j];
}
you should post something like:
endOf(itvs[j][nbMchs-1]) <= duedateint[j];
And if you really want to minimize the total tardiness, you should remove these constraints and do something like:
minimize sum(j in Jobs) maxl(0, endOf(itvs[j][nbMchs-1])-duedateint[j]);
------------------------------
Philippe Laborie
Original Message:
Sent: Tue December 29, 2020 04:57 AM
From: So jana
Subject: CP flowshop
Dears;
I would appreciate your help regarding the model below. In this model, I am using CP solver to minimise the tardiness .When i run the model i get some results that seems to me incoherent. Can you please tell me what i'm doing wrong.
Please find the model and data below:
.mod:
using CP;
int nbJobs = ...;
int nbMchs = ...;
int nbOps=...;
range Jobs = 0..nbJobs-1;
range Mchs = 0..nbMchs-1;
range ops = 1..nbOps;
// Mchs is used both to index machines and operation position in job
tuple Operation {
int opid;
string jobid;
int mch; // Machine, operation id
float pt; // Processing time
float st; // setup time
};
Operation Ops[j in ops] = ...;
string duedate[i in Jobs]=...;
int duedateint[i in Jobs];
execute
{
for(var i in Jobs)
{
var temp=new Date(duedate[i]);
duedateday=Opl.ftoi(Opl.round((temp)/1000/3600/24));
duedateint[i]=duedateday;
}
}
dvar interval itvs[j in Jobs][o in Mchs] ;
dvar sequence mchs[m in Mchs] in all(j in Jobs, o in Mchs : Ops[j in ops].mch == m) itvs[j][o];
execute {
cp.param.TimeLimit = 600;
cp.param.RestartFailLimit = 1000;
cp.param.RelativeOptimalityTolerance = 0;
cp.param.OptimalityTolerance = 0;
cp.param.FailLimit = 300000;
}
minimize max(j in Jobs) endOf(itvs[j][nbMchs-1]);
subject to {
forall (m in Mchs)
noOverlap(mchs[m]);
forall (j in Jobs, o in 0..nbMchs-2)
endBeforeStart(itvs[j][o], itvs[j][o+1]);
forall (j in Jobs, o in 0..nbMchs-2)
endOf(itvs[j][o])<=duedateint[j];
}
.data:
nbJobs = 46;
nbMchs = 19;
nbOps=218;
SheetConnection datasheet("Data bro.xlsx");
Ops from SheetRead (datasheet,"OPS");
duedate from SheetRead (datasheet,"duedate");
------------------------------
So jana
------------------------------
#DecisionOptimization