private void ThreadEntry(Object p) { ThreadEntryData d = (ThreadEntryData)p; try { for (int i = 0; (d.ThreadIndex + i * d.ThreadCount) < networks.Length; ++i) { int networkToRun = d.ThreadIndex + i * d.ThreadCount; if (!networks[networkToRun].Generate(VisualMode)) { continue; } if (VisualMode) { GenerationSteps = networks[networkToRun].GenerationSteps; Branches = networks[networkToRun].Branches; } if (CheckConnected) { if (!networks[networkToRun].CheckConnected()) { continue; } } // Throws exception in Activation research if (!VisualMode && TracingPath != "") { if (!networks[networkToRun].Trace(TracingDirectory, TracingPath + "_" + networkToRun.ToString())) { continue; } } if (!networks[networkToRun].Analyze(VisualMode)) { continue; } if (VisualMode) { ActivesInformation = networks[networkToRun].ActivesInformation; EvolutionInformation = networks[networkToRun].EvolutionInformation; } Interlocked.Increment(ref realizationsDone); } } catch (SystemException ex) { CustomLogger.Write("Exception is thrown in LocalEnsembleManager. Exception message is: " + ex.Message); } finally { waitHandles[d.ThreadIndex].Set(); } }
private void ThreadEntry(object p) { ThreadEntryData d = (ThreadEntryData)p; try { for (int i = 0; (d.ThreadIndex + i * d.ThreadCount) < networks.Length; ++i) { int networkToRun = d.ThreadIndex + i * d.ThreadCount; if (!networks[networkToRun].Generate()) { continue; } if (CheckConnected) { if (!networks[networkToRun].CheckConnected()) { continue; } } if (TracingPath != "") { if (!networks[networkToRun].Trace(TracingPath + "_" + networkToRun.ToString())) { continue; } } if (!networks[networkToRun].Analyze()) { continue; } Interlocked.Increment(ref realizationsDone); } } catch (SystemException ex) { Logger.Write("Exception is thrown in LocalEnsembleManager. Exception message is: " + ex.Message); } finally { waitHandles[d.ThreadIndex].Set(); } }
private void PrepareData() { networks = new AbstractNetwork[RealizationCount]; for (int i = 0; i < RealizationCount; ++i) { networks[i] = AbstractNetwork.CreateNetworkByType(ModelType, ResearchName, ResearchType, GenerationType, TracingType, ResearchParamaterValues, GenerationParameterValues, AnalyzeOptions); networks[i].NetworkID = i; networks[i].OnUpdateStatus += new NetworkStatusUpdateHandler(NetworkStatusUpdateHandlerMethod); } int threadCount = Math.Min(networks.Length, Environment.ProcessorCount); // Creating thread related members threads = new Thread[threadCount]; waitHandles = new AutoResetEvent[threadCount]; threadData = new ThreadEntryData[threadCount]; // Initialize threads and handles for (int i = 0; i < threadCount; ++i) { waitHandles[i] = new AutoResetEvent(false); threadData[i] = new ThreadEntryData(threadCount, i); threads[i] = new Thread(new ParameterizedThreadStart(ThreadEntry)) { Priority = ThreadPriority.Lowest }; } }
private void PrepareData() { networks = new AbstractNetwork[RealizationCount]; NetworkStatuses = new NetworkEventArgs[RealizationCount]; for (int i = 0; i < RealizationCount; ++i) { ModelTypeInfo[] info = (ModelTypeInfo[])ModelType.GetType().GetField(ModelType.ToString()).GetCustomAttributes(typeof(ModelTypeInfo), false); Type t = Type.GetType(info[0].Implementation); Type[] constructTypes = new Type[] { typeof(String), typeof(Dictionary<ResearchParameter, object>), typeof(Dictionary<GenerationParameter, object>), typeof(AnalyzeOption) }; object[] invokeParams = new object[] { ResearchName, ResearchParamaterValues, GenerationParameterValues, AnalyzeOptions }; networks[i] = (AbstractNetwork)t.GetConstructor(constructTypes).Invoke(invokeParams); networks[i].NetworkID = i; networks[i].OnUpdateStatus += new NetworkStatusUpdateHandler(AbstractEnsembleManager_OnUpdateNetworkStatus); NetworkStatuses[i] = new NetworkEventArgs(); NetworkStatuses[i].ID = i; } int threadCount = Math.Min(networks.Length, Environment.ProcessorCount); // Creating thread related members threads = new Thread[threadCount]; waitHandles = new AutoResetEvent[threadCount]; threadData = new ThreadEntryData[threadCount]; // Initialize threads and handles for (int i = 0; i < threadCount; ++i) { waitHandles[i] = new AutoResetEvent(false); threadData[i] = new ThreadEntryData(threadCount, i); threads[i] = new Thread(new ParameterizedThreadStart(ThreadEntry)) { Priority = ThreadPriority.Lowest }; } }