Beispiel #1
0
        public virtual VRPEvaluation Evaluate(IVRPProblemInstance instance, IVRPEncoding solution)
        {
            VRPEvaluation evaluation = CreateTourEvaluation();

            foreach (Tour tour in solution.GetTours())
            {
                EvaluateTour(evaluation, instance, tour, solution);
            }

            return(evaluation);
        }
Beispiel #2
0
        public static PrinsEncoding ConvertFrom(IVRPEncoding encoding, IVRPProblemInstance problemInstance)
        {
            List <Tour> tours = encoding.GetTours();
            List <int>  route = new List <int>();

            foreach (Tour tour in tours)
            {
                foreach (int city in tour.Stops)
                {
                    route.Add(city - 1);
                }
            }

            return(new PrinsEncoding(
                       new Permutation(PermutationTypes.RelativeUndirected, route.ToArray()), problemInstance));
        }
        public int GetDepot(int customer, IVRPEncoding solution)
        {
            int depot = -1;

            Tour tour =
                solution.GetTours().FirstOrDefault(t => t.Stops.Contains(customer));

            if (tour != null)
            {
                int tourIndex = solution.GetTourIndex(tour);
                int vehicle   = solution.GetVehicleAssignment(tourIndex);
                depot = VehicleDepotAssignment[vehicle];
            }

            return(depot);
        }
        public static AlbaEncoding ConvertFrom(IVRPEncoding encoding, IVRPProblemInstance instance)
        {
            List <Tour> tours = encoding.GetTours();

            int cities = 0;

            foreach (Tour tour in tours)
            {
                cities += tour.Stops.Count;
            }

            int emptyVehicles = instance.Vehicles.Value - tours.Count;

            int[] array      = new int[cities + tours.Count + emptyVehicles];
            int   delimiter  = 0;
            int   arrayIndex = 0;

            foreach (Tour tour in tours)
            {
                foreach (int city in tour.Stops)
                {
                    array[arrayIndex] = city - 1;
                    arrayIndex++;
                }

                if (arrayIndex != array.Length)
                {
                    array[arrayIndex] = cities + encoding.GetVehicleAssignment(delimiter);

                    delimiter++;
                    arrayIndex++;
                }
            }

            for (int i = 0; i < emptyVehicles; i++)
            {
                array[arrayIndex] = cities + encoding.GetVehicleAssignment(delimiter);

                delimiter++;
                arrayIndex++;
            }

            AlbaEncoding solution = new AlbaEncoding(new Permutation(PermutationTypes.RelativeUndirected, new IntArray(array)), instance);

            return(solution);
        }
Beispiel #5
0
        public override IOperation InstrumentedApply()
        {
            InitResultParameters();

            VRPEvaluation evaluation = CreateTourEvaluation();
            IVRPEncoding  solution   = VRPToursParameter.ActualValue;

            foreach (Tour tour in solution.GetTours())
            {
                EvaluateTour(evaluation, ProblemInstance, tour, solution);
            }
            SetResultParameters(evaluation);

            QualityParameter.ActualValue = new DoubleValue(evaluation.Quality);

            return(base.InstrumentedApply());
        }
Beispiel #6
0
    public static PrinsEncoding ConvertFrom(IVRPEncoding encoding, IVRPProblemInstance problemInstance) {
      List<Tour> tours = encoding.GetTours();
      List<int> route = new List<int>();

      foreach (Tour tour in tours) {
        foreach (int city in tour.Stops)
          route.Add(city - 1);
      }

      return new PrinsEncoding(
        new Permutation(PermutationTypes.RelativeUndirected, route.ToArray()), problemInstance);
    }
 public static void ConvertFrom(IVRPEncoding encoding, TourEncoding solution, IVRPProblemInstance problemInstance) {
   solution.Tours = new ItemList<Tour>(encoding.GetTours());
   solution.Repair();
 }
Beispiel #8
0
    public virtual VRPEvaluation Evaluate(IVRPProblemInstance instance, IVRPEncoding solution) {
      VRPEvaluation evaluation = CreateTourEvaluation();

      foreach (Tour tour in solution.GetTours()) {
        EvaluateTour(evaluation, instance, tour, solution);
      }

      return evaluation;
    }
Beispiel #9
0
 public static void ConvertFrom(IVRPEncoding encoding, TourEncoding solution, IVRPProblemInstance problemInstance)
 {
     solution.Tours = new ItemList <Tour>(encoding.GetTours());
     solution.Repair();
 }
Beispiel #10
0
    public static AlbaEncoding ConvertFrom(IVRPEncoding encoding, IVRPProblemInstance instance) {
      List<Tour> tours = encoding.GetTours();

      int cities = 0;
      foreach (Tour tour in tours) {
        cities += tour.Stops.Count;
      }

      int emptyVehicles = instance.Vehicles.Value - tours.Count;

      int[] array = new int[cities + tours.Count + emptyVehicles];
      int delimiter = 0;
      int arrayIndex = 0;

      foreach (Tour tour in tours) {
        foreach (int city in tour.Stops) {
          array[arrayIndex] = city - 1;
          arrayIndex++;
        }

        if (arrayIndex != array.Length) {
          array[arrayIndex] = cities + encoding.GetVehicleAssignment(delimiter);

          delimiter++;
          arrayIndex++;
        }
      }

      for (int i = 0; i < emptyVehicles; i++) {
        array[arrayIndex] = cities + encoding.GetVehicleAssignment(delimiter);

        delimiter++;
        arrayIndex++;
      }

      AlbaEncoding solution = new AlbaEncoding(new Permutation(PermutationTypes.RelativeUndirected, new IntArray(array)), instance);

      return solution;
    }
    public int GetDepot(int customer, IVRPEncoding solution) {
      int depot = -1;

      Tour tour =
          solution.GetTours().FirstOrDefault(t => t.Stops.Contains(customer));

      if (tour != null) {
        int tourIndex = solution.GetTourIndex(tour);
        int vehicle = solution.GetVehicleAssignment(tourIndex);
        depot = VehicleDepotAssignment[vehicle];
      }

      return depot;
    }