public override byte[] Solve(byte[] partialData, TimeSpan timeout) { this.State = TaskSolverState.Solving; DVRPPartialDataToSolve pd2s = new DVRPPartialDataToSolve(); pd2s = DVRPPartialDataToSolve.ParsePartialProblemData(partialData); DVRPPartialSolution solution; string solString = "SOL:" + pd2s.partial.Length.ToString() + ":" + pd2s.NodeNumber + "\n"; for (int set = 0; set < pd2s.partial.Length; set++) { DVRPPathFinder pathFinder = new DVRPPathFinder(pd2s.partial[set], this.Dvrp); pathFinder.FindCycle(0, 0, 0, 0, 0); if (pathFinder.best_cycle != null) { solution = new DVRPPartialSolution(set, pathFinder.bestPathLen, pathFinder.best_cycle, pathFinder.bestArrivalsTimes); } else { List <Location> ll = new List <Location>(); ll.Add(new Location { locationID = -1 }); solution = new DVRPPartialSolution(set, -1, ll, new List <double> { -1 }); } solString += solution.ToString(); solString += DVRPPartialSolution.ArrayToString(pd2s.partial[set]); } return(ConvertStringToData(solString)); }
public static DVRPPartialDataToSolve ParsePartialProblemData(byte[] data) { DVRPPartialDataToSolve pd2s = new DVRPPartialDataToSolve(); pd2s.partial = new int[0][]; string text = Communication_Library.CommunicationModule.ConvertDataToString(data, data.Length); string[] lines = text.Split(new[] { '\n' }); int set = 0; int indeks = 0; for (int i = 0; i < lines.Length - 1; i++) { string[] split = DVRPHelper.SplitText(lines[i]); switch (split[0]) { case "NUMSETS": pd2s.partial = new int[int.Parse(split[1])][]; pd2s.NodeNumber = int.Parse(split[2]); break; case "SET": set = int.Parse(split[1]); pd2s.partial[set] = new int[int.Parse(split[2])]; //set++; break; default: for (int j = 0; j < split.Length; j++) { pd2s.partial[set][j] = int.Parse(split[j]); } break; } } return(pd2s); }