Cookie Production Optimizer

Maximize cookies with limited ingredients! Must make at least 0.5 batches of each type.

A Linear Programming adventure for young mathematicians! Scroll down to learn how it works.

šŸ‘‡ Scroll down to learn how this math magic works! šŸ‘‡

Cookie Batches

Sugar Cookies 0
Yield: 60/batch 0 cookies
Gingerbread 0
Yield: 30/batch 0 cookies
Peppermint 0
Yield: 48/batch 0 cookies
Chocolate 0
Yield: 54/batch 0 cookies
Total Cookies
0
Adjust sliders to make cookies!

Ingredient Usage

Flour0 / 15
Powdered Sugar0 / 8
White Sugar0 / 6.5
Brown Sugar0 / 5
Eggs0 / 12

Graphical Method (2D Projection)

Select 2 variables to plot. Others are fixed at slider values.

Flour constraint
Powdered Sugar
White Sugar
Brown Sugar
Eggs constraint
Feasible Region
Current Solution
Iso-profit lines

šŸ¤” Why doesn't the optimal look like a corner? This graph shows only 2 cookie types at a time, but our problem has 4! The optimal IS at a "corner" in 4D space, but when we slice down to 2D (holding the other cookies fixed), that corner might land along an edge instead. It's like how a corner of a 3D cube can look like it's on an edge when you draw its shadow!

Simplex Method Visualization

Step 0: Initial Tableau

šŸ“– What the columns mean:

S' = Sugar batches above 0.5
G' = Gingerbread batches above 0.5
P' = Peppermint batches above 0.5
C' = Chocolate batches above 0.5
s1 = Leftover flour
s2 = Leftover powdered sugar
s3 = Leftover white sugar
s4 = Leftover brown sugar
s5 = Leftover eggs
RHS = Current value
Z = Total cookies (add 96 for minimums)
Basic = What's "active" at this corner

The ' means "extra beyond minimum 0.5". So S'=2 means Sugar batches = 0.5 + 2 = 2.5 total. The "s" variables track leftover ingredients - when s1=0, you've used ALL your flour!

