To solve this optimization problem, we first need to define the decision variables and the objective function. Let's denote the number of bags of berry mix A as \(x_A\) and the number of bags of berry mix B as \(x_B\). The objective is to minimize the total cost, which can be represented as \(5x_A + 3x_B\), since each bag of mix A costs $5 and each bag of mix B costs $3.

We have two main constraints based on the requirements:
1. The hiker must eat at least 150 g of blueberries.
2. The hiker must eat at least 125 g of blackberries.

From the given information, we can formulate these constraints as follows:
- For blueberries: \(30x_A + 20x_B \geq 150\)
- For blackberries: \(45x_A + 15x_B \geq 125\)

Additionally, since we cannot purchase a negative number of bags, we have non-negativity constraints:
- \(x_A \geq 0\)
- \(x_B \geq 0\)

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

```python
from gurobipy import *

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

# Define the decision variables
x_A = m.addVar(name="berry_mix_A", vtype=GRB.CONTINUOUS, lb=0)
x_B = m.addVar(name="berry_mix_B", vtype=GRB.CONTINUOUS, lb=0)

# Set the objective function: minimize the total cost
m.setObjective(5*x_A + 3*x_B, GRB.MINIMIZE)

# Add constraints for blueberries and blackberries
m.addConstr(30*x_A + 20*x_B >= 150, name="blueberry_constraint")
m.addConstr(45*x_A + 15*x_B >= 125, name="blackberry_constraint")

# Optimize the model
m.optimize()

# Check if an optimal solution was found
if m.status == GRB.OPTIMAL:
    print("Optimal solution found:")
    print(f"Purchase {x_A.x} bags of berry mix A")
    print(f"Purchase {x_B.x} bags of berry mix B")
    print(f"Total cost: ${m.objVal}")
else:
    print("No optimal solution found")

```