![]() |
Google OR-Tools v9.12
a fast and portable software suite for combinatorial optimization
|
Public Member Functions | |
SweepLineIntervalTree (int max_y, int num_boxes) | |
void | RecomputeConnectedComponents (TreeNodeIndex idx) |
void | RemoveNodeIfXMaxLowerOrEqual (TreeNodeIndex idx, int x_threshold) |
void | UpdateChildrenIntersecting (TreeNodeIndex idx, int sweep_line_x_pos, int component_index, std::vector< int > *new_connections) |
bool | UpdateParents (TreeNodeIndex node, int sweep_line_x_pos, int component_index, std::vector< int > *new_connections) |
void | AddInterval (TreeNodeIndex idx, int sweep_line_x_pos, int box_index, int x_max, std::vector< int > *new_connections) |
Public Attributes | |
FixedShapeBinaryTree | tree |
util_intops::StrongVector< TreeNodeIndex, BinaryTreeNode > | tree_nodes |
DenseConnectedComponentsFinder | union_find |
A data structure to store which boxes are overlapping the current sweep line. This uses a binary tree in a slight non-standard way: in a typical use of a binary tree the actual values are stored in the leaves and the intermediate nodes are there just to make finding the right leaf efficient. Here we do the opposite: the values are stored as high up in the tree as possible. For example, for a tree of size 8 a box that occupies the y interval [0, 7] will be stored as a single node at the root. In the same tree, a box that occupies [3, 7] will be stored with the nodes representing the [3, 4), [4, 6) and [6, 8) intervals. There is no difference on what is stored in the intermediate nodes or on the leaves. When the sweep line moves, we don't update the existing nodes on the tree. Thus, some nodes will become stale and will represent boxes that no longer overlap the sweep line. Those stale nodes get removed lazily.
Definition at line 1658 of file diffn_util.cc.
|
inlineexplicit |
Definition at line 1659 of file diffn_util.cc.
|
inline |
Add a new box to the sweep line. This will store it in the tree (split in log N intervals) check if it connects to one or more existing connected components, and for each case it does, add the box that it is overlapping to new_connections.
We can only be connecting children if it is not already connect via something above on the tree.
We have already something fully occupying this interval.
Replace the existing box by the new one.
Definition at line 1767 of file diffn_util.cc.
|
inline |
Recompute the connected components of a given node, by simply setting it to {self} + left.connected_components + right.connected_components.
The order is non-deterministic, but since this is doing the union of hash sets the result is deterministic.
Definition at line 1666 of file diffn_util.cc.
|
inline |
We don't have global deletion method in this class, but this method checks if a single interval is fully to the left of the sweep line and removes it if so, also updating its connected components.
Node is already empty.
Node is still overlapping the sweep line.
Definition at line 1689 of file diffn_util.cc.
|
inline |
No need to recurse here: we already connected everything on this branch to the new box.
Since everything is intersecting the current box, all descendants must be in one single component.
Only go down on the tree if we have below either:
Definition at line 1703 of file diffn_util.cc.
|
inline |
Definition at line 1744 of file diffn_util.cc.
FixedShapeBinaryTree operations_research::sat::SweepLineIntervalTree::tree |
Definition at line 1799 of file diffn_util.cc.
util_intops::StrongVector<TreeNodeIndex, BinaryTreeNode> operations_research::sat::SweepLineIntervalTree::tree_nodes |
Definition at line 1800 of file diffn_util.cc.
DenseConnectedComponentsFinder operations_research::sat::SweepLineIntervalTree::union_find |
Definition at line 1801 of file diffn_util.cc.