コード例 #1
0
ファイル: Form1.cs プロジェクト: cielo523/tsp-pso
        private void startButton_Click(object sender, EventArgs e)
        {
            if (thread != null && thread.IsAlive) return; // 1 watek na raz

            CultureInfo ci = (CultureInfo)CultureInfo.CurrentCulture.Clone();
            ci.NumberFormat.CurrencyDecimalSeparator = ".";
            try
            {
                float C1 = float.Parse(c1Val.Text, NumberStyles.Any, ci);
                float C2 = float.Parse(c1Val.Text, NumberStyles.Any, ci);
                float OMEGA = float.Parse(c1Val.Text, NumberStyles.Any, ci);
                Int32 REHOPE = Int32.Parse(rehopeVal.Text);
                Int32 NOCHANGE = Int32.Parse(noChangeVal.Text);
                Int32 particles = Int32.Parse(particlesVal.Text);
                if (openFile.ShowDialog() == DialogResult.OK)
                {
                    algo = new AlgoThread(this, openFile.FileName, 
                        C1, C2, OMEGA, REHOPE, NOCHANGE, particles);
                    thread = new Thread(algo.Run);
                    thread.Start();
                    startButton.Text = "Obliczanie ...";
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show("Błąd: " + exc.Message);
            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: cielo523/tsp-pso
 public void OnAlgoEndHandler(AlgoThread algo)
 {
     vercicesCountLabel.Text = algo.res.verticesCount.ToString();
     psoCostLabel.Text = algo.res.psoCost.ToString();
     saCostLabel.Text = algo.res.saCost.ToString();
     randomCostLabel.Text = algo.res.rsCost.ToString();
     this.maxX = algo.maxIter;
     this.maxY = algo.maxVal;
     this.psoRes = algo.psoRes;
     this.rsRes = algo.rsRes;
     this.saRes = algo.saRes;
     startButton.Text = "Załaduj i rozpocznij";
     panel1.Invalidate();
 }