To solve the given optimization problem, we first need to translate the natural language description into a symbolic representation. This involves defining variables for the quantities of queen and king sized mattresses, formulating the objective function that represents the total profit, and listing all constraints based on the available resources (foam and packaging time).

Let's define:
- \(x_1\) as the number of queen sized mattresses,
- \(x_2\) as the number of king sized mattresses.

The objective function aims to maximize profit. Given that each queen mattress yields a profit of $300 and each king mattress yields a profit of $500, the objective function can be written as:
\[ \text{Maximize:} \quad 300x_1 + 500x_2 \]

Constraints are based on the availability of foam and packaging time. Each queen mattress requires 20 units of foam, and each king mattress requires 30 units of foam. The total available foam is 5000 units. Thus, the foam constraint can be represented as:
\[ 20x_1 + 30x_2 \leq 5000 \]

For packaging time, each queen mattress takes 10 minutes to package, and each king mattress takes 15 minutes. With 2500 minutes available for packaging, the time constraint is:
\[ 10x_1 + 15x_2 \leq 2500 \]

Additionally, \(x_1\) and \(x_2\) must be non-negative since they represent quantities of mattresses.

Thus, the symbolic representation of the problem is:
```json
{
    'sym_variables': [('x1', 'queen sized mattresses'), ('x2', 'king sized mattresses')],
    'objective_function': '300*x1 + 500*x2',
    'constraints': ['20*x1 + 30*x2 <= 5000', '10*x1 + 15*x2 <= 2500', 'x1 >= 0', 'x2 >= 0']
}
```

Now, let's implement this problem using Gurobi in Python:

```python
from gurobipy import *

# Create a new model
m = Model("Mattress_Profit")

# Define variables
x1 = m.addVar(vtype=GRB.INTEGER, name="queen_mattresses")
x2 = m.addVar(vtype=GRB.INTEGER, name="king_mattresses")

# Set the objective function
m.setObjective(300*x1 + 500*x2, GRB.MAXIMIZE)

# Add constraints
m.addConstr(20*x1 + 30*x2 <= 5000, "foam_constraint")
m.addConstr(10*x1 + 15*x2 <= 2500, "packaging_time_constraint")

# Optimize model
m.optimize()

# Print results
if m.status == GRB.OPTIMAL:
    print("Optimal solution found:")
    print(f"Queen mattresses: {x1.x}")
    print(f"King mattresses: {x2.x}")
    print(f"Total profit: ${300*x1.x + 500*x2.x}")
else:
    print("No optimal solution found")
```