Skip to content
Snippets Groups Projects
Commit 24b47721 authored by ThibautDemare's avatar ThibautDemare
Browse files

Improve a bit the code + add a sort_by before deleting smallest warehouses

parent 68ec46ea
Branches
Tags
No related merge requests found
...@@ -13,7 +13,7 @@ global { ...@@ -13,7 +13,7 @@ global {
* Return a small warehouse according to the position of the final destination : the more the warehouse is close to the final destination, the more he has a chance to be selected. * Return a small warehouse according to the position of the final destination : the more the warehouse is close to the final destination, the more he has a chance to be selected.
*/ */
Warehouse findWarehouseLvl1Strat1(FinalConsignee fdm, int sizeOfStock, list<Warehouse> lvl2Warehouses){ Warehouse findWarehouseLvl1Strat1(FinalConsignee fdm, int sizeOfStock, list<Warehouse> lvl2Warehouses){
list<Warehouse> lw <- copy(Warehouse) sort_by (fdm distance_to each); list<Warehouse> lw <- copy(Warehouse);
// Remove the ones which cannot welcome the stocks of the customer because they are already a warehouse of level 2 // Remove the ones which cannot welcome the stocks of the customer because they are already a warehouse of level 2
int i <- 0; int i <- 0;
...@@ -26,6 +26,8 @@ global { ...@@ -26,6 +26,8 @@ global {
} }
} }
lw <- lw sort_by (fdm distance_to each);
int f <- ((rnd(10000)/10000)^32)*(length(lw)-1); int f <- ((rnd(10000)/10000)^32)*(length(lw)-1);
// I assume that there is always at least one warehouse which has a free space greater than the occupied surface of the stock to outsource. // I assume that there is always at least one warehouse which has a free space greater than the occupied surface of the stock to outsource.
// According to results, it doesn't seem foolish. // According to results, it doesn't seem foolish.
...@@ -41,7 +43,7 @@ global { ...@@ -41,7 +43,7 @@ global {
* Return a large warehouse : the more the warehouse has a big free surface, the more he has a chance to be selected. * Return a large warehouse : the more the warehouse has a big free surface, the more he has a chance to be selected.
*/ */
Warehouse findWarehouseLvl2Strat1(FinalConsignee fdm, int sizeOfStock, list<Warehouse> lvl1Warehouses){ Warehouse findWarehouseLvl2Strat1(FinalConsignee fdm, int sizeOfStock, list<Warehouse> lvl1Warehouses){
list<Warehouse> lw <- copy(Warehouse) sort_by (each.totalSurface-each.occupiedSurface); list<Warehouse> lw <- copy(Warehouse);
// Remove the ones which cannot welcome the stocks of the customer because they are already a warehouse of level 1 // Remove the ones which cannot welcome the stocks of the customer because they are already a warehouse of level 1
int i <- 0; int i <- 0;
...@@ -54,6 +56,8 @@ global { ...@@ -54,6 +56,8 @@ global {
} }
} }
lw <- lw sort_by (each.totalSurface-each.occupiedSurface);
int f <- ((rnd(10000)/10000)^6)*(length(lw)-1); int f <- ((rnd(10000)/10000)^6)*(length(lw)-1);
// I assume that there is always at least one warehouse which has a free space greater than the occupied surface of the stock to outsource. // I assume that there is always at least one warehouse which has a free space greater than the occupied surface of the stock to outsource.
// It probably needs a piece of code to avoid problem of no free available surface // It probably needs a piece of code to avoid problem of no free available surface
...@@ -192,6 +196,7 @@ global { ...@@ -192,6 +196,7 @@ global {
} }
// Delete the smallest ones // Delete the smallest ones
lw <- lw sort_by (each.totalSurface - each.occupiedSurface);
i <- 0; i <- 0;
loop while: i < length(lw) { loop while: i < length(lw) {
if( length(lw) - i < numberWarehouseSelected) { if( length(lw) - i < numberWarehouseSelected) {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment