Web Simulation 

 

 

 

 

Min-Max Optimization Sandbox 

This interactive sandbox visualizes optimization algorithms for finding minima in 1D and 2D functions: Hill Climbing, Gradient Descent, Simulated Annealing, Nelder-Mead (Simplex), and Coordinate Descent. Each algorithm is implemented as a JavaScript generator, allowing step-by-step execution so you can pause, resume, and observe how they navigate the optimization landscape.

Switch between 2D f(x) (canvas) and 3D f(x,y) (Plotly surface + contour) modes. The path is shown as a magenta trail with a bright current marker. For Simulated Annealing, the marker color transitions from red (hot) to blue (cold). For Nelder-Mead, a green simplex triangle with Best/Good/Worst vertices and an orange centroid shows the "Amoeba" flipping across the landscape.

Hill Climbing greedily moves to the neighboring point with the lowest value—it can get stuck in local minima (candidate dots show evaluated points). Gradient Descent follows the negative gradient with a tangent line at each step. Simulated Annealing uses Metropolis-Hastings: it may accept worse moves with probability exp(−ΔE/T). Nelder-Mead uses a simplex (triangle) that reflects, expands, contracts, or shrinks. Coordinate Descent minimizes along one axis at a time (axis-aligned steps).

Use the function presets to explore: 2D (Bowl, Peaks, Jagged, Double Well, Triple Valley, Gentle Waves) and 3D (Paraboloid, Rosenbrock, Two Basins, Three Basins, Mild Rastrigin, Saddle Valleys). Drag on the graph to set the initial position.

 

Parameters

  • Dimension: 2D f(x) or 3D f(x,y). 3D mode shows Plotly surface (top) and contour (bottom) plots.
  • Algorithm: Hill Climbing, Gradient Descent, Simulated Annealing; in 3D also Nelder-Mead (Simplex) and Coordinate Descent.
  • Target Function: 2D (Bowl, Peaks, Jagged, Double Well, Triple Valley, Gentle Waves); 3D (Paraboloid, Rosenbrock, Two Basins, Three Basins, Mild Rastrigin, Saddle Valleys, Egg Holder).
  • Step Speed: Milliseconds between algorithm steps (10–500 ms).
  • Learning Rate (α) (Gradient Descent): Step size [0–5].
  • Step Size (Hill Climbing, Nelder-Mead, Coordinate Descent): Neighbor/simplex scale [0–5].
  • Cooling Rate, Initial Temp (Simulated Annealing): Temperature control.
  • Start X, Start Y (3D): Sliders or drag on the plot to set initial position.

Buttons

  • Start/Pause: Runs the algorithm step-by-step. Click again to pause.
  • Step: Advances one iteration manually.
  • Reset: Resets to the Start X/Y position and clears the path trail.

Visualization Features

  • 2D Canvas: Function curve (cyan), path trail (magenta), current point (glowing marker).
  • 3D Plotly: Surface plot (top), contour plot (bottom), trajectory, yellow current marker.
  • Hill Climbing: Small orange dots show all candidate points evaluated at each step.
  • Tangent Line (Gradient Descent): Dashed yellow line shows slope at current point.
  • Search Radius (Simulated Annealing): Shrinking circle; marker color red→blue.
  • Nelder-Mead Simplex: Green triangle (Best=green, Worst=red), orange centroid, operation label (e.g., Reflection, Inside Contraction).
  • Draggable Start: Drag on the 2D canvas or contour plot to set the initial position.
  • Stats Panel: X, f(X), iteration, slope/temperature/mode.
  • Log Console: SA moves; Nelder-Mead operation per step.