protected override AlbaIntraRouteInversionMove[] GenerateMoves(AlbaEncoding individual, IVRPProblemInstance problemInstance) {
      List<AlbaIntraRouteInversionMove> moves = new List<AlbaIntraRouteInversionMove>();

      int currentTourStart = 0;
      int currentTourEnd = 0;
      while (currentTourEnd != individual.Length) {
        currentTourEnd = currentTourStart;
        while (individual[currentTourEnd] < problemInstance.Cities.Value &&
          currentTourEnd < individual.Length) {
          currentTourEnd++;
        }

        int tourLength = currentTourEnd - currentTourStart;
        if (tourLength >= 4) {
          for (int i = 0; i <= tourLength - 4; i++) {
            for (int j = i + 2; j <= tourLength - 2; j++) {
              AlbaIntraRouteInversionMove move = new AlbaIntraRouteInversionMove(
                currentTourStart + i,
                currentTourStart + j,
                individual);

              moves.Add(move);
            }
          }
        }

        currentTourStart = currentTourEnd;
      }

      return moves.ToArray();
    }
        protected override void PerformMove()
        {
            AlbaIntraRouteInversionMove move = IntraRouteInversionMoveParameter.ActualValue;

            Apply(move.Individual as AlbaEncoding, move);
            VRPToursParameter.ActualValue = move.Individual as AlbaEncoding;
        }
    protected override AlbaIntraRouteInversionMove[] GenerateMoves(AlbaEncoding individual, IVRPProblemInstance problemInstance) {
      int sampleSize = SampleSizeParameter.ActualValue.Value;

      AlbaIntraRouteInversionMove[] moves = new AlbaIntraRouteInversionMove[sampleSize];
      for (int i = 0; i < sampleSize; i++) {
        moves[i] = AlbaStochasticIntraRouteInversionSingleMoveGenerator.Apply(
          individual, problemInstance.Cities.Value, RandomParameter.ActualValue);
      }

      return moves;
    }
Exemple #4
0
        protected override AlbaIntraRouteInversionMove[] GenerateMoves(AlbaEncoding individual, IVRPProblemInstance problemInstance)
        {
            int sampleSize = SampleSizeParameter.ActualValue.Value;

            AlbaIntraRouteInversionMove[] moves = new AlbaIntraRouteInversionMove[sampleSize];
            for (int i = 0; i < sampleSize; i++)
            {
                moves[i] = AlbaStochasticIntraRouteInversionSingleMoveGenerator.Apply(
                    individual, problemInstance.Cities.Value, RandomParameter.ActualValue);
            }

            return(moves);
        }
        protected override AlbaIntraRouteInversionMove[] GenerateMoves(AlbaEncoding individual, IVRPProblemInstance problemInstance)
        {
            List <AlbaIntraRouteInversionMove> moves = new List <AlbaIntraRouteInversionMove>();

            AlbaIntraRouteInversionMove move = Apply(individual, problemInstance.Cities.Value, RandomParameter.ActualValue);

            if (move != null)
            {
                moves.Add(move);
            }

            return(moves.ToArray());
        }
        protected override AlbaIntraRouteInversionMove[] GenerateMoves(AlbaEncoding individual, IVRPProblemInstance problemInstance)
        {
            List <AlbaIntraRouteInversionMove> moves = new List <AlbaIntraRouteInversionMove>();

            int currentTourStart = 0;
            int currentTourEnd   = 0;

            while (currentTourEnd != individual.Length)
            {
                currentTourEnd = currentTourStart;
                while (individual[currentTourEnd] < problemInstance.Cities.Value &&
                       currentTourEnd < individual.Length)
                {
                    currentTourEnd++;
                }

                int tourLength = currentTourEnd - currentTourStart;
                if (tourLength >= 4)
                {
                    for (int i = 0; i <= tourLength - 4; i++)
                    {
                        for (int j = i + 2; j <= tourLength - 2; j++)
                        {
                            AlbaIntraRouteInversionMove move = new AlbaIntraRouteInversionMove(
                                currentTourStart + i,
                                currentTourStart + j,
                                individual);

                            moves.Add(move);
                        }
                    }
                }

                currentTourStart = currentTourEnd;
            }

            return(moves.ToArray());
        }
 public static void Apply(AlbaEncoding solution, AlbaIntraRouteInversionMove move)
 {
     AlbaIntraRouteInversionManipulator.Apply(solution, move.Index1, move.Index2);
 }
 protected AlbaIntraRouteInversionMove(AlbaIntraRouteInversionMove original, Cloner cloner)
     : base(original, cloner)
 {
 }
 public static void Apply(AlbaEncoding solution, AlbaIntraRouteInversionMove move) {
   AlbaIntraRouteInversionManipulator.Apply(solution, move.Index1, move.Index2);
 }
 protected AlbaIntraRouteInversionMove(AlbaIntraRouteInversionMove original, Cloner cloner)
   : base(original, cloner) {
 }