## Problem Description and Formulation

The bakery has a limited amount of blueberries, 1000 units, to produce pies and small tarts. The production of each item requires a certain amount of blueberries: 5 units for a pie and 3 units for a tart. Additionally, there are constraints on the production levels:

1. The bakery must make at least three times as many tarts as pies.
2. The bakery must make at least 30 pies.

The profit from selling each pie is $8, and from selling each tart is $5. The goal is to maximize the profit given these constraints.

## Symbolic Representation

Let's denote:
- \(P\) as the number of pies produced,
- \(T\) as the number of tarts produced.

The problem can be formulated as:

### Objective Function
Maximize: \(8P + 5T\)

### Constraints
1. Blueberry limitation: \(5P + 3T \leq 1000\)
2. Tart to pie ratio: \(T \geq 3P\)
3. Minimum pies: \(P \geq 30\)
4. Non-negativity: \(P \geq 0, T \geq 0\)

Since \(P\) and \(T\) represent quantities of items, we implicitly assume \(P \geq 0\) and \(T \geq 0\), but we keep the explicit non-negativity constraints for clarity.

## Gurobi Code

```python
import gurobi

def solve_bakery_problem():
    # Create a new model
    model = gurobi.Model()

    # Define variables
    P = model.addVar(lb=0, name="Pies")
    T = model.addVar(lb=0, name="Tarts")

    # Objective function: Maximize profit
    model.setObjective(8 * P + 5 * T, gurobi.GRB.MAXIMIZE)

    # Constraints
    model.addConstr(5 * P + 3 * T <= 1000, name="Blueberry_Limit")
    model.addConstr(T >= 3 * P, name="Tart_to_Pie_Ratio")
    model.addConstr(P >= 30, name="Minimum_Pies")

    # Optimize
    model.optimize()

    # Print solution
    if model.status == gurobi.GRB.OPTIMAL:
        print(f"Optimal solution: Pies = {P.varValue}, Tarts = {T.varValue}")
        print(f"Max Profit: ${model.objVal:.2f}")
    else:
        print("No optimal solution found.")

if __name__ == "__main__":
    solve_bakery_problem()
```

This code defines a Gurobi model for the bakery problem, sets up the objective function and constraints, and solves the optimization problem. If an optimal solution is found, it prints out the number of pies and tarts to produce and the maximum profit achievable.