## Problem Description and Formulation

The problem is a classic example of a linear programming problem. The goal is to maximize the profit of a mattress company by determining the optimal number of queen and king-sized mattresses to produce, given the constraints on foam and packaging time.

Let's define the decision variables:

* Q: number of queen-sized mattresses to produce
* K: number of king-sized mattresses to produce

The objective function is to maximize the profit:

Maximize: 300Q + 500K

The constraints are:

* Foam constraint: 20Q + 30K ≤ 5000 (available foam units)
* Packaging time constraint: 10Q + 15K ≤ 2500 (available packaging time minutes)
* Non-negativity constraints: Q ≥ 0, K ≥ 0 (cannot produce negative number of mattresses)

## Gurobi Code

```python
import gurobi

# Create a new Gurobi model
m = gurobi.Model()

# Define the decision variables
Q = m.addVar(lb=0, name="Q")  # queen-sized mattresses
K = m.addVar(lb=0, name="K")  # king-sized mattresses

# Define the objective function
m.setObjective(300*Q + 500*K, gurobi.GRB.MAXIMIZE)

# Define the constraints
m.addConstr(20*Q + 30*K <= 5000, name="foam_constraint")
m.addConstr(10*Q + 15*K <= 2500, name="packaging_time_constraint")

# Optimize the model
m.optimize()

# Print the solution
if m.status == gurobi.GRB.OPTIMAL:
    print("Optimal solution found.")
    print(f"Queen-sized mattresses: {Q.varValue}")
    print(f"King-sized mattresses: {K.varValue}")
    print(f"Max Profit: {m.objVal}")
else:
    print("No optimal solution found.")
```

This code defines the decision variables, objective function, and constraints, and then solves the optimization problem using Gurobi. The solution is printed out, including the optimal number of queen and king-sized mattresses to produce and the maximum profit.