Пример #1
0
 public Form1()
 {
     InitializeComponent();
     this.FormClosing += Form1_FormClosing;
     best              = GetObjectBestSampleAlgorithm();
     if (best != null)
     {
         SetControlParams(best);
     }
     if (best == null)
     {
         SaveCheckBox.Checked = false;
     }
 }
Пример #2
0
        private BestSampleAlgorithm GetObjectBestSampleAlgorithm()
        {
            BestSampleAlgorithm bestAlgorithm = new BestSampleAlgorithm();

            try
            {
                ObjectSerializer <BestSampleAlgorithm> objSerializer = new ObjectSerializer <BestSampleAlgorithm>();
                BestSampleAlgorithm yourObjectFromFile = objSerializer.GetSerializedObject(SerializePathObject);
                if (yourObjectFromFile != null)
                {
                    bestAlgorithm = yourObjectFromFile;
                }
                else
                {
                    bestAlgorithm = null;
                }
            }
            catch (Exception) { }
            return(bestAlgorithm);
        }
Пример #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            Random random = new Random(DateTime.Now.Millisecond);

            string function = FunctionTextBox.Text;
            double testStep = double.Parse(TestStepInputTextBox.Text.Replace(".", ","));

            ExtendedPoint point = new ExtendedPoint();

            point.X = random.Next(-10, 10);
            point.Y = random.Next(-10, 10);

            best = new BestSampleAlgorithm(function, testStep);
            best.QuantityVectrors = int.Parse(VectorsInputTextBox.Text);

            var result = best.StartSolution(point);

            OutPutXLabel.Text      = best.EndPoint.X.ToString();
            OutPutYLabel.Text      = best.EndPoint.Y.ToString();
            XinputLabel.Text       = point.X.ToString();
            YinputLabel.Text       = point.Y.ToString();
            ResultOutputLable.Text = result.ToString();
        }
Пример #4
0
 private void SetControlParams(BestSampleAlgorithm best)
 {
     FunctionTextBox.Text      = best.Functioon;
     TestStepInputTextBox.Text = best.TestStep.ToString();
     VectorsInputTextBox.Text  = best.QuantityVectrors.ToString();
 }
Пример #5
0
 private void InitializeBSA()
 {
     best                    = new BestSampleAlgorithm(BSA_FunctionText.Text, 0.1);
     best.Progress          += Best_Progress;
     BSA_ProgressBar.Maximum = 10;
 }