Modeling Issue
AnsweredI have developed an optimization model for the design of district heating network pipes. My objective is to identify the presence of each pipe in the network and finalize the network design. To achieve this goal, I have introduced three binary variables: two for specifying the direction of each pipe, namely direction_AB and direction_BA, and one for indicating the existence of the pipe, denoted as Bp. These variables are interrelated through the following constraints:
for edge in df_edges.index:
model.addConstr(direction_AB[edge] + direction_BA[edge] <= 1)
model.addConstr(Bp[edge] == direction_AB[edge] + direction_BA[edge])
I have also the energy and mass balances in code.
I have also implemented energy and mass balances within the code. However, when I execute the code incorporating the cost objective function with the Bp variable, it fails to perform efficiently. The process consumes excessive time and struggles to converge, hindering the identification of the initial feasible solution. The objective function in question is as follows:
model.addConstr(obj == quicksum((5.36 * D_edge[edge] * 1000 + 139.15) * df_edges.at[edge, 'length'] * Bp[edge] for edge in df_edges.index))
model.setObjective(obj,GRB.MINIMIZE)
D_edge is Variable of diameter of each pipe.
for edge in df_edges.index:
model.addConstr(D_edge[edge] * D_edge[edge] >= fix * mass_edge[edge])
I think the issue is related to the definition of three binary variables, making the model challenging to solve. Could you please recommend an alternative formulation that is more compatible with Gurobi? My network and data are relatively large. I also set these solver parameters:
model.Params.ScaleFlag = 2
model.Params.MIPGap = 0.1
# Set NonConvex parameter to 2
model.setParam('NonConvex', 2)
model.setParam("Threads", 4)
model.setParam(GRB.Param.Method, 2)
model.setParam(GRB.Param.Heuristics, 0.1) # Determines the amount of time spent in MIP heuristics (%)
model.setParam(GRB.Param.MIPFocus, 1)
model.setParam(GRB.Param.IntFeasTol, 1e-06)
model.Params.OptimalityTol = 1e-06
model.Params.IntFeasTol = 1e-06
Thanks.
-
Hi,
I am not sure if it would help, but it seems like you do not need Bp[edge], you can use direction_AB and direction_BA instead. It should remove some variables and make your model more dense, which sometimes makes it faster. I believe it is worth giving it a try.
If I understood it correctly, you have a quadratic constraint with the diamater. This may also be the cause of the slow convergence, it might be worth looking into this constraint as well.
0 -
Thank you. I have a question about the method that Gurobi employs to find the best objective function. In many of my optimization models, the Best Bound of Objective Bounds is not feasible, especially in cases of minimization and integer programming, and it tends to be very low. This results in a significant gap between the Incumbent of Objective Bounds and Best Bound, leading to non-convergence of the model. For instance, in such scenarios, I find it necessary to limit the objective function to a reasonable range to adjust the Best Bound of Objective. Could you please provide guidance on addressing this issue?
0 -
Integer models are solved through branch and cut combined with several heuristics. What you described makes part of the algorithm, having this gap between a relaxed solution and the best integer feasible solution found.
A model that has a big gap between the relaxed solution and the integer one, is called a weak MIP. For better convergence, you want a strong MIP. Gurobi has a few videos on how to improve your model to make it stronger.
1
Please sign in to leave a comment.
Comments
3 comments