public void Should_go_to_the_top_of_all_bloc_and_return() { var warehouse = new Warehouse(2, 3, 1); var wishes = new DummyPickings { PickingList = new List <PickingPos> { new PickingPos(1, 1, 1, 1, 1, 1), new PickingPos(1, 2, 1, 1, 1, 1) } }; var solver = new LargestGapSolver(warehouse, wishes); var solution = solver.Solve(); var shiftPointList = solution.ShiftPointList; var destination1 = new ShiftPoint(1, 1); var destination2 = new ShiftPoint(1, 4); var intermediatePoint = new ShiftPoint(1, 0); var intermediatePoint2 = new ShiftPoint(1, 5); var wantedSolution = new List <ShiftPoint> { _initShiftPoint, intermediatePoint, destination1, destination2, intermediatePoint2, intermediatePoint, _initShiftPoint }; Check.That(shiftPointList).IsEqualTo(wantedSolution); }
public void Should_consider_that_2_wishes_on_the_same_position_idx_but_different_aisle_idx_are_picked_in_the_same_time() { const int aiseLenght = 1; const int nbAisle = 2; var warehouse = new Warehouse(1, nbAisle, aiseLenght); var clientWish1 = new PickingPos(1, 1, 1, 1, aiseLenght, 1); var clientWish2 = new PickingPos(2, 1, 2, 1, aiseLenght, 1); var wishes = new DummyPickings { PickingList = new List <PickingPos> { clientWish1, clientWish2 } }; var solver = new SShapeSolverV2(warehouse, wishes); var solution = solver.Solve(); var intermediatePoint = new ShiftPoint(1, 0); var intermediatePoint3 = new ShiftPoint(1, 0); var wantedSolution = new List <ShiftPoint> { _initShiftPoint, intermediatePoint, clientWish1.ConverToShiftPoint(), intermediatePoint3, _initShiftPoint }; Check.That(solution.ShiftPointList).IsEqualTo(wantedSolution); }
public void Should_no_go_in_empty_aisles() { const int aiseLenght = 2; var warehouse = new Warehouse(1, 6, aiseLenght); var clientWish1 = new PickingPos(1, 1, 1, 1, aiseLenght, 1); var clientWish2 = new PickingPos(2, 1, 6, 1, aiseLenght, 1); var wishes = new DummyPickings { PickingList = new List <PickingPos> { clientWish1, clientWish2 } }; var solver = new SShapeSolverV2(warehouse, wishes); var solution = solver.Solve(); var intermediatePoint = new ShiftPoint(1, 0); var intermediatePoint2 = new ShiftPoint(1, aiseLenght + 1); var intermediatePoint3 = new ShiftPoint(7, aiseLenght + 1); var intermediatePoint4 = new ShiftPoint(7, 0); var wantedSolution = new List <ShiftPoint> { _initShiftPoint, intermediatePoint, clientWish1.ConverToShiftPoint(), intermediatePoint2, intermediatePoint3, clientWish2.ConverToShiftPoint(), intermediatePoint4, _initShiftPoint }; Check.That(solution.ShiftPointList).IsEqualTo(wantedSolution); }
private List <ShiftPoint> GetNextLBottomj(List <ShiftPoint> currentLFrontj, List <ShiftPoint> currentLBackj, List <ShiftPoint> pickingPos, IEnumerable <ShiftPoint> pickingPosRev) { var nextLBottomj = new List <ShiftPoint>(); var previousTopj = currentLBackj.Last(); var previousBottomj = currentLFrontj.Last(); var wishNearFrontAisle = pickingPos.First(); var topj = new ShiftPoint(wishNearFrontAisle.X, previousTopj.Y); var bottomj = new ShiftPoint(wishNearFrontAisle.X, previousBottomj.Y); var transitionWithReturnForBottom = new List <ShiftPoint> { previousBottomj, bottomj }; // go to the bottom of the next aisle transitionWithReturnForBottom.AddRange(pickingPos); // go to the farthest wish (on ajoute ceux au milieu pour rien) transitionWithReturnForBottom.Add(bottomj); // return to bottom var transitionWithSShapeForBottom = new List <ShiftPoint> { previousTopj, topj }; // go to the top of the next aisle transitionWithSShapeForBottom.AddRange(pickingPosRev); // ca n'a pas d'interet d'ajouter ce point juste si on voudrait vérifier qu'on passe par tout les points transitionWithSShapeForBottom.Add(bottomj); // go throught to aisle if (Helper.Length_of_route(currentLFrontj) + Helper.Length_of_route(transitionWithReturnForBottom) > Helper.Length_of_route(currentLBackj) + Helper.Length_of_route(transitionWithSShapeForBottom)) { transitionWithSShapeForBottom.RemoveAt(0); nextLBottomj.AddRange(currentLBackj); nextLBottomj.AddRange(transitionWithSShapeForBottom); } else { transitionWithReturnForBottom.RemoveAt(0); nextLBottomj.AddRange(currentLFrontj); nextLBottomj.AddRange(transitionWithReturnForBottom); } return(nextLBottomj); }
public void Should_go_to_the_first_wish_and_return() { var warehouse = new Warehouse(1, 1, 1); var wishes = new DummyPickings { PickingList = new List <PickingPos> { new PickingPos(1, 1, 1, 1, 1, 1) } }; var solver = new SShapeSolverV2(warehouse, wishes); var solution = solver.Solve(); var shiftPointList = solution.ShiftPointList; var destination = new ShiftPoint(1, 1); var intermediatePoint = new ShiftPoint(1, 0); var wantedSolution = new List <ShiftPoint> { _initShiftPoint, intermediatePoint, destination, intermediatePoint, _initShiftPoint }; Check.That(shiftPointList).IsEqualTo(wantedSolution); }
// シフトポイントをメンバに追加 void AddPoint(GameObject obj) { shiftPointObjs.Add(obj); ShiftPoint shiftPoint = shiftPointObjs.Last().GetComponent <ShiftPoint>(); shiftPoints.Add(shiftPoint); }
public void Should_no_do_the_largest_gap_in_a_aisle() { const int aiseLenght = 3; var warehouse = new Warehouse(1, 9, aiseLenght); var clientWish1 = new PickingPos(1, 1, 1, 1, aiseLenght, 1); // should not do all the 3/4 aisle, largest gap in the middle var clientWish2 = new PickingPos(2, 1, 3, 1, aiseLenght, 1); var clientWish3 = new PickingPos(3, 1, 4, 3, aiseLenght, 1); // should not do all the 5/6 aisle, largest gap in the start var clientWish4 = new PickingPos(4, 1, 5, 1, aiseLenght, 1); var clientWish5 = new PickingPos(5, 1, 6, 2, aiseLenght, 1); // should not do all the 7/8 aisle, largest gap in the end var clientWish6 = new PickingPos(6, 1, 7, 3, aiseLenght, 1); var clientWish7 = new PickingPos(7, 1, 8, 2, aiseLenght, 1); var clientWish8 = new PickingPos(8, 1, 9, 1, aiseLenght, 1); var wishes = new DummyPickings { PickingList = new List <PickingPos> { clientWish1, clientWish2, clientWish3, clientWish4, clientWish5, clientWish6, clientWish7, clientWish8 } }; var solver = new LargestGapSolver(warehouse, wishes); var solution = solver.Solve(); var intermediatePoint = new ShiftPoint(1, 0); var intermediatePoint2 = new ShiftPoint(1, aiseLenght + 1); var intermediatePoint3 = new ShiftPoint(4, aiseLenght + 1); var intermediatePoint5 = new ShiftPoint(10, aiseLenght + 1); var intermediatePoint6 = new ShiftPoint(13, aiseLenght + 1); var intermediatePoint7 = new ShiftPoint(13, 0); var intermediatePoint9 = new ShiftPoint(7, 0); var intermediatePoint10 = new ShiftPoint(4, 0); var wantedSolution = new List <ShiftPoint> { _initShiftPoint,//0 intermediatePoint, clientWish1.ConverToShiftPoint(), intermediatePoint2, intermediatePoint3, clientWish3.ConverToShiftPoint(),//5 intermediatePoint3, intermediatePoint5, clientWish6.ConverToShiftPoint(), clientWish7.ConverToShiftPoint(), intermediatePoint5,//10 intermediatePoint6, clientWish8.ConverToShiftPoint(), intermediatePoint7, // fin de l'allée intermediatePoint9, clientWish4.ConverToShiftPoint(), //15 clientWish5.ConverToShiftPoint(), intermediatePoint9, intermediatePoint10, clientWish2.ConverToShiftPoint(), intermediatePoint10, _initShiftPoint }; Check.That(solution.ShiftPointList).IsEqualTo(wantedSolution); }
private ShiftPoint SShapeOnAisle(int blockIndex, IEnumerable <KeyValuePair <int, List <PickingPos> > > orderedWishesByAisle, Dictionary <int, List <PickingPos> > wishesByAisle, List <ShiftPoint> shiftPointList, ShiftPoint lastShiftPoint, bool isLastDirectionUp) { var bottomY = (blockIndex - 1) * (Warehouse.AisleLenght + 2); //we go to the bottom var aisles = orderedWishesByAisle.Select(x => x.Key).ToList(); while (aisles.Count > 0) { var aisleIdx = aisles.First(); var pickingX = ConvertAislesIndexToPickingX(aisleIdx); aisles.Remove(aisleIdx); var wishes = wishesByAisle[aisleIdx]; // if we are on the left aisle we should check the right aisle if (aisles.Contains(aisleIdx + 1) && aisleIdx % 2 == 1) { wishes.AddRange(wishesByAisle[aisleIdx + 1]); aisles.Remove(aisleIdx + 1); } // if we are on the right aisle we should check the left aisle if (aisles.Contains(aisleIdx - 1) && aisleIdx % 2 == 0) { wishes.AddRange(wishesByAisle[aisleIdx - 1]); aisles.Remove(aisleIdx - 1); } // we go to the back of the aisle var intermediateShitPoint = new ShiftPoint(pickingX, shiftPointList.Last().Y); if (!intermediateShitPoint.Equals(shiftPointList.Last())) { //go to the front of the first aisle of this block shiftPointList.Add(intermediateShitPoint); } var orderedShiftPoints = OrderWishesByAisleAndConvert(wishes, isLastDirectionUp); shiftPointList.AddRange(orderedShiftPoints); // if there is no other aisle and we are coming from front aisle we return to front else go through if (aisles.Count == 0 && !isLastDirectionUp) { var finalShitPoint = new ShiftPoint(pickingX, bottomY); shiftPointList.Add(finalShitPoint); lastShiftPoint = finalShitPoint; } else { // we go through var wantedY = bottomY; //we go to the bottom if (!isLastDirectionUp) { wantedY += Warehouse.AisleLenght + 1; //we go to the top } var finalShitPoint = new ShiftPoint(pickingX, wantedY); shiftPointList.Add(finalShitPoint); lastShiftPoint = finalShitPoint; } isLastDirectionUp = !isLastDirectionUp; } return(lastShiftPoint); }
public ISolution Solve() { var wishesByAislesIdx = new List <PickingPos> [Warehouse.NbAisles]; for (int i = 0; i < wishesByAislesIdx.Length; i++) { wishesByAislesIdx[i] = new List <PickingPos>(); } foreach (var clientWish in Pickings.PickingList) { var arrayIdx = clientWish.AislesIdx - 1; wishesByAislesIdx[arrayIdx].Add(clientWish); } var wishesByAisles = new List <List <PickingPos> >(); for (int i = 0; i < wishesByAislesIdx.Length; i = i + 2) { var wishes = new List <PickingPos>(wishesByAislesIdx[i]); if (i + 1 < wishesByAislesIdx.Length) { var wishesBonus = wishesByAislesIdx[i + 1]; wishes.AddRange(wishesBonus); } if (wishes.Count == 0) { continue; } wishes = RemoveWishWithSameShiftPoint(wishes); wishesByAisles.Add(wishes); } var solution = new DummySolution { Color = Color.Indigo }; var initShiftPoint = new ShiftPoint(0, 0); var shiftPointList = new List <ShiftPoint> { initShiftPoint }; solution.ShiftPointList = shiftPointList; foreach (List <PickingPos> iter in wishesByAisles) { var wishesByAisle = OrderWishes(iter); var lastWishInTheAisle = wishesByAisle.Last(); shiftPointList.Add(new ShiftPoint(lastWishInTheAisle.PickingPointX, 0)); shiftPointList.Add(lastWishInTheAisle.ConverToShiftPoint()); shiftPointList.Add(new ShiftPoint(lastWishInTheAisle.PickingPointX, 0)); } //go to the base shiftPointList.Add(initShiftPoint); return(solution); }
public void Should_go_in_nearest_aisle_o_the_right_when_changing_block() { const int aiseLenght = 2; var warehouse = new Warehouse(2, 6, aiseLenght); var clientWish1 = new PickingPos(1, 1, 1, 1, aiseLenght, 1); //done in the first trip var clientWish2 = new PickingPos(2, 2, 3, 1, aiseLenght, 1); var clientWish3 = new PickingPos(3, 2, 5, 1, aiseLenght, 1); var clientWish4 = new PickingPos(4, 1, 5, 1, aiseLenght, 1); var clientWish5 = new PickingPos(5, 1, 4, 1, aiseLenght, 1); var wishes = new DummyPickings { PickingList = new List <PickingPos> { clientWish1, clientWish2, clientWish3, clientWish4, clientWish5 } }; var solver = new SShapeSolverV2(warehouse, wishes); var solution = solver.Solve(); var intermediatePoint = new ShiftPoint(1, 0); var intermediatePoint2 = new ShiftPoint(1, aiseLenght + 2); var intermediatePoint3 = new ShiftPoint(4, aiseLenght + 2); var intermediatePoint4 = new ShiftPoint(4, 2 * aiseLenght + 3); var intermediatePoint5 = new ShiftPoint(7, 2 * aiseLenght + 3); var intermediatePoint6 = new ShiftPoint(7, aiseLenght + 2); var intermediatePoint7 = new ShiftPoint(7, 0); var intermediatePoint8 = new ShiftPoint(4, 0); var wantedSolution = new List <ShiftPoint> { _initShiftPoint, intermediatePoint, clientWish1.ConverToShiftPoint(), intermediatePoint2, intermediatePoint3, clientWish2.ConverToShiftPoint(), intermediatePoint4, intermediatePoint5, clientWish3.ConverToShiftPoint(), intermediatePoint6, clientWish4.ConverToShiftPoint(), intermediatePoint7, intermediatePoint8, clientWish5.ConverToShiftPoint(), intermediatePoint8, _initShiftPoint }; Check.That(solution.ShiftPointList).IsEqualTo(wantedSolution); }
internal List <PickingPos> RemoveWishWithSameShiftPoint(IEnumerable <PickingPos> wishes) { List <PickingPos> orderedWishes = wishes.OrderBy(w => w.BlockIdx) .ThenBy(w => w.PositionIdx).ThenBy(w => w.AislesIdx).ToList(); // delete wishes on the same position idx var result = new List <PickingPos>(); ShiftPoint lastShiftPoint = null; foreach (var wish in orderedWishes) { var newShiftPoint = wish.ConverToShiftPoint(); if (newShiftPoint.Equals(lastShiftPoint)) { continue; } result.Add(wish); lastShiftPoint = newShiftPoint; } return(result); }
private static void AddIntermediatePositionIfNeeded(IEnumerable <ShiftPoint> orderWishes, List <ShiftPoint> shiftPointList) { var lastShiftPoint = shiftPointList.Last(); foreach (var wish in orderWishes) { if (wish.X == lastShiftPoint.X || wish.Y == lastShiftPoint.Y) { // only vertical or horizontal move, no add needed } else { var intermdiateShiftPoint = new ShiftPoint(wish.X, lastShiftPoint.Y); shiftPointList.Add(intermdiateShiftPoint); } var shiftPoint = new ShiftPoint(wish.X, wish.Y); shiftPointList.Add(shiftPoint); lastShiftPoint = wish; } }
public ISolution Solve() { var lastPositionOnTheAisle = Warehouse.NbBlock * (Warehouse.AisleLenght + 2) - 2; // one for Top, one for last position var solution = new DummySolution(); var initShiftPoint = new ShiftPoint(0, 0); var shiftPointList = new List <ShiftPoint> { initShiftPoint }; int lastX = 0; for (int i = 1; i < Warehouse.NbAisles + 1; i++) { if (i % 2 == 1) { var x = ((i - 1) / 2) * 3 + 1; var goToX = new ShiftPoint(x, 0); shiftPointList.Add(goToX); var goToLastPositionOnTheAisle = new ShiftPoint(x, lastPositionOnTheAisle); shiftPointList.Add(goToLastPositionOnTheAisle); lastX = x; } else { var goToX = new ShiftPoint(lastX + 1, lastPositionOnTheAisle); shiftPointList.Add(goToX); var goToBottom = new ShiftPoint(lastX + 1, 0); shiftPointList.Add(goToBottom); } } if (Warehouse.NbAisles % 2 == 1) { var goToBottom = new ShiftPoint(lastX, 0); shiftPointList.Add(goToBottom); } shiftPointList.Add(initShiftPoint); solution.ShiftPointList = shiftPointList; return(solution); }
public void Should_reoganize_when_changing_aisles() { const int aiseLenght = 2; var warehouse = new Warehouse(1, 4, aiseLenght); var clientWish1 = new ClientWishPos(1, 1, 1, 1, aiseLenght, 1); var clientWish2 = new ClientWishPos(2, 1, 3, 1, aiseLenght, 1); var clientWish3 = new ClientWishPos(3, 1, 3, 2, aiseLenght, 1); var clientWish4 = new ClientWishPos(4, 1, 4, 2, aiseLenght, 1); var wishes = new DummyClientWish { ClientWishes = new List <ClientWishPos> { clientWish1, clientWish2, clientWish3, clientWish4 } }; var solver = new SShapeSolver(warehouse, wishes); var solution = solver.Solve(); var intermediatePoint = new ShiftPoint(1, 0); var intermediatePoint2 = new ShiftPoint(1, 3); var intermediatePoint3 = new ShiftPoint(4, 3); var intermediatePoint4 = new ShiftPoint(4, 2); var intermediatePoint5 = new ShiftPoint(4, 0); var wantedSolution = new List <ShiftPoint> { _initShiftPoint, intermediatePoint, clientWish1.ConverToShiftPoint(), intermediatePoint2, intermediatePoint3, clientWish3.ConverToShiftPoint(), clientWish4.ConverToShiftPoint(), intermediatePoint4, clientWish2.ConverToShiftPoint(), intermediatePoint5, _initShiftPoint }; Check.That(solution.ShiftPointList).IsEqualTo(wantedSolution); }
public void Should_no_go_in_aisle_in_middle_block_already_done_in_first_trip() { const int aiseLenght = 2; var warehouse = new Warehouse(2, 3, aiseLenght); var clientWish1 = new PickingPos(1, 1, 1, 1, aiseLenght, 1); //done in the first trip var clientWish2 = new PickingPos(2, 2, 1, 1, aiseLenght, 1); var clientWish3 = new PickingPos(3, 2, 3, 1, aiseLenght, 1); var wishes = new DummyPickings { PickingList = new List <PickingPos> { clientWish1, clientWish2, clientWish3 } }; var solver = new SShapeSolverV2(warehouse, wishes); var solution = solver.Solve(); var intermediatePoint = new ShiftPoint(1, 0); var intermediatePoint2 = new ShiftPoint(1, aiseLenght + 2); var intermediatePoint3 = new ShiftPoint(1, 2 * aiseLenght + 3); var intermediatePoint4 = new ShiftPoint(4, 2 * aiseLenght + 3); var intermediatePoint5 = new ShiftPoint(4, aiseLenght + 2); var intermediatePoint6 = new ShiftPoint(4, 0); var wantedSolution = new List <ShiftPoint> { _initShiftPoint, intermediatePoint, clientWish1.ConverToShiftPoint(), intermediatePoint2, clientWish2.ConverToShiftPoint(), intermediatePoint3, intermediatePoint4, clientWish3.ConverToShiftPoint(), intermediatePoint5, intermediatePoint6, _initShiftPoint }; Check.That(solution.ShiftPointList).IsEqualTo(wantedSolution); }
public ISolution Solve() { var lastPositionOnTheAisle = Warehouse.NbBlock * (Warehouse.AisleLenght + 2) - 2; // one for Top, one for last position var solution = new DummySolution(); var initShiftPoint = new ShiftPoint(0, 0); var shiftPointList = new List <ShiftPoint> { initShiftPoint }; for (int i = 1; i < Warehouse.NbAisles + 1; i = i + 2) { var x = ((i - 1) / 2) * 3 + 1; var goToX = new ShiftPoint(x, 0); shiftPointList.Add(goToX); var goToLastPositionOnTheAisle = new ShiftPoint(x, lastPositionOnTheAisle); shiftPointList.Add(goToLastPositionOnTheAisle); shiftPointList.Add(goToX); } shiftPointList.Add(initShiftPoint); solution.ShiftPointList = shiftPointList; return(solution); }
public ISolution Solve() { var wishesByAislesIdx = new List <PickingPos> [Warehouse.NbAisles]; for (int i = 0; i < wishesByAislesIdx.Length; i++) { wishesByAislesIdx[i] = new List <PickingPos>(); } foreach (var clientWish in Pickings.PickingList) { var arrayIdx = clientWish.AislesIdx - 1; wishesByAislesIdx[arrayIdx].Add(clientWish); } var solution = new DummySolution { Color = Color.Chocolate }; var initShiftPoint = new ShiftPoint(0, 0); var shiftPointList = new List <ShiftPoint> { initShiftPoint }; var topY = (Warehouse.NbBlock - 1) * (Warehouse.AisleLenght + 2) + Warehouse.AisleLenght + 1; var currentLFrontj = new List <ShiftPoint>(); var currentLBackj = new List <ShiftPoint>(); for (int i = 0; i < wishesByAislesIdx.Length; i = i + 2) { var wishes = new List <PickingPos>(wishesByAislesIdx[i]); if (i + 1 < wishesByAislesIdx.Length) { var wishesBonus = wishesByAislesIdx[i + 1]; wishes.AddRange(wishesBonus); } if (wishes.Count == 0) { continue; } if (currentLFrontj.Count == 0) { wishes = wishes.OrderBy(w => w.BlockIdx).ThenBy(w => w.PositionIdx).ToList(); var wishNearBackAisle = wishes.Last(); var topInit = new ShiftPoint(wishNearBackAisle.PickingPointX, topY); var bottomInit = new ShiftPoint(wishNearBackAisle.PickingPointX, 0); var pickingPos = wishes.Select(x => x.ConverToShiftPoint()).Distinct().ToList(); currentLFrontj.Add(bottomInit); currentLFrontj.AddRange(pickingPos); currentLFrontj.Add(bottomInit); currentLBackj.Add(bottomInit); currentLBackj.AddRange(pickingPos); currentLBackj.Add(topInit); } else { var res = Solve_for_next_aisle(wishes, currentLFrontj, currentLBackj); currentLFrontj = res.Item1; currentLBackj = res.Item2; } } shiftPointList.AddRange(currentLFrontj); shiftPointList.Add(initShiftPoint); solution.ShiftPointList = shiftPointList; return(solution); }
public ISolution Solve() { var wishesByBlockAndAisles = new Dictionary <int, Dictionary <int, List <PickingPos> > >(); var leftPickAisle = int.MaxValue; foreach (var pickingPos in Pickings.PickingList) { if (pickingPos.AislesIdx < leftPickAisle) { leftPickAisle = pickingPos.AislesIdx; } Dictionary <int, List <PickingPos> > wishesByAisles; if (wishesByBlockAndAisles.ContainsKey(pickingPos.BlockIdx)) { wishesByAisles = wishesByBlockAndAisles[pickingPos.BlockIdx]; } else { wishesByAisles = new Dictionary <int, List <PickingPos> >(); wishesByBlockAndAisles.Add(pickingPos.BlockIdx, wishesByAisles); } List <PickingPos> wishes; if (wishesByAisles.ContainsKey(pickingPos.AislesIdx)) { wishes = wishesByAisles[pickingPos.AislesIdx]; } else { wishes = new List <PickingPos>(); wishesByAisles.Add(pickingPos.AislesIdx, wishes); } wishes.Add(pickingPos); } var leftPickingPointX = ConvertAislesIndexToPickingX(leftPickAisle); var orderWishesByBlockAndAisles = wishesByBlockAndAisles.OrderByDescending(x => x.Value.Values.First().First().BlockIdx).ToList(); var solution = new DummySolution { Color = Color.MidnightBlue }; var initShiftPoint = new ShiftPoint(0, 0); var bottomLeftPickingAisle = new ShiftPoint(leftPickingPointX, 0); var shiftPointList = new List <ShiftPoint> { initShiftPoint, bottomLeftPickingAisle }; //for (int i = 0; i < orderWishesByBlockAndAisles.Count; i = i + 2) var isFirstBlock = true; var lastShiftPoint = bottomLeftPickingAisle; foreach (var wishesByAisleCouple in orderWishesByBlockAndAisles) { var blockIndex = wishesByAisleCouple.Key; var wishesByAisle = wishesByAisleCouple.Value; if (isFirstBlock) { isFirstBlock = false; var shiftPointDoneInFirstTrip = RemoveLastAisleForAllOtherBlock(leftPickAisle, orderWishesByBlockAndAisles); shiftPointList.AddRange(shiftPointDoneInFirstTrip); var bottomY = (blockIndex - 1) * (Warehouse.AisleLenght + 2); //we go to the bottom var frontFirstBlock = new ShiftPoint(lastShiftPoint.X, bottomY); if (!frontFirstBlock.Equals(shiftPointList.Last())) { //go to the front of this block on the left aisle shiftPointList.Add(frontFirstBlock); lastShiftPoint = frontFirstBlock; } var orderedWishesByAisle = wishesByAisle.OrderBy(x => x.Key).ToList(); lastShiftPoint = SShapeOnAisle(blockIndex, orderedWishesByAisle, wishesByAisle, shiftPointList, lastShiftPoint, false); } else { // we are one cell upper than the back/top of this block if (wishesByAisle.Values.Count == 0) { // we already have done all the aisle in this block in the frist trip var bottomY = (blockIndex - 1) * (Warehouse.AisleLenght + 2); //we go to the bottom var finalShitPoint = new ShiftPoint(shiftPointList.Last().X, bottomY); shiftPointList.Add(finalShitPoint); lastShiftPoint = finalShitPoint; } else { // we should redo sshape algo for this block var aislesIdx = wishesByAisle.Keys.ToList(); aislesIdx.Sort(); var leftAisleCurrentBlock = aislesIdx.First(); var leftX = ConvertAislesIndexToPickingX(leftAisleCurrentBlock); var rightAisleCurrentBlock = aislesIdx.Last(); var rightX = ConvertAislesIndexToPickingX(rightAisleCurrentBlock); var sShapeLeftToRight = !(Math.Abs(lastShiftPoint.X - rightX) < Math.Abs(lastShiftPoint.X - leftX)); var orderedWishesByAisle = sShapeLeftToRight ? wishesByAisle.OrderBy(x => x.Key).ToList() : wishesByAisle.OrderByDescending(x => x.Key).ToList(); lastShiftPoint = SShapeOnAisle(blockIndex, orderedWishesByAisle, wishesByAisle, shiftPointList, lastShiftPoint, true); } } } shiftPointList.Add(initShiftPoint); solution.ShiftPointList = shiftPointList; return(solution); }
public FirstTrip(ShiftPoint start, ShiftPoint end, bool isHorizontal) : base(start, end, isHorizontal) { }
internal PreviousFinalTrip(ShiftPoint start, ShiftPoint end, bool isHorizontal) : base(start, end, isHorizontal) { }
protected Trip(ShiftPoint start, ShiftPoint end) { End = end; Start = start; }
public SimpleTrip(ShiftPoint start, ShiftPoint end, bool isHorizontal) : base(start, end) { IsHorizontal = isHorizontal; }
public RoundTrip(ShiftPoint start, ShiftPoint end) : base(start, end) { }
public ISolution Solve() { var wishesByAislesIdx = new List <PickingPos> [Warehouse.NbAisles]; for (int i = 0; i < wishesByAislesIdx.Length; i++) { wishesByAislesIdx[i] = new List <PickingPos>(); } foreach (var clientWish in Pickings.PickingList) { var arrayIdx = clientWish.AislesIdx - 1; wishesByAislesIdx[arrayIdx].Add(clientWish); } var wishesByAisles = new List <List <PickingPos> >(); for (int i = 0; i < wishesByAislesIdx.Length; i = i + 2) { var wishes = new List <PickingPos>(wishesByAislesIdx[i]); if (i + 1 < wishesByAislesIdx.Length) { var wishesBonus = wishesByAislesIdx[i + 1]; wishes.AddRange(wishesBonus); } if (wishes.Count == 0) { continue; } wishes = RemoveWishWithSameShiftPoint(wishes); wishesByAisles.Add(wishes); } var solution = new DummySolution { Color = Color.Green }; var initShiftPoint = new ShiftPoint(0, 0); var shiftPointList = new List <ShiftPoint> { initShiftPoint }; solution.ShiftPointList = shiftPointList; // top Y = last line of the warehouse var topY = (Warehouse.NbBlock - 1) * (Warehouse.AisleLenght + 2) + Warehouse.AisleLenght + 1; // special case for first and last aisle var firstAisle = wishesByAisles.FirstOrDefault(); if (firstAisle == null) { // no wish shiftPointList.Add(initShiftPoint); return(solution); } wishesByAisles.Remove(firstAisle); var lastAisle = wishesByAisles.LastOrDefault(); wishesByAisles.Remove(lastAisle); // go through the first aisle firstAisle = OrderWishes(firstAisle, true); var firstXPos = firstAisle.First().PickingPointX; shiftPointList.Add(new ShiftPoint(firstXPos, 0)); shiftPointList.AddRange(firstAisle.Select(wish => wish.ConverToShiftPoint())); shiftPointList.Add(new ShiftPoint(firstXPos, topY)); // do the largest algo coming foreach (List <PickingPos> iter in wishesByAisles) { var wishesByAisle = OrderWishes(iter, false); var largestGap = 0; ShiftPoint currentPos = null; int currentGap; int nbWishes = 0; int potentialNbWishes = 0; var previousY = topY; foreach (var currentWish in wishesByAisle) { currentPos = currentWish.ConverToShiftPoint(); currentGap = previousY - currentPos.Y; if (currentGap > largestGap) { largestGap = currentGap; nbWishes += potentialNbWishes; potentialNbWishes = 0; } potentialNbWishes++; previousY = currentPos.Y; } currentGap = previousY - 0; if (currentGap > largestGap) { nbWishes += potentialNbWishes; } var wishDoneInComming = new List <PickingPos>(); if (nbWishes > 0) { // ReSharper disable once PossibleNullReferenceException var topAisle = new ShiftPoint(currentPos.X, topY); // we enter in this aisle shiftPointList.Add(topAisle); wishDoneInComming.AddRange(wishesByAisle.GetRange(0, nbWishes)); wishesByAisle.RemoveRange(0, nbWishes); shiftPointList.AddRange(wishDoneInComming.Select(wish => wish.ConverToShiftPoint())); // return to top shiftPointList.Add(topAisle); } iter.Clear(); iter.AddRange(wishesByAisle); } // go through the last aisle if (lastAisle == null) { // only one aisle shiftPointList.Add(new ShiftPoint(firstXPos, 0)); } else { var lastXPos = lastAisle.First().PickingPointX; shiftPointList.Add(new ShiftPoint(lastXPos, topY)); lastAisle = OrderWishes(lastAisle, false); shiftPointList.AddRange(lastAisle.Select(wish => wish.ConverToShiftPoint())); shiftPointList.Add(new ShiftPoint(lastXPos, 0)); } // do the largest algo return wishesByAisles.Reverse(); foreach (var wishesByAisle in wishesByAisles) { if (wishesByAisle.Count == 0) { continue; } // enter in the aisle var posX = wishesByAisle.First().PickingPointX; shiftPointList.Add(new ShiftPoint(posX, 0)); wishesByAisle.Reverse(); shiftPointList.AddRange(wishesByAisle.Select(wish => wish.ConverToShiftPoint())); // return to the bottom of the aisle shiftPointList.Add(new ShiftPoint(posX, 0)); } //go to the base shiftPointList.Add(initShiftPoint); return(solution); }
public ISolution Solve() { var isLastDirectionUp = false; var wishesByAislesIdx = new List <PickingPos> [Warehouse.NbAisles]; for (int i = 0; i < wishesByAislesIdx.Length; i++) { wishesByAislesIdx[i] = new List <PickingPos>(); } foreach (var clientWish in Pickings.PickingList) { var arrayIdx = clientWish.AislesIdx - 1; wishesByAislesIdx[arrayIdx].Add(clientWish); } var solution = new DummySolution { Color = Color.Blue }; var initShiftPoint = new ShiftPoint(0, 0); var shiftPointList = new List <ShiftPoint> { initShiftPoint }; // top Y = last line of the warehouse var topY = (Warehouse.NbBlock - 1) * (Warehouse.AisleLenght + 2) + Warehouse.AisleLenght + 1; for (int i = 0; i < wishesByAislesIdx.Length; i = i + 2) { var wishes = new List <PickingPos>(wishesByAislesIdx[i]); if (i + 1 < wishesByAislesIdx.Length) { var wishesBonus = wishesByAislesIdx[i + 1]; wishes.AddRange(wishesBonus); } if (wishes.Count == 0) { continue; } var shiftPoints = OrderWishesByAisle(wishes, isLastDirectionUp); var lastShiftPoint = shiftPoints.Last(); var topWish = new ShiftPoint(lastShiftPoint.X, topY); var bottomWish = new ShiftPoint(lastShiftPoint.X, 0); if (isLastDirectionUp) { // add bottom path shiftPoints.Add(bottomWish); shiftPoints.Insert(0, topWish); } else { // add top path shiftPoints.Add(topWish); shiftPoints.Insert(0, bottomWish); } shiftPointList.AddRange(shiftPoints); isLastDirectionUp = !isLastDirectionUp; } // this is the last aisles, we will go to the base var lastVisitedAisles = shiftPointList.Last(); if (isLastDirectionUp) { var bottomOfLastAisles = new ShiftPoint(lastVisitedAisles.X, 0); shiftPointList.Add(bottomOfLastAisles); } shiftPointList.Add(initShiftPoint); solution.ShiftPointList = shiftPointList; return(solution); }