Пример #1
0
 private void sort_Click(object sender, EventArgs e)
 {
     //Array.Sort(CurrentPop.ind); // works
     //Console.Write(Population.Select(CurrentPop.ind));
     Robot_call.Update_bars(CurrentPop.ind[Population.Pop_size - 1 - _individual]._DNA);
     Robot_call.Update_pts(CurrentPop.ind[Population.Pop_size - 1 - _individual]._DNA);
     Robot_call.Robot_interactive(true);
     Robot_call.Refresh();
     _individual++;
 }
Пример #2
0
        public void Evaluate()
        {
            Robot_call.Robot_interactive(false);

            // Robot_call.Update_pts(this._DNA);
            Robot_call.Update_bars(this._DNA);

            Robot_call.Addsupports();

            // create calculation lists //
            Leg_calc_list();
            HorizBar_calc_list();
            Bracing_calc_list();
            /////////////////////////////

            this.results = Robot_call.Run_analysis();

            // Robot_call.Refresh();
            // Robot_call.Robot_interactive(true);
            Robot_call.Robot_interactive(false);
            Robot_call.Robot_interactive(true);
            Robot_call.Refresh();
            Calc_operations.EC3_Checks(0, ref Repair_instr, Leg_ops, this.results);
            Calc_operations.EC3_Checks(1, ref Repair_instr, Bracing_ops, this.results);
            Calc_operations.EC3_Checks(2, ref Repair_instr, Horiz_ops_plane_bracing, this.results);
            //Calc_operations.EC3_Checks(3, ref Repair_instr, Horiz_ops_Offplane_bracing);

            //sort and create various lists for repair function
            Create_Repair_Function_Lists(Repair_instr, ref over_designed, ref under_designed, ref to_disable);

            Repair(ref over_designed, ref under_designed, ref to_disable);

            //Repair function aqui para cada lista; no disable verificar se podem ser disabled; no over designed ha limite de redução mas escolha e aleatoria
            //(ou nao... ver se deve ser assim ou entao deve ser as primeiras 3 ou 4 da lista (remover da lista caso ja tenha sido alterada?) ou add a uma temp list os n que ja sairam

            this.fitness += get_ton(); // get weight
            Console.WriteLine("Fitness: " + this.fitness);
            // analisar todas as calcOps
            // na classe calc_ops
            // com os resultados reparar as barras
            // funçao repair é nesta classe
            // calc fitness  = peso
            //get matrix with N V MY Mz for each bar
        }
Пример #3
0
        private void draw_Click(object sender, EventArgs e)
        {
            int c = 0;

            this.Chart.Series.Clear();
            this.Chart.Titles.Add("Fitness");
            System.Windows.Forms.DataVisualization.Charting.Series series = this.Chart.Series.Add("fitness");
            series.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Spline;

            double best  = 0.0;
            int    count = 0;

            CurrentPop = new Population(NextPop.ind);
            for (int i = 0; i < 928; i++)
            {
                Generation.Text = i.ToString();
                // CurrentPop = new Population(NextPop.ind);
                if (i == 0)
                {
                    for (int a = 0; a < Population.Pop_size; a++)
                    {
                        CurrentPop.ind[a].Evaluate();
                        c++;
                        series.Points.AddXY(c, CurrentPop.ind[a].fitness);
                        //Robot_call.Robot_interactive(true);
                    }
                    best = CurrentPop.ind[4].fitness;
                }
                else    /*CurrentPop.ind[0].Evaluate();*/
                {
                    c++;
                    series.Points.AddXY(c, CurrentPop.ind[0].fitness);
                }

                Array.Sort(CurrentPop.ind);

                if (best == CurrentPop.ind[Population.Pop_size - 1].fitness)
                {
                    count++;
                }
                else
                {
                    best = CurrentPop.ind[Population.Pop_size - 1].fitness; count = 0;
                }
                if (count > 200)
                {
                    break;
                }

                Individual temp = Population.Evolve_single(CurrentPop.ind, i);
                temp.Evaluate();

                if (temp.fitness < CurrentPop.ind[0].fitness)
                {
                    CurrentPop.ind[0] = temp;
                }
                else
                {
                    CurrentPop.ind[0] = temp;
                }
                //CurrentPop.ind[0] = temp; //Population.Evolve_single(CurrentPop.ind, i).Evaluate();
                //Robot_call.Robot_interactive(true);
                //Robot_call.Refresh();

                //LastPop = new Population(CurrentPop.ind);
                //NextPop = new Population(Population.Evolve(CurrentPop.ind,i));
            }
            // CurrentPop.ind[Population.Pop_size - 1].Evaluate();

            Robot_call.Update_bars(CurrentPop.ind[Population.Pop_size - 1]._DNA);
            Robot_call.Update_pts(CurrentPop.ind[Population.Pop_size - 1]._DNA);
            Robot_call.Robot_interactive(true);
            Robot_call.Refresh();
        }