Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/05/20 04:37:37 (4 years ago)
Author:
abeham
Message:

#2521: working on VRP (refactoring all the capabilities, features, and operator discovery)

Location:
branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Zhu
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Zhu/Crossovers/ZhuMergeCrossover1.cs

    r17698 r17717  
    2020#endregion
    2121
     22using HEAL.Attic;
    2223using HeuristicLab.Common;
    2324using HeuristicLab.Core;
    2425using HeuristicLab.Data;
    25 using HEAL.Attic;
    26 using HeuristicLab.Problems.VehicleRouting.Variants;
     26using HeuristicLab.Problems.VehicleRouting.Interfaces;
    2727
    2828namespace HeuristicLab.Problems.VehicleRouting.Encodings.Zhu {
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Zhu/Crossovers/ZhuMergeCrossover2.cs

    r17698 r17717  
    2121
    2222using System.Collections.Generic;
     23using HEAL.Attic;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
    2526using HeuristicLab.Data;
    26 using HEAL.Attic;
    27 using HeuristicLab.Problems.VehicleRouting.Variants;
     27using HeuristicLab.Problems.VehicleRouting.Interfaces;
    2828
    2929namespace HeuristicLab.Problems.VehicleRouting.Encodings.Zhu {
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Zhu/IZhuOperator.cs

    r17226 r17717  
    2020#endregion
    2121
    22 using HeuristicLab.Problems.VehicleRouting.Variants;
    2322using HEAL.Attic;
     23using HeuristicLab.Problems.VehicleRouting.Interfaces;
    2424
    2525namespace HeuristicLab.Problems.VehicleRouting.Encodings.Zhu {
    2626  [StorableType("CD11FA3C-3B50-4710-AAFC-32C9C61B3321")]
    27   public interface IZhuOperator :
    28     ISingleDepotOperator, IHomogenousCapacitatedOperator, ITimeWindowedOperator {
     27  public interface IZhuOperator : IGeneralVRPOperator {
    2928  }
    3029}
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Zhu/ZhuEncodedSolution.cs

    r17714 r17717  
    2222using System;
    2323using System.Collections.Generic;
     24using System.Linq;
    2425using HEAL.Attic;
    2526using HeuristicLab.Common;
     
    114115    public static ZhuEncodedSolution ConvertFrom(IVRPEncodedSolution encoding, IVRPProblemInstance problemInstance) {
    115116      List<Tour> tours = encoding.GetTours();
    116       List<int> route = new List<int>();
     117      var count = tours.Sum(x => x.Stops.Count);
     118      var route = new int[count];
    117119
     120      var i = 0;
    118121      foreach (Tour tour in tours) {
    119122        foreach (int city in tour.Stops)
    120           route.Add(city - 1);
     123          route[i++] = city - 1;
    121124      }
    122125
    123126      return new ZhuEncodedSolution(
    124         new Permutation(PermutationTypes.RelativeUndirected, route.ToArray()), problemInstance);
     127        new Permutation(PermutationTypes.RelativeUndirected, route), problemInstance);
    125128    }
    126129
    127130    public static ZhuEncodedSolution ConvertFrom(List<int> routeParam, IVRPProblemInstance problemInstance) {
    128       List<int> route = new List<int>(routeParam);
    129 
    130       while (route.Remove(0)) { //remove all delimiters (0)
    131       }
    132 
    133       for (int i = 0; i < route.Count; i++)
    134         route[i]--;
     131      var route = routeParam.Where(x => x != 0).Select(x => x - 1).ToArray();
    135132
    136133      return new ZhuEncodedSolution(
    137         new Permutation(PermutationTypes.RelativeUndirected, route.ToArray()), problemInstance);
     134        new Permutation(PermutationTypes.RelativeUndirected, route), problemInstance);
    138135    }
    139136  }
Note: See TracChangeset for help on using the changeset viewer.