I'm playing around with linear programming for schedule optimization, and I'm using ojAlgo although that shouldn't matter.
The scenario is I have several university classes each with variables start time S and end time E. Assume there is only one room I am scheduling against, and I just want to get possible S and E times for each one without overlap.
I need to express an additional rule that for given two consecutive classes, they must be 15 minutes (1 discrete interval) apart between the end time of the first class Ei and the start time of the second class Sj, or vice versa with Ej and Si.
I felt like I could use some binary tricks like I asked in this previous question, so I did something like this. b is a binary that can only be elements 1,0.
Ei - Sj >= 1 - 100000b
Ej - Si >= 1 - 100000(1-b)
This seemed to work great for the following proofs:
Si=8, Ei=9, Sj=10, Ej=11, b=1, SUCCESS
Si=8, Ei=9, Sj=10, Ej=11, b=0, FAIL
Si=8, Ei=9, Sj=6, Ej=7, b=1, SUCCESS
Si=8, Ei=9, Sj=6, Ej=7, b=0, FAIL
Si=8, Ei=9, Sj=9, Ej=10, b=0, FAIL
But I got a false positive with this:
Si=8, Ei=9, Sj=6, Ej=7, b=1,SUCCESS
Is there a way I can alternate effectively with a binary between Ei - Sj >= 1 and Ej - Si >= 1 ?

