public ConnectionWeightSystem(IIntegrator integrator, DynamicalSystem existingSystem) : base(integrator) { this.SourceSystem = existingSystem; // Generate connection weight nodes for all connections in the incoming system. var links = existingSystem .Nodes .SelectMany(n => n.IncomingNodes) .Where(c => c.From is NeuralOscillatorNode && c.To is NeuralOscillatorNode) .Where(c => c.Plasticity > 0 || c.Decay > 0); Debug.Assert(links.Count() == links.Distinct().Count()); List <NeuralOscillatorConnectionNode> weightNodes = new List <NeuralOscillatorConnectionNode>(); foreach (var link in links) { NeuralOscillatorConnectionNode weightNode = new NeuralOscillatorConnectionNode(0, link); weightNodes.Add(weightNode); } _weightNodes = weightNodes; this.Nodes = weightNodes; }
public Program() { _system = null; _timeStepSize = 0.00001; _exitPrintLoop = new Semaphore(0, 1); _systemLock = new SemaphoreSlim(1, 1); }
public void Run(DynamicalSystem system) { // Store system. _system = system; if (system == null) { Console.WriteLine("Warning: System is null."); } // Inform user. Console.WriteLine("Initializing tasks for new system..."); // Create tasks. Task integratorTask = new Task(ThreadMainIntegrator); Task printerTask = new Task(ThreadMainPrintState); // Run tasks. Console.WriteLine("Starting tasks... press any key to exit early."); Thread.Sleep(1000); printerTask.Start(); integratorTask.Start(); // Block this thread until input. ConsoleKeyInfo input = Console.ReadKey(true); Console.WriteLine("Shutting down tasks..."); // Tell print task to quit. _exitPrintLoop.Release(); // Tell integrator task to quit. _system = null; // Join on tasks. integratorTask.Wait(); printerTask.Wait(); // Done. Thread.Sleep(1000); Console.WriteLine("Application finished."); }