/// <summary> /// Plot function with generation of individuals. /// </summary> /// <param name="selectedFuncId"></param> /// <param name="population"></param> private void PlotGeneration(int selectedFuncId, Individuals population) { ILArray <float> A = ILMath.zeros <float>(3, population.Population.Count - 1); ILArray <float> B = ILMath.zeros <float>(3, 0); var dim = _benchmark.GetById(selectedFuncId).Dimension; var best = population.GetBest(); int c = 0; foreach (var i in population.Population) { if (i == best) { continue; } A[0, c] = i.Dimension[0]; A[1, c] = i.Dimension[1]; A[2, c] = i.Z; c += 1; } // Best individual B[0, 0] = best.Dimension[0]; B[1, 0] = best.Dimension[1]; B[2, 0] = best.Z; _scene = new ILScene() { new ILPlotCube(twoDMode: false) { new ILSurface((x, y) => CallFunction(selectedFuncId, new float[] { x, y }), xmin: (float)genMin.Value, xmax: (float)genMax.Value, xlen: LENGTH, ymin: (float)genMin.Value, ymax: (float)genMax.Value, ylen: LENGTH, colormap: Colormaps.Hsv) { new ILColorbar() }, new ILPoints { Positions = ILMath.tosingle(B), Color = Color.Blue }, new ILPoints { Positions = ILMath.tosingle(A), Color = Color.DarkSlateGray } } }; ilPanel1.Scene = _scene; ilPanel1.Refresh(); return; }
public override Individuals Run(Individuals p, Function f, bool _integer, float?min = null, float?max = null) { if (min == null) { min = f.GetMin(); } if (max == null) { max = f.GetMax(); } Individual best = p.GetBest(); var result = new Individuals(); result.Population.Add(best); result.GeneratePopulation(p.Population.Count - 1, f, _integer, min, max); return(result); }