Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void button1_Click(object sender, EventArgs e)
- {
- HillClimbAlg hc = new HillClimbAlg() {Function= tf.Rastrigin, Iteration = 3, Step = 0.5f, MaxX= 100f, MaxY= 100f, MinX=-0,MinY=0 };
- Random r = new Random();
- var crds = hc.Compute((float)(r.NextDouble() + r.Next(0, 99)), (float)(r.NextDouble() + r.Next(0, 99)), 30);// r.Next(-5, 5), r.Next(-5, 5), 20);
- Plot(new ILSurface(tf.Rastrigin, xmin: -5.12f, xmax: 100f, ymin: -5.12f, ymax: 100f), crds);
- // Plot(new ILSurface(tf.Sphere, xmin: -5.12f, xmax: 100f, ymin: -5.12f, ymax: 100f), ListTo2DArray(crds),Color.Black);
- }
- private void Plot(ILSurface surface, List<P3D> points)
- {
- ilPanel1.Scene.Remove(IplotCub);
- IplotCub = new ILPlotCube(twoDMode: false);
- if (points != null)
- {
- foreach (var p in points)
- {
- surface.Add(new ILPoints(color: p.Color) { Positions = p.Coord });
- }
- }
- IplotCub.Add(surface);
- ilPanel1.Scene.Add(IplotCub);
- }
- public class P3D
- {
- public ILArray<float> Coord { get; set; }
- public Color Color { get; set; } = Color.Black;
- public P3D(float[] coords, Color color)
- {
- Coord = coords;
- Color = color;
- }
- public P3D(float[] coords)
- {
- Coord = coords;
- Color = Color.Black;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement