Thank you for your valuable insights on handling binary-continuous variable products in CPLEX. I would like to share additional information based on my own experience.
I am using CPLEX Studio v22.1, and when I attempt to solve my model with this version, after applying linearization, I encounter an optimality gap of 160% within the 10-hour time limit. In contrast, when I run the same model with Gurobi (using Gurobipy), it reaches a gap of approximately 60%, without the need for linearization.
Could you provide any insights into why Gurobi performs better without linearization? Additionally, what methods or techniques does Gurobi employ that might explain this discrepancy in performance?
I would greatly appreciate any advice or suggestions you can offer.
Thank you again for your assistance!
Best regards,
Aysan
------------------------------
icw suni
------------------------------
Original Message:
Sent: Wed April 16, 2025 04:51 AM
From: PhR
Subject: Issue with Solving Equality Constraint Involving Product of Continuous and Binary Variables in CPLEX
The general case can be formulated this way :
Assume L <= x < = U
and b in {0, 1}
, the formulation of u = x * b
is
L (1-b) <= x - u <= U (1-b)
Lb <= u <= Ub
This formulation is tight: it gives the convex hull.
I assumed the variable u is a brand new one introduced for this product.
Original Message:
Sent: Tue April 15, 2025 05:42 AM
From: icw suni
Subject: Issue with Solving Equality Constraint Involving Product of Continuous and Binary Variables in CPLEX
Dear IBM Community,
I am currently working on an optimization model using Pyomo, and I am using CPLEX for solving it. One of the constraints in my model is an equality constraint that involves the product of a continuous variable and a binary variable. The constraint is as follows:
M_g = read_excel_as_dict(file_path, "M_g")
model.M_g = Param(model.G, initialize=M_g)
delta_qbr = read_excel_as_matrix_dict_3d(file_path, 'delta_qbr')
model.delta_qbr = Param(model.B * model.B * model.B, initialize=delta_qbr)
d_qr = read_excel_as_matrix_dict_2d(file_path, "d_qr")
model.d_qr = Param(model.B * model.B, initialize=d_qr)
model.x_bg = Var(model.B * model.G, domain=Binary)
model.theta_b = Var(model.B, domain=NonNegativeReals)
def C30(model, b): sum_1 = sum(
model.delta_qbr[q, b2, r2] *
(sum(model.M_g[g] * model.x[b,g] *model.theta_b[b] for g in model.G_b[r2])) /
model.d_qr[q, r2]
for b2 in model.B
for q in model.R_b[b2]
for r2 in model.B
if r2 != q and r2 != b2
)
sum_2 = sum(
model.delta_qbr[q, b, r] *
(sum(model.M_g[g] * model.x_bg[r, g] for g in model.G_b[r])) /
model.d_qr[q, r]
for q in model.R_b[b]
for r in model.B
if r != q and r != b
)
return sum_1 == sum_2
model.C30 = Constraint(model.B, rule=C30)
When I run the model using CPLEX, it fails to solve this constraint. However, when I implement the same model using Gurobi with gurobipy
, it is able to solve the constraint without any issues.
Could anyone explain why CPLEX is unable to handle this type of constraint? Are there specific settings or approaches that I need to use in CPLEX to address this issue?
Thank you in advance for your help.
Best regards,
Aysan
------------------------------
icw suni
------------------------------