public void include(ref double[][] costMatrix, ref double lowerBound, ref partialRoute route, int row, int column) { route.Entered[column] = row; route.Exited[row] = column; route.setSize(); route.start = row; route.end = column; while (route.Exited[route.end] != -1) { route.end = route.Exited[route.end]; } while (route.Entered[route.start] != -1) { route.start = route.Entered[route.start]; } if (route.size < Cities.Length - 1) { while (route.start != column) { costMatrix[route.end][route.start] = Double.PositiveInfinity; costMatrix[column][route.start] = Double.PositiveInfinity; route.start = route.Exited[route.start]; } } else { int final = 0; for (int i = 0; i < route.Exited.Length; i++) { if (route.Exited[i] == -1) { final = i; break; } } for (int i = 0; i < route.Entered.Length; i++) { if (route.Entered[i] == -1) { route.Entered[i] = final; route.Exited[final] = i; break; } } route.setSize(); for (int m = 0; m < Cities.Length; m++) { for (int n = 0; n < Cities.Length; n++) { costMatrix[m][n] = Double.PositiveInfinity; } } } for (int r = 0; r < Cities.Length; r++) { costMatrix[r][column] = Double.PositiveInfinity; } for (int c = 0; c < Cities.Length; c++) { costMatrix[row][c] = Double.PositiveInfinity; } costMatrix[column][row] = Double.PositiveInfinity; reduceCostMatrix(ref costMatrix, ref lowerBound); }
public static partialRoute copyArrayList(partialRoute obj) { using (var ms = new MemoryStream()) { var formatter = new BinaryFormatter(); formatter.Serialize(ms, obj); ms.Position = 0; return (partialRoute)formatter.Deserialize(ms); } }