šŸ“ Current Corner (what we're making):

Sugar: 0.5 batches Gingerbread: 0.5 batches Peppermint: 0.5 batches Chocolate: 0.5 batches = 96 cookies

šŸ‘† Look at the graph above! The blue dot shows this corner. Each simplex step moves to a new corner with more cookies! (Tip: Change the graph axes to see how different cookie types change!)

What's Happening:

We start at a corner where we make just the minimum cookies. Then we "hop" to better corners by looking at the bottom row - negative numbers show us paths to MORE cookies! We keep hopping until there's nowhere better to go. That's the best answer!

Recipe Requirements (per batch)

Ingredient Sugar Ginger Pepper Choco On Hand
Flour242.5215
Powdered Sugar3-3-8
White Sugar1.50.5216.5
Brown Sugar-1-0.55
Eggs1-2112
Yield (cookies)60304854

How Does This Work? A Guide for Young Mathematicians

Learn the secrets behind finding the BEST cookie combo!

šŸŖ What is Linear Programming?

Imagine you're planning a pizza party, but you only have limited money, time, and ingredients. Linear Programming (we call it "LP" for short) is like having a super-smart helper that figures out the BEST way to use what you have!

In our cookie problem:

  • šŸŽÆ Goal: Make as many cookies as possible!
  • šŸ“¦ Limits: We only have so much flour, sugar, and eggs
  • šŸ“‹ Rules: Each cookie type needs different amounts of ingredients

LP helps us find the "sweet spot" where we make the MOST cookies without running out of anything!

šŸ—ŗļø The Graphical Method: Finding the Cookie Treasure!

Think of this like a treasure map! We're going to draw a picture that shows us where the "treasure" (best cookie combo) is hiding.

Step 1: Draw the Boundaries šŸ–Šļø

Each ingredient limit creates a line on our map. If you make too many cookies, you cross the line and run out! The colored lines on the graph above show these limits.

Step 2: Find the Safe Zone 🟢

The green shaded area is the "safe zone" where you don't run out of ANYTHING. Any point inside this zone is a valid cookie combo!

Step 3: The Profit Lines šŸ“ˆ

The dashed green lines show combos that make the same number of cookies. Lines further from the corner = more cookies!

Step 4: Find the Corner! šŸ“

Here's the magic: The best answer is ALWAYS at a corner of the safe zone! Push the profit line as far as possible while staying in the green.

šŸ¤” Why corners? Imagine pushing a book across your desk until it hits the edge. It always stops at a corner! Math works the same way - the farthest you can go is always at a corner.

🧮 The Simplex Method: Corner-Hopping Adventure!

The Simplex method is like playing a video game where you hop from corner to corner, always trying to get a higher score!

šŸ

Start at Home Base

We start at a corner where we're making the minimum (0.5 batches of each). This is our "home base" - safe but not many cookies yet!

šŸ‘€

Look Around: Which Way is Better?

At each corner, we check all the paths. The green numbers in the table tell us "go this way for more cookies!" We pick the path that helps the most.

🦘

Hop to the Next Corner

We "pivot" (that's the math word for "hop") to the next corner. The yellow highlighted cell shows where we're pivoting!

šŸ”„

Repeat Until You Can't Get Higher

We keep hopping until there's nowhere better to go. When all the numbers in the bottom row are zero or positive (no more green), we've found the best corner!

šŸ†

Victory! Optimal Solution Found!

The "RHS" column (right side) tells us how many batches of each cookie to make. The bottom-right number is our total cookies!

šŸŽ® Think of it like this: You're climbing a mountain in the fog. You can't see the top, but you can feel which way is "up" from where you stand. You keep walking uphill until every direction goes down - that's when you know you're at the peak!

šŸ“Š Reading the Simplex Table (It's Easier Than It Looks!)

The Columns (S', G', P', C')

These represent our cookie types. The little ' mark means we subtracted 0.5 (the minimum) so the math is easier. S' = Sugar batches minus 0.5.

The s1, s2... Columns

These are "slack" variables - they track how much of each ingredient is LEFT OVER. If s1 = 3, you have 3 cups of flour unused!

The RHS Column

"Right Hand Side" - shows either how much ingredient is left OR how many batches we're making of a cookie type (when it enters the "Basic" column).

The Bottom Row (Z)

This tracks our total cookies! Negative numbers = "we want more of this!" When all numbers are ≄ 0, we've maximized!

🤯 The Tricky Part: Why 312 Instead of 314?

The Simplex finds the mathematically perfect answer, but we can only make cookies in half-batch steps!

Three Different Answers!

1. Perfect Math Answer (Continuous): 314 cookies
S=0.5, G=1.08, P=0.5, C=4.21 batches
This is what Simplex finds - but 1.08 batches isn't real!

2. If You Just Round: 300 cookies 😱
G=1.08 rounds to 1.0, C=4.21 rounds to 4.0
This is WORSE! Rounding doesn't give the best answer!

3. Best Real Answer (0.5 steps): 312 cookies āœ“
S=0.5, G=0.5, P=0.5, C=4.5 batches
This is actually different from rounding! You need special math to find it.

šŸ“ The Integrality Gap = 314 - 312 = 2 cookies

This is the difference between the perfect math answer and the best real-world answer. Notice that just rounding (300) gives you a much worse answer than the true best (312)! Finding the REAL best discrete answer requires a different technique called "Integer Programming" - you can't just round!

⭐ Fun Facts About Linear Programming!

šŸš€ Used Everywhere: Airlines use LP to schedule flights, delivery trucks use it to plan routes, and factories use it to decide what to make!

šŸŽ‚ Birthday: The Simplex method was invented in 1947 by George Dantzig - that's over 75 years ago!

šŸ† Nobel Prize: Scientists who improved LP won the Nobel Prize in Economics!

šŸ’Ŗ Super Fast: Modern computers can solve LP problems with MILLIONS of variables in seconds!

šŸ”¬ For the Extra Curious: The Actual Math

(This is how mathematicians write our cookie problem - don't worry if it looks confusing!)

Maximize: Z = 60S + 30G + 48P + 54C (total cookies)

Subject to:

2S + 4G + 2.5P + 2C ≤ 15 (flour limit)

3S + 3P ≤ 8 (powdered sugar limit)

1.5S + 0.5G + 2P + C ≤ 6.5 (white sugar limit)

G + 0.5C ≤ 5 (brown sugar limit)

S + 2P + C ≤ 12 (eggs limit)

S, G, P, C ≄ 0.5 (must make at least half a batch!)

S = Sugar cookie batches, G = Gingerbread batches, P = Peppermint batches, C = Chocolate batches