Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
operations_research::glop::SumWithOneMissing< supported_infinity_is_positive > Class Template Reference

#include <lp_utils.h>

Public Member Functions

 SumWithOneMissing ()
 
void Add (Fractional x)
 
void RemoveOneInfinity ()
 
Fractional Sum () const
 
Fractional SumWithout (Fractional x) const
 
Fractional SumWithoutLb (Fractional c) const
 
Fractional SumWithoutUb (Fractional c) const
 

Detailed Description

template<bool supported_infinity_is_positive>
class operations_research::glop::SumWithOneMissing< supported_infinity_is_positive >

Given N Fractional elements, this class maintains their sum and can provide, for each element X, the sum of all elements except X. The subtelty is that it works well with infinities: for example, if there is exactly one infinite element X, then SumWithout(X) will be finite.

Two flavors of this class are provided: SumWithPositiveInfiniteAndOneMissing supports calling Add() with normal numbers and positive infinities (and will DCHECK() that), and SumWithNegativeInfiniteAndOneMissing does the same with negative infinities.

The numerical accuracy suffers however. If X is 1e100 and SumWithout(X) should be 1e-100, then the value actually returned by SumWithout(X) is likely to be wrong.

Definition at line 328 of file lp_utils.h.

Constructor & Destructor Documentation

◆ SumWithOneMissing()

template<bool supported_infinity_is_positive>
operations_research::glop::SumWithOneMissing< supported_infinity_is_positive >::SumWithOneMissing ( )
inline

Definition at line 330 of file lp_utils.h.

Member Function Documentation

◆ Add()

template<bool supported_infinity_is_positive>
void operations_research::glop::SumWithOneMissing< supported_infinity_is_positive >::Add ( Fractional x)
inline

If we overflow, then there is not much we can do. This is needed because KahanSum seems to give nan if we try to add stuff to an infinite sum.

Definition at line 332 of file lp_utils.h.

◆ RemoveOneInfinity()

template<bool supported_infinity_is_positive>
void operations_research::glop::SumWithOneMissing< supported_infinity_is_positive >::RemoveOneInfinity ( )
inline

Definition at line 349 of file lp_utils.h.

◆ Sum()

template<bool supported_infinity_is_positive>
Fractional operations_research::glop::SumWithOneMissing< supported_infinity_is_positive >::Sum ( ) const
inline

Definition at line 354 of file lp_utils.h.

◆ SumWithout()

template<bool supported_infinity_is_positive>
Fractional operations_research::glop::SumWithOneMissing< supported_infinity_is_positive >::SumWithout ( Fractional x) const
inline

Definition at line 359 of file lp_utils.h.

◆ SumWithoutLb()

template<bool supported_infinity_is_positive>
Fractional operations_research::glop::SumWithOneMissing< supported_infinity_is_positive >::SumWithoutLb ( Fractional c) const
inline

When the term we substract has a big magnitude, the SumWithout() can be quite imprecise. On can use these version to have more defensive bounds.

Definition at line 371 of file lp_utils.h.

◆ SumWithoutUb()

template<bool supported_infinity_is_positive>
Fractional operations_research::glop::SumWithOneMissing< supported_infinity_is_positive >::SumWithoutUb ( Fractional c) const
inline

Definition at line 376 of file lp_utils.h.


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