示例#1
0
 //Constructor
 /// <summary>
 /// Constructs an instance of State Machine
 /// </summary>
 /// <param name="settings">State Machine settings</param>
 /// <param name="inputRange">Range of input values</param>
 public StateMachine(StateMachineSettings settings, Interval inputRange)
 {
     _settings = settings.DeepClone();
     //Random object
     if (_settings.RandomizerSeek < 0)
     {
         _rand = new System.Random();
     }
     else
     {
         _rand = new System.Random(_settings.RandomizerSeek);
     }
     //Build structure
     //Reservoir instance(s)
     _numOfPredictors             = 0;
     _reservoirInstanceCollection = new List <ReservoirInstance>(_settings.ReservoirInstanceDefinitionCollection.Count);
     foreach (StateMachineSettings.ReservoirInstanceDefinition instanceDefinition in _settings.ReservoirInstanceDefinitionCollection)
     {
         ReservoirInstance reservoirInstance = new ReservoirInstance(instanceDefinition, _settings.RandomizerSeek, inputRange);
         _reservoirInstanceCollection.Add(reservoirInstance);
         _numOfPredictors += reservoirInstance.ReservoirObj.NumOfOutputPredictors;
     }
     if (_settings.RouteInputToReadout)
     {
         _numOfPredictors += _settings.InputFieldNameCollection.Count;
     }
     //Readout layer
     _readoutLayer = new ReadoutLayer(_settings.TaskType, _settings.ReadoutLayerConfig, _rand);
     return;
 }
示例#2
0
 //Constructor
 /// <summary>
 /// Constructs an instance of State Machine
 /// </summary>
 /// <param name="settings">State Machine settings</param>
 public StateMachine(StateMachineSettings settings)
 {
     _settings = settings.DeepClone();
     //Neural preprocessor instance
     NP = new NeuralPreprocessor(settings.NeuralPreprocessorConfig, settings.RandomizerSeek);
     //Readout layer
     RL = null;
     return;
 }
示例#3
0
 //Constructors
 /// <summary>
 /// Creates an initialized instance.
 /// </summary>
 /// <param name="cfg">The state machine configuration.</param>
 public StateMachine(StateMachineSettings cfg)
 {
     Config = (StateMachineSettings)cfg.DeepClone();
     //Neural preprocessor instance
     NP = Config.NeuralPreprocessorCfg == null ? null : new NeuralPreprocessor(Config.NeuralPreprocessorCfg, Config.RandomizerSeek);
     //Readout layer instance
     RL = new ReadoutLayer(Config.ReadoutLayerCfg);
     return;
 }
示例#4
0
 //Constructor
 /// <summary>
 /// Constructs an instance of State Machine
 /// </summary>
 /// <param name="settings">State Machine settings</param>
 public StateMachine(StateMachineSettings settings)
 {
     _settings = settings.DeepClone();
     //Neural preprocessor instance
     NP = new NeuralPreprocessor(settings.NeuralPreprocessorConfig, settings.RandomizerSeek);
     NumOfValidPredictors             = 0;
     PredictorGeneralSwitchCollection = null;
     //Readout layer
     RL = null;
     return;
 }
示例#5
0
        //Constructor
        /// <summary>
        /// Constructs an instance of State Machine
        /// </summary>
        /// <param name="settings">State Machine settings</param>
        public StateMachine(StateMachineSettings settings)
        {
            _settings = settings.DeepClone();
            //Internal input generators
            _internalInputGeneratorCollection = new List <IGenerator>();
            foreach (StateMachineSettings.InputSettings.InternalField field in _settings.InputConfig.InternalFieldCollection)
            {
                if (field.GeneratorSettings.GetType() == typeof(ConstGeneratorSettings))
                {
                    _internalInputGeneratorCollection.Add(new ConstGenerator((ConstGeneratorSettings)field.GeneratorSettings));
                }
                else if (field.GeneratorSettings.GetType() == typeof(RandomValueSettings))
                {
                    _internalInputGeneratorCollection.Add(new RandomGenerator((RandomValueSettings)field.GeneratorSettings));
                }
                else if (field.GeneratorSettings.GetType() == typeof(SinusoidalGeneratorSettings))
                {
                    _internalInputGeneratorCollection.Add(new SinusoidalGenerator((SinusoidalGeneratorSettings)field.GeneratorSettings));
                }
                else if (field.GeneratorSettings.GetType() == typeof(MackeyGlassGeneratorSettings))
                {
                    _internalInputGeneratorCollection.Add(new MackeyGlassGenerator((MackeyGlassGeneratorSettings)field.GeneratorSettings));
                }
                else
                {
                    throw new Exception($"Unsupported internal signal generator for field {field.Name}");
                }
            }
            //Reservoir instance(s)
            //Random generator used for reservoir structure initialization
            Random rand = (_settings.RandomizerSeek < 0 ? new Random() : new Random(_settings.RandomizerSeek));

            _numOfPredictors     = 0;
            _reservoirCollection = new List <Reservoir>(_settings.ReservoirInstanceDefinitionCollection.Count);
            foreach (StateMachineSettings.ReservoirInstanceDefinition instanceDefinition in _settings.ReservoirInstanceDefinitionCollection)
            {
                Reservoir reservoir = new Reservoir(instanceDefinition, DataRange, rand);
                _reservoirCollection.Add(reservoir);
                _numOfPredictors += reservoir.NumOfOutputPredictors;
            }
            if (_settings.InputConfig.RouteExternalInputToReadout)
            {
                _numOfPredictors += _settings.InputConfig.ExternalFieldCollection.Count;
            }
            //Readout layer
            _readoutLayer = null;
            return;
        }