Open gYunTian opened 3 years ago
Hi @gYunTian,
Here's a response from @amahmudwave and @pierrelouisp:
When expanding:
lagrange_hard_shift * sum_d ( effort * sum_n q_i(n,d) - workforce ) ** 2
We get:
lagrange_hard_shift * effort ** 2 * sum_d sum_m sum_n q_i(n,d) q_j(m, d) - 2 * lagrange_hard_shift * sum_d sum_n q_i(n,d) * effort * workforce (Your answer)
+ lagrange_hard_shift * (effort ** 2 * sum_d sum_n q_i(n,d))
This is because
(sum_n q_i(n,d))** 2 == sum_n q_i(n,d)**2 + sum_m sum_n q_i(n,d) q_j(m, d) == sum_n q_i(n,d) + sum_m sum_n q_i(n,d) q_j(m, d)
When we take the summation of binary variables and square them, we get the sum of the different variables multiplied with each other, plus the sum of the square of individual variables. ie. (a + b)**2 == (a**2 + b**2 + 2ab)
.
The sum of the square of individual variables is equal to the sum of the original binary variables, since 0 2 = 0 and 1 2 = 1.
Hope this helps!
I refer to both the hard shift and soft nurse constraint.
In doing my algebra, I wasn't able to reproduce the exact equation found in the documentations for both constraints. I think I may have gotten rusty at my high school math but please look at the following and enlighten me:
Mine: Expanding the following equation and removing the constant:
gives me the following:
Documentation: Notice the (Different) parts - above vs the bottom one:
There is an additional effort **2 among other things. Can someone please kindly explain the differences? Thanks