To solve this optimization problem, we need to define the decision variables, objective function, and constraints. Let's denote the amount invested in each industry as follows:
- $x_g$: amount invested in gold
- $x_d$: amount invested in diamond
- $x_r$: amount invested in ruby
- $x_s$: amount invested in sapphire

The objective is to maximize the total return, which can be calculated using the given annual rates of return for each industry.

Given information:
- Total budget: $1,000,000
- Annual rate of return: gold (3%), diamond (5%), ruby (6%), sapphire (10%)
- Constraints:
  - Amount invested in sapphire does not exceed the amount invested in gold.
  - Amount invested in diamond does not exceed the amount invested in ruby.
  - Maximum of 40% can be invested in the sapphire industry.

The objective function to maximize is: $0.03x_g + 0.05x_d + 0.06x_r + 0.10x_s$

Constraints:
1. Budget constraint: $x_g + x_d + x_r + x_s \leq 1000000$
2. Sapphire investment does not exceed gold investment: $x_s \leq x_g$
3. Diamond investment does not exceed ruby investment: $x_d \leq x_r$
4. Maximum 40% invested in sapphire: $x_s \leq 0.4 \times 1000000 = 400000$

Now, let's translate these into Gurobi code:

```python
from gurobipy import *

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

# Define decision variables
x_g = m.addVar(name="gold")
x_d = m.addVar(name="diamond")
x_r = m.addVar(name="ruby")
x_s = m.addVar(name="sapphire")

# Objective function: Maximize return
m.setObjective(0.03*x_g + 0.05*x_d + 0.06*x_r + 0.10*x_s, GRB.MAXIMIZE)

# Constraints
m.addConstr(x_g + x_d + x_r + x_s <= 1000000, name="budget")
m.addConstr(x_s <= x_g, name="sapphire_vs_gold")
m.addConstr(x_d <= x_r, name="diamond_vs_ruby")
m.addConstr(x_s <= 400000, name="max_sapphire")

# Solve the model
m.optimize()

# Print solution
if m.status == GRB.OPTIMAL:
    print("Optimal solution found:")
    print(f"Gold: {x_g.x}")
    print(f"Diamond: {x_d.x}")
    print(f"Ruby: {x_r.x}")
    print(f"Sapphire: {x_s.x}")
    print(f"Total Return: {m.objVal}")
else:
    print("No optimal solution found")
```