Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/12/14 13:26:18 (11 years ago)
Author:
pfleck
Message:
  • Merged trunk into preprocessing branch.
Location:
branches/DataPreprocessing
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing

  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting

  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/General/Moves/MultiVRPMoveOperator/MultiVRPMoveGenerator.cs

    r10538 r11009  
    3131using HeuristicLab.Parameters;
    3232using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     33using HeuristicLab.Problems.VehicleRouting.Encodings.Alba;
     34using HeuristicLab.Problems.VehicleRouting.Encodings.Potvin;
    3335using HeuristicLab.Problems.VehicleRouting.Interfaces;
    3436using HeuristicLab.Problems.VehicleRouting.Variants;
     
    99101      foreach (IOperator op in operators) {
    100102        if (op is IMultiVRPMoveGenerator && !(op is MultiOperator<IMultiVRPMoveGenerator>)) {
    101           Operators.Add(op.Clone() as IMultiVRPMoveGenerator, true);
     103          Operators.Add(op.Clone() as IMultiVRPMoveGenerator, !(op is IAlbaOperator || op is PotvinVehicleAssignmentMultiMoveGenerator));
    102104        }
    103105      }
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Creators/IterativeInsertionCreator.cs

    r10538 r11009  
    107107        int stopIdx = 0;
    108108        if (currentTour.Stops.Count > 0)
    109           result.FindBestInsertionPlace(currentTour, customers[index]);
     109          stopIdx = result.FindBestInsertionPlace(currentTour, customers[index]);
    110110        currentTour.Stops.Insert(stopIdx, customers[index]);
    111111
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Creators/PushForwardInsertionCreator.cs

    r10538 r11009  
    3333
    3434namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin {
    35   [Item("PushForwardInsertionCreator", "Creates a randomly initialized VRP solution.")]
     35  [Item("PushForwardInsertionCreator", "The push forward insertion heuristic. It is implemented as described in Sam, and Thangiah, R. (1999). A Hybrid Genetic Algorithms, Simulated Annealing and Tabu Search Heuristic for Vehicle Routing Problems with Time Windows. Practical Handbook of Genetic Algorithms, Volume III, pp 347–381.")]
    3636  [StorableClass]
    3737  public sealed class PushForwardInsertionCreator : PotvinCreator, IStochasticOperator {
     
    138138          dueTime = 0;
    139139
    140         double dist;
    141         if (problemInstance.Coordinates[customer + depotCount - 1, 0] < x0)
    142           dist = -distance;
    143         else
    144           dist = distance;
     140        double x = problemInstance.Coordinates[customer + depotCount - 1, 0];
     141        double y = problemInstance.Coordinates[customer + depotCount - 1, 1];
    145142
    146143        double cost = alpha * distance + // distance 0 <-> City[i]
    147                    -beta * dueTime + // latest arrival time
    148                    -gamma * (Math.Asin((problemInstance.Coordinates[customer + depotCount - 1, 1] - y0) / dist) / 360 * dist); // polar angle
     144                      -beta * dueTime + // latest arrival time
     145                      -gamma * ((Math.Atan2(y - y0, x - x0) + Math.PI) / (2.0 * Math.PI) * distance); // polar angle
    149146
    150147        if (cost < minCost) {
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Moves/CustomerRelocation/PotvinCustomerRelocationMoveTabuCriterion.cs

    r9456 r11009  
    2020#endregion
    2121
     22using System.Linq;
    2223using HeuristicLab.Common;
    2324using HeuristicLab.Core;
     
    9899      PotvinCustomerRelocationMove move = CustomerRelocationMoveParameter.ActualValue;
    99100
    100       foreach (IItem tabuMove in tabuList) {
    101         PotvinCustomerRelocationMoveAttribute attribute = tabuMove as PotvinCustomerRelocationMoveAttribute;
    102 
     101      foreach (var attribute in tabuList.OfType<PotvinCustomerRelocationMoveAttribute>()) {
    103102        if (!useAspiration || moveQuality >= attribute.MoveQuality) {
    104103          if (attribute.City == move.City && attribute.Tour == move.Tour) {
  • branches/DataPreprocessing/HeuristicLab.Problems.VehicleRouting/3.4/VehicleRoutingProblem.cs

    r10538 r11009  
    365365      Name = instance.Name;
    366366      Description = instance.Description;
     367
     368      BestKnownQuality = null;
     369      BestKnownSolution = null;
     370
    367371      if (ProblemInstance != null && instance.ProblemInstance != null &&
    368372        instance.ProblemInstance.GetType() == ProblemInstance.GetType())
     
    372376
    373377      OnReset();
    374       BestKnownQuality = null;
    375       BestKnownSolution = null;
    376378
    377379      if (instance.BestKnownQuality != null) {
     
    389391
    390392    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);
     393      var interpreterDataType = data.GetType();
     394      var interpreterType = typeof(IVRPDataInterpreter<>).MakeGenericType(interpreterDataType);
     395
     396      var interpreters = ApplicationManager.Manager.GetTypes(interpreterType);
     397
     398      var concreteInterpreter = interpreters.Single(t => GetInterpreterDataType(t) == interpreterDataType);
     399
     400      Load(data, (IVRPDataInterpreter)Activator.CreateInstance(concreteInterpreter));
     401    }
     402
     403    private Type GetInterpreterDataType(Type type) {
     404      var parentInterfaces = type.BaseType.GetInterfaces();
     405      var interfaces = type.GetInterfaces().Except(parentInterfaces);
     406
     407      var interpreterInterface = interfaces.Single(i => typeof(IVRPDataInterpreter).IsAssignableFrom(i));
     408      return interpreterInterface.GetGenericArguments()[0];
    408409    }
    409410
Note: See TracChangeset for help on using the changeset viewer.