73#ifndef OR_TOOLS_GLOP_MARKOWITZ_H_
74#define OR_TOOLS_GLOP_MARKOWITZ_H_
81#include "absl/container/inlined_vector.h"
84#include "ortools/glop/parameters.pb.h"
114 void Reset(RowIndex num_rows, ColIndex num_cols);
122 std::vector<ColIndex>* singleton_columns,
123 std::vector<RowIndex>* singleton_rows);
157 void Update(RowIndex pivot_row, ColIndex pivot_col,
163 DCHECK(!deleted_columns_[
col]);
164 return col_degree_[
col];
175 return row_non_zero_[
row];
181 void MergeInto(RowIndex pivot_row, RowIndex
row);
188 void MergeIntoSorted(RowIndex pivot_row, RowIndex
row);
203 std::vector<ColIndex> col_scratchpad_;
204 ColIndex num_non_deleted_columns_;
223 void Reset(int32_t max_degree, ColIndex num_cols);
237 std::vector<std::vector<ColIndex>> col_by_degree_;
256 void Reset(ColIndex num_cols);
279 std::vector<int> free_columns_;
280 std::vector<SparseColumn> columns_;
301 ABSL_MUST_USE_RESULT
Status
339 basis_singleton_column_ratio(
"basis_singleton_column_ratio", this),
340 basis_residual_singleton_column_ratio(
341 "basis_residual_singleton_column_ratio", this),
342 pivots_without_fill_in_ratio(
"pivots_without_fill_in_ratio", this),
343 degree_two_pivot_columns(
"degree_two_pivot_columns", this) {}
357 void ExtractSingletonColumns(
const CompactSparseMatrixView& basis_matrix,
368 void ExtractResidualSingletonColumns(
369 const CompactSparseMatrixView& basis_matrix,
RowPermutation* row_perm,
374 bool IsResidualSingletonColumn(
const ColumnView&
column,
399 ColIndex* pivot_col,
Fractional* pivot_coefficient);
403 void UpdateDegree(ColIndex
col,
int degree);
407 void RemoveRowFromResidualMatrix(RowIndex pivot_row, ColIndex pivot_col);
408 void RemoveColumnFromResidualMatrix(RowIndex pivot_row, ColIndex pivot_col);
414 void UpdateResidualMatrix(RowIndex pivot_row, ColIndex pivot_col);
417 CompactSparseMatrixView
const* basis_matrix_;
422 SparseMatrixWithReusableColumnMemory permuted_lower_;
423 SparseMatrixWithReusableColumnMemory permuted_upper_;
428 TriangularMatrix lower_;
429 TriangularMatrix upper_;
438 MatrixNonZeroPattern residual_matrix_non_zero_;
441 ColumnPriorityQueue col_by_degree_;
444 bool contains_only_singleton_columns_;
447 bool is_col_by_degree_initialized_;
451 std::vector<ColIndex> examined_col_;
456 std::vector<ColIndex> singleton_column_;
459 std::vector<RowIndex> singleton_row_;
462 GlopParameters parameters_;
465 int64_t num_fp_operations_;
Statistic on the distribution of a sequence of ratios, displayed as %.
Base class to print a nice summary of a group of statistics.
std::string StatString() const
void Clear()
Releases the memory used by this class.
ColumnPriorityQueue(const ColumnPriorityQueue &)=delete
This type is neither copyable nor movable.
void PushOrAdjust(ColIndex col, int32_t degree)
ColumnPriorityQueue()=default
ColumnPriorityQueue & operator=(const ColumnPriorityQueue &)=delete
void Reset(int32_t max_degree, ColIndex num_cols)
Markowitz & operator=(const Markowitz &)=delete
void Clear()
Releases the memory used by this class.
std::string StatString() const
Returns a string containing the statistics for this class.
ABSL_MUST_USE_RESULT Status ComputeRowAndColumnPermutation(const CompactSparseMatrixView &basis_matrix, RowPermutation *row_perm, ColumnPermutation *col_perm)
double DeterministicTimeOfLastFactorization() const
Returns an estimate of the time spent in the last factorization.
ABSL_MUST_USE_RESULT Status ComputeLU(const CompactSparseMatrixView &basis_matrix, RowPermutation *row_perm, ColumnPermutation *col_perm, TriangularMatrix *lower, TriangularMatrix *upper)
Markowitz(const Markowitz &)=delete
This type is neither copyable nor movable.
void SetParameters(const GlopParameters ¶meters)
Sets the current parameters.
int32_t DecreaseColDegree(ColIndex col)
void AddEntry(RowIndex row, ColIndex col)
Adds a non-zero entry to the matrix. There should be no duplicates.
bool IsColumnDeleted(ColIndex col) const
Returns true if the column has been deleted by DeleteRowAndColumn().
MatrixNonZeroPattern()=default
int32_t ColDegree(ColIndex col) const
MatrixNonZeroPattern(const MatrixNonZeroPattern &)=delete
This type is neither copyable nor movable.
ColIndex GetFirstNonDeletedColumnFromRow(RowIndex row) const
const absl::InlinedVector< ColIndex, 6 > & RowNonZero(RowIndex row) const
int32_t DecreaseRowDegree(RowIndex row)
MatrixNonZeroPattern & operator=(const MatrixNonZeroPattern &)=delete
void Reset(RowIndex num_rows, ColIndex num_cols)
Resets the pattern to the one of an empty square matrix of the given size.
void DeleteRowAndColumn(RowIndex pivot_row, ColIndex pivot_col)
void RemoveDeletedColumnsFromRow(RowIndex row)
void Update(RowIndex pivot_row, ColIndex pivot_col, const SparseColumn &column)
int32_t RowDegree(RowIndex row) const
void InitializeFromMatrixSubset(const CompactSparseMatrixView &basis_matrix, const RowPermutation &row_perm, const ColumnPermutation &col_perm, std::vector< ColIndex > *singleton_columns, std::vector< RowIndex > *singleton_rows)
void Clear()
Releases the memory used by this class.
SparseMatrixWithReusableColumnMemory(const SparseMatrixWithReusableColumnMemory &)=delete
This type is neither copyable nor movable.
void ClearAndReleaseColumn(ColIndex col)
SparseMatrixWithReusableColumnMemory()=default
SparseColumn * mutable_column(ColIndex col)
void Reset(ColIndex num_cols)
Resets the repository to num_cols empty columns.
SparseMatrixWithReusableColumnMemory & operator=(const SparseMatrixWithReusableColumnMemory &)=delete
Permutation< ColIndex > ColumnPermutation
Permutation< RowIndex > RowPermutation
StrictITIVector< ColIndex, bool > DenseBooleanRow
Row of booleans.
In SWIG mode, we don't want anything besides these top-level includes.
util_intops::StrongVector< ColumnEntryIndex, ElementIndex, ElementAllocator > SparseColumn