## Problem Description and Formulation

The problem is a classic example of a linear programming (LP) problem. The farmer has two farms and needs to determine the number of days to operate each farm to meet the market demand for apples, oranges, and pears while minimizing the total operating cost.

Let's define the decision variables:

* $x_1$: number of days to operate farm 1
* $x_2$: number of days to operate farm 2

The objective function is to minimize the total operating cost:

* Minimize $500x_1 + 400x_2$

The constraints are:

* Farm 1 yields 10 apples per day, and farm 2 yields 7 apples per day. The farmer needs to provide 50 apples to the market.
* Farm 1 yields 15 oranges per day, and farm 2 yields 8 oranges per day. The farmer needs to provide 60 oranges to the market.
* Farm 1 yields 5 pears per day, and farm 2 yields 9 pears per day. The farmer needs to provide 55 pears to the market.
* The number of days to operate each farm cannot be negative.

## Mathematical Formulation

The mathematical formulation of the problem is:

Minimize $500x_1 + 400x_2$

Subject to:

* $10x_1 + 7x_2 \geq 50$ (apples)
* $15x_1 + 8x_2 \geq 60$ (oranges)
* $5x_1 + 9x_2 \geq 55$ (pears)
* $x_1 \geq 0, x_2 \geq 0$ (non-negativity)

## Gurobi Code

```python
import gurobipy as gp

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

# Define the decision variables
x1 = m.addVar(name="x1", lb=0)  # number of days to operate farm 1
x2 = m.addVar(name="x2", lb=0)  # number of days to operate farm 2

# Define the objective function
m.setObjective(500 * x1 + 400 * x2, gp.GRB.MINIMIZE)

# Define the constraints
m.addConstr(10 * x1 + 7 * x2 >= 50, name="apples")
m.addConstr(15 * x1 + 8 * x2 >= 60, name="oranges")
m.addConstr(5 * x1 + 9 * x2 >= 55, name="pears")

# Solve the model
m.optimize()

# Print the solution
if m.status == gp.GRB.OPTIMAL:
    print("Optimal solution found.")
    print(f"Operate farm 1 for {x1.varValue} days.")
    print(f"Operate farm 2 for {x2.varValue} days.")
    print(f"Total cost: ${m.objVal:.2f}")
else:
    print("No optimal solution found.")
```