## Problem Description and Formulation

The toy company produces model trains and planes. The production process involves building and painting. The time required for each activity is given as follows:

- Model train: 30 minutes to build, 40 minutes to paint
- Model plane: 40 minutes to build, 50 minutes to paint

The company has limited resources:
- At most 5000 minutes available for building
- At most 6000 minutes available for painting

The profit per unit is:
- $7 per model train
- $9 per model plane

The goal is to maximize profit.

## Mathematical Formulation

Let's denote:
- \(x\) as the number of model trains
- \(y\) as the number of model planes

The objective function to maximize profit is:
\[ \text{Maximize:} \quad 7x + 9y \]

Subject to:
\[ 30x + 40y \leq 5000 \] (building time constraint)
\[ 40x + 50y \leq 6000 \] (painting time constraint)
\[ x \geq 0, y \geq 0 \] (non-negativity constraints)

## Gurobi Code

```python
import gurobi

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

    # Define variables
    x = m.addVar(name="model_trains", obj=7, vtype=gurobi.GRB.INTEGER)
    y = m.addVar(name="model_planes", obj=9, vtype=gurobi.GRB.INTEGER)

    # Building time constraint
    m.addConstr(30*x + 40*y <= 5000, name="building_time")

    # Painting time constraint
    m.addConstr(40*x + 50*y <= 6000, name="painting_time")

    # Solve the model
    m.optimize()

    if m.status == gurobi.GRB.OPTIMAL:
        print("Optimal Solution:")
        print(f"Model Trains: {x.varValue}")
        print(f"Model Planes: {y.varValue}")
        print(f"Max Profit: {m.objVal}")
    else:
        print("The model is infeasible")

solve_model_trains_and_planes()
```

This code defines a Gurobi model for the given problem, adds variables for the number of model trains and planes, sets up the objective function and constraints, and then solves the model. If an optimal solution is found, it prints out the number of model trains and planes to produce and the maximum profit. If the model is infeasible, it indicates that as well.