To solve John's problem of minimizing his cost while meeting his daily nutritional requirements, we need to formulate a linear programming model. The decision variables will be the pounds of pears (P) and broccoli (B) that John should eat.

Let's break down the problem into its components:

1. **Objective Function**: Minimize the total cost.
   - Cost per pound of pears = $6
   - Cost per pound of broccoli = $8

2. **Constraints**:
   - Calcium requirement: 2P + 4B ≥ 15 (since a pound of pears contains 2 units of calcium and a pound of broccoli contains 4 units)
   - Potassium requirement: 5P + 3B ≥ 20
   - Magnesium requirement: 3P + 6B ≥ 17

3. **Non-negativity Constraints**: P ≥ 0, B ≥ 0 (since John cannot eat a negative amount of food)

The linear programming formulation can be summarized as follows:

Minimize: 6P + 8B  
Subject to:
- 2P + 4B ≥ 15
- 5P + 3B ≥ 20
- 3P + 6B ≥ 17
- P, B ≥ 0

Now, let's translate this into Gurobi code in Python:

```python
from gurobipy import *

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

# Define the decision variables
pears = m.addVar(vtype=GRB.CONTINUOUS, name="Pears")
broccoli = m.addVar(vtype=GRB.CONTINUOUS, name="Broccoli")

# Objective function: Minimize cost
m.setObjective(6*pears + 8*broccoli, GRB.MINIMIZE)

# Constraints
m.addConstr(2*pears + 4*broccoli >= 15, "Calcium_Requirement")
m.addConstr(5*pears + 3*broccoli >= 20, "Potassium_Requirement")
m.addConstr(3*pears + 6*broccoli >= 17, "Magnesium_Requirement")

# Non-negativity constraints are handled by the CONTINUOUS variable type

# Optimize model
m.optimize()

# Print solution
if m.status == GRB.OPTIMAL:
    print("Optimal solution found:")
    print(f"Pounds of Pears: {pears.X}")
    print(f"Pounds of Broccoli: {broccoli.X}")
    print(f"Total Cost: ${6*pears.X + 8*broccoli.X:.2f}")
else:
    print("No optimal solution found. The model may be infeasible.")
```