//>>>>Here RUN Gradient Descent private void GradientDescentOptimization() { IsThereDataAvailable = false; double[] InitialParameters = new double[(VLoopModes.Count - 1) * 3]; InitialParameters = GettingInitialValues(); double[] LearningRate = new double[InitialParameters.Length]; for (int i = 0; i < InitialParameters.Length / 3; i++) { LearningRate[0 + i * 3] = TryToDouble(textBoxLRateFreq.Text); LearningRate[1 + i * 3] = TryToDouble(textBoxLRateZeta.Text); LearningRate[2 + i * 3] = TryToDouble(textBoxLRateMass.Text); } GD = new GradientDescent( InitialParameters, LearningRate, (int)TryToDouble(textBoxIterations.Text) ); GD.GD_Settings.Delta = TryToDouble(textBoxDelta.Text); GD.GD_Settings.Error = new Range { MaxValue = 0.0001, MinValue = 0 }; GD.Solve(CostFucntion); #region Writting Results textBoxOPFreq.Clear(); textBoxOPZeta.Clear(); textBoxOPMass.Clear(); for (int i = 0; i < GD.OPTResult.Parameters.Length / 3; i++) { textBoxOPFreq.Text = textBoxOPFreq.Text + " " + GD.OPTResult.Parameters[0 + i * 3].ToString("00.000"); textBoxOPZeta.Text = textBoxOPZeta.Text + " " + GD.OPTResult.Parameters[1 + i * 3].ToString("0.000"); textBoxOPMass.Text = textBoxOPMass.Text + " " + GD.OPTResult.Parameters[2 + i * 3].ToString("0.000"); } textBoxOPError.Text = GD.OPTResult.target[0].ToString(); #endregion IsThereDataAvailable = true; PlottingGAData(); newVLoopModes = new List <Mode>(); newVLoopModes.Add(new Mode { Freq = VLoopModes[0].Freq, Zeta = VLoopModes[0].Zeta, Mass = VLoopModes[0].Mass }); for (int i = 0; i < InitialParameters.Length / 3; i++) { Mode mode = new Mode(); mode.Freq = GD.OPTResult.Parameters[0 + i * 3]; mode.Zeta = GD.OPTResult.Parameters[1 + i * 3]; mode.Mass = GD.OPTResult.Parameters[2 + i * 3]; newVLoopModes.Add(mode); } FRF[] Struct_sim = new FRF[FormMain.Struct_ref.Length]; for (int i = 0; i < FormMain.Struct_ref.Length; i++) { Complex Res = Tool.GetStructureResponse(FormMain.Struct_ref[i].Freq, newVLoopModes, "Velocity"); Struct_sim[i] = new FRF(FormMain.Struct_ref[i].Freq, Res); } FormMain.DrawResult(Struct_sim); }