private void runThread() { m_running_start_time = DateTime.Now; DateTime time_sample = m_running_start_time; while (m_running) { // create a new generation m_ga.Create_Generation(); // detect and start a local minimum escape astrategy m_ga.Local_Minimum_Escape(); // refresh chart every 30 seconds TimeSpan time_diff = DateTime.Now - time_sample; if (time_diff.Seconds >= m_refreash_rate) { time_sample = DateTime.Now; Debug.Assert(ChartControl.InvokeRequired); dumpCallback d = new dumpCallback(dump); Invoke(d, new object[] {}); // stop after 3 minutes time_diff = DateTime.Now - m_running_start_time; if (time_diff.Minutes >= 3) { m_running = false; } } } }
private void runThread() { m_running_start_time = DateTime.Now; DateTime time_sample = m_running_start_time; for (int batch_index = 0; batch_index < 100; batch_index++) { bool Stable = false; while (m_running && !Stable) { Stable = m_Network.Step(false); dumpCallback d = new dumpCallback(dump); if (d != null) { Invoke(d, new object[] { false }); } } dumpCallback d2 = new dumpCallback(dump); if (d2 != null) { Invoke(d2, new object[] { true }); } if (m_batch && m_running) { Console.WriteLine("{0}: {1}, {2}", batch_index, TotalHappinessTextBox.Text, m_Network.IsLegaySolution()); if (!m_Network.IsLegaySolution()) { Console.Write(""); } Source.Preferences Data = Source.Preferences.GetInstance(); Data.Randomize(); m_Network.Randomize(); } else { break; } } m_running = false; m_batch = false; }