OR-Tools  9.0
basis_representation.cc
Go to the documentation of this file.
1 // Copyright 2010-2021 Google LLC
2 // Licensed under the Apache License, Version 2.0 (the "License");
3 // you may not use this file except in compliance with the License.
4 // You may obtain a copy of the License at
5 //
6 // http://www.apache.org/licenses/LICENSE-2.0
7 //
8 // Unless required by applicable law or agreed to in writing, software
9 // distributed under the License is distributed on an "AS IS" BASIS,
10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 // See the License for the specific language governing permissions and
12 // limitations under the License.
13 
15 
16 #include "ortools/base/stl_util.h"
17 #include "ortools/glop/status.h"
19 
20 namespace operations_research {
21 namespace glop {
22 
23 // --------------------------------------------------------
24 // EtaMatrix
25 // --------------------------------------------------------
26 
27 const Fractional EtaMatrix::kSparseThreshold = 0.5;
28 
29 EtaMatrix::EtaMatrix(ColIndex eta_col, const ScatteredColumn& direction)
30  : eta_col_(eta_col),
31  eta_col_coefficient_(direction[ColToRowIndex(eta_col)]),
32  eta_coeff_(),
33  sparse_eta_coeff_() {
34  DCHECK_NE(0.0, eta_col_coefficient_);
35  eta_coeff_ = direction.values;
36  eta_coeff_[ColToRowIndex(eta_col_)] = 0.0;
37 
38  // Only fill sparse_eta_coeff_ if it is sparse enough.
39  if (direction.non_zeros.size() <
40  kSparseThreshold * eta_coeff_.size().value()) {
41  for (const RowIndex row : direction.non_zeros) {
42  if (row == ColToRowIndex(eta_col)) continue;
43  sparse_eta_coeff_.SetCoefficient(row, eta_coeff_[row]);
44  }
45  DCHECK(sparse_eta_coeff_.CheckNoDuplicates());
46  }
47 }
48 
50 
52  RETURN_IF_NULL(y);
53  DCHECK_EQ(RowToColIndex(eta_coeff_.size()), y->size());
54  if (!sparse_eta_coeff_.IsEmpty()) {
55  LeftSolveWithSparseEta(y);
56  } else {
57  LeftSolveWithDenseEta(y);
58  }
59 }
60 
62  RETURN_IF_NULL(d);
63  DCHECK_EQ(eta_coeff_.size(), d->size());
64 
65  // Nothing to do if 'a' is zero at position eta_row.
66  // This exploits the possible sparsity of the column 'a'.
67  if ((*d)[ColToRowIndex(eta_col_)] == 0.0) return;
68  if (!sparse_eta_coeff_.IsEmpty()) {
69  RightSolveWithSparseEta(d);
70  } else {
71  RightSolveWithDenseEta(d);
72  }
73 }
74 
76  RETURN_IF_NULL(y);
77  DCHECK_EQ(RowToColIndex(eta_coeff_.size()), y->size());
78 
79  Fractional y_value = (*y)[eta_col_];
80  bool is_eta_col_in_pos = false;
81  const int size = pos->size();
82  for (int i = 0; i < size; ++i) {
83  const ColIndex col = (*pos)[i];
84  const RowIndex row = ColToRowIndex(col);
85  if (col == eta_col_) {
86  is_eta_col_in_pos = true;
87  continue;
88  }
89  y_value -= (*y)[col] * eta_coeff_[row];
90  }
91 
92  (*y)[eta_col_] = y_value / eta_col_coefficient_;
93 
94  // We add the new non-zero position if it wasn't already there.
95  if (!is_eta_col_in_pos) pos->push_back(eta_col_);
96 }
97 
98 void EtaMatrix::LeftSolveWithDenseEta(DenseRow* y) const {
99  Fractional y_value = (*y)[eta_col_];
100  const RowIndex num_rows(eta_coeff_.size());
101  for (RowIndex row(0); row < num_rows; ++row) {
102  y_value -= (*y)[RowToColIndex(row)] * eta_coeff_[row];
103  }
104  (*y)[eta_col_] = y_value / eta_col_coefficient_;
105 }
106 
107 void EtaMatrix::LeftSolveWithSparseEta(DenseRow* y) const {
108  Fractional y_value = (*y)[eta_col_];
109  for (const SparseColumn::Entry e : sparse_eta_coeff_) {
110  y_value -= (*y)[RowToColIndex(e.row())] * e.coefficient();
111  }
112  (*y)[eta_col_] = y_value / eta_col_coefficient_;
113 }
114 
115 void EtaMatrix::RightSolveWithDenseEta(DenseColumn* d) const {
116  const RowIndex eta_row = ColToRowIndex(eta_col_);
117  const Fractional coeff = (*d)[eta_row] / eta_col_coefficient_;
118  const RowIndex num_rows(eta_coeff_.size());
119  for (RowIndex row(0); row < num_rows; ++row) {
120  (*d)[row] -= eta_coeff_[row] * coeff;
121  }
122  (*d)[eta_row] = coeff;
123 }
124 
125 void EtaMatrix::RightSolveWithSparseEta(DenseColumn* d) const {
126  const RowIndex eta_row = ColToRowIndex(eta_col_);
127  const Fractional coeff = (*d)[eta_row] / eta_col_coefficient_;
128  for (const SparseColumn::Entry e : sparse_eta_coeff_) {
129  (*d)[e.row()] -= e.coefficient() * coeff;
130  }
131  (*d)[eta_row] = coeff;
132 }
133 
134 // --------------------------------------------------------
135 // EtaFactorization
136 // --------------------------------------------------------
138 
140 
142 
143 void EtaFactorization::Update(ColIndex entering_col,
144  RowIndex leaving_variable_row,
145  const ScatteredColumn& direction) {
146  const ColIndex leaving_variable_col = RowToColIndex(leaving_variable_row);
147  EtaMatrix* const eta_factorization =
148  new EtaMatrix(leaving_variable_col, direction);
149  eta_matrix_.push_back(eta_factorization);
150 }
151 
153  RETURN_IF_NULL(y);
154  for (int i = eta_matrix_.size() - 1; i >= 0; --i) {
155  eta_matrix_[i]->LeftSolve(y);
156  }
157 }
158 
160  RETURN_IF_NULL(y);
161  for (int i = eta_matrix_.size() - 1; i >= 0; --i) {
162  eta_matrix_[i]->SparseLeftSolve(y, pos);
163  }
164 }
165 
167  RETURN_IF_NULL(d);
168  const size_t num_eta_matrices = eta_matrix_.size();
169  for (int i = 0; i < num_eta_matrices; ++i) {
170  eta_matrix_[i]->RightSolve(d);
171  }
172 }
173 
174 // --------------------------------------------------------
175 // BasisFactorization
176 // --------------------------------------------------------
178  const CompactSparseMatrix* compact_matrix, const RowToColMapping* basis)
179  : stats_(),
180  compact_matrix_(*compact_matrix),
181  basis_(*basis),
182  tau_is_computed_(false),
183  max_num_updates_(0),
184  num_updates_(0),
185  eta_factorization_(),
186  lu_factorization_(),
187  deterministic_time_(0.0) {
188  SetParameters(parameters_);
189 }
190 
192 
194  SCOPED_TIME_STAT(&stats_);
195  num_updates_ = 0;
196  tau_computation_can_be_optimized_ = false;
197  eta_factorization_.Clear();
198  lu_factorization_.Clear();
199  rank_one_factorization_.Clear();
200  storage_.Reset(compact_matrix_.num_rows());
201  right_storage_.Reset(compact_matrix_.num_rows());
202  left_pool_mapping_.assign(compact_matrix_.num_cols(), kInvalidCol);
203  right_pool_mapping_.assign(compact_matrix_.num_cols(), kInvalidCol);
204 }
205 
207  SCOPED_TIME_STAT(&stats_);
208  Clear();
209  if (IsIdentityBasis()) return Status::OK();
210  return ComputeFactorization();
211 }
212 
213 bool BasisFactorization::IsRefactorized() const { return num_updates_ == 0; }
214 
216  if (IsRefactorized()) return Status::OK();
217  return ForceRefactorization();
218 }
219 
221  SCOPED_TIME_STAT(&stats_);
222  stats_.refactorization_interval.Add(num_updates_);
223  Clear();
224  return ComputeFactorization();
225 }
226 
227 Status BasisFactorization::ComputeFactorization() {
228  CompactSparseMatrixView basis_matrix(&compact_matrix_, &basis_);
229  const Status status = lu_factorization_.ComputeFactorization(basis_matrix);
230  last_factorization_deterministic_time_ =
231  lu_factorization_.DeterministicTimeOfLastFactorization();
232  deterministic_time_ += last_factorization_deterministic_time_;
233  rank_one_factorization_.ResetDeterministicTime();
234  return status;
235 }
236 
237 // This update formula can be derived by:
238 // e = unit vector on the leaving_variable_row
239 // new B = L.U + (matrix.column(entering_col) - B.e).e^T
240 // new B = L.U + L.L^{-1}.(matrix.column(entering_col) - B.e).e^T.U^{-1}.U
241 // new B = L.(Identity +
242 // (right_update_vector - U.column(leaving_column)).left_update_vector).U
243 // new B = L.RankOneUpdateElementatyMatrix(
244 // right_update_vector - U.column(leaving_column), left_update_vector)
245 Status BasisFactorization::MiddleProductFormUpdate(
246  ColIndex entering_col, RowIndex leaving_variable_row) {
247  const ColIndex right_index = right_pool_mapping_[entering_col];
248  const ColIndex left_index =
249  left_pool_mapping_[RowToColIndex(leaving_variable_row)];
250  if (right_index == kInvalidCol || left_index == kInvalidCol) {
251  LOG(INFO) << "One update vector is missing!!!";
252  return ForceRefactorization();
253  }
254 
255  // TODO(user): create a class for these operations.
256  // Initialize scratchpad_ with the right update vector.
257  DCHECK(IsAllZero(scratchpad_));
258  scratchpad_.resize(right_storage_.num_rows(), 0.0);
259  for (const EntryIndex i : right_storage_.Column(right_index)) {
260  const RowIndex row = right_storage_.EntryRow(i);
261  scratchpad_[row] = right_storage_.EntryCoefficient(i);
262  scratchpad_non_zeros_.push_back(row);
263  }
264  // Subtract the column of U from scratchpad_.
265  const SparseColumn& column_of_u =
266  lu_factorization_.GetColumnOfU(RowToColIndex(leaving_variable_row));
267  for (const SparseColumn::Entry e : column_of_u) {
268  scratchpad_[e.row()] -= e.coefficient();
269  scratchpad_non_zeros_.push_back(e.row());
270  }
271 
272  // Creates the new rank one update matrix and update the factorization.
273  const Fractional scalar_product =
274  storage_.ColumnScalarProduct(left_index, Transpose(scratchpad_));
275  const ColIndex u_index = storage_.AddAndClearColumnWithNonZeros(
276  &scratchpad_, &scratchpad_non_zeros_);
277  RankOneUpdateElementaryMatrix elementary_update_matrix(
278  &storage_, u_index, left_index, scalar_product);
279  if (elementary_update_matrix.IsSingular()) {
280  GLOP_RETURN_AND_LOG_ERROR(Status::ERROR_LU, "Degenerate rank-one update.");
281  }
282  rank_one_factorization_.Update(elementary_update_matrix);
283  return Status::OK();
284 }
285 
286 Status BasisFactorization::Update(ColIndex entering_col,
287  RowIndex leaving_variable_row,
288  const ScatteredColumn& direction) {
289  // Note that in addition to the logic here, we also refactorize when we detect
290  // numerical imprecisions. There is various tests for that during an
291  // iteration.
292  if (num_updates_ >= max_num_updates_) {
293  if (!parameters_.dynamically_adjust_refactorization_period()) {
294  return ForceRefactorization();
295  }
296 
297  // We try to equilibrate the factorization time with the EXTRA solve time
298  // incurred since the last factorization.
299  //
300  // Note(user): The deterministic time is not really super precise for now.
301  // We tend to undercount the factorization, but this tends to favorize more
302  // refactorization which is good for numerical stability.
303  if (last_factorization_deterministic_time_ <
304  rank_one_factorization_.DeterministicTimeSinceLastReset()) {
305  return ForceRefactorization();
306  }
307  }
308 
309  // Note(user): in some rare case (to investigate!) MiddleProductFormUpdate()
310  // will trigger a full refactorization. Because of this, it is important to
311  // increment num_updates_ first as this counter is used by IsRefactorized().
312  SCOPED_TIME_STAT(&stats_);
313  ++num_updates_;
314  if (use_middle_product_form_update_) {
316  MiddleProductFormUpdate(entering_col, leaving_variable_row));
317  } else {
318  eta_factorization_.Update(entering_col, leaving_variable_row, direction);
319  }
320  tau_computation_can_be_optimized_ = false;
321  return Status::OK();
322 }
323 
325  SCOPED_TIME_STAT(&stats_);
326  RETURN_IF_NULL(y);
327  if (use_middle_product_form_update_) {
328  lu_factorization_.LeftSolveUWithNonZeros(y);
329  rank_one_factorization_.LeftSolveWithNonZeros(y);
330  lu_factorization_.LeftSolveLWithNonZeros(y);
332  } else {
333  y->non_zeros.clear();
334  eta_factorization_.LeftSolve(&y->values);
335  lu_factorization_.LeftSolve(&y->values);
336  }
337  BumpDeterministicTimeForSolve(y->NumNonZerosEstimate());
338 }
339 
341  SCOPED_TIME_STAT(&stats_);
342  RETURN_IF_NULL(d);
343  if (use_middle_product_form_update_) {
344  lu_factorization_.RightSolveLWithNonZeros(d);
345  rank_one_factorization_.RightSolveWithNonZeros(d);
346  lu_factorization_.RightSolveUWithNonZeros(d);
348  } else {
349  d->non_zeros.clear();
350  lu_factorization_.RightSolve(&d->values);
351  eta_factorization_.RightSolve(&d->values);
352  }
353  BumpDeterministicTimeForSolve(d->NumNonZerosEstimate());
354 }
355 
357  const ScatteredColumn& a) const {
358  SCOPED_TIME_STAT(&stats_);
359  if (use_middle_product_form_update_) {
360  if (tau_computation_can_be_optimized_) {
361  // Once used, the intermediate result is overwritten, so
362  // RightSolveForTau() can no longer use the optimized algorithm.
363  tau_computation_can_be_optimized_ = false;
364  lu_factorization_.RightSolveLWithPermutedInput(a.values, &tau_);
365  } else {
366  ClearAndResizeVectorWithNonZeros(compact_matrix_.num_rows(), &tau_);
367  lu_factorization_.RightSolveLForScatteredColumn(a, &tau_);
368  }
369  rank_one_factorization_.RightSolveWithNonZeros(&tau_);
370  lu_factorization_.RightSolveUWithNonZeros(&tau_);
371  } else {
372  tau_.non_zeros.clear();
373  tau_.values = a.values;
374  lu_factorization_.RightSolve(&tau_.values);
375  eta_factorization_.RightSolve(&tau_.values);
376  }
377  tau_is_computed_ = true;
378  BumpDeterministicTimeForSolve(tau_.NumNonZerosEstimate());
379  return tau_.values;
380 }
381 
383  ScatteredRow* y) const {
384  SCOPED_TIME_STAT(&stats_);
385  RETURN_IF_NULL(y);
387  y);
388  if (!use_middle_product_form_update_) {
389  (*y)[j] = 1.0;
390  y->non_zeros.push_back(j);
391  eta_factorization_.SparseLeftSolve(&y->values, &y->non_zeros);
392  lu_factorization_.LeftSolve(&y->values);
393  BumpDeterministicTimeForSolve(y->NumNonZerosEstimate());
394  return;
395  }
396 
397  // If the leaving index is the same, we can reuse the column! Note also that
398  // since we do a left solve for a unit row using an upper triangular matrix,
399  // all positions in front of the unit will be zero (modulo the column
400  // permutation).
401  if (left_pool_mapping_[j] == kInvalidCol) {
402  const ColIndex start = lu_factorization_.LeftSolveUForUnitRow(j, y);
403  if (y->non_zeros.empty()) {
404  left_pool_mapping_[j] = storage_.AddDenseColumnPrefix(
405  Transpose(y->values), ColToRowIndex(start));
406  } else {
407  left_pool_mapping_[j] = storage_.AddDenseColumnWithNonZeros(
408  Transpose(y->values),
409  *reinterpret_cast<RowIndexVector*>(&y->non_zeros));
410  }
411  } else {
412  DenseColumn* const x = reinterpret_cast<DenseColumn*>(y);
413  RowIndexVector* const nz = reinterpret_cast<RowIndexVector*>(&y->non_zeros);
414  storage_.ColumnCopyToClearedDenseColumnWithNonZeros(left_pool_mapping_[j],
415  x, nz);
416  }
417 
418  rank_one_factorization_.LeftSolveWithNonZeros(y);
419 
420  // We only keep the intermediate result needed for the optimized tau_
421  // computation if it was computed after the last time this was called.
422  if (tau_is_computed_) {
423  tau_computation_can_be_optimized_ =
424  lu_factorization_.LeftSolveLWithNonZeros(y, &tau_);
425  } else {
426  tau_computation_can_be_optimized_ = false;
427  lu_factorization_.LeftSolveLWithNonZeros(y);
428  }
429  tau_is_computed_ = false;
431  BumpDeterministicTimeForSolve(y->NumNonZerosEstimate());
432 }
433 
435  ScatteredRow* y) const {
437  SCOPED_TIME_STAT(&stats_);
438  RETURN_IF_NULL(y);
440  y);
441  lu_factorization_.LeftSolveUForUnitRow(j, y);
442  lu_factorization_.LeftSolveLWithNonZeros(y);
444  BumpDeterministicTimeForSolve(y->NumNonZerosEstimate());
445 }
446 
448  ScatteredColumn* d) const {
449  SCOPED_TIME_STAT(&stats_);
450  RETURN_IF_NULL(d);
451  ClearAndResizeVectorWithNonZeros(compact_matrix_.num_rows(), d);
452 
453  if (!use_middle_product_form_update_) {
454  compact_matrix_.ColumnCopyToClearedDenseColumn(col, &d->values);
455  lu_factorization_.RightSolve(&d->values);
456  eta_factorization_.RightSolve(&d->values);
457  BumpDeterministicTimeForSolve(d->NumNonZerosEstimate());
458  return;
459  }
460 
461  // TODO(user): if right_pool_mapping_[col] != kInvalidCol, we can reuse it and
462  // just apply the last rank one update since it was computed.
463  lu_factorization_.RightSolveLForColumnView(compact_matrix_.column(col), d);
464  rank_one_factorization_.RightSolveWithNonZeros(d);
465  if (col >= right_pool_mapping_.size()) {
466  // This is needed because when we do an incremental solve with only new
467  // columns, we still reuse the current factorization without calling
468  // Refactorize() which would have resized this vector.
469  right_pool_mapping_.resize(col + 1, kInvalidCol);
470  }
471  if (d->non_zeros.empty()) {
472  right_pool_mapping_[col] = right_storage_.AddDenseColumn(d->values);
473  } else {
474  // The sort is needed if we want to have the same behavior for the sparse or
475  // hyper-sparse version.
476  std::sort(d->non_zeros.begin(), d->non_zeros.end());
477  right_pool_mapping_[col] =
478  right_storage_.AddDenseColumnWithNonZeros(d->values, d->non_zeros);
479  }
480  lu_factorization_.RightSolveUWithNonZeros(d);
482  BumpDeterministicTimeForSolve(d->NumNonZerosEstimate());
483 }
484 
486  const ColumnView& a) const {
487  SCOPED_TIME_STAT(&stats_);
489  BumpDeterministicTimeForSolve(a.num_entries().value());
490  return lu_factorization_.RightSolveSquaredNorm(a);
491 }
492 
494  SCOPED_TIME_STAT(&stats_);
496  BumpDeterministicTimeForSolve(1);
497  return lu_factorization_.DualEdgeSquaredNorm(row);
498 }
499 
500 bool BasisFactorization::IsIdentityBasis() const {
501  const RowIndex num_rows = compact_matrix_.num_rows();
502  for (RowIndex row(0); row < num_rows; ++row) {
503  const ColIndex col = basis_[row];
504  if (compact_matrix_.column(col).num_entries().value() != 1) return false;
505  const Fractional coeff = compact_matrix_.column(col).GetFirstCoefficient();
506  const RowIndex entry_row = compact_matrix_.column(col).GetFirstRow();
507  if (entry_row != row || coeff != 1.0) return false;
508  }
509  return true;
510 }
511 
513  if (IsIdentityBasis()) return 1.0;
514  CompactSparseMatrixView basis_matrix(&compact_matrix_, &basis_);
515  return basis_matrix.ComputeOneNorm();
516 }
517 
519  if (IsIdentityBasis()) return 1.0;
520  CompactSparseMatrixView basis_matrix(&compact_matrix_, &basis_);
521  return basis_matrix.ComputeInfinityNorm();
522 }
523 
524 // TODO(user): try to merge the computation of the norm of inverses
525 // with that of MatrixView. Maybe use a wrapper class for InverseMatrix.
526 
528  if (IsIdentityBasis()) return 1.0;
529  const RowIndex num_rows = compact_matrix_.num_rows();
530  const ColIndex num_cols = RowToColIndex(num_rows);
531  Fractional norm = 0.0;
532  for (ColIndex col(0); col < num_cols; ++col) {
533  ScatteredColumn right_hand_side;
534  right_hand_side.values.AssignToZero(num_rows);
535  right_hand_side[ColToRowIndex(col)] = 1.0;
536  // Get a column of the matrix inverse.
537  RightSolve(&right_hand_side);
538  Fractional column_norm = 0.0;
539  // Compute sum_i |inverse_ij|.
540  for (RowIndex row(0); row < num_rows; ++row) {
541  column_norm += std::abs(right_hand_side[row]);
542  }
543  // Compute max_j sum_i |inverse_ij|
544  norm = std::max(norm, column_norm);
545  }
546  return norm;
547 }
548 
550  if (IsIdentityBasis()) return 1.0;
551  const RowIndex num_rows = compact_matrix_.num_rows();
552  const ColIndex num_cols = RowToColIndex(num_rows);
553  DenseColumn row_sum(num_rows, 0.0);
554  for (ColIndex col(0); col < num_cols; ++col) {
555  ScatteredColumn right_hand_side;
556  right_hand_side.values.AssignToZero(num_rows);
557  right_hand_side[ColToRowIndex(col)] = 1.0;
558  // Get a column of the matrix inverse.
559  RightSolve(&right_hand_side);
560  // Compute sum_j |inverse_ij|.
561  for (RowIndex row(0); row < num_rows; ++row) {
562  row_sum[row] += std::abs(right_hand_side[row]);
563  }
564  }
565  // Compute max_i sum_j |inverse_ij|
566  Fractional norm = 0.0;
567  for (RowIndex row(0); row < num_rows; ++row) {
568  norm = std::max(norm, row_sum[row]);
569  }
570  return norm;
571 }
572 
574  if (IsIdentityBasis()) return 1.0;
576 }
577 
579  if (IsIdentityBasis()) return 1.0;
581 }
582 
584  const {
585  if (IsIdentityBasis()) return 1.0;
586  BumpDeterministicTimeForSolve(compact_matrix_.num_rows().value());
587  return ComputeInfinityNorm() *
588  lu_factorization_.ComputeInverseInfinityNormUpperBound();
589 }
590 
592  return deterministic_time_;
593 }
594 
595 void BasisFactorization::BumpDeterministicTimeForSolve(int num_entries) const {
596  // TODO(user): Spend more time finding a good approximation here.
597  if (compact_matrix_.num_rows().value() == 0) return;
598  const double density =
599  static_cast<double>(num_entries) /
600  static_cast<double>(compact_matrix_.num_rows().value());
601  deterministic_time_ +=
603  lu_factorization_.NumberOfEntries().value()) +
605  rank_one_factorization_.num_entries().value());
606 }
607 
608 } // namespace glop
609 } // namespace operations_research
int64_t max
Definition: alldiff_cst.cc:140
#define CHECK(condition)
Definition: base/logging.h:498
#define DCHECK_NE(val1, val2)
Definition: base/logging.h:894
#define LOG(severity)
Definition: base/logging.h:423
#define DCHECK(condition)
Definition: base/logging.h:892
#define DCHECK_EQ(val1, val2)
Definition: base/logging.h:893
BasisFactorization(const CompactSparseMatrix *compact_matrix, const RowToColMapping *basis)
const DenseColumn & RightSolveForTau(const ScatteredColumn &a) const
void LeftSolveForUnitRow(ColIndex j, ScatteredRow *y) const
Fractional RightSolveSquaredNorm(const ColumnView &a) const
void TemporaryLeftSolveForUnitRow(ColIndex j, ScatteredRow *y) const
ABSL_MUST_USE_RESULT Status Update(ColIndex entering_col, RowIndex leaving_variable_row, const ScatteredColumn &direction)
Fractional DualEdgeSquaredNorm(RowIndex row) const
void RightSolveForProblemColumn(ColIndex col, ScatteredColumn *d) const
void SetParameters(const GlopParameters &parameters)
ColIndex AddDenseColumn(const DenseColumn &dense_column)
Definition: sparse.cc:536
ColIndex AddDenseColumnWithNonZeros(const DenseColumn &dense_column, const std::vector< RowIndex > &non_zeros)
Definition: sparse.cc:554
::util::IntegerRange< EntryIndex > Column(ColIndex col) const
Definition: sparse.h:358
ColIndex AddAndClearColumnWithNonZeros(DenseColumn *column, std::vector< RowIndex > *non_zeros)
Definition: sparse.cc:569
void ColumnCopyToClearedDenseColumnWithNonZeros(ColIndex col, DenseColumn *dense_column, RowIndexVector *non_zeros) const
Definition: sparse.h:436
ColIndex AddDenseColumnPrefix(const DenseColumn &dense_column, RowIndex start)
Definition: sparse.cc:540
Fractional EntryCoefficient(EntryIndex i) const
Definition: sparse.h:361
void ColumnCopyToClearedDenseColumn(ColIndex col, DenseColumn *dense_column) const
Definition: sparse.h:426
Fractional ColumnScalarProduct(ColIndex col, const DenseRow &vector) const
Definition: sparse.h:382
RowIndex EntryRow(EntryIndex i) const
Definition: sparse.h:362
ColumnView column(ColIndex col) const
Definition: sparse.h:364
void SparseLeftSolve(DenseRow *y, ColIndexVector *pos) const
void Update(ColIndex entering_col, RowIndex leaving_variable_row, const ScatteredColumn &direction)
EtaMatrix(ColIndex eta_col, const ScatteredColumn &direction)
void SparseLeftSolve(DenseRow *y, ColIndexVector *pos) const
void LeftSolveUWithNonZeros(ScatteredRow *y) const
const SparseColumn & GetColumnOfU(ColIndex col) const
void RightSolveLForColumnView(const ColumnView &b, ScatteredColumn *x) const
void RightSolveLWithPermutedInput(const DenseColumn &a, ScatteredColumn *x) const
Fractional RightSolveSquaredNorm(const ColumnView &a) const
void RightSolveUWithNonZeros(ScatteredColumn *x) const
bool LeftSolveLWithNonZeros(ScatteredRow *y, ScatteredColumn *result_before_permutation) const
ColIndex LeftSolveUForUnitRow(ColIndex col, ScatteredRow *y) const
Fractional DualEdgeSquaredNorm(RowIndex row) const
void RightSolveLForScatteredColumn(const ScatteredColumn &b, ScatteredColumn *x) const
void RightSolveLWithNonZeros(ScatteredColumn *x) const
ABSL_MUST_USE_RESULT Status ComputeFactorization(const CompactSparseMatrixView &compact_matrix)
void Update(const RankOneUpdateElementaryMatrix &update_matrix)
void SetCoefficient(Index index, Fractional value)
static const Status OK()
Definition: status.h:54
void assign(IntType size, const T &v)
Definition: lp_types.h:275
int64_t a
const int INFO
Definition: log_severity.h:31
ColIndex col
Definition: markowitz.cc:183
RowIndex row
Definition: markowitz.cc:182
void STLDeleteElements(T *container)
Definition: stl_util.h:372
std::vector< ColIndex > ColIndexVector
Definition: lp_types.h:309
bool IsAllZero(const Container &input)
StrictITIVector< ColIndex, Fractional > DenseRow
Definition: lp_types.h:300
ColIndex RowToColIndex(RowIndex row)
Definition: lp_types.h:49
void ClearAndResizeVectorWithNonZeros(IndexType size, ScatteredRowOrCol *v)
const DenseRow & Transpose(const DenseColumn &col)
RowIndex ColToRowIndex(ColIndex col)
Definition: lp_types.h:52
std::vector< RowIndex > RowIndexVector
Definition: lp_types.h:310
StrictITIVector< RowIndex, Fractional > DenseColumn
Definition: lp_types.h:329
static double DeterministicTimeForFpOperations(int64_t n)
Definition: lp_types.h:380
const ColIndex kInvalidCol(-1)
Collection of objects used to extend the Constraint Solver library.
EntryIndex num_entries
#define RETURN_IF_NULL(x)
Definition: return_macros.h:20
#define SCOPED_TIME_STAT(stats)
Definition: stats.h:438
#define GLOP_RETURN_IF_ERROR(function_call)
Definition: status.h:70
#define GLOP_RETURN_AND_LOG_ERROR(error_code, message)
Definition: status.h:77
StrictITIVector< Index, Fractional > values