Play n Tools

Free tools & games for everyone

Free · No sign-up · No accounts

Optimization lab

Solve classic best-choice problems exactly: linear programs with a picture, the knapsack, the assignment problem and the shortest round trip.

First line: max or min and the objective's numbers. Then one constraint per line: the numbers, a sign (<=, >= or =) and the limit. Every variable is 0 or more.

How to use

  1. Choose a problem from the tabs. Each opens with an example.
  2. Linear program: type the objective and the limits, press Solve. With two variables, a picture shows the allowed area, its corners and the best one.
  3. Knapsack: list items with weight and value, set the capacity, press Find the best set.
  4. Assignment: type a square table of costs (or scores) and press Match.
  5. Round trip: tap to add stops, or make random ones. Up to 12 stops get the exact shortest trip; up to 60 get a fast near-best one.

Keyboard and touch

Arrow keys on the tabsChange problem
TabMove between the boxes and buttons
Tap the squareAdd a stop (Round trip)

Tips

  • In a linear program the best answer is always at a corner of the allowed area (or along an edge when two corners tie).
  • "Unbounded" usually means a limit is missing; "infeasible" means the limits contradict each other.
  • The knapsack compares the best set with the common shortcut of taking the best value per weight first, which can miss.
  • For the assignment, a job a worker cannot do can get a very large cost (say 9999).
  • The exact round trip checks every possible order cleverly; at 13 stops it would take millions of steps more, so bigger sets use the quick method.

About this lab

Linear programs are solved with the two-phase simplex method using Bland's rule (no cycling); the knapsack with the textbook dynamic programme over whole-number capacities; the assignment with the Hungarian method (Kuhn and Munkres, O(n³)); the round trip exactly with the Held–Karp dynamic programme for up to 12 stops, and otherwise with nearest neighbour followed by 2-opt, which removes crossings but is not guaranteed best. The test for this page compares every method with a brute-force check on random problems. Everything runs in your browser. Nothing is sent anywhere.

See you tomorrow!

A fresh daily puzzle every morning, and new tools added every month.

Browse every product