Equations & optimization

Constrained Nonlinear Optimization Explorer

Four landscapes (a tilted plane, a stretched bowl, the Rosenbrock banana valley and the four-valley Himmelblau function), fenced by a draggable line with a forbidden side and a draggable circle. Projected gradient descent on a quadratic penalty runs from two starts in four stages of growing weight, and a Nelder-Mead triangle searches from the first start without any slopes; every step is a row the canvas plays back over a 25 x 25 heat map. Outputs give each run end, its height, how far it breaks an edge, which edges press on it, the outcome and the work in evaluations, plus a stage-by-stage table. Five challenges are scored by the lab. For learning why a weak penalty leaves the answer outside the edges, why a stiff one makes the steps crawl, and what a slope-free method can do.

Last updated

Calculator overview

Inputs and outputs

This summary comes from the calculator's published input and output contract.

Inputs

Line edge (required)
About this input

On or Off: a straight edge whose forbidden side the answer must avoid. Switch it with the toolbar chip on the canvas.

Default Off Allowed On, Off
Allowed side of the line (required)
About this input

Line on only: which side of the line is allowed. Right means the allowed side is on your right as you walk from handle A to handle B; the other side is shaded as forbidden. Tap the side chip on the line.

Default Right Allowed Left, Right
Landscape (required)
About this input

The landscape whose lowest allowed point is sought: Tilted plane (a flat slope), Bowl (a stretched, turned bowl), Banana valley (the Rosenbrock function, a curved valley with its floor at (1, 1)) or Four valleys (the Himmelblau function, four separate low points). Each has its own view box.

Default Bowl Allowed Tilted plane, Bowl, Banana valley, Four valleys
Line handle A, y (required)
About this input

Line on only: y of line handle A, from -5 to 5.

Default 0.5 Range -5 to 5
Line handle B, x (required)
About this input

Line on only: x of line handle B, from -5 to 5. The two handles must be at least 0.2 apart.

Default 2.5 Range -5 to 5
Line handle B, y (required)
About this input

Line on only: y of line handle B, from -5 to 5.

Default 0.5 Range -5 to 5
Penalty growth power (required)
About this input

0 keeps the penalty weight the same in all four stages; 1 multiplies it by 10 at each new stage. Use the stepper on the canvas.

Default 0 Range 0 to 1
Start A, y (required)
About this input

y of start A, from -5 to 5.

Default -2 Range -5 to 5
Start B, x (required)
About this input

x of start B, from -5 to 5, where gradient run B starts (shown from Experiment). Drag marker B.

Default 2 Range -5 to 5
Start B, y (required)
About this input

y of start B, from -5 to 5.

Default -2 Range -5 to 5
Penalty start power (required)
About this input

The penalty weight of the first stage is 10 to this power (0 to 4, so 1 to 10,000). A larger weight keeps the answer closer to the edges but makes the steps smaller. Use the stepper on the canvas.

Default 3 Range 0 to 4
Starting triangle size (required)
About this input

The side of the simplex method starting triangle at start A, from 0.05 to 2. Drag the triangle handle along its rail on the canvas.

Default 0.45 Range 0.05 to 2
Start A, x (required)
About this input

x of start A, from -5 to 5, where gradient run A and the simplex triangle start; a start outside the view box is moved onto its edge. Drag marker A.

Default -2 Range -5 to 5
Line handle A, x (required)
About this input

Line on only: x of line handle A, from -5 to 5. Drag the handle on the canvas.

Default -2.5 Range -5 to 5
Bowl centre, y (required)
About this input

Bowl only: y of the lowest point of the bowl, from -5 to 5.

Default 1.5 Range -5 to 5
Bowl stretch (required)
About this input

Bowl only: how many times steeper the bowl rises across its long axis than along it, from 1 (round) to 20 (a narrow trough). Drag the stretch handle along the bowl axis on the canvas.

Default 4 Range 1 to 20
Bowl turn (required)
About this input

Bowl only: the direction of the bowl long axis, in whole degrees from 0 to 175. Turn the axis handle about the bowl centre on the canvas.

Unit deg Default 30 Range 0 to 175
Your prediction: edges that hold the answer (required)
About this input

Challenge 1 only: your prediction of which edges the lowest allowed point presses against (None, Line, Circle or Both). It starts at Not yet predicted (a blank counts the same), and the descent stays hidden until you choose.

Default Not yet predicted Allowed Not yet predicted, None, Line, Circle, Both
Valley steepness (required)
About this input

Banana valley only: how steep the valley walls are, a whole number from 1 to 100 (100 is the classic Rosenbrock valley).

Default 100 Range 1 to 100
Bowl centre, x (required)
About this input

Bowl only: x of the lowest point of the bowl, from -5 to 5. Drag the bowl centre on the canvas.

Default 2 Range -5 to 5
Challenge number (required)
About this input

0 for no challenge, or 1 to 5 to load a challenge. A challenge fixes every setting except the ones it leaves to you, and the lab scores it.

Default 0 Range 0 to 5
Circle radius (required)
About this input

Circle on only: the circle radius, from 0.2 to 5. Drag the rim handle on the canvas.

Default 1 Range 0.2 to 5
Stopping tolerance (required)
About this input

