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 PickingScanSolver(WarehouseLayout warehouseLayout) { _warehouseLayout = warehouseLayout; _pathSolver = new PathSolver(warehouseLayout); }