2:40 AM
0
A: MDCVRP Modelisation in OPL CPLEX Solver

Alex FleischerWhat I would do is use artificial nodes for arrival depots. // Déclarations des ensembles et indices int n = ...; int m = ...; int v = ...; // Définition des ensembles et des plages range Clients = 1..n; // Inclut les entrepôts et les clients range Entrepots = 1..m; // Les premiers indices sont...

 
Alex Fleischer, thank you very much for your help, yes now every used vehicule is returning to it's warehouse of beginig, but i have a question if you don't mind : i have tried this model with a lot of different data and i noticed that in most cases all the used vehicules begin with the same warehouse which is the warehouse 3, like even when i have increased the distance between the 3 rd warehouse and all the other points : all the vehicules were beginig with the 2 nd warehouse. is that normal for a MDCVRP ?
Another thing i have noticed : for example : this result ( in the next comment ) : can we add a constraint that obliges that every used vehicule has only 1 sequential road ? in other words can we add a constraint that obliges that every chosen vehicule does have only one Warehouse of begining ( which of course is the same for it end ) ?
// solution (optimal) with objective 154 Parcours pour le véhicule 2 : De 2 à 5, distance : 10 De 1 à 6, distance : 8 De 5 à 2, distance : 10 De 6 à 1, distance : 8 Distance totale parcourue par le véhicule 2 : 36 unités. Parcours pour le véhicule 4 : De 3 à 9, distance : 15 De 4 à 10, distance : 20 De 7 à 11, distance : 15 De 8 à 3, distance : 8 De 9 à 4, distance : 25 De 10 à 7, distance : 25 De 11 à 8, distance : 10 Distance totale parcourue par le véhicule 4 : 118 unités.
A last question, what does n2, m2, Client2, Entrepots 2 that you have added mean ? As well as this Whole Block ? int PO2[c in Clients2]=(c <=m)?PO[c]:PO[c -m]; int VO2[c in Clients2]=(c <=m)?VO[c]:VO[c -m]; Etc ... I'am really sorry for writing a lot of questions i'am very new and unfamiliar with IBM CPLEX.
 
I turned 1..m and then m+1 ..n into 1..2*m for the depots and 2*m+1..n2 for the customers. For this I used the ternary operator. Many simple OPL examples at github.com/AlexFleischerParis/zooopl
 
Alex fleischer, words are not be enough to express how much i'am thankful and grateful for you, it really worked, i just need the constraint that prevent every used vehicule from having 2 or more separate roads ( like : only one warehouse of beginig and end for every used vehicule ) to prevent cases like this : Parcours pour le véhicule 4 : De 3 à 12, De 12 à 3, De 1 à 6, De 6 à 9, De 9 à 3. i mean every used vehicule must have only one sequential road.
In fact i have tried the " One depot for each truck " and it didn' t have effect, i have got the folowing results : Parcours pour le véhicule 1 : De 3 à 12, distance : 10 De 2 à 5, distance : 10 De 5 à 2, distance : 10 De 12 à 3, distance : 10 Parcours pour le véhicule 5 : De 1 à 8, distance : 18 De 4 à 9, distance : 25 De 6 à 1, distance : 8 De 7 à 10, distance : 25 De 8 à 11, distance : 10 De 9 à 6, distance : 5 De 10 à 4, distance : 20 De 11 à 7, distance : 15 you can see that the vehicule 1 has 2 different warehouses of begining, and 2 different roads, DAT :
n = 12; m = 3; v = 6; PO = [0, 0, 0, 15, 25, 20, 10, 30, 35, 5, 15, 20]; VO = [0, 0, 0, 30, 40, 35, 25, 45, 50, 15, 30, 35]; M = [0, 0, 0, 80, 120, 100, 110, 140, 160, 60, 90, 100]; CPO = [90, 110, 100, 120, 130, 80]; CVO = [180, 200, 190, 220, 240, 150]; MO = [200, 150, 180, 250, 220, 170];
D = [[ 0, 42, 55, 60, 60, 8, 72, 18, 30, 50, 75, 80], [42, 0, 68, 68, 10, 50, 55, 30, 70, 45, 30, 35], [55, 68, 0, 30, 20, 65, 60, 8, 15, 65, 75, 10], [60, 68, 30, 0, 55, 70, 68, 40, 25, 20, 60, 40],[60, 10, 20, 55, 0, 50, 8, 58, 33, 70, 15, 20],[8, 50, 65, 70, 50, 0, 25, 30, 5, 60, 80, 65],[72, 55, 60, 68, 8, 25, 0, 5, 45, 25, 15, 25],[18, 30, 8, 40, 58, 30, 5, 0, 42, 68, 10, 25],[30, 70, 15, 25, 33, 5, 45, 42, 0, 50, 85, 80],[50, 45, 65, 20, 70, 60, 25, 68, 50, 0, 60, 45],[75, 30, 75, 60, 15, 80, 15, 10, 85, 60, 0, 35],[80, 35, 10, 40, 20, 65, 25, 25, 80, 45, 35, 0]];
 
