Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
#include <basis_representation.h>
Public Member Functions | |
BasisFactorization (const CompactSparseMatrix *compact_matrix, const RowToColMapping *basis) | |
BasisFactorization (const BasisFactorization &)=delete | |
This type is neither copyable nor movable. | |
BasisFactorization & | operator= (const BasisFactorization &)=delete |
virtual | ~BasisFactorization () |
void | SetParameters (const GlopParameters ¶meters) |
Sets the parameters for this component. | |
const ColumnPermutation & | GetColumnPermutation () const |
void | SetColumnPermutationToIdentity () |
void | Clear () |
ABSL_MUST_USE_RESULT Status | Initialize () |
RowToColMapping | ComputeInitialBasis (const std::vector< ColIndex > &candidates) |
RowIndex | GetNumberOfRows () const |
Return the number of rows in the basis. | |
ABSL_MUST_USE_RESULT Status | Refactorize () |
ABSL_MUST_USE_RESULT Status | ForceRefactorization () |
bool | IsRefactorized () const |
Returns true if the factorization was just recomputed. | |
ABSL_MUST_USE_RESULT Status | Update (ColIndex entering_col, RowIndex leaving_variable_row, const ScatteredColumn &direction) |
void | LeftSolve (ScatteredRow *y) const |
Left solves the system y.B = rhs, where y initially contains rhs. | |
void | LeftSolveForUnitRow (ColIndex j, ScatteredRow *y) const |
void | TemporaryLeftSolveForUnitRow (ColIndex j, ScatteredRow *y) const |
Same as LeftSolveForUnitRow() but does not update any internal data. | |
void | RightSolve (ScatteredColumn *d) const |
Right solves the system B.d = a where the input is the initial value of d. | |
void | RightSolveForProblemColumn (ColIndex col, ScatteredColumn *d) const |
const DenseColumn & | RightSolveForTau (const ScatteredColumn &a) const |
Fractional | RightSolveSquaredNorm (const ColumnView &a) const |
Fractional | DualEdgeSquaredNorm (RowIndex row) const |
Fractional | ComputeOneNormConditionNumber () const |
Fractional | ComputeInfinityNormConditionNumber () const |
Fractional | ComputeInfinityNormConditionNumberUpperBound () const |
Fractional | ComputeOneNorm () const |
Fractional | ComputeInfinityNorm () const |
Fractional | ComputeInverseOneNorm () const |
Fractional | ComputeInverseInfinityNorm () const |
Computes the infinity-norm of the inverse of B. | |
std::string | StatString () const |
void | ResetStats () |
double | DeterministicTime () const |
int | NumUpdates () const |
Returns the number of updates since last refactorization. | |
A basis factorization is the product of an eta factorization and a L.U decomposition, i.e. B = L.U.E_0.E_1. ... .E_{k-1} It is used to solve two systems:
To speed-up and improve stability the factorization is refactorized at least every 'refactorization_period' updates.
This class does not take ownership of the underlying matrix and basis, and thus they must outlive this class (and keep the same address in memory).
Definition at line 160 of file basis_representation.h.
operations_research::glop::BasisFactorization::BasisFactorization | ( | const CompactSparseMatrix * | compact_matrix, |
const RowToColMapping * | basis ) |
Definition at line 187 of file basis_representation.cc.
|
delete |
This type is neither copyable nor movable.
|
virtualdefault |
void operations_research::glop::BasisFactorization::Clear | ( | ) |
Clears the factorization and resets it to an identity matrix of size given by matrix_.num_rows().
Definition at line 203 of file basis_representation.cc.
Fractional operations_research::glop::BasisFactorization::ComputeInfinityNorm | ( | ) | const |
Computes the infinity-norm of B. The infinity-norm A
is defined as max_i sum_j a_ij
http://en.wikipedia.org/wiki/Matrix_norm
Definition at line 542 of file basis_representation.cc.
Fractional operations_research::glop::BasisFactorization::ComputeInfinityNormConditionNumber | ( | ) | const |
Definition at line 602 of file basis_representation.cc.
Fractional operations_research::glop::BasisFactorization::ComputeInfinityNormConditionNumberUpperBound | ( | ) | const |
Definition at line 607 of file basis_representation.cc.
RowToColMapping operations_research::glop::BasisFactorization::ComputeInitialBasis | ( | const std::vector< ColIndex > & | candidates | ) |
This mainly forward the call to LuFactorization::ComputeInitialBasis().
Definition at line 223 of file basis_representation.cc.
Fractional operations_research::glop::BasisFactorization::ComputeInverseInfinityNorm | ( | ) | const |
Computes the infinity-norm of the inverse of B.
Get a column of the matrix inverse.
Compute sum_j inverse_ij
.
Compute max_i sum_j inverse_ij
Definition at line 573 of file basis_representation.cc.
Fractional operations_research::glop::BasisFactorization::ComputeInverseOneNorm | ( | ) | const |
Computes the 1-norm of the inverse of B. For this we iteratively solve B.x = e_j, where e_j is the jth unit vector. The result of this computation is the jth column of B^-1.
Get a column of the matrix inverse.
Compute sum_i inverse_ij
.
Compute max_j sum_i inverse_ij
Definition at line 551 of file basis_representation.cc.
Fractional operations_research::glop::BasisFactorization::ComputeOneNorm | ( | ) | const |
Computes the 1-norm of B. The 1-norm A
is defined as max_j sum_i a_ij
http://en.wikipedia.org/wiki/Matrix_norm
Definition at line 536 of file basis_representation.cc.
Fractional operations_research::glop::BasisFactorization::ComputeOneNormConditionNumber | ( | ) | const |
Computes the condition number of B. For a given norm, this is the matrix norm times the norm of its inverse. A condition number greater than 1E7 will lead to precision problems.
Definition at line 597 of file basis_representation.cc.
double operations_research::glop::BasisFactorization::DeterministicTime | ( | ) | const |
The deterministic time used by this class. It is incremented for each solve and each factorization.
Definition at line 615 of file basis_representation.cc.
Fractional operations_research::glop::BasisFactorization::DualEdgeSquaredNorm | ( | RowIndex | row | ) | const |
Returns the norm of (B^T)^{-1}.e_row where e is an unit vector. This is a bit faster and avoids polluting the stats of LeftSolve(). It can be called only when IsRefactorized() is true.
Definition at line 517 of file basis_representation.cc.
Status operations_research::glop::BasisFactorization::ForceRefactorization | ( | ) |
Like Refactorize(), but do it even if IsRefactorized() is true. Call this if the underlying basis_ changed and Update() wasn't called.
Definition at line 239 of file basis_representation.cc.
|
inline |
Returns the column permutation used by the LU factorization. This call only makes sense if the basis was just refactorized.
Definition at line 182 of file basis_representation.h.
|
inline |
Return the number of rows in the basis.
Definition at line 218 of file basis_representation.h.
Status operations_research::glop::BasisFactorization::Initialize | ( | ) |
Clears the factorization and initializes the class using the current matrix_ and basis_. This is fast if IsIdentityBasis() is true, otherwise it will trigger a refactorization and will return an error if the matrix could not be factorized.
Definition at line 216 of file basis_representation.cc.
bool operations_research::glop::BasisFactorization::IsRefactorized | ( | ) | const |
Returns true if the factorization was just recomputed.
Definition at line 232 of file basis_representation.cc.
void operations_research::glop::BasisFactorization::LeftSolve | ( | ScatteredRow * | y | ) | const |
Left solves the system y.B = rhs, where y initially contains rhs.
Definition at line 348 of file basis_representation.cc.
void operations_research::glop::BasisFactorization::LeftSolveForUnitRow | ( | ColIndex | j, |
ScatteredRow * | y ) const |
Left solves the system y.B = e_j, where e_j has only 1 non-zero coefficient of value 1.0 at position 'j'.
If the leaving index is the same, we can reuse the column! Note also that since we do a left solve for a unit row using an upper triangular matrix, all positions in front of the unit will be zero (modulo the column permutation).
We only keep the intermediate result needed for the optimized tau_ computation if it was computed after the last time this was called.
Definition at line 406 of file basis_representation.cc.
|
inline |
Returns the number of updates since last refactorization.
Definition at line 311 of file basis_representation.h.
|
delete |
Status operations_research::glop::BasisFactorization::Refactorize | ( | ) |
Clears eta factorization and refactorizes LU. Nothing happens if this is called on an already refactorized basis. Returns an error if the matrix could not be factorized: i.e. not a basis.
Definition at line 234 of file basis_representation.cc.
|
inline |
Definition at line 304 of file basis_representation.h.
void operations_research::glop::BasisFactorization::RightSolve | ( | ScatteredColumn * | d | ) | const |
Right solves the system B.d = a where the input is the initial value of d.
Definition at line 364 of file basis_representation.cc.
void operations_research::glop::BasisFactorization::RightSolveForProblemColumn | ( | ColIndex | col, |
ScatteredColumn * | d ) const |
Same as RightSolve() for matrix.column(col). This also exploits its sparsity.
The sort is needed if we want to have the same behavior for the sparse or hyper-sparse version.
Definition at line 474 of file basis_representation.cc.
const DenseColumn & operations_research::glop::BasisFactorization::RightSolveForTau | ( | const ScatteredColumn & | a | ) | const |
Specialized version for ComputeTau() in DualEdgeNorms. This reuses an intermediate result of the last LeftSolveForUnitRow() in order to save a permutation if it is available. Note that the input 'a' should always be equal to the last result of LeftSolveForUnitRow() and will be used for a DCHECK() or if the intermediate result wasn't kept.
Once used, the intermediate result is overwritten, so RightSolveForTau() can no longer use the optimized algorithm.
Definition at line 380 of file basis_representation.cc.
Fractional operations_research::glop::BasisFactorization::RightSolveSquaredNorm | ( | const ColumnView & | a | ) | const |
Returns the norm of B^{-1}.a, this is a specific function because it is a bit faster and it avoids polluting the stats of RightSolve(). It can be called only when IsRefactorized() is true.
Definition at line 509 of file basis_representation.cc.
|
inline |
Sets the column permutation used by the LU factorization to the identity. Hense the Solve() results will be computed without this permutation. This call only makes sense if the basis was just refactorized.
Definition at line 190 of file basis_representation.h.
|
inline |
Sets the parameters for this component.
Definition at line 172 of file basis_representation.h.
|
inline |
Stats related function.
Definition at line 301 of file basis_representation.h.
void operations_research::glop::BasisFactorization::TemporaryLeftSolveForUnitRow | ( | ColIndex | j, |
ScatteredRow * | y ) const |
Same as LeftSolveForUnitRow() but does not update any internal data.
Definition at line 461 of file basis_representation.cc.
Status operations_research::glop::BasisFactorization::Update | ( | ColIndex | entering_col, |
RowIndex | leaving_variable_row, | ||
const ScatteredColumn & | direction ) |
Updates the factorization. The 'eta' column will be modified with a swap to avoid a copy (only if the standard eta update is used). Returns an error if the matrix could not be factorized: i.e. not a basis.
We try to equilibrate the factorization time with the EXTRA solve time incurred since the last factorization.
Note(user): The deterministic time is not really super precise for now. We tend to undercount the factorization, but this tends to favorize more refactorization which is good for numerical stability.
Note(user): in some rare case (to investigate!) MiddleProductFormUpdate() will trigger a full refactorization. Because of this, it is important to increment num_updates_ first as this counter is used by IsRefactorized().
Definition at line 310 of file basis_representation.cc.