Ejemplo n.º 1
0
    public static void Apply(LinearLinkage lle, Swap2Move move) {
      var groups = lle.GetGroups().ToList();
      int g1 = -1, g2 = -1, g1Idx = -1, g2Idx = -1;
      for (var i = 0; i < groups.Count; i++) {
        if (g1 < 0) {
          g1Idx = groups[i].IndexOf(move.Item1);
          if (g1Idx >= 0) {
            g1 = i;
            continue;
          }
        }
        if (g2 < 0) {
          g2Idx = groups[i].IndexOf(move.Item2);
          if (g2Idx >= 0) g2 = i;
        }
      }

      // can happen if (for some reason) the items belong to the same group
      if (g1 < 0 || g2 < 0) throw new InvalidOperationException("Swap2MoveMaker: Cannot apply swap move, items are not found in different groups.");

      var h = groups[g1][g1Idx];
      groups[g1][g1Idx] = groups[g2][g2Idx];
      groups[g2][g2Idx] = h;
      lle.SetGroups(groups);
    }
 public static Swap2Move[] Apply(LinearLinkage lle, IRandom random, int sampleSize) {
   int length = lle.Length;
   Swap2Move[] moves = new Swap2Move[sampleSize];
   for (int i = 0; i < sampleSize; i++) {
     moves[i] = StochasticSwap2SingleMoveGenerator.Apply(lle, random);
   }
   return moves;
 }
        public static Swap2Move[] Apply(LinearLinkage lle, IRandom random, int sampleSize)
        {
            int length = lle.Length;

            Swap2Move[] moves = new Swap2Move[sampleSize];
            for (int i = 0; i < sampleSize; i++)
            {
                moves[i] = StochasticSwap2SingleMoveGenerator.Apply(lle, random);
            }
            return(moves);
        }
Ejemplo n.º 4
0
        public static void Apply(LinearLinkage lle, Swap2Move move)
        {
            var groups = lle.GetGroups().ToList();
            int g1 = -1, g2 = -1, g1Idx = -1, g2Idx = -1;

            for (var i = 0; i < groups.Count; i++)
            {
                if (g1 < 0)
                {
                    g1Idx = groups[i].IndexOf(move.Item1);
                    if (g1Idx >= 0)
                    {
                        g1 = i;
                        continue;
                    }
                }
                if (g2 < 0)
                {
                    g2Idx = groups[i].IndexOf(move.Item2);
                    if (g2Idx >= 0)
                    {
                        g2 = i;
                    }
                }
            }

            // can happen if (for some reason) the items belong to the same group
            if (g1 < 0 || g2 < 0)
            {
                throw new InvalidOperationException("Swap2MoveMaker: Cannot apply swap move, items are not found in different groups.");
            }

            var h = groups[g1][g1Idx];

            groups[g1][g1Idx] = groups[g2][g2Idx];
            groups[g2][g2Idx] = h;
            lle.SetGroups(groups);
        }
Ejemplo n.º 5
0
 protected Swap2Move(Swap2Move original, Cloner cloner) : base(original, cloner) { }
Ejemplo n.º 6
0
 protected Swap2Move(Swap2Move original, Cloner cloner) : base(original, cloner)
 {
 }