To solve this optimization problem, we first need to define the variables and the objective function. Let's denote the amount invested in the rapper as \(R\) and the amount invested in the pop artist as \(P\).

The constraints given are:
1. The total investment is $400,000: \(R + P = 400,000\)
2. The investment in the pop artist is at least three times the investment in the rapper: \(P \geq 3R\)
3. The maximum amount invested in the pop artist is $250,000: \(P \leq 250,000\)

The earnings from each investment are:
- From the rapper: \(0.05R\)
- From the pop artist: \(0.03P\)

The objective is to maximize the total earnings: \(0.05R + 0.03P\).

Given these constraints and the objective function, we can formulate this as a linear programming problem.

```python
from gurobipy import *

# Create a model
m = Model("Investment_Optimization")

# Define variables
R = m.addVar(lb=0, name="Investment_in_Rapper")
P = m.addVar(lb=0, name="Investment_in_Pop_Artist")

# Define constraints
m.addConstr(R + P == 400000, name="Total_Investment")
m.addConstr(P >= 3 * R, name="Pop_vs_Rapper_Investment")
m.addConstr(P <= 250000, name="Max_Pop_Investment")

# Define the objective function
m.setObjective(0.05 * R + 0.03 * P, GRB.MAXIMIZE)

# Optimize the model
m.optimize()

# Print results
if m.status == GRB.OPTIMAL:
    print("Optimal solution found:")
    print(f" Invest in Rapper: ${R.x}")
    print(f" Invest in Pop Artist: ${P.x}")
    print(f" Total Earnings: ${0.05 * R.x + 0.03 * P.x}")
else:
    print("No optimal solution found")
```