I have implemented two state updaters and a constraint to handle that never should a route’s load go under zero. Currently, if a route has load 0 and get a new job with negative load it allows inserting and the load remains on zero.
My implementation works most of the times but there are a couple of edge cases where I would love a second opinion.
My updaters set, per activity, the minimum load, both future and past. The constraint is a HardActivityConstraint.
My problem is that assuming I have 4 services
Service 1 and 3 has load 1
Service 2 and 4 has load -1
My vehicle has load 1 as well. There are more jobs and vehicles in my edge case examples but this is the important part.
At one point of the algorithm calculations, the algorithm creates for the constraint, the route 1,2,4 which is invalid because at one point it does have negative load so I should reject it, but the job getting inserted is job 3 at index 0 so it fixes the route because there is no longer a negative load.
The problem is that if I mark it as fulfilled then not only does the problem assumes that 3,1,2,4 is a successful route but also 1,2,4. In the end the 3 is assigned to another route and I’m left with 1,2,4 which is incorrect.
Is this the correct approach or would it be wiser to user other type of constraint? I can share source code but it is in Kotlin.
Thanks in advance for any input.