Changeset 6854
- Timestamp:
- 09/30/11 11:36:05 (13 years ago)
- Location:
- branches/VRP
- Files:
-
- 5 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/VRP/HeuristicLab.Problems.VehicleRouting.Views/3.4/HeuristicLab.Problems.VehicleRouting.Views-3.4.csproj
r6851 r6854 112 112 </ItemGroup> 113 113 <ItemGroup> 114 <Compile Include="MDCVRPTWView.cs"> 115 <SubType>UserControl</SubType> 116 </Compile> 117 <Compile Include="MDCVRPTWView.Designer.cs"> 118 <DependentUpon>MDCVRPTWView.cs</DependentUpon> 119 </Compile> 114 120 <Compile Include="MultiDepotVRPView.cs"> 115 121 <SubType>UserControl</SubType> -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/ExtendedPotvin/Creators/PushForwardInsertionCreator.cs
r6851 r6854 182 182 double dueTime = 0; 183 183 if (problemInstance is ITimeWindowedProblemInstance) 184 dueTime = (problemInstance as ITimeWindowedProblemInstance).DueTime[i ];184 dueTime = (problemInstance as ITimeWindowedProblemInstance).DueTime[i + depots - 1]; 185 185 186 186 cost = -alpha * distance + // distance 0 <-> City[i] -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Manipulators/PotvinCustomerRelocationManipulator.cs
r6851 r6854 146 146 DoubleArray serviceTimes = vrptw.ServiceTime; 147 147 148 int depot = 0; 149 int depots = 1; 150 151 int tourIndex = individual.GetTourIndex(route1); 152 int vehicle = individual.GetVehicleAssignment(tourIndex); 153 154 if (ProblemInstance is IMultiDepotProblemInstance) { 155 depots = (ProblemInstance as IMultiDepotProblemInstance).Depots.Value; 156 depot = (ProblemInstance as IMultiDepotProblemInstance).VehicleDepotAssignment[vehicle]; 157 } 158 148 159 List<int> timeWindowViolations = new List<int>(); 149 160 double time = 0; 150 161 151 162 for (int i = 0; i < route1.Stops.Count; i++) { 152 int start = 0; 153 if (i > 0) 154 start = route1.Stops[i - 1]; 155 int end = 0; 156 if (i < route1.Stops.Count) 157 end = route1.Stops[i]; 163 int start = route1.Stops[i - 1]; 164 int end = route1.Stops[i]; 158 165 159 166 //drive there … … 161 168 time += currentDistace; 162 169 170 int endIndex = end + depots - 1; 171 163 172 //check if it was serviced on time 164 if (time > dueTime[end ]) {173 if (time > dueTime[endIndex]) { 165 174 timeWindowViolations.Add(end); 166 175 } … … 168 177 //wait 169 178 double currentWaitingTime = 0.0; 170 if (time < readyTime[end ])171 currentWaitingTime = readyTime[end ] - time;179 if (time < readyTime[endIndex]) 180 currentWaitingTime = readyTime[endIndex] - time; 172 181 time += currentWaitingTime; 173 182 174 183 //service 175 double currentServiceTime = serviceTimes[end ];184 double currentServiceTime = serviceTimes[end - 1]; 176 185 time += currentServiceTime; 177 186 } -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/HeuristicLab.Problems.VehicleRouting-3.4.csproj
r6851 r6854 301 301 <Compile Include="ProblemInstances\MultiDepotVRP\MDCVRP\MDCVRPEvaluator.cs" /> 302 302 <Compile Include="ProblemInstances\MultiDepotVRP\MDCVRP\MDCVRPProblemInstance.cs" /> 303 <Compile Include="ProblemInstances\MultiDepotVRP\MDCVRP\MDCVRPTW\MDCVRPTWEvaluator.cs" /> 304 <Compile Include="ProblemInstances\MultiDepotVRP\MDCVRP\MDCVRPTW\MDCVRPTWProblemInstance.cs" /> 303 305 <Compile Include="ProblemInstances\MultiDepotVRP\MultiDepotVRPProblemInstance.cs" /> 304 306 <Compile Include="ProblemInstances\MultiDepotVRP\MultiDepotVRPEvaluator.cs" /> -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/IVRPProblemInstance.cs
r6851 r6854 51 51 double GetDemand(int city); 52 52 double GetDistance(int start, int end, IVRPEncoding solution); 53 double GetInsertionDistance(int start, int customer, int end, IVRPEncoding solution );53 double GetInsertionDistance(int start, int customer, int end, IVRPEncoding solution, out double startDistance, out double endDistance); 54 54 bool Feasible(IVRPEncoding solution); 55 55 bool TourFeasible(Tour tour, IVRPEncoding solution); -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Parsers/CordeauParser.cs
r6851 r6854 132 132 throw new InvalidDataException("File has wrong format!"); 133 133 134 bool timeWindows = int.Parse(m[0].Value) == 6; 134 135 vehicles = int.Parse(m[3].Value); 135 136 line = reader.ReadLine(); … … 146 147 List<double> depotXcoord = new List<double>(); 147 148 List<double> depotYcoord = new List<double>(); 149 List<double> depotReadyTime = new List<double>(); 150 List<double> depotDueTime = new List<double>(); 151 148 152 while ((line != null)) { 149 153 m = reg.Matches(line); 150 154 151 if (m.Count == 11) {155 if (m.Count >= 11) { 152 156 xCoord.Add(double.Parse(m[1].Value, System.Globalization.CultureInfo.InvariantCulture)); 153 157 yCoord.Add(double.Parse(m[2].Value, System.Globalization.CultureInfo.InvariantCulture)); 154 158 demand.Add((double)int.Parse(m[4].Value, System.Globalization.CultureInfo.InvariantCulture)); 155 } else if (m.Count == 7) { 159 160 if (timeWindows) { 161 serviceTime.Add(int.Parse(m[3].Value)); 162 readyTime.Add(int.Parse(m[m.Count - 2].Value)); 163 dueTime.Add(int.Parse(m[m.Count - 1].Value)); 164 } else { 165 serviceTime.Add(0); 166 readyTime.Add(0); 167 dueTime.Add(double.MaxValue); 168 } 169 } else if (m.Count >= 7) { 156 170 depotXcoord.Add(double.Parse(m[1].Value, System.Globalization.CultureInfo.InvariantCulture)); 157 171 depotYcoord.Add(double.Parse(m[2].Value, System.Globalization.CultureInfo.InvariantCulture)); 172 173 if (timeWindows) { 174 depotReadyTime.Add(int.Parse(m[m.Count - 2].Value)); 175 depotDueTime.Add(int.Parse(m[m.Count - 1].Value)); 176 } else { 177 depotReadyTime.Add(0); 178 depotDueTime.Add(double.MaxValue); 179 } 158 180 } 159 181 … … 163 185 xCoord.InsertRange(0, depotXcoord); 164 186 yCoord.InsertRange(0, depotYcoord); 187 readyTime.InsertRange(0, depotReadyTime); 188 dueTime.InsertRange(0, depotDueTime); 165 189 166 190 cities = demand.Count; -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/MultiDepotVRP/MDCVRP/MDCVRPEvaluator.cs
r6851 r6854 111 111 double overloadPenalty = cvrp.OverloadPenalty.Value; 112 112 113 costs += instance.GetInsertionDistance(insertionInfo.Start, customer, insertionInfo.End, solution); 113 double startDistance, endDistance; 114 costs += instance.GetInsertionDistance(insertionInfo.Start, customer, insertionInfo.End, solution, out startDistance, out endDistance); 114 115 115 116 double demand = instance.GetDemand(customer); -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/MultiDepotVRP/MultiDepotVRPEvaluator.cs
r6851 r6854 81 81 double costs = 0; 82 82 feasible = true; 83 double startDistance, endDistance; 83 84 84 costs += instance.GetInsertionDistance(insertionInfo.Start, customer, insertionInfo.End, solution );85 costs += instance.GetInsertionDistance(insertionInfo.Start, customer, insertionInfo.End, solution, out startDistance, out endDistance); 85 86 86 87 return costs; -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/MultiDepotVRP/MultiDepotVRPProblemInstance.cs
r6851 r6854 150 150 } 151 151 152 public override double GetInsertionDistance(int start, int customer, int end, IVRPEncoding solution) { 152 public override double GetInsertionDistance(int start, int customer, int end, IVRPEncoding solution, 153 out double startDistance, out double endDistance) { 153 154 if (start == 0) { 154 155 start = GetDepot(end, solution); … … 164 165 165 166 double distance = base.GetDistance(start, end, solution); 166 double newDistance = 167 base.GetDistance(start, customer, solution) + 168 base.GetDistance(customer, end, solution); 167 168 startDistance = base.GetDistance(start, customer, solution); 169 endDistance = base.GetDistance(customer, end, solution); 170 171 double newDistance = startDistance + endDistance; 169 172 170 173 return newDistance - distance; -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/VRPProblemInstance.cs
r6851 r6854 220 220 } 221 221 222 public virtual double GetInsertionDistance(int start, int customer, int end, IVRPEncoding solution) { 222 public virtual double GetInsertionDistance(int start, int customer, int end, IVRPEncoding solution, 223 out double startDistance, out double endDistance) { 223 224 double distance = GetDistance(start, end, solution); 224 double newDistance = 225 GetDistance(start, customer, solution) + 226 GetDistance(customer, end, solution); 225 226 startDistance = GetDistance(start, customer, solution); 227 endDistance = GetDistance(customer, end, solution); 228 229 double newDistance = startDistance + endDistance; 227 230 228 231 return newDistance - distance; -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/VehicleRoutingProblem.cs
r6851 r6854 247 247 parser.Parse(); 248 248 249 MDCVRP ProblemInstance problem = new MDCVRPProblemInstance();249 MDCVRPTWProblemInstance problem = new MDCVRPTWProblemInstance(); 250 250 251 251 problem.Coordinates = new DoubleMatrix(parser.Coordinates); … … 255 255 problem.Depots.Value = parser.Depots; 256 256 problem.VehicleDepotAssignment = new IntArray(parser.Vehicles); 257 problem.ReadyTime = new DoubleArray(parser.Readytimes); 258 problem.ServiceTime = new DoubleArray(parser.Servicetimes); 259 problem.DueTime = new DoubleArray(parser.Duetimes); 260 257 261 int depot = 0; 258 262 int i = 0;
Note: See TracChangeset
for help on using the changeset viewer.