16#include "absl/log/check.h"
17#include "ortools/glop/parameters.pb.h"
44 const RowIndex transposed_slack =
ColToRowIndex(slack_variable);
49 for (
const auto& entry : sparse_row) {
50 if (transposed_slack == entry.index())
continue;
52 (*values)[
RowToColIndex(entry.index())] * entry.coefficient();
54 (*values)[slack_variable] = -activation;
62 GlopParameters params;
63 Scale(lp, scaler, params.scaling_method());
69 GlopParameters::ScalingAlgorithm scaling_method) {
70 scaler->
Init(&lp->matrix_);
74 &lp->objective_coefficients_);
76 &lp->variable_upper_bounds_);
78 &lp->variable_lower_bounds_);
81 lp->transpose_matrix_is_consistent_ =
false;
90 objective_scaling_factor_ = 1.0 / lp->
ScaleObjective(params.cost_scaling());
95 bound_scaling_factor_ = 1.0;
96 objective_scaling_factor_ = 1.0;
158 const ColIndex num_rows = left_inverse->
values.
size();
159 for (ColIndex
col(0);
col < num_rows; ++
col) {
179 const RowIndex num_rows = right_inverse->
values.
size();
180 for (RowIndex
row(0);
row < num_rows; ++
row) {
const DenseColumn & constraint_lower_bounds() const
const SparseMatrix & GetTransposeSparseMatrix() const
ColIndex GetSlackVariable(RowIndex row) const
Fractional ScaleObjective(GlopParameters::CostScalingAlgorithm method)
const DenseColumn & constraint_upper_bounds() const
ColIndex num_variables() const
Returns the number of variables.
ColIndex GetFirstSlackVariable() const
RowIndex num_constraints() const
Returns the number of constraints.
void UnscaleUnitRowLeftSolve(ColIndex basis_col, ScatteredRow *left_inverse) const
Fractional ScaleVariableValue(ColIndex col, Fractional value) const
Transforms value from unscaled domain to the scaled one.
Fractional UnscaleDualValue(RowIndex row, Fractional value) const
Fractional UnscaleConstraintActivity(RowIndex row, Fractional value) const
void Clear()
Clear all scaling coefficients.
Fractional ScaleDualValue(RowIndex row, Fractional value) const
void Scale(LinearProgram *lp)
Scale the given LP.
Fractional ScaleConstraintActivity(RowIndex row, Fractional value) const
Fractional UnscaleReducedCost(ColIndex col, Fractional value) const
Fractional VariableScalingFactor(ColIndex col) const
Fractional UnscaleVariableValue(ColIndex col, Fractional value) const
Transforms corresponding value from the scaled domain to the original one.
Fractional ScaleReducedCost(ColIndex col, Fractional value) const
void UnscaleColumnRightSolve(const RowToColMapping &basis, ColIndex col, ScatteredColumn *right_inverse) const
Unscale a col vector v such that B.c = matrix_column_col.
void ScaleColumnVector(bool up, DenseColumn *column_vector) const
void Init(SparseMatrix *matrix)
void ScaleRowVector(bool up, DenseRow *row_vector) const
Fractional ColScalingFactor(ColIndex col) const
Fractional RowUnscalingFactor(RowIndex row) const
void Scale(GlopParameters::ScalingAlgorithm method)
Scales the matrix.
Fractional ColUnscalingFactor(ColIndex col) const
constexpr ColIndex kInvalidCol(-1)
void ComputeSlackVariablesValues(const LinearProgram &linear_program, DenseRow *values)
ColIndex RowToColIndex(RowIndex row)
Get the ColIndex corresponding to the column # row.
RowIndex ColToRowIndex(ColIndex col)
Get the RowIndex corresponding to the row # col.
void Scale(LinearProgram *lp, SparseMatrixScaler *scaler)
In SWIG mode, we don't want anything besides these top-level includes.
StrictITIVector< Index, Fractional > values
std::vector< Index > non_zeros