remove mem allocs
This commit is contained in:
@@ -40,7 +40,8 @@ const DenseColumn& DualEdgeNorms::GetEdgeSquaredNorms() {
|
||||
void DualEdgeNorms::UpdateDataOnBasisPermutation(
|
||||
const ColumnPermutation& col_perm) {
|
||||
if (recompute_edge_squared_norms_) return;
|
||||
ApplyColumnPermutationToRowIndexedVector(col_perm, &edge_squared_norms_);
|
||||
ApplyColumnPermutationToRowIndexedVector(col_perm, &edge_squared_norms_,
|
||||
&tmp_edge_squared_norms_);
|
||||
}
|
||||
|
||||
bool DualEdgeNorms::TestPrecision(RowIndex leaving_row,
|
||||
|
||||
@@ -132,6 +132,7 @@ class DualEdgeNorms {
|
||||
|
||||
// The dual edge norms.
|
||||
DenseColumn edge_squared_norms_;
|
||||
DenseColumn tmp_edge_squared_norms_;
|
||||
|
||||
// Whether we should recompute the norm from scratch.
|
||||
bool recompute_edge_squared_norms_;
|
||||
|
||||
@@ -2477,13 +2477,14 @@ void RevisedSimplex::PermuteBasis() {
|
||||
if (col_perm.empty()) return;
|
||||
|
||||
// Permute basis_.
|
||||
ApplyColumnPermutationToRowIndexedVector(col_perm, &basis_);
|
||||
ApplyColumnPermutationToRowIndexedVector(col_perm, &basis_, &tmp_basis_);
|
||||
|
||||
// Permute dual_pricing_vector_ if needed.
|
||||
if (!dual_pricing_vector_.empty()) {
|
||||
// TODO(user): We need to permute dual_prices_ too now, we recompute
|
||||
// everything one each basis factorization, so this don't matter.
|
||||
ApplyColumnPermutationToRowIndexedVector(col_perm, &dual_pricing_vector_);
|
||||
ApplyColumnPermutationToRowIndexedVector(col_perm, &dual_pricing_vector_,
|
||||
&tmp_dual_pricing_vector_);
|
||||
}
|
||||
|
||||
// Notify the other classes.
|
||||
|
||||
@@ -678,6 +678,7 @@ class RevisedSimplex {
|
||||
// Array of column index, giving the column number corresponding
|
||||
// to a given basis row.
|
||||
RowToColMapping basis_;
|
||||
RowToColMapping tmp_basis_;
|
||||
|
||||
// Vector of strings containing the names of variables.
|
||||
// Indexed by column number.
|
||||
@@ -742,6 +743,7 @@ class RevisedSimplex {
|
||||
|
||||
// Used in dual phase I to hold the price of each possible leaving choices.
|
||||
DenseColumn dual_pricing_vector_;
|
||||
DenseColumn tmp_dual_pricing_vector_;
|
||||
|
||||
// Temporary memory used by DualMinimize().
|
||||
std::vector<ColIndex> bound_flip_candidates_;
|
||||
|
||||
@@ -119,6 +119,14 @@ void ApplyColumnPermutationToRowIndexedVector(
|
||||
ApplyPermutation(col_perm, temp_v, v);
|
||||
}
|
||||
|
||||
template <typename RowIndexedVector>
|
||||
void ApplyColumnPermutationToRowIndexedVector(
|
||||
const Permutation<ColIndex>& col_perm, RowIndexedVector* v,
|
||||
RowIndexedVector* tmp) {
|
||||
ApplyPermutation(col_perm, *v, tmp);
|
||||
std::swap(*tmp, *v);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------
|
||||
// Implementation
|
||||
// --------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user