The stopping tolerance of both methods, from 0.00000001 to 0.01 (default 0.0001). A stage of the gradient run ends when the projected step is this small relative to the slope; the simplex stops when its triangle and its values are this small.

Default 0.0001 Range 1E-08 to 0.01
Downhill direction (required)
About this input

Tilted plane only: the direction the plane falls towards, in whole degrees from 0 to 359 (0 points along +x, 90 along +y). Rotate the downhill arrow on the canvas.

Unit deg Default 45 Range 0 to 359
Circle centre, x (required)
About this input

Circle on only: x of the circle centre, from -5 to 5. Drag the centre on the canvas.

Default 0 Range -5 to 5
Circle centre, y (required)
About this input

Circle on only: y of the circle centre, from -5 to 5.

Default 0 Range -5 to 5
Circle edge (required)
About this input

On or Off: the answer must stay inside the circle. Switch it with the toolbar chip on the canvas.

Default On Allowed On, Off

Outputs

Push from the circle (multiplier)
About this output

The push of the circle on the answer, 2 x weight x violation (blank when the circle is off).

No unit declared
Push from the line (multiplier)
About this output

The push of the line on the answer, estimated as 2 x weight x violation (blank when the line is off): the violation equals this push divided by twice the weight.

No unit declared
Formula module versions
About this output

The versions of the formula modules this lab uses.

No unit declared
Model Status
About this output

OK when gradient run A settles inside the allowed region; CHECK when it stalls, uses all 60 steps without settling, or ends outside an edge by more than the feasibility tolerance (results still shown); NOT VALID, naming the input, when an input cannot be used (results empty).

No unit declared
Model version
About this output

The version of this lab's model.

No unit declared
Penalty growth power used
About this output

The penalty growth power the model used (the challenge value when a challenge fixes it); blank when it does not apply or the inputs are not valid.

No unit declared
Run A by penalty stage: the weight, the steps used, the violation left and how the stage ended
About this output

Run A by penalty stage: the weight, the steps used, the largest violation when the stage ended, and how it ended (Test passed, Step cap, Stalled or Not reached).

No unit declared
Gradient run B, step by step: the point and its penalty stage
About this output

Gradient run B step by step: the point and its penalty stage.

No unit declared
Landscape used
About this output

The landscape the model used (the challenge value when a challenge fixes it); blank when it does not apply or the inputs are not valid.

No unit declared
Gradient run A, step by step: the point, its penalty stage, the penalised value and the largest violation
About this output

Gradient run A step by step: the point, its penalty stage (1 to 4), the penalised value and the largest violation. Rows after the end show only the step number.

No unit declared
Line end on the view edge 1, x
About this output

Where the line enters the view box, x (canvas only; blank when the line is off or misses the box).

No unit declared
Line end on the view edge 2, x
About this output

Where the line leaves the view box, x (canvas only).

No unit declared
Line handle B, y used
About this output

The line handle B, y the model used (the challenge value when a challenge fixes it); blank when it does not apply or the inputs are not valid.

No unit declared
Line handle A, y used
About this output

The line handle A, y the model used (the challenge value when a challenge fixes it); blank when it does not apply or the inputs are not valid.

No unit declared
Line handle B, x used
About this output

The line handle B, x the model used (the challenge value when a challenge fixes it); blank when it does not apply or the inputs are not valid.

No unit declared
Allowed side of the line used
About this output

The allowed side of the line the model used (the challenge value when a challenge fixes it); blank when it does not apply or the inputs are not valid.

No unit declared
Start whose end is lower
About this output

Which start reached the lower allowed end: Start A, Start B, Same minimum (both ends are allowed and at the same minimum, so neither is lower), CHECK: tie within the band (different minima whose heights are within one part in a million) or CHECK: neither end is feasible. An end that is not feasible never wins.

No unit declared
Line edge used
About this output

The line edge the model used (the challenge value when a challenge fixes it); blank when it does not apply or the inputs are not valid.

No unit declared
Line end on the view edge 1, y
About this output

Where the line enters the view box, y (canvas only).

No unit declared
Line end on the view edge 2, y
About this output

Where the line leaves the view box, y (canvas only).

No unit declared
Penalty start power used
About this output

The penalty start power the model used (the challenge value when a challenge fixes it); blank when it does not apply or the inputs are not valid.

No unit declared
Start B, y used
About this output

The start B, y the model used (the challenge value when a challenge fixes it; moved into the view box); blank when it does not apply or the inputs are not valid.

No unit declared
Same or different minima
About this output

Same minimum when the two ends are within 0.05 times the box size of each other; otherwise Different minima.

No unit declared
Start B, x used
About this output

The start B, x the model used (the challenge value when a challenge fixes it; moved into the view box); blank when it does not apply or the inputs are not valid.

No unit declared
Start A, x used
About this output

The start A, x the model used (the challenge value when a challenge fixes it; moved into the view box); blank when it does not apply or the inputs are not valid.

No unit declared
Start A, y used
About this output

The start A, y the model used (the challenge value when a challenge fixes it; moved into the view box); blank when it does not apply or the inputs are not valid.

No unit declared
View y to
About this output

View y to: the top edge of the view box (canvas only).

No unit declared
View y from
About this output

View y from: the bottom edge of the view box (canvas only).

