Here's the formulation and the Gurobi code to solve the apple mix problem:

**Decision Variables:**

* `g`: kilograms of green apples used
* `r`: kilograms of red apples used

**Objective Function:**

Minimize the total cost:  `9g + 7r`

**Constraints:**

* Sugar constraint: `0.05g + 0.25r >= 12` (at least 12 kg of sugar)
* Fiber constraint: `0.16g + 0.08r >= 5`  (at least 5 kg of fiber)
* Non-negativity constraints: `g >= 0`, `r >= 0`


```python
import gurobipy as gp
from gurobipy import GRB

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

# Create decision variables
g = model.addVar(lb=0, name="green_apples")
r = model.addVar(lb=0, name="red_apples")

# Set objective function
model.setObjective(9*g + 7*r, GRB.MINIMIZE)

# Add constraints
model.addConstr(0.05*g + 0.25*r >= 12, "sugar_constraint")
model.addConstr(0.16*g + 0.08*r >= 5, "fiber_constraint")

# Optimize model
model.optimize()

# Print results
if model.status == GRB.OPTIMAL:
    print(f"Optimal cost: ${model.objVal:.2f}")
    print(f"Green apples: {g.x:.2f} kg")
    print(f"Red apples: {r.x:.2f} kg")
elif model.status == GRB.INFEASIBLE:
    print("The model is infeasible.")
else:
    print(f"Optimization terminated with status {model.status}")

```