I updated my model in the answer
 
Hi Alex, i still have 2 questions if you i don' t mind : 1- I don't really use these 4 lines ( that obliges that the Warehouse 3 is no more used ), if you delet them from this last mod you gave me, then you will have the same problem with the Véhicule 6 as the following : Parcours pour le véhicule 6 : 3 - > 12 -> 3 And 2->5->2.
2 - Can we add the folowing option : Every Warehouse can order a merchandises just like all the other customers and in this case he will have his merchandises shipped to him just like anyone of the regular customers, Note that in this case the warehouse that ordered the merchandises does not necessarely have any priority over any other regular customer and still is able to ship any merchandises to any customer. Thank you very much for your intent to help, Merci infiniment monsieur Fleisch !
 
2:40 AM
To allow the warehouse 3 let me change // sum(j in Clients2, k in Vehicules) X[3][j][k] ==0; // sum(j in Clients2, k in Vehicules) X[j][3][k] ==0; // sum(j in Clients2, k in Vehicules) X[3+m][j][k] ==0; // sum(j in Clients2, k in Vehicules) X[j][3+m][k] ==0; into forall(i in 1..n) sum(v in Vehicules,j in Clients2) X[i][j][v]<=1;
forall(i in 1..m,k in Vehicules) forall(j in Clients2) X[i][j][k]+X[j][i+m][k]<=1;
I updated the model in the answer and I think I answered your question. For specific other questions do not hesitate to start a new thread
 
Hi Alex, i have tested the .mod for a big variety of .Dat ' s and i have noticed that every Warehouse can only send 1 Vehicule, is there any constraint or anything that prevent every warehouse from sending more than one vehicule ? if yes how can i remove it ? Because The correct logic that i want is : - Every used vehicule can only have one warehouse of beginig ( which is the same for it's end ) But every warehouse can send 0,1 or more than one vehicule.
 
You can then remove forall(i in 1..n) sum(v in Vehicules,j in Clients2) X[i][j][v]<=1;
 
i have removed these two constraints : forall(i in 1..n) sum(v in Vehicules,j in Clients2) X[i][j][v]<=1; forall(i in 1..m,k in Vehicules); forall(j in Clients2) X[i][j][k]+X[j][i+m][k]<=1; and tested for the following dat : PO = [0,0,0,15,25,20,10,12,0,0,0,0]; VO=[0,0,0,30, 40,35,20,13,0,0,0,0]; M=[0,0,0,80,120,100,30,14,0,0,0,0];CPO=[15,25,20,10,12,0]; CVO = [30,40,35,20,13,0]; MO=[80,120,100,30,14,0]; as you can see here : the nodes with orders are :4,5,6,7,8 and their orders are shipped, but i have noticed that also 12 is shipped (by vehicule 4) despite that he didn't make an order !!
Only the nodes with positive ( non null ) values of PO,VO and M must have their orders shipped.
 
Then you can add forall(j in Clients2 : (M2[j] == 0) && (j>2*m)) sum(i in Clients2, k in Vehicules) X[i][j][k] == 0;
 
I want a constraint that obliges that every used vehicule must have a unique sequential road ( a unique warehouse of begining ( which is the same of ending ) )
 
2:40 AM
every used vehicule must have a unique sequential road ==> forall(k in Vehicules) sum(i in 1..m,j in Clients2) X[i][j][v]<=1; And many learnings at linkedin.com/pulse/…
 
Hi Alex, I have created a new thread with the detailed description of my problem, i do not know if you understand french, if not i will translate it to eglish and repost it, the thread link is : stackoverflow.com/questions/78380532/…
 
1) I think you could accept this answer if that helped 2) In stackoverflow questions have to be in English
 
For your last update : yes it works for the given data, but if we update the data as following : PO = [0,0,0,15,25,20,10,30,35,5,15,0];VO = [0,0,0,30,40,35,25,45,50,15,30, 0];M = [0,0,0,80,120,100,110,140,160,60,90,0];CPO = [90, 240, 100, 120, 130, 80];CVO = [180, 200, 190, 220, 240, 150]; MO = [200, 150, 190, 250, 220, 170]; We will have the following results : // solution (optimal) with objective 154 and 2 starting warehouses of vehicule 6 ! ( 1 and 2 ) Parcours pour le véhicule 6 : De 1 à 6, distance : 8 De 2 à 5, distance : 10 De 5 à 2, distance : 10 De 6 à 1, distance : 8
Hi Alex, i have accepted this answer, and i have reposted the detailed description of my problem in english, here is the link : stackoverflow.com/questions/78386991/… Please tell me if it is doable ?, and if yes could you help me with it please ?.