MealPlanner is a personal scheduling tool that calculates optimal times for your meals and workouts based on your daily routine and biological rhythms. Instead of guessing when to eat or dealing with the discomfort of poor timing, let science do the planning for you.
Timing your meals properly has significant health benefits:
- Reduces hunger by spacing meals at intervals that match your body's natural digestive cycles
- Prevents workout nausea by ensuring enough time between eating and exercising
- Improves sleep quality by avoiding late-night eating that can cause acid reflux and disrupt rest
- Eliminates decision fatigue by providing a clear, optimized schedule you can follow daily
MealPlanner uses research-backed biological principles to determine ideal time gaps between activities. The algorithm works by:
-
Defining ideal gap weights based on chronobiological research - representing the optimal proportional duration of gaps between events (not including event durations themselves):
- Wake → Breakfast gap: Weight 1.0 (~60 min for cortisol stabilization)
- Breakfast → Lunch gap: Weight 4.5 (~270 min for cognitive peak and glucose homeostasis)
- Lunch → Workout gap: Weight 3.0 (~180 min for gastric emptying and hemodynamic safety)
- Workout → Dinner gap: Weight 1.5 (~90 min for anabolic window and parasympathetic return)
- Dinner → Sleep gap: Weight 4.0 (~240 min for GERD prevention and sleep architecture)
-
Calculating available gap time by taking your total awake time and subtracting all event durations (breakfast, lunch, workout, dinner)
-
Distributing gaps proportionally based on the ideal weights while fitting your actual schedule constraints
Key insight: Gaps are measured from the end of one event to the start of the next. This ensures activities never overlap and that timing recommendations account for how long each activity actually takes.
- Edit
constraints.txtwith your known schedule information, then save the file (see instructions below) - Run the tool using the instructions below for your operating system
- Check
schedule.txtfor your complete optimized schedule with all times filled in
The .txt extension means "text file"—these are simple files that contain plain text without any special formatting (no bold, italics, or colors). Think of them like a basic notepad.
How to open and edit .txt files:
- On Mac: Double-click the file to open it in TextEdit (or right-click → Open With → TextEdit)
- On Windows: Double-click the file to open it in Notepad (or right-click → Open With → Notepad)
- Alternative: You can also use any text editor like Visual Studio Code, Sublime Text, or Atom if you have them installed.
After you make changes to a .txt file, you need to save it so your edits are stored.
Open constraints.txt in any text editor and fill in your schedule information following these rules:
Important: After editing, remember to save the file!
- On Mac: Press
Cmd + S(⌘ + S) or go to File → Save - On Windows/Linux: Press
Ctrl + Sor go to File → Save
wake- The time you wake up (e.g.,7:15 AM)sleep- The time you go to sleep (e.g.,11:20 PM)
For each event (breakfast, lunch, workout, dinner), you have three related fields:
[event]Start- When the event begins[event]Duration- How long it lasts (in minutes)[event]End- When the event finishes
For each event, you can provide:
- ✅ Only
duration- Let the tool calculate optimal start and end times - ✅
start+end- The tool will calculate duration - ✅
start+duration- The tool will calculate end time - ✅
duration+end- The tool will calculate start time
- ❌ Only
start- Not enough information - ❌ Only
end- Not enough information - ❌ All three blank - Must provide at least some information
- ❌ All three filled - Over-constrained (just pick two!)
wake: 7:00 AM
breakfastStart:
breakfastDuration: 20
breakfastEnd:
lunchStart:
lunchDuration: 30
lunchEnd:
workoutStart:
workoutDuration: 45
workoutEnd:
dinnerStart:
dinnerDuration: 40
dinnerEnd:
sleep: 11:00 PM
In this example, you're only specifying how long each activity takes, and the tool will calculate all the optimal start and end times.
-
Navigate to the MealPlanner directory in Terminal:
cd /path/to/MealPlanner -
First time only: Make the script executable:
chmod +x ./main.sh
-
Run the program:
./main.sh
-
Install Swift for Windows (one-time setup):
- Download and install from swift.org/install/windows
- Follow the installation instructions provided on the website
-
Navigate to the MealPlanner directory in Command Prompt or PowerShell:
cd C:\path\to\MealPlanner -
Run the program:
swift main.swiftNote: Windows users don't need the
chmodstep ormain.shfile—just run Swift directly!
After running the tool, open schedule.txt to see your complete optimized schedule. All the blank fields from your input will now be filled with calculated optimal times.
wake: 7:00 AM
breakfastStart: 7:45 AM
breakfastDuration: 20
breakfastEnd: 8:05 AM
lunchStart: 12:35 PM
lunchDuration: 30
lunchEnd: 1:05 PM
workoutStart: 4:35 PM
workoutDuration: 45
workoutEnd: 5:20 PM
dinnerStart: 6:20 PM
dinnerDuration: 40
dinnerEnd: 7:00 PM
sleep: 11:00 PM
The optimization algorithm (found in main.swift lines 39-67) works in four steps:
-
Define Ideal Biological Intervals - Uses research-based time gaps between activities (45 min after waking, 4.5 hours between meals, etc.)
-
Calculate Available Time - Determines how much time you have awake (sleep time minus wake time) and subtracts the time spent on fixed activities
-
Calculate Scaling Factor - Proportionally adjusts the ideal gaps to fit your actual schedule while maintaining biological ratios. The scale factor has a minimum of 0.5 to prevent unsafe compression (like eating immediately before swimming)
-
Generate Schedule - Applies the scaled gaps to calculate all start and end times, working forward from your wake time through each activity
This approach ensures that even if your schedule is packed or relaxed, the relative proportions between activities remain scientifically sound.
- Be consistent with your wake and sleep times—your body thrives on routine
- If you have fixed commitments (like lunch at work), enter those specific times in
constraints.txt - Adjust durations to match your actual eating and workout speeds
- Re-run the tool whenever your schedule changes to get a new optimized plan
- "File not found" error: Make sure you're in the MealPlanner directory when running the command
- Swift not found on Windows: Install Swift from the official website
- Times seem off: Double-check that you entered times in 12-hour format with AM/PM
- Durations are 0: If you leave duration blank without providing start and end, it defaults to 0
Note: This tool provides general guidance based on biological research. Individual needs may vary. Consult with healthcare professionals for personalized dietary and exercise advice.