To solve this optimization problem, we first need to define the decision variables and the objective function. Let's denote:

- \(x_s\) as the amount invested in the solar energy company.
- \(x_w\) as the amount invested in the wind energy company.

The objective is to maximize the total profit, which can be calculated as \(0.10x_s + 0.09x_w\).

Given constraints are:
1. The total investment cannot exceed $6000: \(x_s + x_w \leq 6000\).
2. At least 45% of the investment should go into the solar energy company: \(x_s \geq 0.45 \times (x_s + x_w)\) or equivalently, \(x_s \geq 0.45 \times 6000\) since \(x_s + x_w = 6000\) for maximum profit.
3. At least $3000 should be invested in the wind energy company: \(x_w \geq 3000\).

However, upon closer inspection, we realize that to maximize profit under these conditions, we don't necessarily need to use all $6000 if the constraint of investing at least 45% in solar and $3000 in wind is met with less than $6000. Thus, our actual constraint for total investment becomes \(x_s + x_w = 6000\) for optimization purposes because we want to utilize all possible funds for maximum profit.

Let's express these constraints mathematically:
1. \(x_s + x_w \leq 6000\)
2. \(x_s \geq 0.45 \times 6000\)
3. \(x_w \geq 3000\)

Given that we aim to use all the funds for maximum profit, and considering the minimum investment requirements:
- The solar company must receive at least $2700 (45% of $6000), so \(x_s \geq 2700\).
- The wind company must receive at least $3000.

Thus, our optimization problem can be formulated as a linear program where we want to maximize \(0.10x_s + 0.09x_w\) under the given constraints.

Here's how this problem would look in Gurobi code:

```python
from gurobipy import *

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

# Create variables
x_s = m.addVar(lb=2700, name="Solar_Investment")  # Minimum of $2700
x_w = m.addVar(lb=3000, name="Wind_Investment")   # Minimum of $3000

# Objective function: Maximize profit
m.setObjective(0.10*x_s + 0.09*x_w, GRB.MAXIMIZE)

# Constraint: Total investment does not exceed $6000
m.addConstr(x_s + x_w <= 6000, name="Total_Investment")

# Since we want to use all funds for maximum profit,
# and given the minimums, this constraint ensures we're optimizing within bounds.
m.optimize()

# Print results
if m.status == GRB.OPTIMAL:
    print("Optimal solution found:")
    print(f"Solar Investment: ${x_s.x}")
    print(f"Wind Investment: ${x_w.x}")
    print(f"Total Profit: ${0.10*x_s.x + 0.09*x_w.x}")
else:
    print("No optimal solution found.")
```