22 : basis_factorization_(basis_factorization),
23 recompute_edge_squared_norms_(true) {}
26 return recompute_edge_squared_norms_;
32 edge_squared_norms_.
resize(new_size, 1.0);
36 if (recompute_edge_squared_norms_) ComputeEdgeSquaredNorms();
37 return edge_squared_norms_;
42 if (recompute_edge_squared_norms_)
return;
44 &tmp_edge_squared_norms_);
50 if (recompute_edge_squared_norms_)
return true;
57 const Fractional old_squared_norm = edge_squared_norms_[leaving_row];
58 const Fractional estimated_edge_norms_accuracy =
59 (sqrt(leaving_squared_norm) - sqrt(old_squared_norm)) /
60 sqrt(leaving_squared_norm);
61 stats_.edge_norms_accuracy.Add(estimated_edge_norms_accuracy);
63 if (std::abs(estimated_edge_norms_accuracy) >
64 parameters_.recompute_edges_norm_threshold()) {
65 VLOG(1) <<
"Recomputing edge norms: " << sqrt(leaving_squared_norm)
66 <<
" vs " << sqrt(old_squared_norm);
67 recompute_edge_squared_norms_ =
true;
71 edge_squared_norms_[leaving_row] = leaving_squared_norm;
72 const bool result = old_squared_norm > 0.25 * leaving_squared_norm;
74 VLOG(1) <<
"Recomputing leaving row. Norm was " << sqrt(old_squared_norm)
75 <<
" vs precise version " << sqrt(leaving_squared_norm);
81 ColIndex entering_col, RowIndex leaving_row,
85 if (recompute_edge_squared_norms_)
return;
89 const Fractional pivot = direction[leaving_row];
91 edge_squared_norms_[leaving_row] /
Square(pivot);
94 int stat_lower_bounded_norms = 0;
95 auto output = edge_squared_norms_.
view();
96 for (
const auto e : direction) {
100 e.coefficient() * (e.coefficient() * new_leaving_squared_norm -
101 2.0 / pivot * tau[e.row()]);
108 if (output[e.row()] < kLowerBound) {
109 if (e.row() == leaving_row)
continue;
110 output[e.row()] = kLowerBound;
111 ++stat_lower_bounded_norms;
114 output[leaving_row] = new_leaving_squared_norm;
118 void DualEdgeNorms::ComputeEdgeSquaredNorms() {
125 edge_squared_norms_.
resize(num_rows, 0.0);
126 for (RowIndex
row(0);
row < num_rows; ++
row) {
129 recompute_edge_squared_norms_ =
false;
133 const ScatteredColumn& unit_row_left_inverse) {
const DenseColumn & RightSolveForTau(const ScatteredColumn &a) const
bool IsRefactorized() const
Fractional DualEdgeSquaredNorm(RowIndex row) const
RowIndex GetNumberOfRows() const
void UpdateBeforeBasisPivot(ColIndex entering_col, RowIndex leaving_row, const ScatteredColumn &direction, const ScatteredRow &unit_row_left_inverse)
void UpdateDataOnBasisPermutation(const ColumnPermutation &col_perm)
const DenseColumn & GetEdgeSquaredNorms()
bool TestPrecision(RowIndex leaving_row, const ScatteredRow &unit_row_left_inverse)
void ResizeOnNewRows(RowIndex new_size)
DualEdgeNorms(const BasisFactorization &basis_factorization)
bool NeedsBasisRefactorization() const
void resize(IntType size)
Fractional Square(Fractional f)
Fractional SquaredNorm(const SparseColumn &v)
double Density(const DenseRow &row)
const DenseRow & Transpose(const DenseColumn &col)
void ApplyColumnPermutationToRowIndexedVector(const Permutation< ColIndex > &col_perm, RowIndexedVector *v)
StrictITIVector< RowIndex, Fractional > DenseColumn
const ScatteredRow & TransposedView(const ScatteredColumn &c)
Collection of objects used to extend the Constraint Solver library.
#define IF_STATS_ENABLED(instructions)
#define SCOPED_TIME_STAT(stats)
#define VLOG(verboselevel)