No unit declared
View x from
About this output

View x from: the left edge of the view box, which is also a hard limit for both methods (canvas only).

No unit declared
Tied height
About this output

In a tie between different minima, the tied height (run A end); blank otherwise, including when both starts reach the same minimum.

No unit declared
View x to
About this output

View x to: the right edge of the view box (canvas only).

No unit declared
Simplex evaluations
About this output

The penalised values the simplex method computed (3 for the starting triangle, 3 more at each new stage, then 1 to 4 per iteration).

No unit declared
The simplex method, iteration by iteration: the move and the triangle (best vertex first)
About this output

The simplex method iteration by iteration: the move (Start, Reflect, Expand, Contract outside, Contract inside or Shrink), the three corners best first, and the best penalised value.

No unit declared
Simplex best point, y
About this output

y of the simplex best point at the end.

No unit declared
Height at the simplex best point
About this output

The height of the landscape at the simplex best point.

No unit declared
Simplex best point, x
About this output

x of the simplex best point at the end.

No unit declared
Starting triangle size used
About this output

The starting triangle size the model used (the challenge value when a challenge fixes it); blank when it does not apply or the inputs are not valid.

No unit declared
Simplex outcome
About this output

How the simplex method ended: Converged (its triangle and its values became small in the last stage) or Reached the iteration cap.

No unit declared
Simplex iterations
About this output

The simplex iteration at which it stopped, or 60.

No unit declared
Triangle size handle, x
About this output

x of the starting triangle second corner, where its size handle sits (canvas only).

No unit declared
Triangle size handle, y
About this output

y of the starting triangle second corner (canvas only).

No unit declared
Circle edge used
About this output

The circle edge the model used (the challenge value when a challenge fixes it); blank when it does not apply or the inputs are not valid.

No unit declared
Circle radius used
About this output

The circle radius the model used (the challenge value when a challenge fixes it); blank when it does not apply or the inputs are not valid.

No unit declared
Circle centre, y used
About this output

The circle centre, y the model used (the challenge value when a challenge fixes it); blank when it does not apply or the inputs are not valid.

No unit declared
Challenge result
About this output

No challenge selected, MET or NOT MET.

No unit declared
Circle centre, x used
About this output

The circle centre, x the model used (the challenge value when a challenge fixes it); blank when it does not apply or the inputs are not valid.

No unit declared
Height of the landscape at the end of run A
About this output

The height of the landscape (the objective f, without the penalty) at the end of run A.

No unit declared
Height of the landscape at the end of run B
About this output

The height of the landscape at the end of run B.

No unit declared
Gradient measure at the end of run A
About this output

The size of the projected penalised slope at the end of run A (the square root of the gradient mapping used by the stopping test).

No unit declared
Stopping tolerance used
About this output

The stopping tolerance the model used (the challenge value when a challenge fixes it); blank when it does not apply or the inputs are not valid.

No unit declared
Downhill direction used
About this output

The downhill direction the model used (the challenge value when a challenge fixes it); blank when it does not apply or the inputs are not valid.

Unit deg
Bowl centre, y used
About this output

The bowl centre, y the model used (the challenge value when a challenge fixes it); blank when it does not apply or the inputs are not valid.

No unit declared
Bowl stretch used
About this output

The bowl stretch the model used (the challenge value when a challenge fixes it); blank when it does not apply or the inputs are not valid.

No unit declared
Bowl centre, x used
About this output

The bowl centre, x the model used (the challenge value when a challenge fixes it); blank when it does not apply or the inputs are not valid.

No unit declared
Edges pressing on the answer
About this output

The edges pressing on the end of run A: None, Line, Circle or Both (an edge is active when it is on and the end lies within 0.001 times the box size of it, or beyond).

No unit declared
Valley steepness used
About this output

The valley steepness the model used (the challenge value when a challenge fixes it); blank when it does not apply or the inputs are not valid.

No unit declared
Challenge: the value scored
About this output

The value the selected challenge scores: challenge 2 the smaller signed edge value at the end, challenge 3 the largest violation, challenge 4 the distance between the ends, challenge 5 the simplex evaluations to reach (1, 1) (blank for challenge 1, or when never reached).

No unit declared
Challenge score
About this output

100 when the selected challenge is met, otherwise 0.

No unit declared
Challenge goal
About this output

The goal of the selected challenge.

No unit declared
Bowl turn used
About this output

The bowl turn the model used (the challenge value when a challenge fixes it); blank when it does not apply or the inputs are not valid.

Unit deg
Challenge feedback
About this output

Feedback on the selected challenge: the prompt to predict first (challenge 1), what meeting it shows, or a hint.

No unit declared
Penalised value at the end of run A
About this output

The penalised value at the end of run A: the height plus the final penalty weight times the squared violations.

No unit declared
Run B steps used
About this output

The number of steps run B used.

No unit declared
Run A outcome
About this output

How run A ended: Converged (it passed its stopping test in the last stage), Reached the iteration cap (the last stage used all its steps) or Stalled (no trial step lowered the penalised value).

No unit declared
Run A steps used
About this output

The number of steps run A used (1 to 60), counting the steps that only tested the stopping rule.

No unit declared
Run A evaluations
About this output

The work of run A in evaluations: each penalised value counts 1 and each slope counts 2 (one per variable).

