- Timestamp:
- 09/10/10 13:00:54 (14 years ago)
- Location:
- branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Moves/AlbaMoveMaker.cs
r4369 r4378 39 39 : base() { 40 40 } 41 42 public override IOperation Apply() {43 IVRPEncoding solution = VRPToursParameter.ActualValue;44 if (!(solution is AlbaEncoding)) {45 //VRPToursParameter.ActualValue = AlbaEncoding.ConvertFrom(solution, VehiclesParameter.ActualValue.Value,46 // DistanceMatrixParameter);47 }48 49 return base.Apply();50 }51 41 } 52 42 } -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/PotvinEncoding.cs
r4376 r4378 99 99 for (int tour = 0; tour < Tours.Count; tour++) { 100 100 if (tour != routeToAvoid) { 101 double length = GetTourLength(Tours[tour]); 102 101 103 for (int i = 0; i <= Tours[tour].Stops.Count; i++) { 102 double length = GetTourLength(Tours[tour]);103 104 104 Tours[tour].Stops.Insert(i, city); 105 105 106 if (ProblemInstance.Feasible(Tours[tour])) { 107 double newLength = GetTourLength(Tours[tour]); 106 VRPEvaluation eval = ProblemInstance.EvaluatorParameter.Value.Evaluate( 107 ProblemInstance, Tours[tour]); 108 if (ProblemInstance.EvaluatorParameter.Value.Feasible(eval)) { 109 double newLength = eval.Distance; 108 110 109 111 double detour = newLength - length; -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/IVRPEvaluator.cs
r4369 r4378 26 26 using HeuristicLab.Core; 27 27 using HeuristicLab.Optimization; 28 using HeuristicLab.Problems.VehicleRouting.ProblemInstances; 28 29 29 30 namespace HeuristicLab.Problems.VehicleRouting.Interfaces { … … 31 32 ILookupParameter<IVRPEncoding> VRPToursParameter { get; } 32 33 33 bool Feasible(IVRPProblemInstance instance, IVRPEncoding solution); 34 bool Feasible(IVRPProblemInstance instance, Tour tour); 35 double Evaluate(IVRPProblemInstance instance, IVRPEncoding solution); 36 double Evaluate(IVRPProblemInstance instance, Tour tour); 34 VRPEvaluation Evaluate(IVRPProblemInstance instance, IVRPEncoding solution); 35 VRPEvaluation Evaluate(IVRPProblemInstance instance, Tour tour); 36 bool Feasible(VRPEvaluation evaluation); 37 37 } 38 38 } -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/SingleDepotVRP/CVRP/CVRPEvaluator.cs
r4377 r4378 73 73 eval.Quality += instance.DistanceFactor.Value * distance; 74 74 75 eval.Distance = distance;76 eval.VehicleUtilization = 1;75 eval.Distance += distance; 76 eval.VehicleUtilization += 1; 77 77 78 78 double capacity = cvrpInstance.Capacity.Value; … … 81 81 } 82 82 83 (eval as CVRPEvaluation).Overload = overweight;83 (eval as CVRPEvaluation).Overload += overweight; 84 84 double penalty = overweight * cvrpInstance.OverloadPenalty.Value; 85 85 eval.Penalty += penalty; -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/SingleDepotVRP/CVRP/CVRPTW/CVRPTWEvaluator.cs
r4377 r4378 101 101 eval.Quality += instance.FleetUsageFactor.Value; 102 102 eval.Quality += instance.DistanceFactor.Value * distance; 103 eval.Distance = distance;104 eval.VehicleUtilization = 1;103 eval.Distance += distance; 104 eval.VehicleUtilization += 1; 105 105 106 106 double capacity = cvrpInstance.Capacity.Value; … … 109 109 } 110 110 111 (eval as CVRPEvaluation).Overload = overweight;111 (eval as CVRPEvaluation).Overload += overweight; 112 112 double penalty = overweight * cvrpInstance.OverloadPenalty.Value; 113 113 eval.Penalty += penalty; 114 114 eval.Quality += penalty; 115 115 116 (eval as CVRPTWEvaluation).Tardiness = tardiness;117 (eval as CVRPTWEvaluation).TravelTime = time;116 (eval as CVRPTWEvaluation).Tardiness += tardiness; 117 (eval as CVRPTWEvaluation).TravelTime += time; 118 118 119 119 penalty = tardiness * vrptw.TardinessPenalty.Value; -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/SingleDepotVRP/SingleDepotVRPEvaluator.cs
r4363 r4378 62 62 quality += instance.DistanceFactor.Value * distance; 63 63 64 eval.Distance = distance;65 eval.VehicleUtilization = 1;64 eval.Distance += distance; 65 eval.VehicleUtilization += 1; 66 66 67 eval.Quality = quality;67 eval.Quality += quality; 68 68 } 69 69 -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/VRPEvaluator.cs
r4376 r4378 84 84 } 85 85 86 pr otectedVRPEvaluation EvaluateTour(IVRPProblemInstance instance, Tour tour) {86 private VRPEvaluation EvaluateTour(IVRPProblemInstance instance, Tour tour) { 87 87 VRPEvaluation evaluation = CreateTourEvaluation(); 88 88 EvaluateTour(evaluation, instance, tour); … … 92 92 #region IVRPEvaluator Members 93 93 94 public bool Feasible(IVRPProblemInstance instance, IVRPEncoding solution) { 95 bool feasible = true; 94 public bool Feasible(VRPEvaluation evaluation) { 95 return evaluation.Penalty < double.Epsilon; 96 } 97 98 public VRPEvaluation Evaluate(IVRPProblemInstance instance, IVRPEncoding solution) { 99 VRPEvaluation evaluation = CreateTourEvaluation(); 96 100 97 101 foreach (Tour tour in solution.GetTours()) { 98 if (!Feasible(instance, tour)) { 99 feasible = false; 100 break; 101 } 102 EvaluateTour(evaluation, instance, tour); 102 103 } 103 104 104 return feasible;105 return evaluation; 105 106 } 106 107 107 public bool Feasible(IVRPProblemInstance instance, Tour tour) { 108 return EvaluateTour(instance, tour).Penalty < double.Epsilon; 109 } 110 111 public double Evaluate(IVRPProblemInstance instance, IVRPEncoding solution) { 112 double quality = 0; 113 114 foreach (Tour tour in solution.GetTours()) { 115 quality += Evaluate(instance, tour); 116 } 117 118 return quality; 119 } 120 121 public double Evaluate(IVRPProblemInstance instance, Tour tour) { 122 return EvaluateTour(instance, tour).Quality; 108 public VRPEvaluation Evaluate(IVRPProblemInstance instance, Tour tour) { 109 return EvaluateTour(instance, tour); 123 110 } 124 111 -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/VRPProblemInstance.cs
r4377 r4378 147 147 148 148 public bool Feasible(IVRPEncoding solution) { 149 return EvaluatorParameter.Value.Feasible(this, solution); 149 return EvaluatorParameter.Value.Feasible( 150 EvaluatorParameter.Value.Evaluate( 151 this, solution)); 150 152 } 151 153 152 154 public bool Feasible(Tour tour) { 153 return EvaluatorParameter.Value.Feasible(this, tour); 155 return EvaluatorParameter.Value.Feasible( 156 EvaluatorParameter.Value.Evaluate( 157 this, tour)); 154 158 } 155 159 156 160 public double Evaluate(IVRPEncoding solution) { 157 return EvaluatorParameter.Value.Evaluate(this, solution) ;161 return EvaluatorParameter.Value.Evaluate(this, solution).Quality; 158 162 } 159 163 160 164 public double Evaluate(Tour tour) { 161 return EvaluatorParameter.Value.Evaluate(this, tour) ;165 return EvaluatorParameter.Value.Evaluate(this, tour).Quality; 162 166 } 163 167
Note: See TracChangeset
for help on using the changeset viewer.