private void Start_geom_Click(object sender, EventArgs e) { //robApp = new RobotApplication(); // if (robApp.Visible == 0) { robApp.Interactive = 1;robApp.Visible = 1; } //create []hcabos int[] h_cabos = new int[4] { (int)h_cabo1_int.Value, (int)h_cabo2_int.Value, (int)h_cabo3_int.Value, (int)h_cabo4_int.Value }; //create []dist_centro double[] dist_centro = new double[4] { (double)w_cabo1_int.Value, (double)w_cabo2_int.Value, (double)w_cabo3_int.Value, (double)w_cabo4_int.Value }; if (BaseDNA != null || CurrentPop != null) { BaseDNA = null; CurrentPop = null; } BaseDNA = new Fraser.Genome((double)Largura_ap_int.Value, (int)Altura_int.Value, (double)h_div_int.Value, (double)subdiv_int.Value, (int)n_cabos_int.Value, h_cabos, dist_centro); //display the init structure (for user confirmation + add forces) Robot_call.Start_pts(BaseDNA); Robot_call.Start_bars(BaseDNA); Robot_call.Refresh(); // create initial population NextPop = new Population((int)Population_cnt.Value, BaseDNA); }
private void btn_get_sec_Click(object sender, EventArgs e) { new Sections(sec_name.Text, (double)sec_area.Value, (double)sec_iz.Value, (double)sec_iy.Value, (double)sec_iv.Value); Robot_call.Set_sections(sec_name.Text, (double)sec_area.Value, (double)sec_iz.Value, (double)sec_iy.Value); // add to the matrix the area of each section in the get_sections Sec_list.Items.Add(sec_name.Text); Sec_list.Update(); }
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++; }
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 }
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(); }
public Form1() { InitializeComponent(); Robot_call.Start(); }