## Problem Description and Formulation

The pie shop optimization problem can be formulated as a linear programming problem. The goal is to maximize profit given certain constraints on the production of apple and peach pies.

### Decision Variables

- \(x\): The number of apple pies to be made.
- \(y\): The number of peach pies to be made.

### Objective Function

The profit per apple pie is $7, and the profit per peach pie is $8. The objective function to maximize profit (\(P\)) is:

\[P = 7x + 8y\]

### Constraints

1. **Minimum Production Requirements:**
   - At least 15 apple pies: \(x \geq 15\)
   - At least 12 peach pies: \(y \geq 12\)

2. **Maximum Production Capacities:**
   - At most 20 apple pies: \(x \leq 20\)
   - At most 18 peach pies: \(y \leq 18\)

3. **Total Pie Crust Limitation:**
   - Total pies not exceeding 30: \(x + y \leq 30\)

4. **Non-Negativity Constraints:**
   - \(x \geq 0\) and \(y \geq 0\), but these are partially covered by the minimum production requirements.

## Gurobi Code Formulation

Given the problem formulation, we can now translate it into Gurobi code in Python:

```python
import gurobi

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

    # Define variables
    x = model.addVar(lb=0, ub=20, name="apple_pies")  # Number of apple pies
    y = model.addVar(lb=0, ub=18, name="peach_pies")  # Number of peach pies

    # Update model to include new variables
    model.update()

    # Objective function: Maximize profit
    model.setObjective(7 * x + 8 * y, gurobi.GRB.MAXIMIZE)

    # Constraints
    model.addConstr(x >= 15, name="min_apple_pies")
    model.addConstr(y >= 12, name="min_peach_pies")
    model.addConstr(x <= 20, name="max_apple_pies")
    model.addConstr(y <= 18, name="max_peach_pies")
    model.addConstr(x + y <= 30, name="total_pies_limit")

    # Optimize model
    model.optimize()

    # Print solution
    if model.status == gurobi.GRB.OPTIMAL:
        print(f"Optimal profit: {model.objVal}")
        print(f"Number of apple pies: {x.varValue}")
        print(f"Number of peach pies: {y.varValue}")
    else:
        print("No optimal solution found.")

solve_pie_shop_problem()
```

This code sets up the optimization problem with Gurobi, solves it, and prints out the optimal number of apple and peach pies to maximize profit, along with the optimal profit value.