Changeset 10744
- Timestamp:
- 04/14/14 10:04:43 (11 years ago)
- Location:
- stable
- Files:
-
- 19 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 10435,10460,10475,10651-10652
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.Instances.VehicleRouting/3.4/CordeauFormat/CordeauFormatInstanceProvider.cs
r9456 r10744 23 23 24 24 namespace HeuristicLab.Problems.Instances.VehicleRouting { 25 public abstract class CordeauFormatInstanceProvider : VRPInstanceProvider <MDCVRPTWData>{26 protected override MDCVRPTWData LoadData(Stream stream) {25 public abstract class CordeauFormatInstanceProvider : VRPInstanceProvider { 26 protected override VRPData LoadData(Stream stream) { 27 27 return LoadInstance(new CordeauParser(stream)); 28 28 } … … 31 31 get { return true; } 32 32 } 33 public override MDCVRPTWData ImportData(string path) {33 public override VRPData ImportData(string path) { 34 34 return LoadInstance(new CordeauParser(path)); 35 35 } -
stable/HeuristicLab.Problems.Instances.VehicleRouting/3.4/GoldenFormat/GoldenFormatInstanceProvider.cs
r9456 r10744 24 24 25 25 namespace HeuristicLab.Problems.Instances.VehicleRouting { 26 public abstract class GoldenFormatInstanceProvider : VRPInstanceProvider <CVRPTWData>{27 protected override CVRPTWData LoadData(Stream stream) {26 public abstract class GoldenFormatInstanceProvider : VRPInstanceProvider { 27 protected override VRPData LoadData(Stream stream) { 28 28 return LoadInstance(new GoldenParser(stream)); 29 29 } … … 32 32 get { return true; } 33 33 } 34 public override CVRPTWData ImportData(string path) {34 public override VRPData ImportData(string path) { 35 35 return LoadInstance(new GoldenParser(path)); 36 36 } -
stable/HeuristicLab.Problems.Instances.VehicleRouting/3.4/LiLimFormat/LiLimFormatInstanceProvider.cs
r9456 r10744 23 23 24 24 namespace HeuristicLab.Problems.Instances.VehicleRouting { 25 public abstract class LiLimFormatInstanceProvider : VRPInstanceProvider <PDPTWData>{26 protected override PDPTWData LoadData(Stream stream) {25 public abstract class LiLimFormatInstanceProvider : VRPInstanceProvider { 26 protected override VRPData LoadData(Stream stream) { 27 27 return LoadInstance(new LiLimParser(stream)); 28 28 } … … 31 31 get { return true; } 32 32 } 33 public override PDPTWData ImportData(string path) {33 public override VRPData ImportData(string path) { 34 34 return LoadInstance(new LiLimParser(path)); 35 35 } -
stable/HeuristicLab.Problems.Instances.VehicleRouting/3.4/SolomonFormat/SolomonFormatInstanceProvider.cs
r9456 r10744 23 23 24 24 namespace HeuristicLab.Problems.Instances.VehicleRouting { 25 public abstract class SolomonFormatInstanceProvider : VRPInstanceProvider <CVRPTWData>{26 protected override CVRPTWData LoadData(Stream stream) {25 public abstract class SolomonFormatInstanceProvider : VRPInstanceProvider { 26 protected override VRPData LoadData(Stream stream) { 27 27 return LoadInstance(new SolomonParser(stream)); 28 28 } … … 31 31 get { return true; } 32 32 } 33 public override CVRPTWData ImportData(string path) {33 public override VRPData ImportData(string path) { 34 34 return LoadInstance(new SolomonParser(path)); 35 35 } -
stable/HeuristicLab.Problems.Instances.VehicleRouting/3.4/TSPLibFormat/TSPLibFormatInstanceProvider.cs
r9456 r10744 25 25 26 26 namespace HeuristicLab.Problems.Instances.VehicleRouting { 27 public abstract class TSPLibFormatInstanceProvider : VRPInstanceProvider <CVRPData>{28 protected override CVRPData LoadData(Stream stream) {27 public abstract class TSPLibFormatInstanceProvider : VRPInstanceProvider { 28 protected override VRPData LoadData(Stream stream) { 29 29 return LoadInstance(new TSPLIBParser(stream)); 30 30 } … … 33 33 get { return true; } 34 34 } 35 public override CVRPData ImportData(string path) {35 public override VRPData ImportData(string path) { 36 36 return LoadInstance(new TSPLIBParser(path)); 37 37 } -
stable/HeuristicLab.Problems.Instances.VehicleRouting/3.4/TaillardFormat/TaillardFormatInstanceProvider.cs
r9456 r10744 23 23 24 24 namespace HeuristicLab.Problems.Instances.VehicleRouting { 25 public abstract class TaillardFormatInstanceProvider : VRPInstanceProvider <CVRPData>{26 protected override CVRPData LoadData(Stream stream) {25 public abstract class TaillardFormatInstanceProvider : VRPInstanceProvider { 26 protected override VRPData LoadData(Stream stream) { 27 27 return LoadInstance(new TaillardParser(stream)); 28 28 } … … 31 31 get { return true; } 32 32 } 33 public override CVRPData ImportData(string path) {33 public override VRPData ImportData(string path) { 34 34 return LoadInstance(new TaillardParser(path)); 35 35 } -
stable/HeuristicLab.Problems.Instances.VehicleRouting/3.4/VRPInstanceProvider.cs
r9456 r10744 29 29 30 30 namespace HeuristicLab.Problems.Instances.VehicleRouting { 31 public abstract class VRPInstanceProvider <T> : ProblemInstanceProvider<T>, IVRPInstanceProvider where T : IVRPData{31 public abstract class VRPInstanceProvider : ProblemInstanceProvider<VRPData>, IVRPInstanceProvider { 32 32 protected abstract string FileName { get; } 33 33 … … 52 52 } 53 53 54 public override TLoadData(IDataDescriptor id) {54 public override VRPData LoadData(IDataDescriptor id) { 55 55 var descriptor = (VRPDataDescriptor)id; 56 56 var instanceArchiveName = GetResourceName(FileName + @"\.zip"); … … 76 76 } 77 77 78 private static void LoadSolution(Stream stream, Tinstance) {78 private static void LoadSolution(Stream stream, VRPData instance) { 79 79 List<List<int>> routes = new List<List<int>>(); 80 80 … … 99 99 } 100 100 101 public static void LoadSolution(string path, Tinstance) {101 public static void LoadSolution(string path, VRPData instance) { 102 102 using (FileStream stream = new FileStream(path, FileMode.Open)) { 103 103 LoadSolution(stream, instance); … … 105 105 } 106 106 107 protected abstract TLoadData(Stream stream);107 protected abstract VRPData LoadData(Stream stream); 108 108 109 109 public IVRPData Import(string vrpFile, string tourFile) { … … 116 116 117 117 public void Export(IVRPData instance, string path) { 118 ExportData(( T)instance, path);118 ExportData((VRPData)instance, path); 119 119 } 120 120 -
stable/HeuristicLab.Problems.VehicleRouting
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Problems.VehicleRouting merged: 10435,10460,10475,10651
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Creators/IterativeInsertionCreator.cs
r10507 r10744 81 81 } 82 82 83 p rivatestatic PotvinEncoding CreateSolution(IVRPProblemInstance instance, IRandom random, bool adhereTimeWindows) {83 public static PotvinEncoding CreateSolution(IVRPProblemInstance instance, IRandom random, bool adhereTimeWindows) { 84 84 PotvinEncoding result = new PotvinEncoding(instance); 85 85 … … 91 91 customers.Add(i); 92 92 93 customers.Sort( delegate(int city1, int city2){94 95 93 customers.Sort((city1, city2) => { 94 double angle1 = CalculateAngleToDepot(instance, city1); 95 double angle2 = CalculateAngleToDepot(instance, city2); 96 96 97 98 97 return angle1.CompareTo(angle2); 98 }); 99 99 100 100 Tour currentTour = new Tour(); -
stable/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Manipulators/PotvinLocalSearchManipulator.cs
r9456 r10744 52 52 } 53 53 54 private bool FindBetterInsertionPlace(55 PotvinEncoding individual, int tour, int city, int length,54 private static bool FindBetterInsertionPlace( 55 PotvinEncoding individual, IVRPProblemInstance instance, int tour, int city, int length, 56 56 out int insertionTour, out int insertionPlace) { 57 57 bool insertionFound = false; … … 70 70 distance = individual.GetTourLength(individual.Tours[currentTour]); 71 71 individual.Tours[currentTour].Stops.InsertRange(currentCity, toBeDeleted); 72 if ( ProblemInstance.TourFeasible(individual.Tours[currentTour], individual)) {72 if (instance.TourFeasible(individual.Tours[currentTour], individual)) { 73 73 double lengthIncrease = 74 74 individual.GetTourLength(individual.Tours[currentTour]) - distance; … … 92 92 } 93 93 94 p rotected override void Manipulate(IRandom random, PotvinEncoding individual) {94 public static void ApplyManipulation(IRandom random, PotvinEncoding individual, IVRPProblemInstance instance, int maxIterations) { 95 95 //only apply to feasible individuals 96 if ( ProblemInstance.Feasible(individual)) {96 if (instance.Feasible(individual)) { 97 97 bool insertionFound; 98 98 int iterations = 0; … … 107 107 while (city <= individual.Tours[tour].Stops.Count - length && !insertionFound) { 108 108 int insertionTour, insertionPlace; 109 if (FindBetterInsertionPlace(individual, tour, city, length,109 if (FindBetterInsertionPlace(individual, instance, tour, city, length, 110 110 out insertionTour, out insertionPlace)) { 111 111 insertionFound = true; … … 126 126 iterations++; 127 127 } while (insertionFound && 128 iterations < Iterations.Value.Value);128 iterations < maxIterations); 129 129 130 130 IList<Tour> toBeRemoved = new List<Tour>(); … … 139 139 } 140 140 } 141 142 143 protected override void Manipulate(IRandom random, PotvinEncoding individual) { 144 ApplyManipulation(random, individual, ProblemInstance, Iterations.Value.Value); 145 } 141 146 } 142 147 } -
stable/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Manipulators/PotvinManipulator.cs
r10507 r10744 55 55 protected abstract void Manipulate(IRandom random, PotvinEncoding individual); 56 56 57 protected int SelectRandomTourBiasedByLength(IRandom random, PotvinEncoding individual) {57 protected static int SelectRandomTourBiasedByLength(IRandom random, PotvinEncoding individual, IVRPProblemInstance instance) { 58 58 int tourIndex = -1; 59 59 … … 61 61 double[] probabilities = new double[individual.Tours.Count]; 62 62 for (int i = 0; i < individual.Tours.Count; i++) { 63 probabilities[i] = 1.0 / ((double)individual.Tours[i].Stops.Count / (double) ProblemInstance.Cities.Value);63 probabilities[i] = 1.0 / ((double)individual.Tours[i].Stops.Count / (double)instance.Cities.Value); 64 64 sum += probabilities[i]; 65 65 } … … 82 82 } 83 83 84 protected bool FindInsertionPlace(PotvinEncoding individual, int city, int routeToAvoid, bool allowInfeasible, out int route, out int place) {84 protected static bool FindInsertionPlace(PotvinEncoding individual, int city, int routeToAvoid, bool allowInfeasible, out int route, out int place) { 85 85 return individual.FindInsertionPlace( 86 86 city, routeToAvoid, allowInfeasible, out route, out place); -
stable/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Manipulators/PotvinOneLevelExchangeManipulator.cs
r9456 r10744 23 23 using HeuristicLab.Core; 24 24 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 25 using HeuristicLab.Problems.VehicleRouting.Interfaces; 25 26 26 27 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin { … … 41 42 } 42 43 43 protected override void Manipulate(IRandom random, PotvinEncoding individual) { 44 bool allowInfeasible = AllowInfeasibleSolutions.Value.Value; 45 46 int selectedIndex = SelectRandomTourBiasedByLength(random, individual); 44 public static void ApplyManipulation(IRandom random, PotvinEncoding individual, IVRPProblemInstance instance, bool allowInfeasible) { 45 int selectedIndex = SelectRandomTourBiasedByLength(random, individual, instance); 47 46 if (selectedIndex >= 0) { 48 47 Tour route1 = … … 68 67 } 69 68 } 69 70 protected override void Manipulate(IRandom random, PotvinEncoding individual) { 71 bool allowInfeasible = AllowInfeasibleSolutions.Value.Value; 72 ApplyManipulation(random, individual, ProblemInstance, allowInfeasible); 73 } 70 74 } 71 75 } -
stable/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Manipulators/PotvinPairwiseOneLevelExchangeManipulator.cs
r9456 r10744 25 25 using HeuristicLab.Problems.VehicleRouting.ProblemInstances; 26 26 using HeuristicLab.Problems.VehicleRouting.Variants; 27 using HeuristicLab.Problems.VehicleRouting.Interfaces; 27 28 28 29 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin { … … 43 44 } 44 45 45 public bool PairwiseMove(PotvinEncoding individual, int city, bool allowInfeasible) {46 public static bool PairwiseMove(PotvinEncoding individual, IVRPProblemInstance instance, int city, bool allowInfeasible) { 46 47 bool success; 47 48 48 IPickupAndDeliveryProblemInstance pdp = ProblemInstance as IPickupAndDeliveryProblemInstance;49 IPickupAndDeliveryProblemInstance pdp = instance as IPickupAndDeliveryProblemInstance; 49 50 50 51 if (pdp != null) { … … 64 65 65 66 int source, target; 66 if ( ProblemInstance.GetDemand(city) >= 0) {67 if (instance.GetDemand(city) >= 0) { 67 68 source = city; 68 69 target = dest; … … 80 81 if (tourIdx != routeToAvoid) { 81 82 Tour tour = individual.Tours[tourIdx]; 82 VRPEvaluation eval = ProblemInstance.EvaluateTour(tour, individual);83 individual.InsertPair(tour, source, target, ProblemInstance);84 VRPEvaluation evalNew = ProblemInstance.EvaluateTour(tour, individual);83 VRPEvaluation eval = instance.EvaluateTour(tour, individual); 84 individual.InsertPair(tour, source, target, instance); 85 VRPEvaluation evalNew = instance.EvaluateTour(tour, individual); 85 86 86 87 double delta = evalNew.Quality - eval.Quality; 87 88 88 89 if (delta < bestQuality && 89 ( ProblemInstance.Feasible(evalNew) || allowInfeasible)) {90 (instance.Feasible(evalNew) || allowInfeasible)) { 90 91 bestQuality = delta; 91 92 bestTour = tourIdx; … … 127 128 } 128 129 130 public static void ApplyManipulation(IRandom random, PotvinEncoding individual, IPickupAndDeliveryProblemInstance pdp, bool allowInfeasible) { 131 int selectedIndex = SelectRandomTourBiasedByLength(random, individual, pdp); 132 if (selectedIndex >= 0) { 133 Tour route1 = 134 individual.Tours[selectedIndex]; 135 136 int count = route1.Stops.Count; 137 138 if (count > 0) { 139 int i = random.Next(0, count); 140 int city = route1.Stops[i]; 141 142 if (!PairwiseMove(individual, pdp, city, allowInfeasible)) 143 i++; 144 145 count = route1.Stops.Count; 146 } 147 } 148 } 149 150 129 151 protected override void Manipulate(IRandom random, PotvinEncoding individual) { 130 152 bool allowInfeasible = AllowInfeasibleSolutions.Value.Value; 153 131 154 IPickupAndDeliveryProblemInstance pdp = ProblemInstance as IPickupAndDeliveryProblemInstance; 132 155 133 156 if (pdp != null) { 134 int selectedIndex = SelectRandomTourBiasedByLength(random, individual); 135 if (selectedIndex >= 0) { 136 Tour route1 = 137 individual.Tours[selectedIndex]; 138 139 int count = route1.Stops.Count; 140 141 if (count > 0) { 142 int i = random.Next(0, count); 143 int city = route1.Stops[i]; 144 145 if (!PairwiseMove(individual, city, allowInfeasible)) 146 i++; 147 148 count = route1.Stops.Count; 149 } 150 } 157 ApplyManipulation(random, individual, pdp, allowInfeasible); 151 158 } 152 159 } -
stable/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Manipulators/PotvinPairwiseTwoLevelExchangeManipulator.cs
r9456 r10744 26 26 using HeuristicLab.Problems.VehicleRouting.ProblemInstances; 27 27 using HeuristicLab.Problems.VehicleRouting.Variants; 28 using HeuristicLab.Problems.VehicleRouting.Interfaces; 28 29 29 30 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin { … … 44 45 } 45 46 46 private PotvinEncoding ReplacePair(PotvinEncoding individual, int replaced, int replacing, bool allowInfeasible) {47 private static PotvinEncoding ReplacePair(PotvinEncoding individual, IVRPProblemInstance instance, int replaced, int replacing, bool allowInfeasible) { 47 48 individual = individual.Clone() as PotvinEncoding; 48 IPickupAndDeliveryProblemInstance pdp = ProblemInstance as IPickupAndDeliveryProblemInstance;49 IPickupAndDeliveryProblemInstance pdp = instance as IPickupAndDeliveryProblemInstance; 49 50 50 51 int replacedDest = pdp.GetPickupDeliveryLocation(replaced); … … 76 77 77 78 replacedSourceTour.Stops[replacedSourceTour.Stops.IndexOf(replacedSource)] = replacingSource; 78 if (!allowInfeasible && ! ProblemInstance.TourFeasible(replacedSourceTour, individual))79 if (!allowInfeasible && !instance.TourFeasible(replacedSourceTour, individual)) 79 80 return null; 80 81 81 82 replacedTargetTour.Stops[replacedTargetTour.Stops.IndexOf(replacedTarget)] = replacingTarget; 82 if (!allowInfeasible && ! ProblemInstance.TourFeasible(replacedTargetTour, individual))83 if (!allowInfeasible && !instance.TourFeasible(replacedTargetTour, individual)) 83 84 return null; 84 85 … … 93 94 if (tourIdx != routeToAvoid) { 94 95 Tour tour = individual.Tours[tourIdx]; 95 VRPEvaluation eval = ProblemInstance.EvaluateTour(tour, individual);96 individual.InsertPair(tour, replacedSource, replacedTarget, ProblemInstance);97 VRPEvaluation evalNew = ProblemInstance.EvaluateTour(tour, individual);96 VRPEvaluation eval = instance.EvaluateTour(tour, individual); 97 individual.InsertPair(tour, replacedSource, replacedTarget, instance); 98 VRPEvaluation evalNew = instance.EvaluateTour(tour, individual); 98 99 99 100 double delta = evalNew.Quality - eval.Quality; 100 101 101 102 if (delta < bestQuality && 102 ( ProblemInstance.Feasible(evalNew) || allowInfeasible)) {103 (instance.Feasible(evalNew) || allowInfeasible)) { 103 104 bestQuality = delta; 104 105 bestTour = tourIdx; … … 127 128 } 128 129 130 public static PotvinEncoding ApplyManipulation(IRandom random, PotvinEncoding individual, IPickupAndDeliveryProblemInstance pdp, bool allowInfeasible) { 131 PotvinEncoding result = null; 132 133 int selectedIndex = SelectRandomTourBiasedByLength(random, individual, pdp); 134 if (selectedIndex >= 0) { 135 bool performed = false; 136 Tour route1 = individual.Tours[selectedIndex]; 137 138 if (route1.Stops.Count > 0) { 139 //randomize customer selection 140 Permutation perm = new Permutation(PermutationTypes.Absolute, route1.Stops.Count, random); 141 int customer1Position = 0; 142 143 while (customer1Position < route1.Stops.Count) { 144 performed = false; 145 146 int customer1 = route1.Stops[perm[customer1Position]]; 147 int customer2 = -1; 148 149 for (int i = 0; i < individual.Tours.Count; i++) { 150 if (i != selectedIndex) { 151 Tour tour = individual.Tours[i]; 152 for (int customer2Position = 0; customer2Position < tour.Stops.Count; customer2Position++) { 153 customer2 = tour.Stops[customer2Position]; 154 155 if (pdp.GetPickupDeliveryLocation(customer1) != customer2) { 156 result = ReplacePair(individual, pdp, customer2, customer1, allowInfeasible); 157 if (result != null) { 158 individual = result; 159 160 route1 = individual.Tours[selectedIndex]; 161 performed = true; 162 break; 163 } 164 } 165 } 166 } 167 168 if (performed) { 169 break; 170 } 171 } 172 173 if (!performed) 174 customer1Position++; 175 else 176 break; 177 } 178 } 179 } 180 181 return result; 182 } 183 129 184 protected override void Manipulate(IRandom random, PotvinEncoding individual) { 130 185 bool allowInfeasible = AllowInfeasibleSolutions.Value.Value; … … 132 187 133 188 if (pdp != null) { 134 int selectedIndex = SelectRandomTourBiasedByLength(random, individual); 135 if (selectedIndex >= 0) { 136 bool performed = false; 137 Tour route1 = individual.Tours[selectedIndex]; 138 139 if (route1.Stops.Count > 0) { 140 //randomize customer selection 141 Permutation perm = new Permutation(PermutationTypes.Absolute, route1.Stops.Count, random); 142 int customer1Position = 0; 143 144 while (customer1Position < route1.Stops.Count) { 145 performed = false; 146 147 int customer1 = route1.Stops[perm[customer1Position]]; 148 int customer2 = -1; 149 150 for (int i = 0; i < individual.Tours.Count; i++) { 151 if (i != selectedIndex) { 152 Tour tour = individual.Tours[i]; 153 for (int customer2Position = 0; customer2Position < tour.Stops.Count; customer2Position++) { 154 customer2 = tour.Stops[customer2Position]; 155 156 if (pdp.GetPickupDeliveryLocation(customer1) != customer2) { 157 PotvinEncoding result = ReplacePair(individual, customer2, customer1, allowInfeasible); 158 if (result != null) { 159 VRPToursParameter.ActualValue = result; 160 individual = result; 161 162 route1 = individual.Tours[selectedIndex]; 163 performed = true; 164 break; 165 } 166 } 167 } 168 } 169 170 if (performed) { 171 break; 172 } 173 } 174 175 if (!performed) 176 customer1Position++; 177 else 178 break; 179 } 180 } 181 } 189 PotvinEncoding result = ApplyManipulation(random, individual, pdp, allowInfeasible); 190 if (result != null) { 191 VRPToursParameter.ActualValue = result; 192 } 182 193 } 183 194 } -
stable/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Manipulators/PotvinTwoLevelExchangeManipulator.cs
r9456 r10744 23 23 using HeuristicLab.Core; 24 24 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 25 using HeuristicLab.Problems.VehicleRouting.Interfaces; 25 26 26 27 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin { … … 41 42 } 42 43 43 protected override void Manipulate(IRandom random, PotvinEncoding individual) { 44 bool allowInfeasible = AllowInfeasibleSolutions.Value.Value; 45 46 int selectedIndex = SelectRandomTourBiasedByLength(random, individual); 44 public static void ApplyManipulation(IRandom random, PotvinEncoding individual, IVRPProblemInstance instance, bool allowInfeasible) { 45 int selectedIndex = SelectRandomTourBiasedByLength(random, individual, instance); 47 46 if (selectedIndex >= 0) { 48 47 Tour route1 = individual.Tours[selectedIndex]; … … 63 62 route1.Stops.RemoveAt(customer1Position); 64 63 65 if ( ProblemInstance.TourFeasible(tour, individual)) {64 if (instance.TourFeasible(tour, individual)) { 66 65 int routeIdx, place; 67 66 if (FindInsertionPlace(individual, … … 92 91 } 93 92 } 93 94 95 protected override void Manipulate(IRandom random, PotvinEncoding individual) { 96 bool allowInfeasible = AllowInfeasibleSolutions.Value.Value; 97 98 ApplyManipulation(random, individual, ProblemInstance, allowInfeasible); 99 } 94 100 } 95 101 } -
stable/HeuristicLab.Problems.VehicleRouting/3.4/VehicleRoutingProblem.cs
r10648 r10744 39 39 40 40 namespace HeuristicLab.Problems.VehicleRouting { 41 public interface IVRPInstanceConsumer :42 IProblemInstanceConsumer<CVRPData>, IProblemInstanceConsumer<CVRPTWData>,43 IProblemInstanceConsumer<MDCVRPData>, IProblemInstanceConsumer<MDCVRPTWData>,44 IProblemInstanceConsumer<PDPTWData> {45 }46 47 41 [Item("Vehicle Routing Problem", "Represents a Vehicle Routing Problem.")] 48 42 [Creatable("Problems")] 49 43 [StorableClass] 50 public sealed class VehicleRoutingProblem : Problem, ISingleObjectiveHeuristicOptimizationProblem, IStorableContent, I VRPInstanceConsumer{44 public sealed class VehicleRoutingProblem : Problem, ISingleObjectiveHeuristicOptimizationProblem, IStorableContent, IProblemInstanceConsumer<VRPData> { 51 45 public string Filename { get; set; } 52 46 … … 390 384 } 391 385 } 392 393 public void Load(CVRPData data) { 394 Load(data, new CVRPInterpreter()); 395 } 396 397 public void Load(CVRPTWData data) { 398 Load(data, new CVRPTWInterpreter()); 399 } 400 401 public void Load(MDCVRPData data) { 402 Load(data, new MDCVRPInterpreter()); 403 } 404 405 public void Load(MDCVRPTWData data) { 406 Load(data, new MDCVRPTWInterpreter()); 407 } 408 409 public void Load(PDPTWData data) { 410 Load(data, new PDPTWInterpreter()); 386 #endregion 387 388 #region IProblemInstanceConsumer<VRPData> Members 389 390 public void Load(VRPData data) { 391 var interpreterDataType = data.GetType(); 392 var interpreterType = typeof(IVRPDataInterpreter<>).MakeGenericType(interpreterDataType); 393 394 var interpreters = ApplicationManager.Manager.GetTypes(interpreterType); 395 396 var concreteInterpreter = interpreters.Single(t => GetInterpreterDataType(t) == interpreterDataType); 397 398 Load(data, (IVRPDataInterpreter)Activator.CreateInstance(concreteInterpreter)); 399 } 400 401 private Type GetInterpreterDataType(Type type) { 402 var parentInterfaces = type.BaseType.GetInterfaces(); 403 var interfaces = type.GetInterfaces().Except(parentInterfaces); 404 405 var interpreterInterface = interfaces.Single(i => typeof(IVRPDataInterpreter).IsAssignableFrom(i)); 406 return interpreterInterface.GetGenericArguments()[0]; 411 407 } 412 408 -
stable/HeuristicLab.Tests
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Tests merged: 10652
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Tests/HeuristicLab.Tests.csproj
r10743 r10744 464 464 <Compile Include="HeuristicLab.Problems.TravelingSalesman-3.3\TSPMoveEvaluatorTest.cs" /> 465 465 <Compile Include="HeuristicLab.Problems.LinearAssignment-3.3\LinearAssignmentProblemSolverTest.cs" /> 466 <Compile Include="HeuristicLab.Problems.VehicleRouting-3.4\VRPInstancesTest.cs" /> 466 467 <Compile Include="HeuristicLab.Random-3.3\RandomEnumerableSampleTest.cs" /> 467 468 <Compile Include="Properties\AssemblyInfo.cs" />
Note: See TracChangeset
for help on using the changeset viewer.