Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
operations_research::SimpleDynamicPartition Class Reference

#include <dynamic_partition.h>

Public Member Functions

 SimpleDynamicPartition (int num_elements)
 
int NumElements () const
 
int NumParts () const
 
int PartOf (int element) const
 
int SizeOfPart (int part) const
 
void Refine (absl::Span< const int > distinguished_subset)
 
template<typename T >
std::vector< absl::Span< const T > > GetParts (std::vector< T > *buffer)
 

Detailed Description

A subset of the API of DynamicPartition without backtrack support. The Refine() here is about twice as fast, but we have limited query support until a batch ComputeElementsByPart() is called.

Definition at line 273 of file dynamic_partition.h.

Constructor & Destructor Documentation

◆ SimpleDynamicPartition()

operations_research::SimpleDynamicPartition::SimpleDynamicPartition ( int num_elements)
inlineexplicit

Definition at line 275 of file dynamic_partition.h.

Member Function Documentation

◆ GetParts()

template<typename T >
std::vector< absl::Span< const T > > operations_research::SimpleDynamicPartition::GetParts ( std::vector< T > * buffer)
inline

This is meant to be called once after a bunch of Refine(). The returned Span<> points into the given buffer which is re-initialized. To handle strongly typed int, we actually call T(int) as we fill the buffer.

Compute start of each part in buffer.

Fill result.

Copy elements in order and at their place.

Definition at line 374 of file dynamic_partition.h.

◆ NumElements()

int operations_research::SimpleDynamicPartition::NumElements ( ) const
inline

Definition at line 279 of file dynamic_partition.h.

◆ NumParts()

int operations_research::SimpleDynamicPartition::NumParts ( ) const
inline

Definition at line 280 of file dynamic_partition.h.

◆ PartOf()

int operations_research::SimpleDynamicPartition::PartOf ( int element) const
inline

Definition at line 281 of file dynamic_partition.h.

◆ Refine()

void operations_research::SimpleDynamicPartition::Refine ( absl::Span< const int > distinguished_subset)

Compute the size of the non-empty intersection of each part with the distinguished_subset.

Reuse local_sizes to store new_part index or zero (no remapping). Also update the size of each part.

No need to remap if the whole part is in distinguished_subset.

For each part not completely included or excluded, split out the element from distinguished_subset into a new part.

Sparse clean.

Definition at line 298 of file dynamic_partition.cc.

◆ SizeOfPart()

int operations_research::SimpleDynamicPartition::SizeOfPart ( int part) const
inline

Definition at line 282 of file dynamic_partition.h.


The documentation for this class was generated from the following files: