- Timestamp:
- 02/20/14 14:56:39 (11 years ago)
- Location:
- branches/LogResidualEvaluator
- Files:
-
- 54 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/LogResidualEvaluator
- Property svn:mergeinfo changed
-
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting
- Property svn:mergeinfo changed
-
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Creators/AlbaCreator.cs
r9456 r10483 45 45 } 46 46 47 public override IOperation Apply() {47 public override IOperation InstrumentedApply() { 48 48 (VRPToursParameter.ActualValue as AlbaEncoding).Repair(); 49 49 50 return base. Apply();50 return base.InstrumentedApply(); 51 51 } 52 52 } -
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Creators/RandomCreator.cs
r9456 r10483 86 86 } 87 87 88 public override IOperation Apply() {88 public override IOperation InstrumentedApply() { 89 89 //choose default encoding here 90 90 VRPToursParameter.ActualValue = AlbaEncoding.ConvertFrom(CreateSolution(), ProblemInstance); 91 91 92 return base. Apply();92 return base.InstrumentedApply(); 93 93 } 94 94 } -
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Crossovers/AlbaCrossover.cs
r9456 r10483 52 52 protected abstract AlbaEncoding Crossover(IRandom random, AlbaEncoding parent1, AlbaEncoding parent2); 53 53 54 public override IOperation Apply() {54 public override IOperation InstrumentedApply() { 55 55 ItemArray<IVRPEncoding> parents = new ItemArray<IVRPEncoding>(ParentsParameter.ActualValue.Length); 56 56 for (int i = 0; i < ParentsParameter.ActualValue.Length; i++) { … … 69 69 (ChildParameter.ActualValue as AlbaEncoding).Repair(); 70 70 71 return base. Apply();71 return base.InstrumentedApply(); 72 72 } 73 73 } -
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/LocalImprovement/AlbaLambdaInterchangeLocalImprovementOperator.cs
r9462 r10483 125 125 } 126 126 127 public override IOperation Apply() {127 public override IOperation InstrumentedApply() { 128 128 int maxIterations = MaximumIterationsParameter.ActualValue.Value; 129 129 AlbaEncoding solution = null; … … 146 146 QualityParameter.ActualValue.Value = quality; 147 147 148 return base. Apply();148 return base.InstrumentedApply(); 149 149 } 150 150 } -
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Manipulators/AlbaManipulator.cs
r9456 r10483 62 62 } 63 63 64 public override IOperation Apply() {64 public override IOperation InstrumentedApply() { 65 65 IVRPEncoding solution = VRPToursParameter.ActualValue; 66 66 if (!(solution is AlbaEncoding)) { … … 71 71 (VRPToursParameter.ActualValue as AlbaEncoding).Repair(); 72 72 73 return base. Apply();73 return base.InstrumentedApply(); 74 74 } 75 75 } -
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Moves/AlbaMoveGenerator.cs
r9456 r10483 41 41 } 42 42 43 public override IOperation Apply() {43 public override IOperation InstrumentedApply() { 44 44 IVRPEncoding solution = VRPToursParameter.ActualValue; 45 45 if (!(solution is AlbaEncoding)) { … … 47 47 } 48 48 49 return base. Apply();49 return base.InstrumentedApply(); 50 50 } 51 51 } -
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Moves/IntraRouteInversion/AlbaIntraRouteInversionMoveGenerator.cs
r9456 r10483 58 58 protected abstract AlbaIntraRouteInversionMove[] GenerateMoves(AlbaEncoding individual, IVRPProblemInstance problemInstance); 59 59 60 public override IOperation Apply() {61 IOperation next = base. Apply();60 public override IOperation InstrumentedApply() { 61 IOperation next = base.InstrumentedApply(); 62 62 63 63 AlbaEncoding individual = VRPToursParameter.ActualValue as AlbaEncoding; -
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Moves/LambdaInterchange/AlbaLambdaInterchangeMoveGenerator.cs
r9456 r10483 68 68 protected abstract AlbaLambdaInterchangeMove[] GenerateMoves(AlbaEncoding individual, IVRPProblemInstance problemInstance, int lambda); 69 69 70 public override IOperation Apply() {71 IOperation next = base. Apply();70 public override IOperation InstrumentedApply() { 71 IOperation next = base.InstrumentedApply(); 72 72 73 73 AlbaEncoding individual = VRPToursParameter.ActualValue as AlbaEncoding; -
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Moves/ThreeOpt/AlbaStochasticTranslocationSingleMoveGenerator.cs
r9456 r10483 69 69 } 70 70 71 public override IOperation Apply() {72 IOperation next = base. Apply();71 public override IOperation InstrumentedApply() { 72 IOperation next = base.InstrumentedApply(); 73 73 74 74 IVRPEncoding solution = VRPToursParameter.ActualValue; -
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Moves/ThreeOpt/AlbaTranslocationMoveGenerator.cs
r9456 r10483 93 93 } 94 94 95 public override IOperation Apply() {96 IOperation next = base. Apply();95 public override IOperation InstrumentedApply() { 96 IOperation next = base.InstrumentedApply(); 97 97 98 98 IVRPEncoding solution = VRPToursParameter.ActualValue; -
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Moves/ThreeOpt/AlbaTranslocationMoveHardTabuCriterion.cs
r9456 r10483 81 81 } 82 82 83 public override IOperation Apply() {84 IOperation next = base. Apply();83 public override IOperation InstrumentedApply() { 84 IOperation next = base.InstrumentedApply(); 85 85 86 86 IVRPEncoding solution = VRPToursParameter.ActualValue; -
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Moves/ThreeOpt/AlbaTranslocationMoveSoftTabuCriterion.cs
r9456 r10483 81 81 } 82 82 83 public override IOperation Apply() {84 IOperation next = base. Apply();83 public override IOperation InstrumentedApply() { 84 IOperation next = base.InstrumentedApply(); 85 85 86 86 IVRPEncoding solution = VRPToursParameter.ActualValue; -
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Moves/ThreeOpt/AlbaTranslocationMoveTabuMaker.cs
r9456 r10483 81 81 } 82 82 83 public override IOperation Apply() {84 IOperation next = base. Apply();83 public override IOperation InstrumentedApply() { 84 IOperation next = base.InstrumentedApply(); 85 85 86 86 IVRPEncoding solution = VRPToursParameter.ActualValue; -
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/GVR/Crossovers/GVRCrossover.cs
r9456 r10483 103 103 } 104 104 105 public override IOperation Apply() {105 public override IOperation InstrumentedApply() { 106 106 ItemArray<IVRPEncoding> parents = new ItemArray<IVRPEncoding>(ParentsParameter.ActualValue.Length); 107 107 for (int i = 0; i < ParentsParameter.ActualValue.Length; i++) { … … 117 117 ChildParameter.ActualValue = Crossover(RandomParameter.ActualValue, parents[0] as GVREncoding, parents[1] as GVREncoding); 118 118 119 return base. Apply();119 return base.InstrumentedApply(); 120 120 } 121 121 } -
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/GVR/Manipulators/GVRManipulator.cs
r9456 r10483 49 49 protected abstract void Manipulate(IRandom random, GVREncoding individual); 50 50 51 public override IOperation Apply() {51 public override IOperation InstrumentedApply() { 52 52 IVRPEncoding solution = VRPToursParameter.ActualValue; 53 53 if (!(solution is GVREncoding)) { … … 57 57 Manipulate(RandomParameter.ActualValue, VRPToursParameter.ActualValue as GVREncoding); 58 58 59 return base. Apply();59 return base.InstrumentedApply(); 60 60 } 61 61 } -
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/General/Creators/MultiVRPSolutionCreator.cs
r9456 r10483 97 97 } 98 98 99 public override IOperation Apply() {99 public override IOperation InstrumentedApply() { 100 100 if (Operators.Count == 0) throw new InvalidOperationException(Name + ": Please add at least one VRP creator to choose from."); 101 return base. Apply();101 return base.InstrumentedApply(); 102 102 } 103 103 } -
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/General/Crossovers/BiasedMultiVRPSolutionCrossover.cs
r9462 r10483 21 21 22 22 using System; 23 using System.Collections.Generic;24 23 using System.Linq; 25 using System.Text; 24 using HeuristicLab.Analysis; 25 using HeuristicLab.Collections; 26 using HeuristicLab.Common; 26 27 using HeuristicLab.Core; 28 using HeuristicLab.Data; 29 using HeuristicLab.Optimization; 30 using HeuristicLab.Parameters; 27 31 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 using HeuristicLab.Common; 29 using HeuristicLab.Analysis; 30 using HeuristicLab.Parameters; 31 using HeuristicLab.Optimization; 32 using HeuristicLab.Data; 33 using HeuristicLab.Collections; 32 using HeuristicLab.Random; 34 33 35 34 namespace HeuristicLab.Problems.VehicleRouting.Encodings.General { … … 69 68 Parameters.Add(new ValueParameter<DoubleValue>("LowerBound", "The depth of the individuals in the scope tree.", new DoubleValue(0.01))); 70 69 Parameters.Add(new ValueParameter<IntValue>("Depth", "The depth of the individuals in the scope tree.", new IntValue(1))); 70 71 SelectedOperatorParameter.ActualName = "SelectedCrossoverOperator"; 71 72 } 72 73 … … 81 82 } 82 83 83 public override IOperation Apply() {84 public override IOperation InstrumentedApply() { 84 85 IOperator successor = null; 85 86 … … 133 134 } 134 135 135 //////////////// 136 //////////////// code has to be duplicated since ActualProbabilitiesParameter.ActualValue are updated and used for operator selection 136 137 IRandom random = RandomParameter.ActualValue; 137 138 DoubleArray probabilities = ActualProbabilitiesParameter.ActualValue; … … 142 143 if (checkedOperators.Count() > 0) { 143 144 // select a random operator from the checked operators 144 double sum = (from indexedItem in checkedOperators select probabilities[indexedItem.Index]).Sum(); 145 if (sum == 0) throw new InvalidOperationException(Name + ": All selected operators have zero probability."); 146 double r = random.NextDouble() * sum; 147 sum = 0; 148 foreach (var indexedItem in checkedOperators) { 149 sum += probabilities[indexedItem.Index]; 150 if (sum > r) { 151 successor = indexedItem.Value; 152 break; 153 } 154 } 145 successor = checkedOperators.SampleProportional(random, 1, probabilities, false, false).First().Value; 155 146 } 156 147 -
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/General/Crossovers/MultiVRPSolutionCrossover.cs
r9456 r10483 67 67 Parameters.Add(new LookupParameter<IVRPEncoding>("Child", "The child permutation resulting from the crossover.")); 68 68 ChildParameter.ActualName = "VRPTours"; 69 70 SelectedOperatorParameter.ActualName = "SelectedCrossoverOperator"; 69 71 } 70 72 … … 106 108 } 107 109 108 public override IOperation Apply() {110 public override IOperation InstrumentedApply() { 109 111 if (Operators.Count == 0) throw new InvalidOperationException(Name + ": Please add at least one permutation crossover to choose from."); 110 return base. Apply();112 return base.InstrumentedApply(); 111 113 } 112 114 } -
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/General/Crossovers/RandomParentCloneCrossover.cs
r9456 r10483 65 65 } 66 66 67 public override IOperation Apply() {67 public override IOperation InstrumentedApply() { 68 68 if (RandomParameter.ActualValue.Next() < 0.5) 69 69 ChildParameter.ActualValue = ParentsParameter.ActualValue[0].Clone() as IVRPEncoding; … … 71 71 ChildParameter.ActualValue = ParentsParameter.ActualValue[1].Clone() as IVRPEncoding; 72 72 73 return base. Apply();73 return base.InstrumentedApply(); 74 74 } 75 75 } -
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/General/Manipulators/BiasedMultiVRPSolutionManipulator.cs
r9462 r10483 21 21 22 22 using System; 23 using System.Collections.Generic;24 23 using System.Linq; 25 using System.Text; 24 using HeuristicLab.Analysis; 25 using HeuristicLab.Collections; 26 using HeuristicLab.Common; 26 27 using HeuristicLab.Core; 28 using HeuristicLab.Data; 29 using HeuristicLab.Optimization; 30 using HeuristicLab.Parameters; 27 31 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 using HeuristicLab.Common; 29 using HeuristicLab.Analysis; 30 using HeuristicLab.Parameters; 31 using HeuristicLab.Optimization; 32 using HeuristicLab.Data; 33 using HeuristicLab.Collections; 32 using HeuristicLab.Random; 34 33 35 34 namespace HeuristicLab.Problems.VehicleRouting.Encodings.General { … … 40 39 get { return (ValueLookupParameter<DoubleArray>)Parameters["ActualProbabilities"]; } 41 40 } 42 41 43 42 public ValueLookupParameter<StringValue> SuccessProgressAnalyisis { 44 43 get { return (ValueLookupParameter<StringValue>)Parameters["SuccessProgressAnalysis"]; } … … 63 62 : base() { 64 63 Parameters.Add(new ValueLookupParameter<DoubleArray>("ActualProbabilities", "The array of relative probabilities for each operator.")); 65 Parameters.Add(new ValueLookupParameter<StringValue>("SuccessProgressAnalysis", "The success progress analyisis to be considered", 64 Parameters.Add(new ValueLookupParameter<StringValue>("SuccessProgressAnalysis", "The success progress analyisis to be considered", 66 65 new StringValue("ExecutedMutationOperator"))); 67 66 … … 69 68 Parameters.Add(new ValueParameter<DoubleValue>("LowerBound", "The depth of the individuals in the scope tree.", new DoubleValue(0.01))); 70 69 Parameters.Add(new ValueParameter<IntValue>("Depth", "The depth of the individuals in the scope tree.", new IntValue(1))); 70 71 SelectedOperatorParameter.ActualName = "SelectedManipulationOperator"; 71 72 } 72 73 … … 81 82 } 82 83 83 public override IOperation Apply() {84 public override IOperation InstrumentedApply() { 84 85 IOperator successor = null; 85 86 … … 133 134 } 134 135 135 //////////////// 136 //////////////// code has to be duplicated since ActualProbabilitiesParameter.ActualValue are updated and used for operator selection 136 137 IRandom random = RandomParameter.ActualValue; 137 138 DoubleArray probabilities = ActualProbabilitiesParameter.ActualValue; … … 142 143 if (checkedOperators.Count() > 0) { 143 144 // select a random operator from the checked operators 144 double sum = (from indexedItem in checkedOperators select probabilities[indexedItem.Index]).Sum(); 145 if (sum == 0) throw new InvalidOperationException(Name + ": All selected operators have zero probability."); 146 double r = random.NextDouble() * sum; 147 sum = 0; 148 foreach (var indexedItem in checkedOperators) { 149 sum += probabilities[indexedItem.Index]; 150 if (sum > r) { 151 successor = indexedItem.Value; 152 break; 153 } 154 } 145 successor = 146 checkedOperators.SampleProportional(random, 1, probabilities, false, false).First().Value; 155 147 } 156 148 -
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/General/Manipulators/MultiVRPSolutionManipulator.cs
r9456 r10483 59 59 Parameters.Add(new LookupParameter<IVRPProblemInstance>("ProblemInstance", "The VRP problem instance")); 60 60 Parameters.Add(new LookupParameter<IVRPEncoding>("VRPTours", "The VRP tours to be manipulated.")); 61 62 SelectedOperatorParameter.ActualName = "SelectedManipulationOperator"; 61 63 } 62 64 … … 97 99 } 98 100 99 public override IOperation Apply() {101 public override IOperation InstrumentedApply() { 100 102 if (Operators.Count == 0) throw new InvalidOperationException(Name + ": Please add at least one permutation manipulator to choose from."); 101 return base. Apply();103 return base.InstrumentedApply(); 102 104 } 103 105 } -
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/General/Moves/MultiVRPMoveOperator/MultiVRPMoveEvaluator.cs
r9456 r10483 53 53 protected override void EvaluateMove() { } 54 54 55 public override IOperation Apply() {55 public override IOperation InstrumentedApply() { 56 56 IVRPMove move = VRPMoveParameter.ActualValue as IVRPMove; 57 57 … … 59 59 moveEvaluator.VRPMoveParameter.ActualName = VRPMoveParameter.Name; 60 60 61 OperationCollection next = new OperationCollection(base. Apply());61 OperationCollection next = new OperationCollection(base.InstrumentedApply()); 62 62 next.Insert(0, ExecutionContext.CreateOperation(moveEvaluator)); 63 63 -
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/General/Moves/MultiVRPMoveOperator/MultiVRPMoveGenerator.cs
r9456 r10483 153 153 } 154 154 155 public override IOperation Apply() {155 public override IOperation InstrumentedApply() { 156 156 if (Operators.Count == 0) throw new InvalidOperationException(Name + ": Please add at least one VRP move generator choose from."); 157 OperationCollection next = new OperationCollection(base. Apply());157 OperationCollection next = new OperationCollection(base.InstrumentedApply()); 158 158 159 159 for (int i = 0; i < SelectedOperatorsParameter.ActualValue.Value; i++) { -
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/General/Moves/VRPMoveEvaluator.cs
r9456 r10483 76 76 protected abstract void EvaluateMove(); 77 77 78 public override IOperation Apply() {78 public override IOperation InstrumentedApply() { 79 79 EvaluateMove(); 80 80 81 return base. Apply();81 return base.InstrumentedApply(); 82 82 } 83 83 } -
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/General/Moves/VRPMoveMaker.cs
r9456 r10483 99 99 } 100 100 101 public override IOperation Apply() {101 public override IOperation InstrumentedApply() { 102 102 PerformMove(); 103 103 UpdateMoveEvaluation(); 104 104 105 return base. Apply();105 return base.InstrumentedApply(); 106 106 } 107 107 } -
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Creators/IterativeInsertionCreator.cs
r9456 r10483 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(); … … 140 140 } 141 141 142 public override IOperation Apply() {142 public override IOperation InstrumentedApply() { 143 143 VRPToursParameter.ActualValue = CreateSolution(ProblemInstance, RandomParameter.ActualValue, AdhereTimeWindowsParameter.Value.Value); 144 144 145 return base. Apply();145 return base.InstrumentedApply(); 146 146 } 147 147 } -
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Creators/PushForwardInsertionCreator.cs
r9456 r10483 373 373 } 374 374 375 public override IOperation Apply() {375 public override IOperation InstrumentedApply() { 376 376 VRPToursParameter.ActualValue = CreateSolution(ProblemInstance, RandomParameter.ActualValue, 377 377 Alpha.Value.Value, Beta.Value.Value, Gamma.Value.Value, 378 378 AlphaVariance.Value.Value, BetaVariance.Value.Value, GammaVariance.Value.Value); 379 379 380 return base. Apply();380 return base.InstrumentedApply(); 381 381 } 382 382 } -
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Crossovers/PotvinCrossover.cs
r9456 r10483 144 144 } 145 145 146 public override IOperation Apply() {146 public override IOperation InstrumentedApply() { 147 147 ItemArray<IVRPEncoding> parents = new ItemArray<IVRPEncoding>(ParentsParameter.ActualValue.Length); 148 148 for (int i = 0; i < ParentsParameter.ActualValue.Length; i++) { … … 160 160 (ChildParameter.ActualValue as PotvinEncoding).Repair(); 161 161 162 return base. Apply();162 return base.InstrumentedApply(); 163 163 } 164 164 } -
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Manipulators/PotvinLocalSearchManipulator.cs
r9456 r10483 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 } -
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Manipulators/PotvinManipulator.cs
r9456 r10483 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); 87 87 } 88 88 89 public override IOperation Apply() {89 public override IOperation InstrumentedApply() { 90 90 IVRPEncoding solution = VRPToursParameter.ActualValue; 91 91 if (!(solution is PotvinEncoding)) { … … 96 96 (VRPToursParameter.ActualValue as PotvinEncoding).Repair(); 97 97 98 return base. Apply();98 return base.InstrumentedApply(); 99 99 } 100 100 } -
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Manipulators/PotvinOneLevelExchangeManipulator.cs
r9456 r10483 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 } -
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Manipulators/PotvinPairwiseOneLevelExchangeManipulator.cs
r9456 r10483 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 } -
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Manipulators/PotvinPairwiseTwoLevelExchangeManipulator.cs
r9456 r10483 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 } -
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Manipulators/PotvinTwoLevelExchangeManipulator.cs
r9456 r10483 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 } -
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Manipulators/PotvinVehicleAssignmentManipulator.cs
r9456 r10483 60 60 } 61 61 62 public override IOperation Apply() {62 public override IOperation InstrumentedApply() { 63 63 IVRPEncoding solution = VRPToursParameter.ActualValue; 64 64 if (!(solution is PotvinEncoding)) { … … 66 66 } 67 67 68 OperationCollection next = new OperationCollection(base. Apply());68 OperationCollection next = new OperationCollection(base.InstrumentedApply()); 69 69 70 70 VehicleAssignmentParameter.ActualValue = (VRPToursParameter.ActualValue as PotvinEncoding).VehicleAssignment; -
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Moves/CustomerRelocation/PotvinCustomerRelocationMoveGenerator.cs
r9456 r10483 57 57 protected abstract PotvinCustomerRelocationMove[] GenerateMoves(PotvinEncoding individual, IVRPProblemInstance problemInstance); 58 58 59 public override IOperation Apply() {60 IOperation next = base. Apply();59 public override IOperation InstrumentedApply() { 60 IOperation next = base.InstrumentedApply(); 61 61 62 62 PotvinEncoding individual = VRPToursParameter.ActualValue as PotvinEncoding; -
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Moves/PickupDelivery/PDExchange/PotvinPDExchangeMoveGenerator.cs
r9456 r10483 57 57 protected abstract PotvinPDExchangeMove[] GenerateMoves(PotvinEncoding individual, IVRPProblemInstance problemInstance); 58 58 59 public override IOperation Apply() {60 IOperation next = base. Apply();59 public override IOperation InstrumentedApply() { 60 IOperation next = base.InstrumentedApply(); 61 61 62 62 PotvinEncoding individual = VRPToursParameter.ActualValue as PotvinEncoding; -
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Moves/PickupDelivery/PDRearrange/PotvinPDRearrangeMoveGenerator.cs
r9456 r10483 57 57 protected abstract PotvinPDRearrangeMove[] GenerateMoves(PotvinEncoding individual, IVRPProblemInstance problemInstance); 58 58 59 public override IOperation Apply() {60 IOperation next = base. Apply();59 public override IOperation InstrumentedApply() { 60 IOperation next = base.InstrumentedApply(); 61 61 62 62 PotvinEncoding individual = VRPToursParameter.ActualValue as PotvinEncoding; -
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Moves/PickupDelivery/PDShift/PotvinPDShiftMoveGenerator.cs
r9456 r10483 57 57 protected abstract PotvinPDShiftMove[] GenerateMoves(PotvinEncoding individual, IVRPProblemInstance problemInstance); 58 58 59 public override IOperation Apply() {60 IOperation next = base. Apply();59 public override IOperation InstrumentedApply() { 60 IOperation next = base.InstrumentedApply(); 61 61 62 62 PotvinEncoding individual = VRPToursParameter.ActualValue as PotvinEncoding; -
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Moves/PotvinMoveGenerator.cs
r9456 r10483 41 41 } 42 42 43 public override IOperation Apply() {43 public override IOperation InstrumentedApply() { 44 44 IVRPEncoding solution = VRPToursParameter.ActualValue; 45 45 if (!(solution is PotvinEncoding)) { … … 47 47 } 48 48 49 return base. Apply();49 return base.InstrumentedApply(); 50 50 } 51 51 } -
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Moves/TwoOptStar/PotvinTwoOptStarMoveGenerator.cs
r9456 r10483 57 57 protected abstract PotvinTwoOptStarMove[] GenerateMoves(PotvinEncoding individual, IVRPProblemInstance problemInstance); 58 58 59 public override IOperation Apply() {60 IOperation next = base. Apply();59 public override IOperation InstrumentedApply() { 60 IOperation next = base.InstrumentedApply(); 61 61 62 62 PotvinEncoding individual = VRPToursParameter.ActualValue as PotvinEncoding; -
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Moves/VehicleAssignment/PotvinVehicleAssignmentMoveGenerator.cs
r9456 r10483 57 57 protected abstract PotvinVehicleAssignmentMove[] GenerateMoves(PotvinEncoding individual, IVRPProblemInstance problemInstance); 58 58 59 public override IOperation Apply() {60 IOperation next = base. Apply();59 public override IOperation InstrumentedApply() { 60 IOperation next = base.InstrumentedApply(); 61 61 62 62 PotvinEncoding individual = VRPToursParameter.ActualValue as PotvinEncoding; -
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Prins/Crossovers/PrinsCrossover.cs
r9456 r10483 51 51 protected abstract PrinsEncoding Crossover(IRandom random, PrinsEncoding parent1, PrinsEncoding parent2); 52 52 53 public override IOperation Apply() {53 public override IOperation InstrumentedApply() { 54 54 ItemArray<IVRPEncoding> parents = new ItemArray<IVRPEncoding>(ParentsParameter.ActualValue.Length); 55 55 for (int i = 0; i < ParentsParameter.ActualValue.Length; i++) { … … 67 67 Crossover(RandomParameter.ActualValue, parents[0] as PrinsEncoding, parents[1] as PrinsEncoding); 68 68 69 return base. Apply();69 return base.InstrumentedApply(); 70 70 } 71 71 } -
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Prins/Manipulators/PrinsManipulator.cs
r9456 r10483 50 50 protected abstract void Manipulate(IRandom random, PrinsEncoding individual); 51 51 52 public override IOperation Apply() {52 public override IOperation InstrumentedApply() { 53 53 IVRPEncoding solution = VRPToursParameter.ActualValue; 54 54 if (!(solution is PrinsEncoding)) { … … 58 58 Manipulate(RandomParameter.ActualValue, VRPToursParameter.ActualValue as PrinsEncoding); 59 59 60 return base. Apply();60 return base.InstrumentedApply(); 61 61 } 62 62 } -
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/VRPOperator.cs
r9456 r10483 30 30 [Item("VRPOperator", "Represents a VRP operator.")] 31 31 [StorableClass] 32 public abstract class VRPOperator : SingleSuccessorOperator, IVRPOperator {32 public abstract class VRPOperator : InstrumentedOperator, IVRPOperator { 33 33 public ILookupParameter<IVRPProblemInstance> ProblemInstanceParameter { 34 34 get { return (LookupParameter<IVRPProblemInstance>)Parameters["ProblemInstance"]; } -
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Zhu/Crossovers/ZhuCrossover.cs
r9456 r10483 50 50 protected abstract ZhuEncoding Crossover(IRandom random, ZhuEncoding parent1, ZhuEncoding parent2); 51 51 52 public override IOperation Apply() {52 public override IOperation InstrumentedApply() { 53 53 ItemArray<IVRPEncoding> parents = new ItemArray<IVRPEncoding>(ParentsParameter.ActualValue.Length); 54 54 for (int i = 0; i < ParentsParameter.ActualValue.Length; i++) { … … 66 66 Crossover(RandomParameter.ActualValue, parents[0] as ZhuEncoding, parents[1] as ZhuEncoding); 67 67 68 return base. Apply();68 return base.InstrumentedApply(); 69 69 } 70 70 } -
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Zhu/Manipulators/ZhuManipulator.cs
r9456 r10483 50 50 protected abstract void Manipulate(IRandom random, ZhuEncoding individual); 51 51 52 public override IOperation Apply() {52 public override IOperation InstrumentedApply() { 53 53 IVRPEncoding solution = VRPToursParameter.ActualValue; 54 54 if (!(solution is ZhuEncoding)) { … … 58 58 Manipulate(RandomParameter.ActualValue, VRPToursParameter.ActualValue as ZhuEncoding); 59 59 60 return base. Apply();60 return base.InstrumentedApply(); 61 61 } 62 62 } -
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/HeuristicLab.Problems.VehicleRouting-3.4.csproj
r8894 r10483 465 465 <Private>False</Private> 466 466 </ProjectReference> 467 <ProjectReference Include="..\..\HeuristicLab.Random\3.3\HeuristicLab.Random-3.3.csproj"> 468 <Project>{F4539FB6-4708-40C9-BE64-0A1390AEA197}</Project> 469 <Name>HeuristicLab.Random-3.3</Name> 470 </ProjectReference> 467 471 </ItemGroup> 468 472 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> -
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/Improver/VRPImprovementOperator.cs
r9456 r10483 75 75 } 76 76 77 public override IOperation Apply() {77 public override IOperation InstrumentedApply() { 78 78 var solution = SolutionParameter.ActualValue as IVRPEncoding; 79 79 var potvinSolution = solution is PotvinEncoding ? solution as PotvinEncoding : PotvinEncoding.ConvertFrom(solution, ProblemInstance); … … 87 87 LocalEvaluatedSolutions.ActualValue = new IntValue(evaluatedSolutions); 88 88 89 return base. Apply();89 return base.InstrumentedApply(); 90 90 } 91 91 -
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/Plugin.cs.frame
r10037 r10483 41 41 [PluginDependency("HeuristicLab.Persistence", "3.3")] 42 42 [PluginDependency("HeuristicLab.Problems.Instances", "3.3")] 43 [PluginDependency("HeuristicLab.Random", "3.3")] 43 44 public class HeuristicLabProblemsVehicleRoutingPlugin : PluginBase { 44 45 } -
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/VRPEvaluator.cs
r9456 r10483 128 128 } 129 129 130 public override IOperation Apply() {130 public override IOperation InstrumentedApply() { 131 131 InitResultParameters(); 132 132 … … 140 140 QualityParameter.ActualValue = new DoubleValue(evaluation.Quality); 141 141 142 return base. Apply();142 return base.InstrumentedApply(); 143 143 } 144 144 -
branches/LogResidualEvaluator/HeuristicLab.Problems.VehicleRouting/3.4/VehicleRoutingProblem.cs
r9456 r10483 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 … … 143 137 AttachEventHandlers(); 144 138 AttachProblemInstanceEventHandlers(); 139 140 EvaluatorParameter.Value = ProblemInstance.SolutionEvaluator; 145 141 } 146 142 … … 153 149 : base(original, cloner) { 154 150 this.AttachEventHandlers(); 151 this.AttachProblemInstanceEventHandlers(); 152 153 ProblemInstance.SolutionEvaluator = EvaluatorParameter.Value; 155 154 } 156 155 … … 173 172 AttachEventHandlers(); 174 173 AttachProblemInstanceEventHandlers(); 174 175 ProblemInstance.SolutionEvaluator = EvaluatorParameter.Value; 175 176 } 176 177 … … 189 190 private void AttachProblemInstanceEventHandlers() { 190 191 if (ProblemInstance != null) { 191 EvaluatorParameter.Value = ProblemInstance.SolutionEvaluator;192 192 ProblemInstance.EvaluationChanged += new EventHandler(ProblemInstance_EvaluationChanged); 193 193 } … … 209 209 210 210 void ProblemInstance_EvaluationChanged(object sender, EventArgs e) { 211 EvaluatorParameter.Value = ProblemInstance.SolutionEvaluator;212 211 EvalBestKnownSolution(); 213 212 } … … 216 215 InitializeOperators(); 217 216 AttachProblemInstanceEventHandlers(); 217 218 EvaluatorParameter.Value = ProblemInstance.SolutionEvaluator; 218 219 219 220 OnSolutionCreatorChanged(); … … 383 384 } 384 385 } 385 386 public void Load(CVRPData data) { 387 Load(data, new CVRPInterpreter()); 388 } 389 390 public void Load(CVRPTWData data) { 391 Load(data, new CVRPTWInterpreter()); 392 } 393 394 public void Load(MDCVRPData data) { 395 Load(data, new MDCVRPInterpreter()); 396 } 397 398 public void Load(MDCVRPTWData data) { 399 Load(data, new MDCVRPTWInterpreter()); 400 } 401 402 public void Load(PDPTWData data) { 403 Load(data, new PDPTWInterpreter()); 386 #endregion 387 388 #region IProblemInstanceConsumer<VRPData> Members 389 390 public void Load(VRPData data) { 391 Type interpreterType = typeof(IVRPDataInterpreter<>).MakeGenericType(data.GetType()); 392 var interpreters = ApplicationManager.Manager.GetInstances(interpreterType); 393 IVRPDataInterpreter interpreter = null; 394 foreach (object i in interpreters) { 395 var parentInterfaces = i.GetType().BaseType.GetInterfaces(); 396 var interfaces = i.GetType().GetInterfaces().Except(parentInterfaces); 397 var interpreterInterface = interfaces.First(j => typeof(IVRPDataInterpreter).IsAssignableFrom(j)); 398 var interpreterDataType = interpreterInterface.GetGenericArguments()[0]; 399 if (interpreterDataType == data.GetType()) { 400 interpreter = i as IVRPDataInterpreter; 401 break; 402 } 403 } 404 405 if (interpreter == null) 406 throw new ArgumentException("No interpreter found for the VRP type"); 407 Load(data, interpreter); 404 408 } 405 409
Note: See TracChangeset
for help on using the changeset viewer.