## Problem Description and Formulation

The peanut farmer needs to transport peanut packages to the city using trains and trucks. The goal is to maximize the number of packages transported under certain constraints.

- Trains can carry 80 packages per trip at a cost of $50 per trip.
- Trucks can carry 50 packages per trip at a cost of $40 per trip.
- The total cost must not exceed $3000.
- The number of train trips must not exceed the number of truck trips.

## Mathematical Formulation

Let \(T\) be the number of train trips and \(K\) be the number of truck trips.

- The objective is to maximize \(80T + 50K\), which represents the total number of packages transported.
- The cost constraint is \(50T + 40K \leq 3000\).
- The trip constraint is \(T \leq K\).
- Non-negativity constraints are \(T \geq 0\) and \(K \geq 0\), since the number of trips cannot be negative.

## Gurobi Code

```python
import gurobi

def solve_transportation_problem():
    # Create a new model
    model = gurobi.Model()

    # Define variables
    T = model.addVar(name="T", vtype=gurobi.GRB.INTEGER, lb=0)  # Train trips
    K = model.addVar(name="K", vtype=gurobi.GRB.INTEGER, lb=0)  # Truck trips

    # Objective: Maximize the number of packages transported
    model.setObjective(80 * T + 50 * K, gurobi.GRB.MAXIMIZE)

    # Cost constraint: 50T + 40K <= 3000
    model.addConstr(50 * T + 40 * K <= 3000, name="cost_constraint")

    # Trip constraint: T <= K
    model.addConstr(T <= K, name="trip_constraint")

    # Optimize
    model.optimize()

    # Print solution
    if model.status == gurobi.GRB.OPTIMAL:
        print(f"Optimal solution: Train trips = {T.varValue}, Truck trips = {K.varValue}")
        print(f"Maximum packages transported: {80 * T.varValue + 50 * K.varValue}")
    else:
        print("No optimal solution found")

solve_transportation_problem()
```