public void CalculatePickingRoutes(PathSolver solver) { var coordsSet = new HashSet <Coord>(PickingSlots.Select(x => x.Value.Position)) { GetPickingStartPosition(), GetPickingEndPosition() }; var coords = coordsSet.ToArray(); var collection = new ConcurrentDictionary <RouteBetweenCoords, byte>(); int done = 1; int todo = coords.Length; var sw = new Stopwatch(); sw.Start(); Parallel.For(0, coords.Length, startIndex => { var coord1 = coords[startIndex]; for (var endIndex = startIndex + 1; endIndex < PickingSlots.Count; endIndex++) { var coord2 = coords[endIndex]; var result = solver.FindPath(new TravelStep(coord1), new TravelStep(coord2), false); if (result.Success) { //Debug.WriteLine($"Sprawdzono {coord1} - {coord2}"); var route = new RouteBetweenCoords(coord1, coord2); route.ReadTravelsteps(result.Steps); collection.AddOrUpdate(route, x => 0, (x, b) => 0); } } done += 1; PickingRoutesCalculationProgress?.Invoke(null, new CalculatePickingRouteProgressEventArgs() { Done = done, IterationIndex = startIndex, Todo = todo, Elapsed = sw.Elapsed, CheckeCoord = coord1 }); }); PickingSlotRoutes = new HashSet <RouteBetweenCoords>(collection.Keys); }
public List <PickingSlot> GetPickingSlots() { return(new List <PickingSlot>(PickingSlots.Select(x => x.Value))); }
//public RouteBetweenCoords TravelRouteBetween(Coord coord1, Coord coord2) //{ // if (coord1 == coord2) // { // return new RouteBetweenCoords(coord1, coord2); // } // if (PickingSlotRoutes.TryGetValue(new RouteBetweenCoords(coord1, coord2), out var route)) // { // return route; // } // else // { // throw new Exception("Travel route unknown"); // } //} public List <PickingSlot> GetPickingSlotsWithSku(long sku) { return(PickingSlots.Select(x => x.Value).Where(x => x.Sku == sku && x.Units - x.ReservedUnits > 0).ToList()); }