Advertisement
lu4kedr

Untitled

Sep 29th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.56 KB | None | 0 0
  1.         private void button1_Click(object sender, EventArgs e)
  2.         {
  3.  
  4.             HillClimbAlg hc = new HillClimbAlg() {Function= tf.Rastrigin, Iteration = 3, Step = 0.5f, MaxX= 100f, MaxY= 100f, MinX=-0,MinY=0 };
  5.             Random r = new Random();
  6.            
  7.             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);
  8.  
  9.             Plot(new ILSurface(tf.Rastrigin, xmin: -5.12f, xmax: 100f, ymin: -5.12f, ymax: 100f), crds);
  10.  
  11.             // Plot(new ILSurface(tf.Sphere, xmin: -5.12f, xmax: 100f, ymin: -5.12f, ymax: 100f), ListTo2DArray(crds),Color.Black);
  12.         }
  13.  
  14.         private void Plot(ILSurface surface, List<P3D> points)
  15.         {
  16.             ilPanel1.Scene.Remove(IplotCub);
  17.             IplotCub = new ILPlotCube(twoDMode: false);
  18.             if (points != null)
  19.             {
  20.                 foreach (var p in points)
  21.                 {
  22.                     surface.Add(new ILPoints(color: p.Color) { Positions = p.Coord });
  23.  
  24.                 }
  25.             }
  26.             IplotCub.Add(surface);
  27.             ilPanel1.Scene.Add(IplotCub);
  28.         }
  29.  
  30.  
  31.  
  32.  
  33.     public class P3D
  34.     {
  35.         public ILArray<float> Coord { get; set; }
  36.         public Color Color { get; set; } = Color.Black;
  37.  
  38.         public P3D(float[] coords, Color color)
  39.         {
  40.             Coord = coords;
  41.             Color = color;
  42.         }
  43.         public P3D(float[] coords)
  44.         {
  45.             Coord = coords;
  46.             Color = Color.Black;
  47.         }
  48.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement