Exemplo n.º 1
0
        /// <summary>
        /// Creates columns on the node.
        /// </summary>
        /// <param name="msg"></param>
        private int InitializeColumns(InitColumnsMsg msg)
        {
            Dict = new Dictionary <object, object>();

            for (int i = msg.MinKey; i <= msg.MaxKey; i++)
            {
                this.Dict[i] = new Column(this.HtmConfig.CellsPerColumn, i, this.HtmConfig.SynPermConnected, this.HtmConfig.NumInputs);
            }

            return(msg.MaxKey - msg.MinKey + 1);
        }
Exemplo n.º 2
0
        //public int[] GetInputNeighborhood(int centerInput, int potentialRadius)
        //{
        //    return this.config.IsWrapAround ?
        //        this.InputTopology.GetWrappingNeighborhood(centerInput, potentialRadius) :
        //            this.InputTopology.GetNeighborhood(centerInput, potentialRadius);
        //}


        #region Private Methods
        /// <summary>
        /// Creates columns on the node.
        /// </summary>
        /// <param name="msg"></param>
        private void initializeColumns(InitColumnsMsg msg)
        {
            this.partitionKey = msg.PartitionKey;

            dict = new Dictionary <object, object>();

            Console.WriteLine($"{Self.Path} -  Received message: '{msg.GetType().Name}' - min={msg.MinKey}, max={msg.MaxKey}, partitionKey: {this.partitionKey}");

            for (int i = msg.MinKey; i <= msg.MaxKey; i++)
            {
                this.dict[i] = new Column(this.config.CellsPerColumn, i, this.config.SynPermConnected, this.config.NumInputs);
            }

            /*
             * if (msg.Elements == null || msg.Elements.Count == 0)
             *  throw new DistributedException($"{nameof(DictNodeActor)} failed to create columns. List of elements cannot be empty.");
             *
             * ParallelOptions opts = new ParallelOptions();
             * opts.MaxDegreeOfParallelism = Environment.ProcessorCount;
             *
             * //
             * // Here is upload performed in context of every actor (partition).
             * // Because keys are grouped by partitions (actors) parallel upload can be done here.
             * foreach (var element in msg.Elements)
             * {
             *  HtmConfig cfg = element.Value as HtmConfig;
             *  if (cfg == null)
             *      throw new ArgumentException($"Value hast to be of type {nameof(HtmConfig)}");
             *
             *  this.dict[element.Key] = new Column(this.config.CellsPerColumn, (int)element.Key, this.config.SynPermConnected, cfg.NumInputs);
             * }
             */

            Debug.WriteLine($"Init completed. {msg.PartitionKey} - {this.dict.Count} - min={msg.MinKey}, max={msg.MaxKey}");

            Console.WriteLine($"{Self.Path} - Init completed. '{msg.GetType().Name}' - min={msg.MinKey}, max={msg.MaxKey}");

            Sender.Tell(msg.MaxKey - msg.MinKey, Self);

            Console.WriteLine($"{Self.Path} -  Response on init message sent '{msg.GetType().Name}' - min={msg.MinKey}, max={msg.MaxKey}");
        }