Free cookie consent management tool by TermsFeed Policy Generator

source: branches/DynamicVehicleRouting/HeuristicLab.PDPSimulation/3.3/Optimizers/LocalUpdate/NearestDestinationDispatching.cs @ 8813

Last change on this file since 8813 was 8813, checked in by svonolfe, 12 years ago

Added earliest due time and nearest destination dispatching (#1955)

File size: 1.7 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Diagnostics;
4using System.Linq;
5using HeuristicLab.Common;
6using HeuristicLab.Core;
7using HeuristicLab.Encodings.RealVectorEncoding;
8using HeuristicLab.Parameters;
9using HeuristicLab.PDPSimulation.DomainModel;
10using HeuristicLab.PDPSimulation.Operators;
11using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
12
13namespace HeuristicLab.PDPSimulation {
14  [Item("NearestDestinationDispatching", "")]
15  [StorableClass]
16  public class NearestDestinationDispatching : Dispatching {
17    [StorableConstructor]
18    protected NearestDestinationDispatching(bool deserializing) : base(deserializing) { }
19    protected NearestDestinationDispatching(NearestDestinationDispatching original, Cloner cloner) : base(original, cloner) { }
20    public NearestDestinationDispatching() {
21    }
22
23    public override IDeepCloneable Clone(Cloner cloner) {
24      return new NearestDestinationDispatching(this, cloner);
25    }
26
27    protected override void GetHighestPriorityOrder(DynPDPProblemInstance instance, Vehicle vehicle, IEnumerable<Order> orders, out Order order, out double priority) {
28      order = orders.OrderBy(o => scenario.DistanceMeasure.GetDistance(vehicle.TargetPositionX, vehicle.TargetPositionY,
29        IsPickup(o, instance) ? o.PickupXCoord : o.DeliveryXCoord,
30        IsPickup(o, instance) ? o.PickupYCoord : o.DeliveryYCoord)).First();
31
32      priority = - scenario.DistanceMeasure.GetDistance(vehicle.TargetPositionX, vehicle.TargetPositionY,
33        IsPickup(order, instance) ? order.PickupXCoord : order.DeliveryXCoord,
34        IsPickup(order, instance) ? order.PickupYCoord : order.DeliveryYCoord);
35    }
36  }
37}
Note: See TracBrowser for help on using the repository browser.