How do I reduce the summation of a binary variable Integer Linear Programming
An answer to this question on Stack Overflow.
Question
I am working with an optimization problem where I have a variable with 3 indices
Binary Variable: Viup <- i is for no. of tasks, u is the machine, and p is the time
Integer Variable: Xi <- the cost of each task i
I am trying to impose a constraint such that the cost to perform the task should not be more than a fixed quantity (here Budget )that the cost of each task should be calculated only once even though the task is performed by multiple machines many times.
I want to sum the values in Viup such that for each value of i the summation should not be more than 1 or could be 0, so that I can form a an equation something like
Sum of Viup * Xi <= Budget
Learning to formulate ILP equations please help
Answer
If I understand right, you need to know if any of Viup is 1 for fixed u,p across all i.
If you are performing a minimization, one way to do this would be to introduce a binary indicator variable d_i and a new constraint
sum_i(V_iup)-B*d_i<=0
where B is a constant and an upper bound for sum_i(V_iup). Now, if d_i=1, then sum_i(V_iup)>=0 otherwise, if d_i=0 then sum_i(V_iup)=0.
You can now rewrite you budget summation as:
d_i*X_i<=Budget