## Problem Description and Formulation

The problem is a classic example of a linear programming problem. The man wants to meet his carbohydrate and protein requirements at minimum cost by eating beans and cereal. Let's define the decision variables:

- \(x\): the number of servings of beans
- \(y\): the number of servings of cereal

The objective is to minimize the total cost, which is given by \(2x + y\), since the cost per serving of beans is $2 and the cost per serving of cereal is $1.

The constraints are:

1. Carbohydrate requirement: \(50x + 30y \geq 300\)
2. Protein requirement: \(20x + 5y \geq 150\)
3. Non-negativity constraints: \(x \geq 0, y \geq 0\)

## Gurobi Code

To solve this problem using Gurobi in Python, we first need to install the Gurobi library if it's not already installed. You can install it using pip:

```bash
pip install gurobi
```

Here's the Gurobi code to solve the problem:

```python
import gurobi as gp

# Create a new model
model = gp.Model("diet_problem")

# Define the decision variables
x = model.addVar(name="beans", lb=0)  # servings of beans
y = model.addVar(name="cereal", lb=0)  # servings of cereal

# Objective: minimize cost
model.setObjective(2*x + y, gp.GRB.MINIMIZE)

# Constraints
model.addConstr(50*x + 30*y >= 300, name="carbohydrates")
model.addConstr(20*x + 5*y >= 150, name="protein")

# Solve the model
model.optimize()

# Print the results
if model.status == gp.GRB.OPTIMAL:
    print(f"Optimal solution: {x.varName} = {x.x}, {y.varName} = {y.x}")
    print(f"Minimum cost: ${model.objVal:.2f}")
else:
    print("No optimal solution found")
```

This code defines the model, sets up the objective function and constraints, solves the optimization problem, and then prints out the optimal servings of beans and cereal along with the minimum cost. If no optimal solution is found, it indicates that the problem is infeasible.