Gurobi: Prod() in addConstrs()

1.3k Views Asked by At

When I set up the constraint, the code is

m.addConstr(binary_var.prod(cost_con) <= budget[k])

binary_var is the variable name, cost_con is the coefficients of the variables. The constraint is a linear expression, like

cost_con[0]*binary_var[0]+cost_con[1]*binary_var[1]+cost_con[2]*binary_var[2]+....

Here is the problem. Since the number of variables is very large, nearly 5000. So the code binary_var.prod(cost_con) costs a lot of time. Could you please tell me if you have some better solutions to decrease the running time?

Thanks

0

There are 0 best solutions below