How to linearize the sum of a product of two decision variables in LP?

时间:2017-10-23 20:48:17

标签: python linear-programming

Being new to Linear Programming and Gurobi, I am dealing with an Integer Linear program where I have two binary decision variables defined as B[u_v, x_y] and A[u_x], I am trying to implement this constraint in Gurobi via Python but I am stuck on how to translate the sum of the product of the two decision variables defined in this loop :

for each edge(u,v) in Set_of_edges:
    for each vertex x in Set_of_vertices:
        Sum_over(y) (B[u_v,x_y]) * A[u_x] == 1

From this book, it has to be linearized but I am not able to do it. Anyone could shed some light and provide me with some insights ?

Thanks

1 个答案:

答案 0 :(得分:1)

如果您有两个二进制变量xy,则可以通过这些约束添加新的辅助二进制变量z = x*y

  • z <= x
  • z <= y
  • z >= x + y - 1

由于我无法执行您的任务(不完整的伪代码),您将不得不使用新引入的变量z自行完成其他任务。