protected OptimisationMethod(string name, double eps, Delegate f, Vector<double> startVector,
            int maxIterations = 50)
        {
            _maxIterations = maxIterations;

            Name = name;
            Eps = eps;
            Fh = new FunctionHolder(f, startVector);
        }
Пример #2
0
 /// <summary>
 ///     CALCULATE BUTTON CLICK
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void calculateButton_Click(object sender, EventArgs e)
 {
     _currMethod.AlphaMethod = null;
     Vector<double> start = new DenseVector(_varCount);
     try
     {
         var text = startingPointTextBox.Text;
         var textValues = text.Split(',');
         for (var i = 0; i < _varCount; i++)
         {
             start[i] = double.Parse(textValues[i]);
         }
     }
     catch (Exception)
     {
         start.Clear();
     }
     var fh = new FunctionHolder(_currFunction, start);
     _currMethod.Fh = fh;
     if (_alphaMethodChosen)
     {
         _currAlphaMethod.F = fh.AlphaFunction;
         _currAlphaMethod.Df = fh.AlphaDiffFunction;
         _currMethod.AlphaMethod = _currAlphaMethod;
     }
     double eps;
     try
     {
         eps = double.Parse(precisionTextBox.Text);
     }
     catch (Exception)
     {
         eps = 1e-5;
         precisionTextBox.Text = @"1e-5";
     }
     _currMethod.Eps = eps;
     //Делаем сам метод
     var sw = Stopwatch.StartNew();
     _currMethod.Execute();
     sw.Stop();
     //Вывод, Двуменрная функция
     var coord = _currMethod.Answer;
     answerTextBox.Text = @"Answer:" + Environment.NewLine + coord.ToString();
     iterationTextBox.Text = Convert.ToString("Iterations: " + _currMethod.IterationCount);
     timeTextBox.Text = @"Time (ms):" + Environment.NewLine +((sw.ElapsedMilliseconds == 0) ? ("<1") : (sw.ElapsedMilliseconds.ToString()));
 }
Пример #3
0
 /// <summary>
 ///     Нажатие кнопки "TEST ALL"
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void materialFlatButton1_Click(object sender, EventArgs e)
 {
     var exports = new List<TestExport>(_functions.Count*_methods.Count);
     foreach (var function in _functions)
     {
         ParseFunction(function);
         foreach (var method in _methods)
         {
             _currMethod = method;
             _currMethod.AlphaMethod = null;
             Vector<double> start = new DenseVector(_varCount);
             try
             {
                 var text = startingPointTextBox.Text;
                 var textValues = text.Split(',');
                 for (var i = 0; i < _varCount; i++)
                 {
                     start[i] = double.Parse(textValues[i]);
                 }
             }
             catch (Exception)
             {
                 start.Clear();
             }
             var fh = new FunctionHolder(_currFunction, start);
             _currMethod.Fh = fh;
             if (_alphaMethodChosen)
             {
                 _currAlphaMethod.F = fh.AlphaFunction;
                 _currAlphaMethod.Df = fh.AlphaDiffFunction;
                 _currMethod.AlphaMethod = _currAlphaMethod;
             }
             double eps;
             try
             {
                 eps = double.Parse(precisionTextBox.Text);
             }
             catch (Exception)
             {
                 eps = 1e-5;
                 precisionTextBox.Text = @"1e-5";
             }
             _currMethod.Eps = eps;
             //Делаем сам метод
             var sw = Stopwatch.StartNew();
             _currMethod.Execute();
             sw.Stop();
             //Вывод, Двуменрная функция
             var coord = _currMethod.Answer;
             exports.Add(new TestExport(method.Name,function,coord.ToVectorString(),method.IterationCount.ToString(),sw.ElapsedMilliseconds.ToString(),eps.ToString()));
         }
     }
     var testForm = new TestForm(exports);
     _materialSkinManager.AddFormToManage(testForm);
     testForm.ShowDialog();
 }