private void loadNetworkToolStripMenuItem_Click(object sender, EventArgs e) { if (ofd.ShowDialog() == DialogResult.OK && File.Exists(ofd.FileName)) { try { nw = SFNetworkOscillator.Debinarize(ofd.FileName); // вот эта лажа - попытка линейно интерполировать значения между 2 значениями фаз.. работает, но качественно получается плохой результат double n = 1; for (int i = 0; i < nw.States.Count / n - 1; i++) { SFNetworkOscillatorState d = nw.States[(int)(i * n)]; SFNetworkOscillatorState d2 = nw.States[(int)(i * n) + 1]; for (int j = 1; j < n; j++) { double time = d.Time + (d2.Time - d.Time) / n * j; double[] phs = new double[d.Phases.Length]; for (int k = 0; k < phs.Length; k++) { phs[k] = d.Phases[k] + (d2.Phases[k] - d.Phases[k]) / n * j; } SFNetworkOscillatorState st = new SFNetworkOscillatorState(time, phs); nw.States.Insert(i * (int)(n) + j, st); } } VisualizeNetwork(); InitializeMacro(); InitializeHist(); } catch (Exception ex) { MessageBox.Show("Error occured while loading file: " + ex.Message, "Loading error"); } } }
public SFNWOscGraph(SFNetworkOscillator nw, string path, Color clrSS, Color clrCH) { Network = nw; Path = path; Name = System.IO.Path.GetFileName(path); ColorSignal = clrSS; ColorCoherency = clrCH; Visible = true; InitializeMacro(); }
private static void CalculateSFNetworkDynamics() { Console.CursorLeft = 0; Console.WriteLine(" "); SFNetworkOscillator nw = new SFNetworkOscillator(100, 3, .65, 1, 10, -Math.PI, Math.PI, 0, .1, .001, 170302); Stopwatch swGlobal = new Stopwatch(); CancellationTokenSource ctSrc = new CancellationTokenSource(); Task task = new Task(() => { Console.WriteLine("Time: {0:F5}\t0\t0", nw.Time); Stopwatch sw = new Stopwatch(); while (!ctSrc.IsCancellationRequested) { sw.Restart(); nw.SimulateDynamicStep(); sw.Stop(); swGlobal.Stop(); Console.WriteLine("Time: {0:F5}\t{1}\t{2}", nw.Time, sw.Elapsed, swGlobal.Elapsed); swGlobal.Start(); } swGlobal.Stop(); Console.WriteLine("Calculating finished in {0}\n{1} states calculated from t={2} to t={3}", swGlobal.Elapsed, nw.States.Count, nw.States[0].Time, nw.Time); string path = "SFNetworkOscillator_" + nw.Nodes.Count + "_" + nw.Multiplier + "_" + nw.Strength + "_" + nw.FrequenciesInitMin + "_" + nw.FrequenciesInitMax + "_" + nw.PhasesInitMin + "_" + nw.PhasesInitMax + "_" + nw.TimeInit + "_" + nw.TimeStep + "_" + nw.SolveStep + "_" + nw.RandomSeed + "_" + nw.States.Count + ".sfnwosc"; nw.Serialize(path); Console.WriteLine("Serializing finished successfully!\nNetwork saved by path: {0}\nFile size: {1} bytes", path, new FileInfo(path).Length); }, ctSrc.Token); task.Start(); swGlobal.Start(); bool cliStop = false; while (!cliStop) { string s = Console.ReadLine(); if (s == "stop") { ctSrc.Cancel(); } } }
static void Main(string[] args) { SFNetworkOscillator nw = new SFNetworkOscillator(75, 3, 0.3, 1, 10, -Math.PI, Math.PI, 0, 0.1, 0.005, 626); Stopwatch sw = new Stopwatch(); for (int i = 0; i < 300; i++) { sw.Restart(); nw.SimulateDynamicStep(); Console.WriteLine(sw.ElapsedMilliseconds); } nw.Serialize("cs_network_dynamics_check"); return; string s = ""; for (int i = 0; i < nw.Phases.Length; i++) { s += nw.Phases[i] + "\n"; } File.WriteAllText("cs_network_check_dynamics", s); }
private void nwopenToolStripMenuItem_Click(object sender, EventArgs e) { if (ofd.ShowDialog() == DialogResult.OK && File.Exists(ofd.FileName)) { try { foreach (string fn in ofd.FileNames) { SFNetworkOscillator nw = SFNetworkOscillator.Debinarize(fn); SFNWOscGraph nwg = new SFNWOscGraph(nw, fn, Color.Red, Color.Blue); networks.Add(nwg); listBox1.Items.Clear(); foreach (SFNWOscGraph i in networks) { listBox1.Items.Add(i); } OnNetworkOpened?.Invoke(this, nwg); } } catch (Exception ex) { MessageBox.Show("Error occured while loading file: " + ex.Message, "Loading error"); } } }