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();
233 for (RowIndex
row(0);
row < num_rows; ++
row) {
234 const ColIndex
col = basis_[
row];
236 GetLowerBoundInfeasibility(
col));
237 if (infeasibility > tolerance) {
255 for (
const RowIndex
row : rows) {
256 const ColIndex
col = basis_[
row];
258 GetLowerBoundInfeasibility(
col));
259 if (infeasibility > tolerance) {
261 Square(infeasibility) / squared_norms[
row]);
Fractional InfinityNorm(const DenseColumn &v)
void UpdateDualPrices(const std::vector< RowIndex > &row)
bool IsRefactorized() const
const DenseColumn & GetEdgeSquaredNorms()
void SetNonBasicVariableValueFromStatus(ColIndex col)
const DenseBitRow & GetNotBasicBitRow() const
void RecomputeDualPrices()
std::vector< double > lower_bounds
bool ShouldUseDenseIteration(double ratio_for_using_dense_representation) const
#define SCOPED_TIME_STAT(stats)
RowIndex num_rows() const
bool IsFinite(Fractional value)
void RightSolve(ScatteredColumn *d) const
Fractional ComputeMaximumPrimalResidual() const
void UpdateGivenNonBasicVariables(const std::vector< ColIndex > &cols_to_update, bool update_basic_variables)
void RecomputeBasicVariableValues()
void Remove(Index position)
#define DCHECK_NE(val1, val2)
Fractional ComputeMaximumPrimalInfeasibility() const
StrictITIVector< Index, Fractional > values
void AssignToZero(IntType size)
bool IsAllZero(const Container &input)
void ColumnAddMultipleToSparseScatteredColumn(ColIndex col, Fractional multiplier, ScatteredColumn *column) const
void AddOrUpdate(Index position, Fractional value)
const DenseRow & GetVariableUpperBounds() const
Fractional ComputeSumOfPrimalInfeasibilities() const
const DenseRow & GetVariableLowerBounds() const
void DenseAddOrUpdate(Index position, Fractional value)
void resize(IntType size)
#define DCHECK(condition)
#define DCHECK_EQ(val1, val2)
void UpdateOnPivoting(const ScatteredColumn &direction, ColIndex entering_col, Fractional step)
Fractional Square(Fractional f)
void ClearAndResize(Index n)
Collection of objects used to extend the Constraint Solver library.
const VariableStatusRow & GetStatusRow() const
std::vector< double > upper_bounds
ColIndex num_cols() const
double primal_feasibility_tolerance() const
void ResetAllNonBasicVariableValues(const DenseRow &free_initial_values)
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 ClearNonZerosIfTooDense(double ratio_for_using_dense_representation)
std::vector< Index > non_zeros
void ColumnAddMultipleToDenseColumn(ColIndex col, Fractional multiplier, DenseColumn *dense_column) const