No unit declared
Run B evaluations
About this output

The work of run B in evaluations (a value counts 1, a slope 2).

No unit declared
Largest edge violation at the end of run B
About this output

How far the end of run B breaks an edge (0 when both hold).

No unit declared
Line handle A, x used
About this output

The line handle A, x the model used (the challenge value when a challenge fixes it); blank when it does not apply or the inputs are not valid.

No unit declared
Largest edge violation at the end of run A
About this output

How far the end of run A breaks an edge: the larger of the distance outside the line and the amount outside the circle (0 when both hold). A quadratic penalty leaves about the edge push divided by twice the weight.

No unit declared
Run B outcome
About this output

How run B ended: Converged, Reached the iteration cap or Stalled.

No unit declared
The landscape as 25 x 25 colour levels from 0 (lowest) to 1 (highest), log scaled; each row starts with its y
About this output

The landscape as 25 x 25 colour levels from 0 (lowest) to 1 (highest) on a log scale, sampled on the view box edge to edge; each row starts with its y, row 1 at the top (canvas heat map).

No unit declared
Feasibility tolerance
About this output

The feasibility tolerance: 0.001 times the longer side of the view box.

No unit declared
Final penalty weight
About this output

The penalty weight of the stage in which run A ended.

No unit declared
Is run B's end allowed?
About this output

Feasible or Not feasible for the end of run B, against the same tolerance.

No unit declared
Distance between the two ends
About this output

The distance between the ends of runs A and B.

No unit declared
Is run A's end allowed?
About this output

Feasible when the end of run A breaks no edge by more than the feasibility tolerance; otherwise Not feasible.

No unit declared
Gradient run A end, x
About this output

x of the point where gradient run A ends.

No unit declared
Gradient run A end, y
About this output

y of the point where gradient run A ends.

No unit declared
Gradient run B end, y
About this output

y of the point where gradient run B ends.

No unit declared
The forbidden side of the line inside the view (corners in order; for drawing)
About this output

The forbidden side of the line inside the view box as up to five corner points in order, for shading (canvas only).

No unit declared
Gradient run B end, x
About this output

x of the point where gradient run B (from start B) ends.

No unit declared
This page is provided by LogicCommons for informational purposes only. Results are analysis outputs computed from the inputs you supply and are not professional advice. Verify all inputs and results independently.

LogicCommons is in beta. If a result, label, or reference looks wrong, tell us here; we read every message.

Methodology

Purpose and model boundary

This lab looks for the lowest allowed point of a landscape in two variables, x and y. The landscape is one of four fixed shapes: a tilted plane, a stretched and turned bowl, the Rosenbrock banana valley, or the four-valley Himmelblau function. Up to two edges fence it: a straight line with a forbidden side, and a circle whose inside is allowed; the view box is a hard limit as well. Projected gradient descent on a quadratic penalty runs from start A and from start B in four stages of the penalty weight, and a Nelder-Mead simplex searches from start A with no slopes at all. Every step is a row of the model's results, up to 60 a run. The model returns where each run ended, its height, how far it breaks an edge, which edges press on it, how it ended and its work in evaluations, a stage-by-stage table, a 25 by 25 map of the landscape, and five scored challenges.

It is a lab for learning how a penalty turns edges into part of the landscape: why a weak penalty leaves the answer outside the edges, why a stiff one makes the steps crawl or stall, why the start decides which valley you reach, and what a method without slopes can do. It is not a general optimization solver. It has two variables, four landscapes and at most one line and one circle. The quadratic penalty only ever makes the answer approximately allowed, and the budgets are fixed.

The model is the calculation authority. The page sends the values you set to the model and draws only what it returns: the landscape colours, the line's ends at the box edge, the shaded forbidden side, the paths of the two gradient runs, the simplex triangles and the end points all come from the model's own results. The page computes no height, slope, step, violation or end point itself.

Inputs and units

Every input is a pure number or a choice; the lab has no physical units. Points are given as (x, y), with x to the right and y upward.

