```python
from gurobipy import Model, GRB, quicksum

# Define the model
model = Model("Food Optimization")

# Define variables
foods = ['black beans', 'ham sandwiches', 'peanutbutter sandwiches', 'tomatoes', 'green beans', 'granola bars', 'cherry pies']
x = model.addVars(foods, lb=0, continuous=True, name=foods)

# Define objective function
model.setObjective(
    2 * x['black beans'] * x['black beans'] + 4 * x['black beans'] * x['ham sandwiches'] + x['black beans'] * x['green beans'] + 6 * x['black beans'] * x['granola bars'] + 6 * x['black beans'] * x['cherry pies'] +
    9 * x['ham sandwiches'] * x['ham sandwiches'] + 3 * x['ham sandwiches'] * x['peanutbutter sandwiches'] + x['ham sandwiches'] * x['green beans'] + x['ham sandwiches'] * x['granola bars'] +
    9 * x['peanutbutter sandwiches'] * x['peanutbutter sandwiches'] + 7 * x['peanutbutter sandwiches'] * x['tomatoes'] + 5 * x['peanutbutter sandwiches'] * x['green beans'] + 5 * x['peanutbutter sandwiches'] * x['granola bars'] + 6 * x['peanutbutter sandwiches'] * x['cherry pies'] +
    3 * x['tomatoes'] * x['tomatoes'] + 4 * x['tomatoes'] * x['green beans'] + x['tomatoes'] * x['granola bars'] + 8 * x['tomatoes'] * x['cherry pies'] +
    8 * x['granola bars'] * x['granola bars'] + 7 * x['granola bars'] * x['cherry pies'] +
    2 * x['cherry pies'] * x['cherry pies'] +
    4 * x['black beans'] + 7 * x['ham sandwiches'] + x['peanutbutter sandwiches'] + 5 * x['tomatoes'] + 8 * x['green beans'] + 4 * x['granola bars'],
    GRB.MAXIMIZE
)

# Define resource constraints
resources = {
    'r0': {'description': 'grams of fiber', 'upper_bound': 108, 'black beans': 2, 'ham sandwiches': 5, 'peanutbutter sandwiches': 5, 'tomatoes': 7, 'green beans': 8, 'granola bars': 1, 'cherry pies': 7},
    'r1': {'description': 'milligrams of iron', 'upper_bound': 130, 'black beans': 8, 'ham sandwiches': 6, 'peanutbutter sandwiches': 2, 'tomatoes': 3, 'green beans': 6, 'granola bars': 6, 'cherry pies': 4}
}

for r, data in resources.items():
    model.addConstr(quicksum(data[food] * x[food] for food in foods) <= data['upper_bound'], name=f"{data['description']} upper bound")

# Define additional constraints
model.addConstr(5 * x['ham sandwiches'] + 1 * x['granola bars'] >= 6, "fiber_constraint1")
model.addConstr(5 * x['ham sandwiches'] + 7 * x['tomatoes'] >= 15, "fiber_constraint2")
model.addConstr(5 * x['peanutbutter sandwiches'] + 8 * x['green beans'] >= 9, "fiber_constraint3")
model.addConstr(2 * x['black beans'] + 5 * x['peanutbutter sandwiches'] >= 5, "fiber_constraint4")

# ... (Add all other constraints similarly)

# Optimize the model
model.optimize()

# Print results
if model.status == GRB.OPTIMAL:
    print("Optimal solution found:")
    for food in foods:
        print(f"{food}: {x[food].x}")
    print(f"Objective value: {model.objVal}")
elif model.status == GRB.INFEASIBLE:
    print("Model is infeasible.")
else:
    print(f"Optimization terminated with status: {model.status}")

```