## Problem Description and Formulation

The movie producer has $500,000 to invest in two movies: an action movie and an animation movie. The goal is to maximize earnings given the following constraints:

1. The total investment is $500,000.
2. The amount invested in the animation movie must be at least three times the amount invested in the action movie.
3. The amount invested in the animation movie can be at most $400,000.
4. The action movie earns 9% on investment, and the animation movie earns 6% on investment.

Let's denote:
- \(x\) as the amount invested in the action movie.
- \(y\) as the amount invested in the animation movie.

The objective function to maximize earnings (\(E\)) is:
\[ E = 0.09x + 0.06y \]

Subject to:
1. \( x + y \leq 500,000 \) (total investment constraint)
2. \( y \geq 3x \) (animation movie investment constraint)
3. \( y \leq 400,000 \) (animation movie upper limit constraint)
4. \( x \geq 0 \) and \( y \geq 0 \) (non-negativity constraints)

## Gurobi Code

```python
import gurobi

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

    # Define variables
    x = model.addVar(name="action_movie_investment", lb=0)
    y = model.addVar(name="animation_movie_investment", lb=0)

    # Objective function: Maximize earnings
    model.setObjective(0.09 * x + 0.06 * y, gurobi.GRB.MAXIMIZE)

    # Constraints
    model.addConstr(x + y <= 500000, name="total_investment_constraint")
    model.addConstr(y >= 3 * x, name="animation_movie_investment_constraint")
    model.addConstr(y <= 400000, name="animation_movie_upper_limit_constraint")

    # Optimize model
    model.optimize()

    # Print solution
    if model.status == gurobi.GRB.OPTIMAL:
        print(f"Optimal investment in action movie: ${x.varValue:.2f}")
        print(f"Optimal investment in animation movie: ${y.varValue:.2f}")
        print(f"Maximized earnings: ${0.09 * x.varValue + 0.06 * y.varValue:.2f}")
    else:
        print("No optimal solution found.")

solve_investment_problem()
```