Input Meaning and unit
Landscape Tilted plane, Bowl (default), Banana valley or Four valleys. Each has its own view box: x and y from -3 to 3 for the tilted plane and the bowl, x from -2 to 2 and y from -1 to 3 for the banana valley, and x and y from -5 to 5 for the four valleys.
Downhill direction Tilted plane only: the direction the plane falls towards, a whole number of degrees from 0 to 359 (default 45). 0 points along +x and 90 along +y.
Bowl centre, x and y Bowl only: the bowl's lowest point, each from -5 to 5 (default (2, 1.5)).
Bowl stretch Bowl only: how many times steeper the bowl rises across its long axis than along it, from 1 (round) to 20 (a narrow trough) (default 4).
Bowl turn Bowl only: the direction of the bowl's long axis, a whole number of degrees from 0 to 175 (default 30).
Valley steepness Banana valley only: how steep the valley walls are, a whole number from 1 to 100 (default 100, the classic Rosenbrock valley).
Line edge On or Off (default Off).
Line handle A and B, x and y Line on only: the two points the line passes through, each coordinate from -5 to 5 (default (-2.5, 0.5) and (2.5, 0.5)). The handles must be at least 0.2 apart.
Allowed side of the line Line on only: Left or Right (default Right). Right means the allowed side is on your right as you walk from handle A to handle B.
Circle edge On (default) or Off. With the circle on, the answer must stay inside it.
Circle centre, x and y Circle on only: each from -5 to 5 (default (0, 0)).
Circle radius Circle on only: from 0.2 to 5 (default 1).
Start A, x and y Where gradient run A and the simplex start, each from -5 to 5 (default (-2, -2)). A start outside the view box is moved onto its edge.
Start B, x and y Where gradient run B starts, each from -5 to 5 (default (2, -2)).
Penalty start power A whole number from 0 to 4 (default 3): the first stage's penalty weight is 10 to this power, so from 1 to 10,000.
Penalty growth power 0 or 1 (default 0): 0 keeps the weight the same in all four stages; 1 multiplies it by 10 at each new stage.
Starting triangle size h, from 0.05 to 2 (default 0.45): the side of the simplex method's starting triangle at start A.
Stopping tolerance From 1×10⁻⁸ to 0.01 (default 1×10⁻⁴): the stopping tolerance of both methods.
Challenge number 0 for free exploration, or 1 to 5 to load a challenge.
Your prediction: edges that hold the answer Not yet predicted (the start), None, Line, Circle or Both: your answer for challenge 1.

Where each input is set:

  • On the canvas only: the landscape and the line and circle switches (chips above the map), the downhill arrow (turned about the middle of the box), the bowl centre, turn and stretch handles, the two line handles, the side chip drawn on the line, the circle's centre and rim handles, start markers A and B, the two penalty steppers (each with a live label such as "weight starts at 1,000" or "×10 per stage"), and the triangle-size handle on its rail. None of these is in the input panel. Handles stay inside the view box shown.
  • With challenge 1 only: your prediction. It is not in the input panel and appears only in that challenge.
  • In the input panel: the valley steepness (shown for the banana valley), the stopping tolerance and the challenge number. The page offers the tolerance as one of five choices, 0.01, 0.001, 0.0001, 0.000001 and 0.00000001; the model accepts any value from 1×10⁻⁸ to 0.01.

Start B, the penalty steppers and the triangle handle appear from the Experiment level. An input that does not apply to the chosen landscape or to an edge that is off is neither checked nor used; the model uses its default in its place.

Governing relationships

The landscapes. The model evaluates the height f and its exact slope (the gradient fx, fy) in these forms:

  • Tilted plane: f = -(cos θ·x + sin θ·y), with θ the downhill direction, so the plane falls along (cos θ, sin θ). A cosine or sine smaller than 1×10⁻¹⁵ in size is taken as exactly 0.
  • Bowl: with (x_c, y_c) the centre, φ the turn and e the stretch, u = cos φ·(x - x_c) + sin φ·(y - y_c) runs along the long axis and w = cos φ·(y - y_c) - sin φ·(x - x_c) across it; f = u² + e·w².
  • Banana valley: f = (1 - x)² + b·(y - x²)², with b the valley steepness. Its floor is f = 0 at (1, 1).
  • Four valleys: f = (x² + y - 11)² + (x + y² - 7)². It has four separate low points; one is f = 0 at (3, 2).

The edges. Each edge is a function g that is negative or zero where the point is allowed and positive where it is not:

  • Line: with n the unit normal to the line that points to the forbidden side, g₁ = n·(p - A), the signed distance of the point p from the line through handle A. Its slope is n.
  • Circle: with centre c and radius r, g₂ = (|p - c|² - r²)/(2·r), positive outside the circle and, near the rim, close to the distance outside it. Its slope is (p - c)/r.

An edge that is off contributes nothing. How far a point breaks edge i is v_i = g_i when g_i is positive, and 0 otherwise.

The quadratic penalty. With μ the penalty weight, the gradient runs and the simplex both search the penalised height P = f + μ·(v₁² + v₂²), whose slope is ∇P = ∇f + 2·μ·(v₁·∇g₁ + v₂·∇g₂). The penalty only grows once a point breaks an edge, so the lowest point of P sits just outside an edge that the landscape pushes against: at a weight μ the answer breaks the edge by about λ/(2·μ), where λ is the push of that edge. A larger weight keeps the answer closer to the edge but makes P steeper across it.

The penalty stages. The weight of stage s (s = 1 to 4) is 10^(p₀ + (s - 1)·q), with p₀ the penalty start power and q the growth power, so from 1 to 10,000,000.

The box. The view box is a hard limit: every point either method forms is clamped into it coordinate by coordinate (a projection onto the box).

