Пример #1
0
        int z = 0; //flag


        private void recountBtn_Click(object sender, EventArgs e)
        {
            I1 -= 0.09;
            I2 -= 0.09;
            I3 -= 0.09;
            I4 -= 0.09;
            I5 -= 0.09;
            I6 -= 0.09;

            I1tb.Text = I1.ToString();
            I2tb.Text = I2.ToString();
            I3tb.Text = I3.ToString();
            I4tb.Text = I4.ToString();
            I5tb.Text = I5.ToString();
            I6tb.Text = I6.ToString();

            U2 = I2 * EU * IV / ((IV + I2 + I1) * (I2 + I3 + I4 + I5 - Math.Pow(I2, 2) / (IV + I2 + I1) - Math.Pow((I4 + I5), 2) / (I4 + I5 + I6)));
            U1 = U2 * I2 / (IV + I2 + I1) + EU * IV / (IV + I2 + I1);
            U3 = U2 * (I4 + I5) / (I4 + I5 + I6);
            U1 = Math.Round(U1, 3);
            U2 = Math.Round(U2, 3);
            U3 = Math.Round(U3, 3);

            U1label.Text = "U1 = " + U1.ToString();
            U2label.Text = "U2 = " + U2.ToString();
            U3label.Text = "U3 = " + U3.ToString();

            if (z == 1)
            {
                F1 = Math.Round(Math.Pow(U11 - U1, 2), 3);
            }
            if (z == 2)
            {
                F1 = Math.Round(Math.Pow(U22 - U2, 2), 3);
            }
            if (z == 3)
            {
                F1 = Math.Round(Math.Pow(U33 - U3, 2), 3);
            }

            if (F1 < F)
            {
                FTB.Text = F1.ToString();
                F        = F1;
                logsRTB.AppendText("Целевая функция уменьшается F=" + F1.ToString() + "\n");
                logsRTB.ScrollToCaret();
            }
            else
            {
                logsRTB.AppendText("Целевая функция увеличилась F=" + F1.ToString() + "\n");
                logsRTB.ScrollToCaret();
                recountBtn.Enabled = false;
            }
            Fz = 0;

            calculateGrad();
            calculateHessian();
        }
        static void Main(string[] args)
        {
            int I1 = 55;                                                                                //声明整型变量I1,并赋值为55
            int I2 = 10;                                                                                //声明整型变量I1,并赋值为10
            int I3;                                                                                     //声明整型变量I3

            I3 = I1 % I2;                                                                               //使I3等于I1与I2求余运算之后的值
            Console.WriteLine(I3.ToString());
            Console.Read();
        }