🥗 Diet Optimization, live

Multi-objective menu search over 405 foods. Pick a user and an algorithm; the real Python code (pymoo) runs entirely in your browser, with no server involved.

Run settings

Algorithm

Starting…

Population 100, 50 generations: the same settings as the project's main.py. The same seed always gives the same result.

How it works

  1. Problem. Build one day of meals (breakfast plus lunch/dinner) from 405 foods, balancing three conflicting goals: maximise the user's food preference, minimise cost, minimise preparation + cooking time.
  2. Constraints. Energy, protein, carbohydrate, fibre and sodium should sit inside the user's age and gender Dietary Reference Intake range. They are soft: violations are penalised in all three objectives. A vegetarian user has meat, fish and poultry groups removed.
  3. Search. Each candidate is a priority ordering of foods, turned into a menu by a greedy decoder. NSGA-II (non-dominated sorting + crowding distance) or SPEA2 (strength Pareto + density estimation) evolves 100 candidates for 50 generations.
  4. Result. The final non-dominated set is the Pareto front: no menu is better on all three goals than another. Hypervolume measures how much objective space the front covers (larger is better), and the card shows the highest-preference menu that satisfies every nutrient bound.
  5. In your browser. The project's own src/ code and its SQLite database run in Pyodide (Python compiled to WebAssembly) inside a Web Worker, so this page stays responsive. pymoo 0.6.1.6 runs unmodified apart from two stand-ins: a pure-Python exact hypervolume replacing the compiled moocore, and a stub for a terminal progress bar. Results match the desktop Python run for the same seed (see the parity check in the repository).
  6. Seed. The seed is passed to pymoo's minimize, exactly as main.py --seed does, so the demo with seed 42 reproduces the results in the README.

Credits

Team: Saed O S Radi, Kenan Alemam, Ahmed Alsaleh, Abdulrahman Aljabahji, Mamdouh Al Masri. Heuristic Optimization course project, FSMVU.

Dataset: the Turkish food database provided for the Heuristic Optimization course (FSMVU): 405 foods, nutrients, DRI bounds and user ratings; food data from diyetasistan.com. Food names are shown in the original Turkish. Users are anonymous numeric ids.

Built with: pymoo, Pyodide, Plotly.js.

View the source on GitHub →