# Changeset 4268

Ignore:
Timestamp:
08/19/10 16:51:30 (12 years ago)
Message:

Location:
branches/VRP
Files:
25 edited
1 moved

Unmodified
Removed
• ## branches/VRP/HeuristicLab.Problems.VehicleRouting.Views/3.3/VRPSolutionView.cs

 r4230 using HeuristicLab.MainForm; using HeuristicLab.Problems.VehicleRouting.Encodings; using HeuristicLab.Parameters; namespace HeuristicLab.Problems.VehicleRouting.Views { if (Content.Solution != null) { int currentTour = 0; foreach (Tour tour in Content.Solution.GetTours()) { foreach (Tour tour in Content.Solution.GetTours(new ValueLookupParameter("DistanceMatrix", distanceMatrix))) { double t = 0.0; Point[] tourPoints = new Point[tour.Cities.Count + 2];
• ## branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/AlbaEncoding.cs

 r4230 [Item("AlbaEncoding", "Represents an Alba encoding of VRP solutions. It is implemented as described in Alba, E. and Dorronsoro, B. (2004). Solving the Vehicle Routing Problem by Using Cellular Genetic Algorithms.")] [StorableClass] public class AlbaEncoding : Permutation, IVRPEncoding { public class AlbaEncoding : PermutationEncoding { [Storable] private int cities; #region IVRPEncoding Members public List GetTours() { public override List GetTours(ILookupParameter distanceMatrix = null, int maxVehicles = int.MaxValue) { List result = new List(); public AlbaEncoding(Permutation permutation, int cities) : base(PermutationTypes.RelativeUndirected) { this.array = new int[permutation.Length]; for (int i = 0; i < array.Length; i++) this.array[i] = permutation[i]; : base(permutation) { this.cities = cities; } [StorableConstructor] private AlbaEncoding(bool serializing) : base() { : base(serializing) { } public static AlbaEncoding ConvertFrom(IVRPEncoding encoding, int vehicles) { List tours = encoding.GetTours(); public static AlbaEncoding ConvertFrom(IVRPEncoding encoding, int vehicles, ILookupParameter distanceMatrix) { List tours = encoding.GetTours(distanceMatrix, vehicles); int cities = 0; internal static void RemoveUnusedParameters(ParameterCollection parameters) { parameters.Remove("DistanceMatrix"); parameters.Remove("UseDistanceMatrix"); parameters.Remove("Capacity");
• ## branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Crossovers/AlbaCrossover.cs

 r4206 if (!(solution is AlbaEncoding)) { parents[i] = AlbaEncoding.ConvertFrom(solution, VehiclesParameter.ActualValue.Value); parents[i] = AlbaEncoding.ConvertFrom(solution, VehiclesParameter.ActualValue.Value, DistanceMatrixParameter); } else { parents[i] = solution;
• ## branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Manipulators/AlbaManipulator.cs

 r4206 IVRPEncoding solution = VRPToursParameter.ActualValue; if (!(solution is AlbaEncoding)) { VRPToursParameter.ActualValue = AlbaEncoding.ConvertFrom(solution, VehiclesParameter.ActualValue.Value); VRPToursParameter.ActualValue = AlbaEncoding.ConvertFrom(solution, VehiclesParameter.ActualValue.Value, DistanceMatrixParameter); }
• ## branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/AlbaMoveOperator.cs

 r4204 IVRPEncoding solution = VRPToursParameter.ActualValue; if (!(solution is AlbaEncoding)) { VRPToursParameter.ActualValue = AlbaEncoding.ConvertFrom(solution, VehiclesParameter.ActualValue.Value); VRPToursParameter.ActualValue = AlbaEncoding.ConvertFrom(solution, VehiclesParameter.ActualValue.Value, DistanceMatrixParameter); }
• ## branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/IntraRouteInversion/IntraRouteInversionEvaluator.cs

 r4206 public static TourEvaluation GetMoveQuality(AlbaEncoding individual, IntraRouteInversionMove move, IntValue vehicles, DoubleArray dueTimeArray, DoubleArray serviceTimeArray, DoubleArray readyTimeArray, DoubleArray demandArray, DoubleValue capacity, DoubleMatrix coordinates, return VRPEvaluator.Evaluate( newSolution, dueTimeArray, serviceTimeArray, readyTimeArray, newSolution, vehicles, dueTimeArray, serviceTimeArray, readyTimeArray, demandArray, capacity, fleetUsageFactor, timeFactor, distanceFactor, overloadPenalty, tardinessPenalty, coordinates, distanceMatrix, useDistanceMatrix); return GetMoveQuality( VRPToursParameter.ActualValue as AlbaEncoding, IntraRouteInversionMoveParameter.ActualValue, VehiclesParameter.ActualValue, DueTimeParameter.ActualValue, ServiceTimeParameter.ActualValue, ReadyTimeParameter.ActualValue, DemandParameter.ActualValue, CapacityParameter.ActualValue, CoordinatesParameter.ActualValue,
• ## branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/IntraRouteInversion/IntraRouteInversionMove.cs

 r4206 public TourEvaluation GetMoveQuality( IVRPEncoding individual, IVRPEncoding individual, IntValue vehicles, DoubleArray dueTimeArray, DoubleArray serviceTimeArray, DoubleArray readyTimeArray, DoubleArray demandArray, DoubleValue capacity, DoubleMatrix coordinates, DoubleValue overloadPenalty, DoubleValue tardinessPenalty, ILookupParameter distanceMatrix, Data.BoolValue useDistanceMatrix) { return IntraRouteInversionMoveEvaluator.GetMoveQuality(individual as AlbaEncoding, this, return IntraRouteInversionMoveEvaluator.GetMoveQuality(individual as AlbaEncoding, this, vehicles, dueTimeArray, serviceTimeArray, readyTimeArray, demandArray, capacity, coordinates, fleetUsageFactor, timeFactor, distanceFactor,
• ## branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/LambdaInterchange/LambdaInterchangeMove.cs

 r4206 public TourEvaluation GetMoveQuality( IVRPEncoding individual, IVRPEncoding individual, IntValue vehicles, DoubleArray dueTimeArray, DoubleArray serviceTimeArray, DoubleArray readyTimeArray, DoubleArray demandArray, DoubleValue capacity, DoubleMatrix coordinates, DoubleValue overloadPenalty, DoubleValue tardinessPenalty, ILookupParameter distanceMatrix, Data.BoolValue useDistanceMatrix) { return LambdaInterchangeMoveEvaluator.GetMoveQuality(individual as AlbaEncoding, this, return LambdaInterchangeMoveEvaluator.GetMoveQuality(individual as AlbaEncoding, this,  vehicles, dueTimeArray, serviceTimeArray, readyTimeArray, demandArray, capacity, coordinates, fleetUsageFactor, timeFactor, distanceFactor,
• ## branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/LambdaInterchange/LambdaInterchangeMoveEvaluator.cs

 r4206 public static TourEvaluation GetMoveQuality(AlbaEncoding individual, LambdaInterchangeMove move, IntValue vehicles, DoubleArray dueTimeArray, DoubleArray serviceTimeArray, DoubleArray readyTimeArray, DoubleArray demandArray, DoubleValue capacity, DoubleMatrix coordinates, return VRPEvaluator.Evaluate( newSolution, dueTimeArray, serviceTimeArray, readyTimeArray, newSolution, vehicles, dueTimeArray, serviceTimeArray, readyTimeArray, demandArray, capacity, fleetUsageFactor, timeFactor, distanceFactor, overloadPenalty, tardinessPenalty, coordinates, distanceMatrix, useDistanceMatrix); return GetMoveQuality( VRPToursParameter.ActualValue as AlbaEncoding, LambdaInterchangeMoveParameter.ActualValue, VehiclesParameter.ActualValue, DueTimeParameter.ActualValue, ServiceTimeParameter.ActualValue, ReadyTimeParameter.ActualValue, DemandParameter.ActualValue, CapacityParameter.ActualValue, CoordinatesParameter.ActualValue,
• ## branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/ThreeOpt/PermutationTranslocationMoveEvaluator.cs

 r4208 return VRPEvaluator.Evaluate( newSolution, VehiclesParameter.ActualValue, DueTimeParameter.ActualValue, ServiceTimeParameter.ActualValue, ReadyTimeParameter.ActualValue, DemandParameter.ActualValue, CapacityParameter.ActualValue,
• ## branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/GVR/Crossovers/GVRCrossover.cs

 r4230 for (int i = 0; i < ParentsParameter.ActualValue.Length; i++) { IVRPEncoding solution = ParentsParameter.ActualValue[i]; if (!(solution is GVREncoding)) { parents[i] = GVREncoding.ConvertFrom(solution, CapacityParameter.ActualValue, DemandParameter.ActualValue, VehiclesParameter.ActualValue); parents[i] = GVREncoding.ConvertFrom(solution, CapacityParameter.ActualValue, DemandParameter.ActualValue, DistanceMatrixParameter); } else { parents[i] = solution;
• ## branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/GVR/GVREncoding.cs

 r4230 [Storable] private IntValue vehicles { get; set; } [Storable] private DoubleArray demand { get; set; } public override List GetTours() { public override List GetTours(ILookupParameter distanceMatrix = null, int maxVehicles = int.MaxValue) { List tours = new List(); Tour newTour = new Tour(); double currentDemand = 0; int toursProcessed = 0; foreach (Tour tour in base.Tours) { Tour newTour = new Tour(); double currentDemand = 0; if (maxVehicles > tours.Count) { newTour = new Tour(); currentDemand = 0; } foreach (int city in tour.Cities) { currentDemand += demand[city]; if (vehicles.Value > tours.Count + base.Tours.Count - toursProcessed && if (maxVehicles > tours.Count && currentDemand > capacity.Value) { if(newTour.Cities.Count > 0) } if (newTour.Cities.Count > 0) if (newTour.Cities.Count > 0 && maxVehicles > tours.Count) tours.Add(newTour); toursProcessed++; } public override IDeepCloneable Clone(HeuristicLab.Common.Cloner cloner) { GVREncoding clone = new GVREncoding(capacity, demand, vehicles); GVREncoding clone = new GVREncoding(capacity, demand); cloner.RegisterClonedObject(this, clone); clone.Tours = (ItemList)cloner.Clone(this.Tours); } public GVREncoding(DoubleValue capacity, DoubleArray demand, IntValue vehicles) public GVREncoding(DoubleValue capacity, DoubleArray demand) : base() { this.capacity = capacity; this.demand = demand; this.vehicles = vehicles; } } public static GVREncoding ConvertFrom(IVRPEncoding encoding, DoubleValue capacity, DoubleArray demand, IntValue vehicles) { GVREncoding solution = new GVREncoding(capacity, demand, vehicles); public static GVREncoding ConvertFrom(IVRPEncoding encoding, DoubleValue capacity, DoubleArray demand, ILookupParameter distanceMatrix) { GVREncoding solution = new GVREncoding(capacity, demand); TourEncoding.ConvertFrom(encoding, solution); TourEncoding.ConvertFrom(encoding, solution, distanceMatrix); return solution; } public static GVREncoding ConvertFrom(List route, DoubleValue capacity, DoubleArray demand, IntValue vehicles) { GVREncoding solution = new GVREncoding(capacity, demand, vehicles); public static GVREncoding ConvertFrom(List route, DoubleValue capacity, DoubleArray demand) { GVREncoding solution = new GVREncoding(capacity, demand); TourEncoding.ConvertFrom(route, solution);
• ## branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/GVR/Manipulators/GVRManipulator.cs

 r4230 //remove unused parameters Parameters.Remove("Coordinates"); Parameters.Remove("DistanceMatrix"); Parameters.Remove("UseDistanceMatrix"); Parameters.Remove("ReadyTime"); if (!(solution is GVREncoding)) { VRPToursParameter.ActualValue = GVREncoding.ConvertFrom(solution, CapacityParameter.ActualValue, DemandParameter.ActualValue, VehiclesParameter.ActualValue); DistanceMatrixParameter); }
• ## branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/Moves/Interfaces/IVRPMove.cs

 r4205 namespace HeuristicLab.Problems.VehicleRouting.Encodings.General { public interface IVRPMove : IItem { TourEvaluation GetMoveQuality(IVRPEncoding individual, TourEvaluation GetMoveQuality(IVRPEncoding individual,  IntValue vehicles, DoubleArray dueTimeArray, DoubleArray serviceTimeArray, DoubleArray readyTimeArray, DoubleArray demandArray, DoubleValue capacity,DoubleMatrix coordinates,
• ## branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/Moves/MultiVRPMoveOperator/MultiVRPMoveEvaluator.cs

 r4205 return move.GetMoveQuality( VRPToursParameter.ActualValue, VehiclesParameter.ActualValue, DueTimeParameter.ActualValue, ServiceTimeParameter.ActualValue,
• ## branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/TourEncoding.cs

 r4230 #region IVRPEncoding Members public virtual List GetTours() { return new List(Tours); public virtual List GetTours(ILookupParameter distanceMatrix = null, int maxVehicles = int.MaxValue) { List result = new List(Tours); while (result.Count > maxVehicles) { Tour tour = result[result.Count - 1]; result[result.Count - 2].Cities.AddRange(tour.Cities); result.Remove(tour); } return result; } : base() { } public static void ConvertFrom(IVRPEncoding encoding, TourEncoding solution) { solution.Tours = new ItemList(encoding.GetTours()); public static void ConvertFrom(IVRPEncoding encoding, TourEncoding solution, ILookupParameter distanceMatrix) { solution.Tours = new ItemList(encoding.GetTours(distanceMatrix)); }
• ## branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Crossovers/PotvinCrossover.cs

 r4206 if (!(solution is PotvinEncoding)) { parents[i] = PotvinEncoding.ConvertFrom(solution); parents[i] = PotvinEncoding.ConvertFrom(solution, DistanceMatrixParameter); } else { parents[i] = solution;
• ## branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Manipulators/PotvinManipulator.cs

 r4206 IVRPEncoding solution = VRPToursParameter.ActualValue; if (!(solution is PotvinEncoding)) { VRPToursParameter.ActualValue = PotvinEncoding.ConvertFrom(solution); VRPToursParameter.ActualValue = PotvinEncoding.ConvertFrom(solution, DistanceMatrixParameter); }
• ## branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/PotvinEncoding.cs

 r4230 } public static PotvinEncoding ConvertFrom(IVRPEncoding encoding) { public static PotvinEncoding ConvertFrom(IVRPEncoding encoding, ILookupParameter distanceMatrix) { PotvinEncoding solution = new PotvinEncoding(); TourEncoding.ConvertFrom(encoding, solution); TourEncoding.ConvertFrom(encoding, solution, distanceMatrix); return solution;
• ## branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Evaluators/VRPEvaluator.cs

 r4230 IVRPEncoding vrpSolution = VRPToursParameter.ActualValue; return vrpSolution.GetTours().Count; return vrpSolution.GetTours(DistanceMatrixParameter, VehiclesParameter.ActualValue.Value).Count; } } public static TourEvaluation Evaluate(IVRPEncoding solution, DoubleArray dueTimeArray, public static TourEvaluation Evaluate(IVRPEncoding solution, IntValue vehicles, DoubleArray dueTimeArray, DoubleArray serviceTimeArray, DoubleArray readyTimeArray, DoubleArray demandArray, DoubleValue capacity, DoubleValue fleetUsageFactor, DoubleValue timeFactor, DoubleValue distanceFactor, DoubleValue overloadPenalty, DoubleValue tardinessPenalty, sumEval.Tardiness = 0; foreach (Tour tour in solution.GetTours()) { foreach (Tour tour in solution.GetTours(distanceMatrix)) { TourEvaluation eval = EvaluateTour(tour, dueTimeArray, serviceTimeArray, readyTimeArray, demandArray, capacity, fleetUsageFactor, timeFactor, distanceFactor, overloadPenalty, tardinessPenalty, IVRPEncoding solution = VRPToursParameter.ActualValue; TourEvaluation sumEval = Evaluate(solution, DueTimeParameter.ActualValue, ServiceTimeParameter.ActualValue, ReadyTimeParameter.ActualValue, TourEvaluation sumEval = Evaluate(solution, VehiclesParameter.ActualValue, DueTimeParameter.ActualValue, ServiceTimeParameter.ActualValue, ReadyTimeParameter.ActualValue, DemandParameter.ActualValue, CapacityParameter.ActualValue, FleetUsageFactor.ActualValue, TimeFactor.ActualValue, DistanceFactor.ActualValue, OverloadPenalty.ActualValue, TardinessPenalty.ActualValue,
• ## branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/HeuristicLab.Problems.VehicleRouting-3.3.csproj

 r4241
• ## branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Interfaces/IVRPEncoding.cs

 r4230 using HeuristicLab.Problems.VehicleRouting.Encodings; using System.Collections.Generic; using HeuristicLab.Data; namespace HeuristicLab.Problems.VehicleRouting { public interface IVRPEncoding : IItem { List GetTours(); List GetTours(ILookupParameter distanceMatrix, int maxVehicles = int.MaxValue); } }
• ## branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/VRPOperator.cs

 r4241 bool feasible = true; foreach (Tour tour in solution.GetTours()) { foreach (Tour tour in solution.GetTours(DistanceMatrixParameter)) { if (!Feasible(tour)) { feasible = false;
• ## branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/VRPUtilities.cs

 r4154 if (useDistanceMatrix.Value) { if (distanceMatrix.ActualValue == null) { distanceMatrix.ActualValue = CreateDistanceMatrix(coordinates); } if (distanceMatrix is IValueLookupParameter && (distanceMatrix as IValueLookupParameter).Value != null) { distance = (distanceMatrix as IValueLookupParameter).Value[start, end]; } else { if (distanceMatrix.ActualValue == null) { distanceMatrix.ActualValue = CreateDistanceMatrix(coordinates); } distance = distanceMatrix.ActualValue[start, end]; distance = distanceMatrix.ActualValue[start, end]; } } else { distance = CalculateDistance(start, end, coordinates);
• ## branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/VehicleRoutingProblem.cs

 r4241 using HeuristicLab.Problems.VehicleRouting.Encodings.Alba; using HeuristicLab.Problems.VehicleRouting.Encodings.General; using HeuristicLab.Problems.VehicleRouting.Encodings.Prins; namespace HeuristicLab.Problems.VehicleRouting { } foreach (IPrinsOperator op in Operators.OfType()) { op.FleetUsageFactor.ActualName = FleetUsageFactor.Name; op.TimeFactor.ActualName = TimeFactor.Name; op.DistanceFactor.ActualName = DistanceFactor.Name; op.OverloadPenalty.ActualName = OverloadPenalty.Name; op.TardinessPenalty.ActualName = TardinessPenalty.Name; } foreach (IVRPMoveEvaluator op in Operators.OfType()) { op.FleetUsageFactor.ActualName = FleetUsageFactor.Name;
Note: See TracChangeset for help on using the changeset viewer.