IBMDecisionOptimization/docplex-examples

Opposite of no_overlap

Opened this issue · 2 comments

Hi, I am using python for CP solving.
I would like to know if there is constraint that does the opposite of no_overlap.
This will be like
overlap(interval, arr, n)
interval - single interval variable
arr - array of interval variables
n - positive integer less than length of arr

this will mean that atleast n interval variables from arr overlap in the interval of interval

This is for a situation in job scheduling when a job is not possible to be scheduled on a machine because there are already n higher priority jobs.

Hello, you can use the overlapLength expression to know how much overlap there are between two interval variables. This way you can count the number of non-zero overlaps between 'interval' and all the elements of 'arr'. Something like:

mdl.sum([mdl.overlap_length(interval, a) > 0 for a in arr]) >= n

Hello,
Thanks for the reply, but actually what I need is a bit more complex.
I need that whenever interval starts then n intervals from a set have already started or start parallelly with interval. that is something above the overlap constraint