Пример #1
0
        public BoolMatrix InitializeInterations(int length, int nComponents, int nInteractions, IRandom random)
        {
            BoolMatrix m = new BoolMatrix(length, nComponents);
            int        maxBitDistance = MaximumDistance(length, nInteractions);
            var        minBounds      = new Bounds(0, length - nInteractions);
            var        maxBounds      = new Bounds(nInteractions, length - 1);

            for (int c = 0; c < m.Columns; c++)
            {
                int min     = minBounds.Bounded(c - maxBitDistance);
                int max     = maxBounds.Bounded(c + maxBitDistance);
                var indices = Enumerable.Range(min, max - min).ToList();
                indices.Remove(c);
                m[c, c] = true;
                while (indices.Count > nInteractions)
                {
                    indices.RemoveAt(random.Next(indices.Count));
                }
                foreach (var i in indices)
                {
                    m[i, c] = true;
                }
            }
            return(m);
        }
 public BoolMatrix InitializeInterations(int length, int nComponents, int nInteractions, IRandom random) {
   BoolMatrix m = new BoolMatrix(length, nComponents);
   int maxBitDistance = MaximumDistance(length, nInteractions);
   var minBounds = new Bounds(0, length - nInteractions);
   var maxBounds = new Bounds(nInteractions, length - 1);
   for (int c = 0; c < m.Columns; c++) {
     int min = minBounds.Bounded(c - maxBitDistance);
     int max = maxBounds.Bounded(c + maxBitDistance);
     var indices = Enumerable.Range(min, max - min).ToList();
     indices.Remove(c);
     m[c, c] = true;
     while (indices.Count > nInteractions) {
       indices.RemoveAt(random.Next(indices.Count));
     }
     foreach (var i in indices) {
       m[i, c] = true;
     }
   }
   return m;
 }