Does Pyomo allow parallel construction of model?

41 Views Asked by At

I have a large-scale scenarios-based optimization model that takes a long time to solve on Pyomo using the Gurobi solver. While solving the model using Gurobi (as it uses all available cores) is quick, the constraints definition part (done by Pyomo) takes all the time. Can we parallelize the model definition part on Pyomo? I asked chatGPT, which said the model definition part is inherently done in a single process and can not be parallelized. I was just wondering if you have encountered the same problem and have a way around it.

** My understanding of solving an optimization model using Pyomo and Gurobi solver is that Pyomo defines and constructs the model and passes it to the Gurobi solver to solve it. I want to leverage a parallel computing mechanism for the model construction part (done by Pyomo). Apparently, this is not possible.

*** The following two constraints are taking the majority of the time:

for k in range(len(y)):
    for i in range(NumBus):
        model.Constraints.add(inequality(Pminm[i], model.P[i]-model.Lambda[i] * sum(y[k, :]), Pmaxm[i]))


for k in range(len(y)):
    for i in range(NumBus):
        for j in range(NumBus):
            if i != j:
                model.Constraints.add(
                    inequality(
                        -100, 
                        B[i, j] * (
                            model.Angles[i] + 
                            sum(B_u[i, m] * (y[k, i] - model.Lambda[m]) for m in range(NumBus)) - 
                            model.Angles[j] - 
                            sum(B_u[j, n] * (y[k, j] - model.Lambda[n]) for n in range(NumBus))
                        ),
                        100
                    )
                )  

Here, len(y)=10,000 and NumBus=118.

0

There are 0 best solutions below