Projected gradient descent with Armijo backtracking. One step of a gradient run, at the point x with the current weight μ:

  1. The gradient mapping is m = x - Proj(x - ∇P), the move a full slope step would make, kept in the box. The stopping test passes when |m|² ≤ tol²·max(1, |∇f|²), with tol the stopping tolerance.
  2. If the test fails, the model tries 16 step lengths α = 1, 1/2, 1/4, ... down to 2⁻¹⁵. Each trial point is t = Proj(x - α·∇P), and it is accepted when P(t) ≤ P(x) + 0.3·∇P·(t - x) (Armijo's sufficient-decrease test, measured along the clamped step). The first accepted trial is the next point.
  3. If no trial is accepted, the run ends Stalled and the point holds.

The stage rule. A run starts at its clamped start in stage 1. When the stopping test passes in stages 1 to 3, the point holds and the next stage begins with its own weight; when it passes in stage 4, the run ends Converged. A stage may take at most 15 steps; a stage that uses its 15th step without passing its test hands on to the next stage, and in stage 4 the run ends Reached the iteration cap. The steps that only test the stopping rule count, so a run uses at most 60 steps.

Counting the work. Each value of P counts 1 evaluation and each slope counts 2, one for each variable. A gradient run starts with 1 (the value at its start). Each step then adds 2 for its slope, plus the trials it tried (the accepted one included), or 16 when it stalled, and nothing more when the test passed; the first step of each new stage adds 1 for the value at the new weight.

The Nelder-Mead simplex. The simplex starts from the clamped start A with the triangle A, A + (h, 0) and A + (0, h); a corner that would leave the box is placed at A - (h, 0) or A - (0, h) instead. Iterations 1 to 15 use the weight of stage 1, 16 to 30 of stage 2, 31 to 45 of stage 3 and 46 to 60 of stage 4; at each change the three corners are valued again. With the corners sorted into best b, middle and worst w (equal values keep their earlier order) and x̄ the midpoint of the best two, each iteration tries in this order, using the standard coefficients 1, 2, 0.5 and 0.5:

  • the reflection r = 2·x̄ - w; if it beats the best, the expansion e = 3·x̄ - 2·w, kept if it beats r, else r is kept;
  • otherwise r is kept if it beats the middle corner;
  • otherwise, if r beats the worst, the outside contraction c = 1.5·x̄ - 0.5·w, kept if it is no worse than r;
  • otherwise the inside contraction 0.5·x̄ + 0.5·w, kept if it beats the worst;
  • when a contraction is not kept, every corner shrinks halfway towards the best: v = b + 0.5·(v - b).

Every new point is clamped into the box. From iteration 46 on (the last stage) the simplex stops Converged when every corner lies within tol·max(1, |b|) of the best and the values differ by at most tol·max(1, |P(b)|); otherwise it ends Reached the iteration cap after iteration 60. Its work counts 3 for the starting triangle, 3 more at each new stage, then 1 for the reflection, 1 for an expansion or contraction and 2 for a shrink in each iteration.

Reading the end. At the end point of run A, with feasTol = 0.001·S and S the longer side of the view box:

  • the largest violation is the larger of v₁ and v₂, and the end is Feasible when it is at most feasTol;
  • an edge is active (pressing on the end) when it is on and g > -0.001·S;
  • each edge's push is estimated as 2·μ·v at the final weight, so the violation equals the push over twice the weight.

Comparing the starts. The two ends are the Same minimum when they lie within 0.05·S of each other, and Different minima otherwise. Which start reached the lower allowed end: when both ends are feasible and at the same minimum, Same minimum; when both are feasible at different minima, the start with the lower height, or a tie when the heights differ by at most 1×10⁻⁶ times the larger of 1 and their sizes; when only one is feasible, that start.

The landscape map. The model samples f on 25 by 25 points spread evenly over the view box, edges included. Each point's colour level is ln(1 + (f - f_min)) / ln(1 + (f_max - f_min)), from 0 at the lowest sample to 1 at the highest (0 everywhere on a flat map). The logarithm keeps the floor of the banana valley visible. The map shows the height f, never the penalised height.

The line on the map. The model finds where the line crosses the sides of the box (its two ends on the map) and outlines the forbidden part of the box with at most five points.

Calculation sequence

The model works through the relationships above in this order:

  1. It checks the inputs that apply in the order of the status list under Errors and warnings, on the values entered, up to the challenge number and your prediction.
  2. It fixes the values in use: in a challenge the challenge's own, except the inputs it leaves to you; your entry for an input that applies; the default for one that does not. The starts are clamped into the view box.
  3. It sets up the box, the tolerances, the four stage weights, the landscape map, and the line's ends and forbidden region on the map.
  4. It runs gradient run A and gradient run B step by step, each until it converges, stalls or reaches the iteration cap.
  5. It runs the simplex from start A for up to 60 iterations.
  6. It reads the end measures: heights, violations, feasibility, active edges, pushes, the stage table, the comparison of the two starts and, for challenge 5, where each run first reaches (1, 1).
  7. It sets the status and, in a challenge, scores it and holds back what the challenge keeps back.

Outputs and interpretation

  • End of run A (x and y), the height there (f, without the penalty) and the penalised value (f plus the final weight times the squared violations).
  • Largest violation: how far the end breaks an edge, 0 when both hold; feasibility: Feasible when it is at most the feasibility tolerance, 0.001 times the longer side of the view box.
  • Active edges: None, Line, Circle or Both: the edges pressing on the end of run A.
  • How run A ended (Converged, Reached the iteration cap or Stalled), the steps it used (1 to 60) and the final penalty weight.
  • Run B: its end, height, largest violation, feasibility, how it ended and the steps it used.
  • Distance between the ends; the starts agree (Same minimum or Different minima); the lower start (Start A, Start B, Same minimum, CHECK: tie within the band, or CHECK: neither end is feasible; an end that is not feasible never wins); and the tied height, only in a tie between different minima.
  • The simplex: how it ended (Converged or Reached the iteration cap), the iteration it stopped at (or 60), its best point and the height there.
  • Push of the line and of the circle: 2 × weight × violation at the end of run A, blank for an edge that is off; the size of the projected slope at the end of run A; the work in evaluations of each run.
  • Penalty stages: for each stage of run A, its weight, the steps it used, the largest violation when it ended, and how it ended: Test passed, Step cap, Stalled or Not reached.
  • Settings used: the values the model used (a challenge's own while one is selected; the starts as clamped), blank for an input that does not apply, and the model and module versions.
  • The runs, step by step, 61 rows from step 0 (the start) to 60: run A with the point, its stage (1 to 4), the penalised value and the largest violation; run B with the point and its stage; the simplex with its move (Start, Reflect, Expand, Contract outside, Contract inside or Shrink), its corners best first and the best penalised value. Rows after a run ends show only the step number.

Reading the canvas: the map colours the landscape from lower to higher, with no numbers on its legend. The line runs between its returned ends with its forbidden side shaded lightly, and the circle is drawn from its centre and radius. Run A is drawn as dots and a line, one colour for each penalty stage; one player steps through the rows, and a large dot marks each run's end. A formula line shows the chosen landscape with your numbers. From the Experiment level run B is drawn in a second colour and the simplex as one triangle for each iteration; the Advanced level adds the pushes, the slope size, the tied height, the evaluation counts, the stage table and the settings used. The status and the verdicts are results, never drawn on the map.

What to take from the lab: gradient descent on a quadratic penalty settles quickly when the answer is inside the allowed region, in a corner where both edges press, or on a straight slide along an edge. A weak penalty settles but leaves the answer outside the edges, by about the edge's push over twice the weight. A stiff penalty makes the steep direction across the edge cap the step, so the descent crawls along a single curved edge or stalls. In a landscape with several valleys, the start decides which one you reach. The simplex needs no slopes at all, and a large enough starting triangle can stride along a curved valley that the slope-following run crawls through.

Challenges

Each challenge fixes its own landscape, edges, starts, weights and triangle size, with a stopping tolerance of 1×10⁻⁴, and leaves only the inputs it names to you. On the page a challenge's runs wait for you: challenge 1 until you predict, challenges 2 to 5 until you press Run. The model scores each one MET (100) or NOT MET (0) and gives a one-line hint while it is not met.

  1. Which edges hold it? (Explore). A stretched bowl fenced by a line and a circle. Before the run, predict which edges the lowest allowed point will press against: none, the line, the circle, or both. Met when your prediction equals the active edges at the end of run A.
  2. Pin it in a corner (Explore). A tilted plane with a circle and a line. Drag the line so the answer sits in the corner where the line meets the circle, with both edges pressing on it. Met when the status is OK and both edges are active. The value scored is the smaller signed edge value at the end.
  3. Strong but not stiff (Experiment). A bowl fenced by a line and a circle. Set the penalty start and growth so the answer is allowed, within the feasibility tolerance, and the descent settles. Met when the status is OK: run A converged and its end is feasible. The value scored is the largest violation.
  4. Two starts, two answers (Experiment). The four valleys inside a circle of radius 4. Place the two starts so both descents settle inside the allowed region, in two different valleys. Met when the status is OK, run B converged with a feasible end, and the ends are Different minima. The value scored is the distance between the ends.
  5. No slopes needed (Experiment). The banana valley with no edges. Size the starting triangle so the simplex reaches the valley floor at (1, 1), within 0.001, using fewer evaluations than the gradient run. Met when the simplex's best point comes within 0.001 of (1, 1) with fewer evaluations than gradient run A took to come that close; a gradient run that never gets there counts as never. The value scored is the simplex's evaluations to reach (1, 1), blank when it never does.

Challenge 1 holds back the answer until you predict. While your prediction reads Not yet predicted, every result of the three runs and the value scored are blank, as are rows 1 to 60 of the step tables and the whole stage table, and the page asks you to choose your prediction first. The status, the feasibility tolerance, the map with its edges, the starts and the settings used stay. Any prediction reveals everything, met or not. Challenges 2 to 5 hold nothing back: their results are feedback on your own line, penalty settings, starts or triangle. Your prediction changes nothing outside challenge 1.

Validation and status logic

The status reads the first match in the list under Errors and warnings. The NOT VALID checks read the values you entered, and only for the inputs that apply: the downhill direction only for the tilted plane, the bowl inputs only for the bowl, the valley steepness only for the banana valley, the line inputs only with the line on, and the circle inputs only with the circle on. In a challenge only the inputs it leaves to you are checked; the challenge number and the prediction are always checked. The CHECK items read the values in use and follow gradient run A only; run B and the simplex report through their own endings, so they never turn the status to CHECK. CHECK items apply inside challenges too. A challenge number that is not a whole number from 0 to 5 counts as no challenge selected.

Assumptions and limitations

  • Two variables, four landscapes with their own numbers, at most one line and one circle. The view box is a hard limit, applied by clamping.
  • The quadratic penalty makes the answer only approximately allowed: it breaks an edge by about the edge's push over twice the weight, and the lab reports how far.
  • Fixed budgets: four stages of at most 15 steps (60 in all) for each gradient run, and 60 simplex iterations. Plain gradient descent crawls along a single curved edge at a stiff weight; such a run reaches the iteration cap by the nature of the method.
  • 16 trial step lengths, halving from 1, with a sufficient-decrease constant of 0.3.
  • The map has 25 by 25 points, and its colours are compressed by a logarithm.
  • A value within about 1×10⁻⁹ (relative) of a stopping test or a challenge threshold, or within about 1×10⁻⁹ times the box size of the feasibility, active-edge or same-minimum threshold, may fall either side of it. A trial step or a simplex comparison within about 1×10⁻¹² (relative) of its decision may go either way, and a long run carries such a difference on. In a scene that is mirror-symmetric about start A, two corners of the starting triangle can have exactly equal values; equal values keep their earlier order.

Restrictions and non-computing states

Under NOT VALID every result, every table and the map are blank, except the model and module versions, the challenge status (No challenge selected, or NOT MET with a challenge selected), a score of 0, and the goal and hint of a selected challenge.

A gradient run that stalls stops at the point where no trial step lowered the penalised value; its later rows show only the step number. A run that converges early leaves its later rows blank in the same way.

In challenge 1, until you predict, the results listed under Challenges are held back.

Errors and warnings

The status messages, first match wins:

  • NOT VALID: choose the landscape from the list
  • NOT VALID: choose On or Off for the line and for the circle
  • NOT VALID: choose which side of the line is allowed from the list — line on.
  • NOT VALID: the downhill direction must be a whole number of degrees from 0 to 359 — tilted plane.
  • NOT VALID: every point you place must have x and y from minus 5 to 5 — the starts always, the bowl centre for the bowl, the line handles with the line on and the circle centre with the circle on.
  • NOT VALID: the bowl stretch must be from 1 to 20 and its turn a whole number of degrees from 0 to 175 — bowl.
  • NOT VALID: the valley steepness must be a whole number from 1 to 100 — banana valley.
  • NOT VALID: the two line handles must be at least 0.2 apart — line on.
  • NOT VALID: the circle radius must be from 0.2 to 5 — circle on.
  • NOT VALID: the penalty start power must be a whole number from 0 to 4 and the growth power 0 or 1
  • NOT VALID: the starting triangle size must be from 0.05 to 2
  • NOT VALID: the stopping tolerance must be from 0.00000001 to 0.01
  • NOT VALID: the challenge number must be a whole number from 0 to 5, and the prediction blank or one of its four choices
  • CHECK: the gradient run stalled because no trial step lowered the penalised value; lower the penalty start power — run A ended Stalled.
  • CHECK: the gradient run used all 60 steps without passing its stopping test; try a gentler penalty or a looser tolerance — run A reached the iteration cap.
  • CHECK: the answer still breaks a constraint by more than the feasibility tolerance; raise the penalty — the end of run A is not feasible.
  • OK — run A converged inside the allowed region.

References

This laboratory is an educational model of finding the lowest allowed point of a two-variable landscape: a tilted plane, a stretched bowl, the Rosenbrock banana valley or the four-valley Himmelblau function, fenced by a straight edge with a forbidden side and by the inside of a circle. The edges enter through a quadratic penalty, the height plus a weight times the squares of how far the point breaks each edge, and the weight grows over four stages. Projected gradient descent runs from two starts: each step goes downhill on the penalised height, is clamped into the view box, and is halved until the height falls by at least 0.3 times the predicted decrease (Armijo backtracking). A Nelder-Mead simplex with the standard coefficients 1, 2, 0.5 and 0.5 searches the same penalised height from the first start without using any slopes. Every step is an explicit row that the canvas plays back over the landscape.

Sources and further reading

  • Line searches with a sufficient-decrease test, and the quadratic penalty method for constraints: J. Nocedal and S. J. Wright, Numerical Optimization, 2nd edition, Springer, 2006, chapter 3, Line Search Methods, and chapter 17, Penalty and Augmented Lagrangian Methods. doi:10.1007/978-0-387-40065-5
  • Descent methods and the backtracking line search, which accepts a step once the height falls by a set fraction, between 0 and 0.5, of the decrease predicted by the slope: S. Boyd and L. Vandenberghe, Convex Optimization, Cambridge University Press, 2004, section 9.2, Descent methods, Algorithm 9.2. Book page
  • The simplex method that needs no slopes: J. A. Nelder and R. Mead, "A simplex method for function minimization", The Computer Journal 7(4), 1965, pages 308-313. doi:10.1093/comjnl/7.4.308
  • How the Nelder-Mead method behaves in one and two dimensions, including a case where it settles at a point that is not a minimum: J. C. Lagarias, J. A. Reeds, M. H. Wright and P. E. Wright, "Convergence properties of the Nelder-Mead simplex method in low dimensions", SIAM Journal on Optimization 9(1), 1998, pages 112-147. doi:10.1137/S1052623496303470

No table or text from any of these publications is reproduced, and none of their authors or publishers has reviewed or endorses this laboratory.

This laboratory is for learning. Its results hold only within its stated ranges; it is not a general optimization solver, and real problems need scaling, more variables and exact handling of their constraints.

Results are informational and not professional advice. See our Terms of Use. Powered by SpreadsheetWeb · About · Privacy · Terms