or-toolscp-sat

How can we apply constraints for a start time in a given time series with Google ORTools?


I have an startTime interval, and a series of shift times like (2025-03-14 08:00-11:00,2025-03-14 11:30-15:00,2025-03-15 08:00-11:00,2025-03-15 11:30-15:00,2025-03-16 08:00-11:00,2025-03-16 11:30-15:00). And i also have these time ranges as the horizon ranges i mean (0-34500,40000-65000..etc..).

I want startTime interval must be in ONE OF THE HORIZON RANGES. i tried model.AddExactlyOne method it wantd ILiteral[] which i cannot write since if i write an expression 'startTime<iteratedRange.start' it is type of BoundedLinearExpression.

I need something like model.Add(startTime<iteratedRange.start).Or(startTime<iteratedRange2.start).Or(.....


Solution

  • start_var = model.new_int_var_from_domain(    cp_model.Domain.FromIntervals([0, 34500], [40000,54000]), 'start_var')
    

    and more generally, this doc section.