public static VRPSimultaneousPickupDelivery LoadSalhiNagyProblem(string path, int fleet, bool serieX) { //formato del fichero //clientes capacidad tiempo-maximo tiempo-ruptura //depot-x depot-y //para cada clietne //x y demand int id = ParseNagySalhiName(path); StreamReader reader = new StreamReader(path); var sp = SalhiNagyProblemSpecification(reader); int clientAmount = sp.Item1; int vehicleCapacity = sp.Item2; List <Tuple <double, double, double> > clientsInfo = LoadClientInfo(reader, clientAmount); TravelData matrix = BuildTravelCostMatrix(clientsInfo); ClientSet <PickupDeliveryClient> clientSet = BuildClientSet(clientsInfo, serieX); Fleet vehicles = Fleet.CreateHomogeneousFleet(fleet, vehicleCapacity); reader.Close(); VRPSimultaneousPickupDelivery problem = new VRPSimultaneousPickupDelivery(clientSet, vehicles, matrix); string serie = (serieX) ? "X" : "Y"; problem.ProblemName = string.Format("CMT{0}-{1}-{2}{3}", id, clientAmount, fleet, serie); return(problem); }
public static VRPSimultaneousPickupDelivery LoadDenthoffProblem(string path) { Tuple <DethloffType, int, int> dataName = ParseDethloffName(path); DethloffType type = dataName.Item1; int x = dataName.Item2; int y = dataName.Item3; StreamReader reader = new StreamReader(path); Fleet f = ParseFleetInfo(reader, x + 1); int clientAmount = int.Parse(reader.ReadLine().Trim()); TravelData m = ParseTravelMatrix(reader, clientAmount); ClientSet <PickupDeliveryClient> c = ParseClientInfo(reader, clientAmount); VRPSimultaneousPickupDelivery instance = new VRPSimultaneousPickupDelivery(c, f, m); instance.ProblemName = type.ToString() + x.ToString() + "-" + y.ToString(); return(instance); }
public static VRPSimultaneousPickupDelivery LoadSalhiNagyProblem(string path, int fleet, bool serieX) { //formato del fichero //clientes capacidad tiempo-maximo tiempo-ruptura //depot-x depot-y //para cada clietne //x y demand int id = ParseNagySalhiName(path); StreamReader reader = new StreamReader(path); string[] specification = reader.ReadLine().Split(' '); int clientAmount = int.Parse(specification[1]); int vehicleCapacity = int.Parse(specification[2]); string[] depot = reader.ReadLine().Split(' '); double xDepot = double.Parse(depot[1]); double yDepot = double.Parse(depot[2]); List <Tuple <double, double, double> > clientsInfo = new List <Tuple <double, double, double> >(clientAmount + 1); clientsInfo.Add(new Tuple <double, double, double>(xDepot, yDepot, 0)); while (!reader.EndOfStream) { string[] client = reader.ReadLine().Split(' '); if (client.Length == 4) { clientsInfo.Add(new Tuple <double, double, double>(double.Parse(client[1]), double.Parse(client[2]), double.Parse(client[3]))); } } TravelData matrix = BuildTravelCostMatrix(clientsInfo); ClientSet <PickupDeliveryClient> clientSet = BuildClientSet(clientsInfo, serieX); Fleet vehicles = Fleet.CreateHomogeneousFleet(fleet, vehicleCapacity); reader.Close(); VRPSimultaneousPickupDelivery problem = new VRPSimultaneousPickupDelivery(clientSet, vehicles, matrix); string serie = (serieX) ? "X" : "Y"; problem.ProblemName = string.Format("CMT{0}-{1}-{2}{3}", id, clientAmount, fleet, serie); return(problem); }
public static VRPSimultaneousPickupDelivery ParseSalhiNagyMixed(string path, int clientInterval, int[] fleet) { int id = ParseNagySalhiName(path); int fleetSize = fleet[id - 1]; StreamReader reader = new StreamReader(path); var sp = SalhiNagyProblemSpecification(reader); int clientAmount = sp.Item1; int vehicleCapacity = sp.Item2; List <Tuple <double, double, double> > clientsInfo = LoadClientInfo(reader, clientAmount); reader.Close(); TravelData matrix = BuildTravelCostMatrix(clientsInfo); ClientSet <PickupDeliveryClient> clientSet = BuildSalhiMixedClientSet(clientsInfo, clientInterval); Fleet vehicles = Fleet.CreateHomogeneousFleet(fleetSize, vehicleCapacity); VRPSimultaneousPickupDelivery problem = new VRPSimultaneousPickupDelivery(clientSet, vehicles, matrix); problem.ProblemName = string.Format("CMT{0}", id); return(problem); }
public static VRPSimultaneousPickupDelivery Combine(VRPSimultaneousPickupDelivery problem1, VRPSimultaneousPickupDelivery problem2) { ClientSet <PickupDeliveryClient> clientSet = new ClientSet <PickupDeliveryClient>(); foreach (var item in problem1.Clients) { clientSet.Add(item); } for (int i = 0; i < problem2.Clients.Count; i++) { PickupDeliveryClient newClient = (PickupDeliveryClient)problem2.Clients[i + 1].Clone(); newClient.ID = clientSet.Count + 1; clientSet.Add(newClient); } Fleet fleet = new Fleet(); foreach (var item in problem1.Vehicles) { fleet.Add(item); } foreach (var item in problem2.Vehicles) { fleet.Add(item); } double[,] travel = new double[clientSet.Count + 1, clientSet.Count + 1]; double maxCost = int.MaxValue / 10; for (int i = 0; i < travel.GetLength(0); i++) { for (int j = i + 1; j < travel.GetLength(1); j++) { travel[i, j] = travel[j, i] = maxCost; } } for (int i = 0; i < problem1.Clients.Count + 1; i++) { for (int j = 0; j < problem1.Clients.Count + 1; j++) { travel[i, j] = problem1.TravelDistance[i, j]; } } for (int i = 0; i < problem2.Clients.Count + 1; i++) { for (int j = 0; j < problem2.Clients.Count + 1; j++) { if (i == 0 && j != 0) { travel[0, problem1.Clients.Count + j] = problem2.TravelDistance[0, j]; } else if (j == 0 && i != 0) { travel[problem1.Clients.Count + i, 0] = problem2.TravelDistance[i, 0]; } else if (i != 0 && j != 0) { travel[problem1.Clients.Count + i, problem1.Clients.Count + j] = problem2.TravelDistance[i, j]; } } } return(new VRPSimultaneousPickupDelivery(clientSet, fleet, new TravelData(travel))); }