ortools.util.python.sorted_interval_list

class Domain(pybind11_builtins.pybind11_object):

We call domain any subset of Int64 = [kint64min, kint64max].

This class can be used to represent such set efficiently as a sorted and non-adjacent list of intervals. This is efficient as long as the size of such list stays reasonable.

In the comments below, the domain of *this will always be written 'D'. Note that all the functions are safe with respect to integer overflow.

Domain(arg0: int, arg1: int)

__init__(self: ortools.util.python.sorted_interval_list.Domain, arg0: int, arg1: int) -> None

By default, Domain will be empty.

def all_values() -> Domain:

all_values() -> ortools.util.python.sorted_interval_list.Domain

Returns the full domain Int64.

def greater_or_equal(value: int) -> Domain:

greater_or_equal(value: int) -> ortools.util.python.sorted_interval_list.Domain

Returns the domain [value., int_max].

def from_values(values: list[int]) -> Domain:

from_values(values: list[int]) -> ortools.util.python.sorted_interval_list.Domain

Creates a domain from the union of an unsorted list of integer values. Input values may be repeated, with no consequence on the output

def from_intervals( intervals: list[list[int]]) -> Domain:

from_intervals(intervals: list[list[int]]) -> ortools.util.python.sorted_interval_list.Domain

This method is available in Python, Java and .NET. It allows building a Domain object from a list of intervals (long[][] in Java and .NET, [[0, 2], [5, 5], [8, 10]] in python).

def from_flat_intervals( flat_intervals: list[int]) -> Domain:

from_flat_intervals(flat_intervals: list[int]) -> ortools.util.python.sorted_interval_list.Domain

This method is available in Python, Java and .NET. It allows building a Domain object from a flattened list of intervals (long[] in Java and .NET, [0, 2, 5, 5, 8, 10] in python).

def lower_or_equal(value: int) -> Domain:

lower_or_equal(value: int) -> ortools.util.python.sorted_interval_list.Domain

Returns the domain [int_min, value].

def addition_with( self, domain: Domain) -> Domain:

addition_with(self: ortools.util.python.sorted_interval_list.Domain, domain: ortools.util.python.sorted_interval_list.Domain) -> ortools.util.python.sorted_interval_list.Domain

Returns {x ∈ Int64, ∃ a ∈ D, ∃ b ∈ domain, x = a + b}.

def complement(self) -> Domain:
def contains(self, value: int) -> bool:

contains(self: ortools.util.python.sorted_interval_list.Domain, value: int) -> bool

Returns true iff value is in Domain.

def flattened_intervals(self) -> list[int]:

flattened_intervals(self: ortools.util.python.sorted_interval_list.Domain) -> list[int]

This method returns the flattened list of interval bounds of the domain.

Thus the domain {0, 1, 2, 5, 8, 9, 10} will return [0, 2, 5, 5, 8, 10] (as a C++ std::vector, as a java or C# long[], as a python list of integers).

def intersection_with( self, domain: Domain) -> Domain:
def is_empty(self) -> bool:

is_empty(self: ortools.util.python.sorted_interval_list.Domain) -> bool

Returns true if this is the empty set.

def is_included_in(self, domain: Domain) -> bool:

is_included_in(self: ortools.util.python.sorted_interval_list.Domain, domain: ortools.util.python.sorted_interval_list.Domain) -> bool

Returns true iff D is included in the given domain.

def size(self) -> int:

size(self: ortools.util.python.sorted_interval_list.Domain) -> int

Returns the number of elements in the domain. It is capped at kint64max

def max(self) -> int:

max(self: ortools.util.python.sorted_interval_list.Domain) -> int

Returns the max value of the domain. The domain must not be empty.

def min(self) -> int:

min(self: ortools.util.python.sorted_interval_list.Domain) -> int

Returns the min value of the domain. The domain must not be empty.

def negation(self) -> Domain:

negation(self: ortools.util.python.sorted_interval_list.Domain) -> ortools.util.python.sorted_interval_list.Domain

Returns {x ∈ Int64, ∃ e ∈ D, x = -e}.

Note in particular that if the negation of Int64 is not Int64 but Int64 \ {kint64min} !!

def overlaps_with(self, domain: Domain) -> bool:

overlaps_with(self: ortools.util.python.sorted_interval_list.Domain, domain: ortools.util.python.sorted_interval_list.Domain) -> bool

  • Returns true iff D overlaps with the given domain, that is, the intersection of the two domains is not empty.
def union_with( self, domain: Domain) -> Domain:
def AllValues() -> Domain:

AllValues() -> ortools.util.python.sorted_interval_list.Domain

Returns the full domain Int64.

def FromValues(values: list[int]) -> Domain:

FromValues(values: list[int]) -> ortools.util.python.sorted_interval_list.Domain

Creates a domain from the union of an unsorted list of integer values. Input values may be repeated, with no consequence on the output

def FromIntervals( intervals: list[list[int]]) -> Domain:

FromIntervals(intervals: list[list[int]]) -> ortools.util.python.sorted_interval_list.Domain

This method is available in Python, Java and .NET. It allows building a Domain object from a list of intervals (long[][] in Java and .NET, [[0, 2], [5, 5], [8, 10]] in python).

def FromFlatIntervals( flat_intervals: list[int]) -> Domain:

FromFlatIntervals(flat_intervals: list[int]) -> ortools.util.python.sorted_interval_list.Domain

This method is available in Python, Java and .NET. It allows building a Domain object from a flattened list of intervals (long[] in Java and .NET, [0, 2, 5, 5, 8, 10] in python).

def FlattenedIntervals(self) -> list[int]:

FlattenedIntervals(self: ortools.util.python.sorted_interval_list.Domain) -> list[int]

This method returns the flattened list of interval bounds of the domain.

Thus the domain {0, 1, 2, 5, 8, 9, 10} will return [0, 2, 5, 5, 8, 10] (as a C++ std::vector, as a java or C# long[], as a python list of integers).