32 variables_info_(variables_info),
33 basis_factorization_(basis_factorization),
34 dual_edge_norms_(dual_edge_norms),
35 dual_prices_(dual_prices),
36 stats_(
"VariableValues") {}
58 LOG(DFATAL) <<
"SetNonBasicVariableValueFromStatus() shouldn't "
59 <<
"be called on a FREE variable.";
62 LOG(DFATAL) <<
"SetNonBasicVariableValueFromStatus() shouldn't "
63 <<
"be called on a BASIC variable.";
71 const DenseRow& free_initial_value) {
75 const ColIndex num_cols = matrix_.
num_cols();
76 variable_values_.
resize(num_cols, 0.0);
77 for (ColIndex
col(0);
col < num_cols; ++
col) {
78 switch (statuses[
col]) {
80 ABSL_FALLTHROUGH_INTENDED;
88 variable_values_[
col] =
89 col < free_initial_value.
size() ? free_initial_value[
col] : 0.0;
100 const RowIndex num_rows = matrix_.
num_rows();
107 basis_factorization_.
RightSolve(&scratchpad_);
108 for (RowIndex
row(0);
row < num_rows; ++
row) {
109 variable_values_[basis_[
row]] = scratchpad_[
row];
113 dual_prices_->Clear();
120 const ColIndex num_cols = matrix_.
num_cols();
121 for (ColIndex
col(0);
col < num_cols; ++
col) {
131 const ColIndex num_cols = matrix_.
num_cols();
132 for (ColIndex
col(0);
col < num_cols; ++
col) {
134 GetUpperBoundInfeasibility(
col), GetLowerBoundInfeasibility(
col));
135 primal_infeasibility =
std::max(primal_infeasibility, col_infeasibility);
137 return primal_infeasibility;
143 const ColIndex num_cols = matrix_.
num_cols();
144 for (ColIndex
col(0);
col < num_cols; ++
col) {
146 GetUpperBoundInfeasibility(
col), GetLowerBoundInfeasibility(
col));
147 sum +=
std::max(0.0, col_infeasibility);
168 for (
const auto e : direction) {
169 const ColIndex
col = basis_[e.row()];
170 variable_values_[
col] -= e.coefficient() * step;
172 variable_values_[entering_col] += step;
176 const std::vector<ColIndex>& cols_to_update,
bool update_basic_variables) {
178 if (!update_basic_variables) {
179 for (ColIndex
col : cols_to_update) {
185 const RowIndex num_rows = matrix_.
num_rows();
186 initially_all_zero_scratchpad_.
values.
resize(num_rows, 0.0);
189 bool use_dense =
false;
190 for (ColIndex
col : cols_to_update) {
195 col, variable_values_[
col] - old_value,
196 &initially_all_zero_scratchpad_.
values);
199 col, variable_values_[
col] - old_value,
200 &initially_all_zero_scratchpad_);
207 basis_factorization_.
RightSolve(&initially_all_zero_scratchpad_);
208 if (initially_all_zero_scratchpad_.
non_zeros.empty()) {
209 for (RowIndex
row(0);
row < num_rows; ++
row) {
210 variable_values_[basis_[
row]] -= initially_all_zero_scratchpad_[
row];
217 for (
const auto e : initially_all_zero_scratchpad_) {
218 variable_values_[basis_[e.row()]] -= e.coefficient();
219 initially_all_zero_scratchpad_[e.row()] = 0.0;
222 initially_all_zero_scratchpad_.non_zeros.clear();
227 const RowIndex num_rows = matrix_.
num_rows();
228 dual_prices_->ClearAndResize(num_rows);
229 dual_prices_->StartDenseUpdates();
233 for (RowIndex
row(0);
row < num_rows; ++
row) {
234 const ColIndex
col = basis_[
row];
236 GetLowerBoundInfeasibility(
col));
237 if (infeasibility > tolerance) {
238 dual_prices_->DenseAddOrUpdate(
245 if (dual_prices_->Size() != matrix_.
num_rows()) {
255 for (
const RowIndex
row : rows) {
256 const ColIndex
col = basis_[
row];
258 GetLowerBoundInfeasibility(
col));
259 if (infeasibility > tolerance) {
260 dual_prices_->AddOrUpdate(
row,
261 Square(infeasibility) / squared_norms[
row]);
263 dual_prices_->Remove(
row);
#define DCHECK_NE(val1, val2)
#define DCHECK(condition)
#define DCHECK_EQ(val1, val2)
bool IsRefactorized() const
void RightSolve(ScatteredColumn *d) const
ColIndex num_cols() const
void ColumnAddMultipleToSparseScatteredColumn(ColIndex col, Fractional multiplier, ScatteredColumn *column) const
RowIndex num_rows() const
void ColumnAddMultipleToDenseColumn(ColIndex col, Fractional multiplier, DenseColumn *dense_column) const
const DenseColumn & GetEdgeSquaredNorms()
double primal_feasibility_tolerance() const
void AssignToZero(IntType size)
void resize(IntType size)
void SetNonBasicVariableValueFromStatus(ColIndex col)
Fractional ComputeMaximumPrimalInfeasibility() const
Fractional ComputeSumOfPrimalInfeasibilities() const
void UpdateGivenNonBasicVariables(const std::vector< ColIndex > &cols_to_update, bool update_basic_variables)
void ResetAllNonBasicVariableValues(const DenseRow &free_initial_values)
void UpdateDualPrices(const std::vector< RowIndex > &row)
void UpdateOnPivoting(const ScatteredColumn &direction, ColIndex entering_col, Fractional step)
VariableValues(const GlopParameters ¶meters, const CompactSparseMatrix &matrix, const RowToColMapping &basis, const VariablesInfo &variables_info, const BasisFactorization &basis_factorization, DualEdgeNorms *dual_edge_norms, DynamicMaximum< RowIndex > *dual_prices)
void RecomputeBasicVariableValues()
Fractional ComputeMaximumPrimalResidual() const
void RecomputeDualPrices()
const DenseRow & GetVariableLowerBounds() const
const DenseBitRow & GetNotBasicBitRow() const
const VariableStatusRow & GetStatusRow() const
const DenseRow & GetVariableUpperBounds() const
Fractional Square(Fractional f)
Fractional InfinityNorm(const DenseColumn &v)
bool IsAllZero(const Container &input)
bool IsFinite(Fractional value)
Collection of objects used to extend the Constraint Solver library.
std::vector< double > lower_bounds
std::vector< double > upper_bounds
#define SCOPED_TIME_STAT(stats)
bool ShouldUseDenseIteration(double ratio_for_using_dense_representation) const
void ClearNonZerosIfTooDense(double ratio_for_using_dense_representation)
std::vector< Index > non_zeros
StrictITIVector< Index, Fractional > values