Changeset 17711 for branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/MultiDepotVRP/MultiDepotVRPProblemInstance.cs
- Timestamp:
- 08/03/20 18:06:16 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/MultiDepotVRP/MultiDepotVRPProblemInstance.cs
r17698 r17711 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using HEAL.Attic; 25 26 using HeuristicLab.Common; 26 27 using HeuristicLab.Core; 27 28 using HeuristicLab.Data; 28 using HeuristicLab.Optimization;29 29 using HeuristicLab.Parameters; 30 using HEAL.Attic;31 using HeuristicLab.PluginInfrastructure;32 30 using HeuristicLab.Problems.VehicleRouting.Interfaces; 33 31 using HeuristicLab.Problems.VehicleRouting.Variants; … … 60 58 } 61 59 62 protected override IEnumerable<IOperator> GetOperators() { 63 return ApplicationManager.Manager.GetInstances<IMultiDepotOperator>().Cast<IOperator>(); 64 } 65 66 protected override IEnumerable<IOperator> GetAnalyzers() { 67 return ApplicationManager.Manager.GetInstances<IMultiDepotOperator>() 68 .Where(o => o is IAnalyzer) 69 .Cast<IOperator>(); 70 } 71 72 public override IntValue Cities { 73 get { 74 return new IntValue(Demand.Length); 75 } 76 } 77 78 protected override IVRPEvaluator Evaluator { 79 get { 80 return new MultiDepotVRPEvaluator(); 81 } 82 } 83 84 protected override IVRPCreator Creator { 85 get { 86 return new HeuristicLab.Problems.VehicleRouting.Encodings.Alba.RandomCreator(); 87 } 88 } 60 public override IEnumerable<IOperator> FilterOperators(IEnumerable<IOperator> operators) { 61 return base.FilterOperators(operators).Where(x => x is IMultiDepotOperator); 62 } 63 64 public override IntValue Cities => new IntValue(Demand.Length); 65 89 66 90 67 public override double GetDemand(int city) { … … 172 149 return newDistance - distance; 173 150 } 151 protected override void EvaluateTour(VRPEvaluation eval, Tour tour, IVRPEncodedSolution solution) { 152 TourInsertionInfo tourInfo = new TourInsertionInfo(solution.GetVehicleAssignment(solution.GetTourIndex(tour))); 153 eval.InsertionInfo.AddTourInsertionInfo(tourInfo); 154 155 double distance = 0.0; 156 double quality = 0.0; 157 158 //simulate a tour, start and end at depot 159 for (int i = 0; i <= tour.Stops.Count; i++) { 160 int start = 0; 161 if (i > 0) 162 start = tour.Stops[i - 1]; 163 int end = 0; 164 if (i < tour.Stops.Count) 165 end = tour.Stops[i]; 166 167 //drive there 168 double currentDistace = GetDistance(start, end, solution); 169 distance += currentDistace; 170 171 StopInsertionInfo stopInfo = new StopInsertionInfo(start, end); 172 tourInfo.AddStopInsertionInfo(stopInfo); 173 } 174 175 //Fleet usage 176 quality += FleetUsageFactor.Value; 177 //Distance 178 quality += DistanceFactor.Value * distance; 179 180 eval.Distance += distance; 181 eval.VehicleUtilization += 1; 182 183 eval.Quality += quality; 184 tourInfo.Quality = quality; 185 } 186 187 protected override double GetTourInsertionCosts(IVRPEncodedSolution solution, TourInsertionInfo tourInsertionInfo, int index, int customer, 188 out bool feasible) { 189 StopInsertionInfo insertionInfo = tourInsertionInfo.GetStopInsertionInfo(index); 190 191 double costs = 0; 192 feasible = true; 193 double startDistance, endDistance; 194 195 costs += GetInsertionDistance(insertionInfo.Start, customer, insertionInfo.End, solution, out startDistance, out endDistance); 196 197 return costs; 198 } 174 199 175 200 [StorableConstructor]
Note: See TracChangeset
for help on using the changeset viewer.