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

Similar to MaxBoundedSubsetSum() above but use a different algo. More...

#include <util.h>

Public Member Functions

int64_t MaxSubsetSum (absl::Span< const int64_t > elements, int64_t bin_size)
 
double ComplexityEstimate (int num_elements, int64_t bin_size)
 

Detailed Description

Similar to MaxBoundedSubsetSum() above but use a different algo.

Definition at line 533 of file util.h.

Member Function Documentation

◆ ComplexityEstimate()

double operations_research::sat::MaxBoundedSubsetSumExact::ComplexityEstimate ( int num_elements,
int64_t bin_size )

Returns an estimate of how many elementary operations MaxSubsetSum() is going to take.

Definition at line 968 of file util.cc.

◆ MaxSubsetSum()

int64_t operations_research::sat::MaxBoundedSubsetSumExact::MaxSubsetSum ( absl::Span< const int64_t > elements,
int64_t bin_size )

If we pack the given elements into a bin of size 'bin_size', returns largest possible sum that can be reached.

This implementation allow to solve this in O(2^(num_elements/2)) allowing to go easily to 30 or 40 elements. If bin_size is small, complexity is more like O(num_element * bin_size).

Get rid of a few easy to decide corner cases.

We split the elements in two equal-sized parts.

For all possible sum a, we compute the largest sum b that fits. We do that in linear time thanks to the sorted partial sums.

Definition at line 978 of file util.cc.


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