Пример #1
0
        /// <summary>
        /// Recalculate cutting speed.
        /// </summary>
        void Calculate_Vc()
        {
#if TRACE_EVENTS
            log.Debug($"Calculator: Vc({material.Vc})");
#endif
            Vc.SetValueScaled(material.Vc);
        }
Пример #2
0
            /// <summary>
            /// Recalculate Vc value.
            /// </summary>
            void Calculate_Vc()
            {
                // calculate Vc from n and tool D
                // Vc = pi D n

                // n from rotations to time domain. (not yet done automatic)
                var v1_3 = new DoubleST(1, "[1/s]") * (DoubleST)n / n.BaseNormal();
                var v1   = Math.PI * (DoubleST)tool.D * v1_3;

#if TRACE_EVENTS
                log.Debug($"Calculator.Material: Vc({v1})");
#endif
                Vc.SetValueScaled(v1);
            }
Пример #3
0
        private void startBtn_Click(object sender, EventArgs e)
        {
            double a         = Convert.ToDouble(aBox.Text);
            double b         = Convert.ToDouble(bBox.Text);
            double d         = Convert.ToDouble(dBox.Text);
            int    T         = Convert.ToInt32(Tbox.Text);
            Random generator = new Random();
            int    round     = 0;
            int    l         = (int)Math.Ceiling(Math.Log(((b - a) * (1 / d)) + 1, 2));

            double pom = d;

            while (pom < 1)
            {
                round++;
                pom *= 10;
            }
            List <Individual>         individuals  = new List <Individual>();
            List <List <Individual> > ListofListVc = new List <List <Individual> >();
            List <Individual>         ListVcBest   = new List <Individual>();
            Individual        Vc;
            Individual        VBest = null;
            Individual        Vn;
            List <Individual> listVc;

            for (int i = 0; i < T; i++)
            {
                listVc = new List <Individual>();
                Vc     = HC.MakeFirstInd(a, b, d, l, generator);
                listVc.Add(Vc.Clone());
                if (i == 0)
                {
                    VBest = Vc.Clone();
                }
                while (true)
                {
                    Vn = HC.MakeVn(Vc, a, b, l, round);
                    if (Vn.Fx > Vc.Fx)
                    {
                        Vc = Vn.Clone();
                        listVc.Add(Vc.Clone());
                    }
                    else
                    {
                        break;
                    }
                }
                ListofListVc.Add(listVc);
                if (VBest.Fx < Vc.Fx)
                {
                    VBest = Vc.Clone();
                }
                ListVcBest.Add(VBest.Clone());
                if (VBest.Xreal == 10.999)
                {
                    break;
                }
            }
            individuals.Add(VBest);
            var bindingList = new BindingList <Individual>(individuals);
            var source      = new BindingSource(bindingList, null);

            table.DataSource = source;
            ToTxt.WriteToFile(ListofListVc, T, d);
            MakeChart(ListofListVc, ListVcBest);
        }
Пример #4
0
        private void startTestBtn_Click(object sender, EventArgs e)
        {
            double a         = Convert.ToDouble(aBox.Text);
            double b         = Convert.ToDouble(bBox.Text);
            double d         = Convert.ToDouble(dBox.Text);
            Random generator = new Random();
            int    round     = 0;
            int    l         = (int)Math.Ceiling(Math.Log(((b - a) * (1 / d)) + 1, 2));

            double pom = d;

            while (pom < 1)
            {
                round++;
                pom *= 10;
            }
            List <List <Individual> > ListofListVc = new List <List <Individual> >();
            List <Individual>         ListVcBest   = new List <Individual>();
            Individual        Vc;
            Individual        VBest = null;
            Individual        Vn;
            List <Individual> listVc;
            List <Generation> listGen = new List <Generation>();

            for (int i = 0; i < 3000; i++)
            {
                Generation generation = new Generation
                {
                    Iteration = i + 1
                };
                listGen.Add(generation);
            }
            for (int j = 0; j < 10000; j++)
            {
                for (int i = 0; i < 3000; i++)
                {
                    listVc = new List <Individual>();
                    Vc     = HC.MakeFirstInd(a, b, d, l, generator);
                    listVc.Add(Vc.Clone());
                    if (i == 0)
                    {
                        VBest = Vc.Clone();
                    }
                    while (true)
                    {
                        Vn = HC.MakeVn(Vc, a, b, l, round);
                        if (Vn.Fx > Vc.Fx)
                        {
                            Vc = Vn.Clone();
                            listVc.Add(Vc.Clone());
                        }
                        else
                        {
                            break;
                        }
                    }
                    ListofListVc.Add(listVc);
                    if (VBest.Fx < Vc.Fx)
                    {
                        VBest = Vc.Clone();
                    }
                    ListVcBest.Add(VBest.Clone());
                    if (VBest.Xreal == 10.999)
                    {
                        listGen[i].SolveCount += 1;
                        break;
                    }
                }
            }

            for (int i = 1; i < listGen.Count; i++)
            {
                listGen[i].Cumulation += listGen[i - 1].SolveCount + listGen[i - 1].Cumulation;
            }

            MakeTestChart(listGen);
            var bindingList = new BindingList <Generation>(listGen);
            var source      = new BindingSource(bindingList, null);

            testTable.DataSource = source;
        }