To solve Andy's investment problem, we need to maximize the return on investment given the constraints. Let's denote:

- $x_e$ as the amount invested in the energy sector,
- $x_t$ as the amount invested in the travel sector.

The total investment is $10 million, so we have:
\[ x_e + x_t = 10,000,000 \]

The return on investment for the energy sector is 32%, and for the travel sector, it's 20%. The objective function to maximize the total return is:
\[ \text{Maximize: } 0.32x_e + 0.20x_t \]

Given that at least 25% of the investment should be in the energy sector, we have:
\[ x_e \geq 0.25 \times 10,000,000 \]
\[ x_e \geq 2,500,000 \]

And since at most 50% of the investment should be in the travel sector, we have:
\[ x_t \leq 0.50 \times 10,000,000 \]
\[ x_t \leq 5,000,000 \]

Also, both $x_e$ and $x_t$ must be non-negative since they represent amounts of money.

Here is the Gurobi code to solve this linear programming problem:

```python
from gurobipy import *

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

# Define variables
xe = m.addVar(lb=2500000, name="energy_investment")
xt = m.addVar(ub=5000000, name="travel_investment")

# Objective function: Maximize return
m.setObjective(0.32*xe + 0.20*xt, GRB.MAXIMIZE)

# Constraint: Total investment is $10 million
m.addConstr(xe + xt == 10000000, "total_investment")

# Optimize model
m.optimize()

# Print results
if m.status == GRB.OPTIMAL:
    print("Optimal solution found:")
    print(f"Energy Sector Investment: ${xe.x}")
    print(f"Travel Sector Investment: ${xt.x}")
    print(f"Total Return: ${0.32*xe.x + 0.20*xt.x}")
else:
    print("No optimal solution found")
```