private void addPopulationControls(Population pop, double[] data) { SuspendLayout(); populationPanel.Controls.Clear(); for (int i = 0; i < pop.popSize; i++) { Individual ind = pop.getInd(i); ButtonInd btn = new ButtonInd(ind,data); btn.Text = "(" + i + "): " + ind.getLastFitness(); btn.MouseClick += new MouseEventHandler(ind_btn_mouseClick); btn.Location = new Point(0, i * btn.Height); populationPanel.Controls.Add(btn); } ResumeLayout(); PerformLayout(); }
private void TestPop() { int numberOfTests = 10; double[] data = new double[] { 1, 2, 5, 6,10, 8, 7, 3, 2, 5, 5, 5,25, 1,10, 10,18, 6, 4, 3, 5, 5, 4, 6,10, 13,18,27,35,40, 38,37,39,36,35}; int testLength = data.Length - numberOfTests; Population pop = new Population(); pop.initialize(30, new Range(3,7), testLength); //pop.printInfix(); pop.scaleIndividuals(data, numberOfTests); pop.calculateFitness(data, numberOfTests); pop.bubbleSort(); addPopulationControls(pop,data); }