using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using HeuristicLab.Common; using HeuristicLab.Core; using HeuristicLab.Encodings.RealVectorEncoding; using HeuristicLab.Parameters; using HeuristicLab.PDPSimulation.DomainModel; using HeuristicLab.PDPSimulation.Operators; using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; namespace HeuristicLab.PDPSimulation { [Item("NearestDestinationDispatching", "")] [StorableClass] public class NearestDestinationDispatching : Dispatching { [StorableConstructor] protected NearestDestinationDispatching(bool deserializing) : base(deserializing) { } protected NearestDestinationDispatching(NearestDestinationDispatching original, Cloner cloner) : base(original, cloner) { } public NearestDestinationDispatching() { } public override IDeepCloneable Clone(Cloner cloner) { return new NearestDestinationDispatching(this, cloner); } protected override void GetHighestPriorityOrder(DynPDPProblemInstance instance, Vehicle vehicle, IEnumerable orders, out Order order, out double priority) { order = orders.OrderBy(o => scenario.DistanceMeasure.GetDistance(vehicle.TargetPositionX, vehicle.TargetPositionY, IsPickup(o, instance) ? o.PickupXCoord : o.DeliveryXCoord, IsPickup(o, instance) ? o.PickupYCoord : o.DeliveryYCoord)).First(); priority = - scenario.DistanceMeasure.GetDistance(vehicle.TargetPositionX, vehicle.TargetPositionY, IsPickup(order, instance) ? order.PickupXCoord : order.DeliveryXCoord, IsPickup(order, instance) ? order.PickupYCoord : order.DeliveryYCoord); } } }