- Timestamp:
- 06/19/12 13:17:29 (12 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Creators
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Creators/IterativeInsertionCreator.cs
r6857 r8053 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 0Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 22 22 using System; 23 23 using System.Collections.Generic; 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Core; 25 26 using HeuristicLab.Data; 26 using HeuristicLab.Encodings.PermutationEncoding;27 27 using HeuristicLab.Optimization; 28 28 using HeuristicLab.Parameters; 29 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 30 using HeuristicLab.Common;31 30 using HeuristicLab.Problems.VehicleRouting.Interfaces; 32 31 using HeuristicLab.Problems.VehicleRouting.ProblemInstances; … … 85 84 PotvinEncoding result = new PotvinEncoding(instance); 86 85 87 IPickupAndDeliveryProblemInstance pdp = instance as IPickupAndDeliveryProblemInstance; 86 IPickupAndDeliveryProblemInstance pdp = instance as IPickupAndDeliveryProblemInstance; 88 87 89 88 List<int> customers = new List<int>(); 90 89 for (int i = 1; i <= instance.Cities.Value; i++) 91 if (pdp == null || pdp.GetDemand(i) >= 0)90 if (pdp == null || pdp.GetDemand(i) >= 0) 92 91 customers.Add(i); 93 92 94 customers.Sort(delegate(int city1, int city2) 95 { 93 customers.Sort(delegate(int city1, int city2) { 96 94 double angle1 = CalculateAngleToDepot(instance, city1); 97 95 double angle2 = CalculateAngleToDepot(instance, city2); … … 108 106 109 107 int stopIdx = 0; 110 if (currentTour.Stops.Count > 0)108 if (currentTour.Stops.Count > 0) 111 109 result.FindBestInsertionPlace(currentTour, customers[index]); 112 110 currentTour.Stops.Insert(stopIdx, customers[index]); … … 118 116 119 117 CVRPEvaluation evaluation = instance.EvaluateTour(currentTour, result) as CVRPEvaluation; 120 if (result.Tours.Count < instance.Vehicles.Value && 118 if (result.Tours.Count < instance.Vehicles.Value && 121 119 ((adhereTimeWindows && !instance.Feasible(evaluation)) || ((!adhereTimeWindows) && evaluation.Overload > double.Epsilon))) { 122 123 124 120 currentTour.Stops.Remove(customers[index]); 121 if (pdp != null) 122 currentTour.Stops.Remove(pdp.GetPickupDeliveryLocation(customers[index])); 125 123 126 124 if (currentTour.Stops.Count == 0) … … 128 126 currentTour = new Tour(); 129 127 result.Tours.Add(currentTour); 130 128 131 129 currentTour.Stops.Add(customers[index]); 132 130 if (pdp != null) { -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Creators/PotvinCreator.cs
r5127 r8053 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 0Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 using HeuristicLab.Data;24 using HeuristicLab.Operators;25 using HeuristicLab.Parameters;26 24 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 25 using HeuristicLab.Problems.VehicleRouting.Encodings.General; 27 26 using HeuristicLab.Problems.VehicleRouting.Interfaces; 28 using HeuristicLab.Problems.VehicleRouting.Encodings.General;29 using HeuristicLab.Common;30 27 31 28 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin { … … 36 33 get { return false; } 37 34 } 38 35 39 36 [StorableConstructor] 40 37 protected PotvinCreator(bool deserializing) : base(deserializing) { } -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Creators/PushForwardInsertionCreator.cs
r6881 r8053 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 0Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 22 22 using System; 23 23 using System.Collections.Generic; 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Core; 25 26 using HeuristicLab.Data; 26 using HeuristicLab.Encodings.PermutationEncoding;27 27 using HeuristicLab.Optimization; 28 28 using HeuristicLab.Parameters; 29 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 30 using HeuristicLab.Common;31 30 using HeuristicLab.Problems.VehicleRouting.Interfaces; 32 31 using HeuristicLab.Problems.VehicleRouting.ProblemInstances; … … 116 115 } 117 116 118 private static int GetNearestDepot(IVRPProblemInstance problemInstance, List<int> depots, int customer, 117 private static int GetNearestDepot(IVRPProblemInstance problemInstance, List<int> depots, int customer, 119 118 double alpha, double beta, double gamma, out double minCost) { 120 119 int nearest = -1; … … 132 131 133 132 double distance = GetDistance(customer + depotCount - 1, depot, problemInstance); 134 133 135 134 double dueTime = 0; 136 135 if (problemInstance is ITimeWindowedProblemInstance) … … 158 157 } 159 158 160 private static List<int> SortCustomers(IVRPProblemInstance problemInstance, List<int> customers, List<int> depots, 161 Dictionary<int, int> depotAssignment, 159 private static List<int> SortCustomers(IVRPProblemInstance problemInstance, List<int> customers, List<int> depots, 160 Dictionary<int, int> depotAssignment, 162 161 double alpha, double beta, double gamma) { 163 162 List<int> sortedCustomers = new List<int>(); … … 168 167 for (int i = 0; i < customers.Count; i++) { 169 168 double cost; 170 int depot = GetNearestDepot(problemInstance, depots, customers[i], 169 int depot = GetNearestDepot(problemInstance, depots, customers[i], 171 170 alpha, beta, gamma, 172 171 out cost);
Note: See TracChangeset
for help on using the changeset viewer.