Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
Typedefs | |
typedef int32_t | Index |
typedef double | Fractional |
typedef StrictITIVector< ColIndex, Fractional > | DenseRow |
Row-vector types. Row-vector types are indexed by a column index. | |
typedef StrictITIVector< ColIndex, bool > | DenseBooleanRow |
Row of booleans. | |
typedef StrictITIVector< ColIndex, ColIndex > | ColMapping |
Row of column indices. Used to represent mappings between columns. | |
typedef std::vector< ColIndex > | ColIndexVector |
Vector of row or column indices. Useful to list the non-zero positions. | |
typedef std::vector< RowIndex > | RowIndexVector |
typedef StrictITIVector< ColIndex, RowIndex > | ColToRowMapping |
typedef StrictITIVector< ColIndex, VariableType > | VariableTypeRow |
Row of variable types. | |
typedef StrictITIVector< ColIndex, VariableStatus > | VariableStatusRow |
Row of variable statuses. | |
typedef Bitset64< ColIndex > | DenseBitRow |
Row of bits. | |
typedef StrictITIVector< RowIndex, Fractional > | DenseColumn |
Column-vector types. Column-vector types are indexed by a row index. | |
typedef StrictITIVector< RowIndex, bool > | DenseBooleanColumn |
Column of booleans. | |
typedef Bitset64< RowIndex > | DenseBitColumn |
Column of bits. | |
typedef StrictITIVector< RowIndex, RowIndex > | RowMapping |
Column of row indices. Used to represent mappings between rows. | |
typedef StrictITIVector< RowIndex, ColIndex > | RowToColMapping |
typedef StrictITIVector< RowIndex, ConstraintStatus > | ConstraintStatusColumn |
Column of constraints (slack variables) statuses. | |
typedef AccurateSum< Fractional > | KahanSum |
typedef SumWithOneMissing< true > | SumWithPositiveInfiniteAndOneMissing |
typedef SumWithOneMissing< false > | SumWithNegativeInfiniteAndOneMissing |
typedef Permutation< RowIndex > | RowPermutation |
typedef Permutation< ColIndex > | ColumnPermutation |
using | ScatteredColumnIterator = VectorIterator<ScatteredColumnEntry> |
using | ScatteredRowIterator = VectorIterator<ScatteredRowEntry> |
using | SparseColumnIterator = VectorIterator<SparseColumnEntry> |
using | SparseRowIterator = VectorIterator<SparseRowEntry> |
typedef util_intops::StrongVector< RowIndex, SparseRow > | RowMajorSparseMatrix |
A matrix stored by rows. | |
Enumerations | |
enum class | ProblemStatus : int8_t { OPTIMAL , PRIMAL_INFEASIBLE , DUAL_INFEASIBLE , INFEASIBLE_OR_UNBOUNDED , PRIMAL_UNBOUNDED , DUAL_UNBOUNDED , INIT , PRIMAL_FEASIBLE , DUAL_FEASIBLE , ABNORMAL , INVALID_PROBLEM , IMPRECISE } |
Different statuses for a given problem. More... | |
enum class | VariableType : int8_t { UNCONSTRAINED , LOWER_BOUNDED , UPPER_BOUNDED , UPPER_AND_LOWER_BOUNDED , FIXED_VARIABLE } |
Different types of variables. More... | |
enum class | VariableStatus : int8_t { BASIC , FIXED_VALUE , AT_LOWER_BOUND , AT_UPPER_BOUND , FREE } |
enum class | ConstraintStatus : int8_t { BASIC , FIXED_VALUE , AT_LOWER_BOUND , AT_UPPER_BOUND , FREE } |
Functions | |
std::string | ValidateParameters (const GlopParameters ¶ms) |
void | FixConstraintWithFixedStatuses (const DenseColumn &row_lower_bounds, const DenseColumn &row_upper_bounds, ProblemSolution *solution) |
std::string | GetErrorCodeString (Status::ErrorCode error_code) |
Returns the string representation of the ErrorCode enum. | |
bool | AreBoundsValid (Fractional lower_bound, Fractional upper_bound) |
void | ComputeSlackVariablesValues (const LinearProgram &linear_program, DenseRow *values) |
void | Scale (LinearProgram *lp, SparseMatrixScaler *scaler) |
void | Scale (LinearProgram *lp, SparseMatrixScaler *scaler, GlopParameters::ScalingAlgorithm scaling_method) |
std::string | StringifyRational (const double x, const double precision) |
std::string | Stringify (const Fractional x, bool fraction) |
std::string | StringifyMonomial (const Fractional a, absl::string_view x, bool fraction) |
std::string | Stringify (const float a) |
std::string | Stringify (const double a) |
std::string | Stringify (const long double a) |
std::string | GetProblemStatusString (ProblemStatus problem_status) |
Returns the string representation of the ProblemStatus enum. | |
std::string | GetVariableTypeString (VariableType variable_type) |
Returns the string representation of the VariableType enum. | |
std::string | GetVariableStatusString (VariableStatus status) |
Returns the string representation of the VariableStatus enum. | |
std::string | GetConstraintStatusString (ConstraintStatus status) |
Returns the string representation of the ConstraintStatus enum. | |
ConstraintStatus | VariableToConstraintStatus (VariableStatus status) |
Returns the ConstraintStatus corresponding to a given VariableStatus. | |
DEFINE_STRONG_INDEX_TYPE (ColIndex) | |
DEFINE_STRONG_INDEX_TYPE (RowIndex) | |
ColIndex | RowToColIndex (RowIndex row) |
Get the ColIndex corresponding to the column # row. | |
RowIndex | ColToRowIndex (ColIndex col) |
Get the RowIndex corresponding to the row # col. | |
Index | ColToIntIndex (ColIndex col) |
Get the integer index corresponding to the col. | |
Index | RowToIntIndex (RowIndex row) |
Get the integer index corresponding to the row. | |
DEFINE_STRONG_INT64_TYPE (EntryIndex) | |
static double | ToDouble (double f) |
static double | ToDouble (long double f) |
bool | IsFinite (Fractional value) |
constexpr RowIndex | kInvalidRow (-1) |
constexpr ColIndex | kInvalidCol (-1) |
std::ostream & | operator<< (std::ostream &os, ProblemStatus status) |
std::ostream & | operator<< (std::ostream &os, VariableType type) |
std::ostream & | operator<< (std::ostream &os, VariableStatus status) |
std::ostream & | operator<< (std::ostream &os, ConstraintStatus status) |
static double | DeterministicTimeForFpOperations (int64_t n) |
template<typename SparseColumnLike > | |
Fractional | SquaredNormTemplate (const SparseColumnLike &column) |
Fractional | SquaredNorm (const SparseColumn &v) |
Fractional | SquaredNorm (const ColumnView &v) |
Fractional | PreciseSquaredNorm (const SparseColumn &v) |
Fractional | SquaredNorm (const ScatteredColumn &v) |
Fractional | PreciseSquaredNorm (const ScatteredColumn &v) |
Fractional | SquaredNorm (absl::Span< const Fractional > data) |
Fractional | SquaredNormAndResetToZero (absl::Span< Fractional > data) |
Fractional | SquaredNorm (const DenseColumn &column) |
Fractional | PreciseSquaredNorm (const DenseColumn &column) |
Fractional | InfinityNorm (const DenseColumn &v) |
Returns the maximum of the coefficients of 'v'. | |
template<typename SparseColumnLike > | |
Fractional | InfinityNormTemplate (const SparseColumnLike &column) |
Fractional | InfinityNorm (const SparseColumn &v) |
Fractional | InfinityNorm (const ColumnView &v) |
double | Density (const DenseRow &row) |
void | RemoveNearZeroEntries (Fractional threshold, DenseRow *row) |
Fractional | RestrictedInfinityNorm (const ColumnView &column, const DenseBooleanColumn &rows_to_consider, RowIndex *row_index) |
void | SetSupportToFalse (const ColumnView &column, DenseBooleanColumn *b) |
bool | IsDominated (const ColumnView &column, const DenseColumn &radius) |
Returns true iff for all 'row' we have '|column[row]| <= radius[row]'. | |
Fractional | Square (Fractional f) |
static Fractional | Fractionality (Fractional f) |
template<class DenseRowOrColumn1 , class DenseRowOrColumn2 > | |
Fractional | ScalarProduct (const DenseRowOrColumn1 &u, const DenseRowOrColumn2 &v) |
template<class DenseRowOrColumn > | |
Fractional | ScalarProduct (const DenseRowOrColumn &u, const SparseColumn &v) |
template<class DenseRowOrColumn > | |
Fractional | ScalarProduct (const DenseRowOrColumn &u, const ScatteredColumn &v) |
template<class DenseRowOrColumn , class DenseRowOrColumn2 > | |
Fractional | PreciseScalarProduct (const DenseRowOrColumn &u, const DenseRowOrColumn2 &v) |
template<class DenseRowOrColumn > | |
Fractional | PreciseScalarProduct (const DenseRowOrColumn &u, const SparseColumn &v) |
template<class DenseRowOrColumn > | |
Fractional | PartialScalarProduct (const DenseRowOrColumn &u, const SparseColumn &v, int max_index) |
Computes a scalar product for entries with index not greater than max_index. | |
const DenseRow & | Transpose (const DenseRow &row) |
Similar comment as the other Transpose() implementation above. | |
template<typename IndexType > | |
void | ComputeNonZeros (const StrictITIVector< IndexType, Fractional > &input, std::vector< IndexType > *non_zeros) |
Computes the positions of the non-zeros of a dense vector. | |
template<typename Container > | |
bool | IsAllZero (const Container &input) |
Returns true if the given Fractional container is all zeros. | |
template<typename BoolVector > | |
bool | IsAllFalse (const BoolVector &v) |
Returns true if the given vector of bool is all false. | |
template<typename IndexType , typename PermutationIndexType > | |
void | PermuteWithScratchpad (const Permutation< PermutationIndexType > &permutation, StrictITIVector< IndexType, Fractional > *zero_scratchpad, StrictITIVector< IndexType, Fractional > *input_output) |
Permutes the given dense vector. It uses for this an all zero scratchpad. | |
template<typename IndexType > | |
void | PermuteWithKnownNonZeros (const Permutation< IndexType > &permutation, StrictITIVector< IndexType, Fractional > *zero_scratchpad, StrictITIVector< IndexType, Fractional > *output, std::vector< IndexType > *non_zeros) |
template<typename IndexType , typename ScatteredRowOrCol > | |
void | ClearAndResizeVectorWithNonZeros (IndexType size, ScatteredRowOrCol *v) |
Sets a dense vector for which the non zeros are known to be non_zeros. | |
template<typename IndexType > | |
void | ChangeSign (StrictITIVector< IndexType, Fractional > *data) |
Changes the sign of all the entries in the given vector. | |
ColMapping | FindProportionalColumns (const SparseMatrix &matrix, Fractional tolerance) |
ColMapping | FindProportionalColumnsUsingSimpleAlgorithm (const SparseMatrix &matrix, Fractional tolerance) |
bool | AreFirstColumnsAndRowsExactlyEquals (RowIndex num_rows, ColIndex num_cols, const SparseMatrix &matrix_a, const CompactSparseMatrix &matrix_b) |
bool | IsRightMostSquareMatrixIdentity (const SparseMatrix &matrix) |
Returns true iff the rightmost square matrix is an identity matrix. | |
bool | LoadMPModelProtoFromModelOrRequest (const std::string &input_file_path, MPModelProto *model) |
bool | LoadLinearProgramFromModelOrRequest (const std::string &input_file_path, LinearProgram *linear_program) |
absl::StatusOr< MPModelProto > | MpsDataToMPModelProto (absl::string_view mps_data) |
Parses an MPS model from a string. | |
absl::StatusOr< MPModelProto > | MpsFileToMPModelProto (absl::string_view mps_file) |
Parses an MPS model from a file. | |
class | ABSL_DEPRECATED ("Use the direct methods instead") MPSReader |
template<typename IndexType , typename ITIVectorType > | |
void | ApplyPermutation (const Permutation< IndexType > &perm, const ITIVectorType &b, ITIVectorType *result) |
template<typename IndexType , typename ITIVectorType > | |
void | ApplyInversePermutation (const Permutation< IndexType > &perm, const ITIVectorType &b, ITIVectorType *result) |
template<typename RowIndexedVector > | |
void | ApplyColumnPermutationToRowIndexedVector (const Permutation< ColIndex > &col_perm, RowIndexedVector *v) |
template<typename RowIndexedVector > | |
void | ApplyColumnPermutationToRowIndexedVector (const Permutation< ColIndex > &col_perm, RowIndexedVector *v, RowIndexedVector *tmp) |
void | LinearProgramToMPModelProto (const LinearProgram &input, MPModelProto *output) |
Converts a LinearProgram to a MPModelProto. | |
void | MPModelProtoToLinearProgram (const MPModelProto &input, LinearProgram *output) |
Converts a MPModelProto to a LinearProgram. | |
const ScatteredRow & | TransposedView (const ScatteredColumn &c) |
const ScatteredColumn & | TransposedView (const ScatteredRow &r) |
const RowIndex | kNonPivotal (-1) |
Variables | |
e_ | |
constexpr const uint64_t | kDeterministicSeed = 42 |
constexpr double | kRangeMax = std::numeric_limits<double>::max() |
Range max for type Fractional. DBL_MAX for double for example. | |
constexpr double | kInfinity = std::numeric_limits<double>::infinity() |
Infinity for type Fractional. | |
constexpr double | kEpsilon = std::numeric_limits<double>::epsilon() |
Epsilon for type Fractional, i.e. the smallest e such that 1.0 + e != 1.0 . | |
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
typedef std::vector<ColIndex> operations_research::glop::ColIndexVector |
Vector of row or column indices. Useful to list the non-zero positions.
Definition at line 362 of file lp_types.h.
typedef StrictITIVector<ColIndex, ColIndex> operations_research::glop::ColMapping |
Row of column indices. Used to represent mappings between columns.
Definition at line 359 of file lp_types.h.
typedef StrictITIVector<ColIndex, RowIndex> operations_research::glop::ColToRowMapping |
Row of row indices. Useful for knowing which row corresponds to a particular column in the basis, or for storing the number of rows for a given column.
Definition at line 368 of file lp_types.h.
typedef Permutation<ColIndex> operations_research::glop::ColumnPermutation |
Definition at line 97 of file permutation.h.
typedef StrictITIVector<RowIndex, ConstraintStatus> operations_research::glop::ConstraintStatusColumn |
Column of constraints (slack variables) statuses.
Definition at line 399 of file lp_types.h.
typedef Bitset64<RowIndex> operations_research::glop::DenseBitColumn |
Column of bits.
Definition at line 388 of file lp_types.h.
typedef Bitset64<ColIndex> operations_research::glop::DenseBitRow |
Row of bits.
Definition at line 377 of file lp_types.h.
typedef StrictITIVector<RowIndex, bool> operations_research::glop::DenseBooleanColumn |
Column of booleans.
Definition at line 385 of file lp_types.h.
typedef StrictITIVector<ColIndex, bool> operations_research::glop::DenseBooleanRow |
Row of booleans.
Definition at line 356 of file lp_types.h.
typedef StrictITIVector<RowIndex, Fractional> operations_research::glop::DenseColumn |
Column-vector types. Column-vector types are indexed by a row index.
Column of fractional values.
Definition at line 382 of file lp_types.h.
typedef StrictITIVector<ColIndex, Fractional> operations_research::glop::DenseRow |
Row-vector types. Row-vector types are indexed by a column index.
Row of fractional values.
Definition at line 353 of file lp_types.h.
typedef double operations_research::glop::Fractional |
The type Fractional denotes the type of numbers on which the computations are performed. This is defined as double here, but it could as well be float, DoubleDouble, QuadDouble, or infinite-precision rationals. Floating-point representations are binary fractional numbers, thus the name. (See http://en.wikipedia.org/wiki/Fraction_(mathematics) .)
Definition at line 83 of file lp_types.h.
typedef int32_t operations_research::glop::Index |
This type is defined to avoid cast issues during index conversions, e.g. converting ColIndex into RowIndex. All types should use 'Index' instead of int32_t.
Definition at line 43 of file lp_types.h.
Definition at line 37 of file lp_utils.h.
typedef std::vector<RowIndex> operations_research::glop::RowIndexVector |
Definition at line 363 of file lp_types.h.
typedef util_intops::StrongVector<RowIndex, SparseRow> operations_research::glop::RowMajorSparseMatrix |
A matrix stored by rows.
Definition at line 61 of file sparse_row.h.
typedef StrictITIVector<RowIndex, RowIndex> operations_research::glop::RowMapping |
Column of row indices. Used to represent mappings between rows.
Definition at line 391 of file lp_types.h.
typedef Permutation<RowIndex> operations_research::glop::RowPermutation |
Definition at line 96 of file permutation.h.
typedef StrictITIVector<RowIndex, ColIndex> operations_research::glop::RowToColMapping |
Column of column indices. Used to represent which column corresponds to a particular row in the basis, or for storing the number of columns for a given row.
Definition at line 396 of file lp_types.h.
Definition at line 190 of file scattered_vector.h.
Definition at line 191 of file scattered_vector.h.
Definition at line 42 of file sparse_column.h.
Definition at line 36 of file sparse_row.h.
Definition at line 391 of file lp_utils.h.
Definition at line 390 of file lp_utils.h.
typedef StrictITIVector<ColIndex, VariableStatus> operations_research::glop::VariableStatusRow |
Row of variable statuses.
Definition at line 374 of file lp_types.h.
typedef StrictITIVector<ColIndex, VariableType> operations_research::glop::VariableTypeRow |
Row of variable types.
Definition at line 371 of file lp_types.h.
|
strong |
Different constraints statuses. The meaning is the same for the constraint activity relative to its bounds as it is for a variable value relative to its bounds. Actually, this is the VariableStatus of the slack variable associated to a constraint modulo a change of sign. The difference is that because of precision error, a constraint activity cannot exactly be equal to one of its bounds or to zero.
Enumerator | |
---|---|
BASIC | |
FIXED_VALUE | |
AT_LOWER_BOUND | |
AT_UPPER_BOUND | |
FREE |
Definition at line 236 of file lp_types.h.
|
strong |
Different statuses for a given problem.
Enumerator | |
---|---|
OPTIMAL | The problem has been solved to optimality. Both the primal and dual have a feasible solution. |
PRIMAL_INFEASIBLE | The problem has been proven primal-infeasible. Note that the problem is not necessarily DUAL_UNBOUNDED (See Chvatal p.60). The solver does not have a dual unbounded ray in this case. |
DUAL_INFEASIBLE | The problem has been proven dual-infeasible. Note that the problem is not necessarily PRIMAL_UNBOUNDED (See Chvatal p.60). The solver does note have a primal unbounded ray in this case, |
INFEASIBLE_OR_UNBOUNDED | The problem is either INFEASIBLE or UNBOUNDED (this applies to both the primal and dual algorithms). This status is only returned by the presolve step and means that a primal or dual unbounded ray was found during presolve. Note that because some presolve techniques assume that a feasible solution exists to simplify the problem further, it is difficult to distinguish between infeasibility and unboundedness. If a client needs to distinguish, it is possible to run the primal algorithm on the same problem with a 0 objective function to know if the problem was PRIMAL_INFEASIBLE. |
PRIMAL_UNBOUNDED | The problem has been proven feasible and unbounded. That means that the problem is DUAL_INFEASIBLE and that the solver has a primal unbounded ray. |
DUAL_UNBOUNDED | The problem has been proven dual-feasible and dual-unbounded. That means the problem is PRIMAL_INFEASIBLE and that the solver has a dual unbounded ray to prove it. |
INIT | The solver didn't had a chance to prove anything. All the statuses below correspond to a case where the solver was interrupted. This can happen because of a timeout, an iteration limit or an error. |
PRIMAL_FEASIBLE | The problem has been proven primal-feasible but may still be PRIMAL_UNBOUNDED. |
DUAL_FEASIBLE | The problem has been proven dual-feasible, but may still be DUAL_UNBOUNDED. That means that if the primal is feasible, then it has a finite optimal solution. |
ABNORMAL | An error occurred during the solving process. |
INVALID_PROBLEM | The input problem was invalid (see LinearProgram.IsValid()). |
IMPRECISE | The problem was solved to a feasible status, but the solution checker found the primal and/or dual infeasibilities too important for the specified parameters. |
Definition at line 107 of file lp_types.h.
|
strong |
Different variables statuses. If a solution is OPTIMAL or FEASIBLE, then all the properties described here should be satisfied. These properties should also be true during the execution of the revised simplex algorithm, except that because of bound-shifting, the variable may not be at their exact bounds until the shifts are removed.
Definition at line 202 of file lp_types.h.
|
strong |
Different types of variables.
Enumerator | |
---|---|
UNCONSTRAINED | |
LOWER_BOUNDED | |
UPPER_BOUNDED | |
UPPER_AND_LOWER_BOUNDED | |
FIXED_VARIABLE |
Definition at line 180 of file lp_types.h.
class operations_research::glop::ABSL_DEPRECATED | ( | "Use the direct methods instead" | ) |
Implementation class. Please use the 2 functions above.
Reads a linear program in the mps format.
All Parse() methods clear the previously parsed instance and store the result in the given Data class.
Parses instance from a file.
Loads instance from string. Useful with MapReduce. Automatically detects the file's format (free or fixed).
Definition at line 43 of file mps_reader.h.
void operations_research::glop::ApplyColumnPermutationToRowIndexedVector | ( | const Permutation< ColIndex > & | col_perm, |
RowIndexedVector * | v ) |
Specialization of ApplyPermutation(): apply a column permutation to a row-indexed vector v.
Definition at line 118 of file permutation.h.
void operations_research::glop::ApplyColumnPermutationToRowIndexedVector | ( | const Permutation< ColIndex > & | col_perm, |
RowIndexedVector * | v, | ||
RowIndexedVector * | tmp ) |
Definition at line 125 of file permutation.h.
void operations_research::glop::ApplyInversePermutation | ( | const Permutation< IndexType > & | perm, |
const ITIVectorType & | b, | ||
ITIVectorType * | result ) |
Applies the inverse of perm to the vector b. Overwrites result to store the result.
Empty size means identity.
Empty size means identity.
Definition at line 223 of file permutation.h.
void operations_research::glop::ApplyPermutation | ( | const Permutation< IndexType > & | perm, |
const ITIVectorType & | b, | ||
ITIVectorType * | result ) |
Applies the permutation perm to the vector b. Overwrites result to store the result.
Empty size means identity.
Empty size means identity.
Definition at line 204 of file permutation.h.
|
inline |
bool operations_research::glop::AreFirstColumnsAndRowsExactlyEquals | ( | RowIndex | num_rows, |
ColIndex | num_cols, | ||
const SparseMatrix & | matrix_a, | ||
const CompactSparseMatrix & | matrix_b ) |
Returns true iff the two given matrices have exactly the same first num_rows entries on the first num_cols columns. The two given matrices must be ordered by rows (this is DCHECKed, but only for the first one at this point).
Definition at line 198 of file matrix_utils.cc.
|
inline |
Changes the sign of all the entries in the given vector.
Definition at line 307 of file lp_utils.h.
|
inline |
Sets a dense vector for which the non zeros are known to be non_zeros.
Only use the sparse version if there is less than 5% non-zeros positions compared to the wanted size. Note that in most cases the vector will already be of the correct size.
Definition at line 285 of file lp_utils.h.
|
inline |
Get the integer index corresponding to the col.
Definition at line 60 of file lp_types.h.
|
inline |
Get the RowIndex corresponding to the row # col.
Definition at line 57 of file lp_types.h.
|
inline |
Computes the positions of the non-zeros of a dense vector.
Definition at line 216 of file lp_utils.h.
void operations_research::glop::ComputeSlackVariablesValues | ( | const LinearProgram & | linear_program, |
DenseRow * | values ) |
For all constraints in linear_program, if the constraint has a slack variable, change its value in *values so that the constraints itself is satisfied.
If there are no slack variable, we can give up.
Row in the initial matrix (column in the transposed).
Definition at line 27 of file lp_data_utils.cc.
operations_research::glop::DEFINE_STRONG_INDEX_TYPE | ( | ColIndex | ) |
ColIndex is the type for integers representing column/variable indices. int32s are enough for handling even the largest problems.
operations_research::glop::DEFINE_STRONG_INDEX_TYPE | ( | RowIndex | ) |
RowIndex is the type for integers representing row/constraint indices. int32s are enough for handling even the largest problems.
operations_research::glop::DEFINE_STRONG_INT64_TYPE | ( | EntryIndex | ) |
EntryIndex is the type for integers representing entry indices. An entry in a sparse matrix is a pair (row, value) for a given known column. See classes SparseColumn and SparseMatrix.
double operations_research::glop::Density | ( | const DenseRow & | row | ) |
Returns the fraction of non-zero entries of the given row.
Definition at line 176 of file lp_utils.cc.
|
inlinestatic |
This is used during the deterministic time computation to convert a given number of floating-point operations to something in the same order of magnitude as a second (on a 2014 desktop).
Definition at line 435 of file lp_types.h.
ColMapping operations_research::glop::FindProportionalColumns | ( | const SparseMatrix & | matrix, |
Fractional | tolerance ) |
Finds the proportional columns of the given matrix: all the pairs of columns such that one is a non-zero scalar multiple of the other. The returned mapping for a given column will either be:
Because of precision errors, two columns are declared proportional if the multiples (>= 1.0) defined by all the couple of coefficients of the same row are equal up to the given absolute tolerance.
The complexity is in most cases O(num entries of the matrix). However, compared to the less efficient algorithm below, it is highly unlikely but possible that some pairs of proportional columns are not detected.
Compute the fingerprint of each columns and sort them.
Find a representative of each proportional columns class. This only compares columns with a close-enough fingerprint.
Sort the mapping so that the representative of each class is the smallest column. To achieve this, the current representative is used as a pointer to the new one, a bit like in an union find algorithm.
Definition at line 123 of file matrix_utils.cc.
ColMapping operations_research::glop::FindProportionalColumnsUsingSimpleAlgorithm | ( | const SparseMatrix & | matrix, |
Fractional | tolerance ) |
A simple version of FindProportionalColumns() that compares all the columns pairs one by one. This is slow, but here for reference. The complexity is O(num_cols * num_entries).
Definition at line 179 of file matrix_utils.cc.
void operations_research::glop::FixConstraintWithFixedStatuses | ( | const DenseColumn & | row_lower_bounds, |
const DenseColumn & | row_upper_bounds, | ||
ProblemSolution * | solution ) |
Because of numerical imprecision, a preprocessor like DoubletonEqualityRowPreprocessor can transform a constraint/variable domain like [1, 1+1e-7] to a fixed domain (for ex by multiplying the above domain by 1e9). This causes an issue because at postsolve, a FIXED_VALUE status now needs to be transformed to a AT_LOWER_BOUND/AT_UPPER_BOUND status. This is what this function is doing for the constraint statuses only.
We need to fix the status and we just need to make sure that the bound we choose satisfies the LP optimality conditions.
Definition at line 3402 of file preprocessor.cc.
|
inlinestatic |
Returns distance from a given fractional number to the closest integer. It means that the result is always contained in range of [0.0, 0.5].
Definition at line 45 of file lp_utils.h.
std::string operations_research::glop::GetConstraintStatusString | ( | ConstraintStatus | status | ) |
Returns the string representation of the ConstraintStatus enum.
Fallback. We don't use "default:" so the compiler will return an error if we forgot one enum case above.
Definition at line 94 of file lp_types.cc.
std::string operations_research::glop::GetErrorCodeString | ( | Status::ErrorCode | error_code | ) |
std::string operations_research::glop::GetProblemStatusString | ( | ProblemStatus | problem_status | ) |
Returns the string representation of the ProblemStatus enum.
Fallback. We don't use "default:" so the compiler will return an error if we forgot one enum case above.
Definition at line 23 of file lp_types.cc.
std::string operations_research::glop::GetVariableStatusString | ( | VariableStatus | status | ) |
Returns the string representation of the VariableStatus enum.
Fallback. We don't use "default:" so the compiler will return an error if we forgot one enum case above.
Definition at line 75 of file lp_types.cc.
std::string operations_research::glop::GetVariableTypeString | ( | VariableType | variable_type | ) |
Returns the string representation of the VariableType enum.
Fallback. We don't use "default:" so the compiler will return an error if we forgot one enum case above.
Definition at line 56 of file lp_types.cc.
Fractional operations_research::glop::InfinityNorm | ( | const ColumnView & | v | ) |
Definition at line 172 of file lp_utils.cc.
Fractional operations_research::glop::InfinityNorm | ( | const DenseColumn & | v | ) |
Returns the maximum of the coefficients
of 'v'.
Definition at line 151 of file lp_utils.cc.
Fractional operations_research::glop::InfinityNorm | ( | const SparseColumn & | v | ) |
Definition at line 168 of file lp_utils.cc.
Fractional operations_research::glop::InfinityNormTemplate | ( | const SparseColumnLike & | column | ) |
Definition at line 160 of file lp_utils.cc.
bool operations_research::glop::IsAllFalse | ( | const BoolVector & | v | ) |
Returns true if the given vector of bool is all false.
Definition at line 238 of file lp_utils.h.
|
inline |
Returns true if the given Fractional container is all zeros.
Definition at line 229 of file lp_utils.h.
bool operations_research::glop::IsDominated | ( | const ColumnView & | column, |
const DenseColumn & | radius ) |
Returns true iff for all 'row' we have '|column[row]| <= radius[row]'.
Definition at line 224 of file lp_utils.cc.
|
inline |
Returns true if the given value is finite, that means for a double: not a NaN and not +/- infinity.
Definition at line 96 of file lp_types.h.
bool operations_research::glop::IsRightMostSquareMatrixIdentity | ( | const SparseMatrix & | matrix | ) |
Returns true iff the rightmost square matrix is an identity matrix.
Definition at line 239 of file matrix_utils.cc.
|
constexpr |
|
constexpr |
Constants to represent invalid row or column index. It is important that their values be the same because during transposition, one needs to be converted into the other.
const RowIndex operations_research::glop::kNonPivotal | ( | - | 1 | ) |
void operations_research::glop::LinearProgramToMPModelProto | ( | const LinearProgram & | input, |
MPModelProto * | output ) |
Converts a LinearProgram to a MPModelProto.
We need the matrix transpose because a LinearProgram stores the data column-wise but the MPModelProto uses a row-wise format.
Definition at line 27 of file proto_utils.cc.
bool operations_research::glop::LoadLinearProgramFromModelOrRequest | ( | const std::string & | input_file_path, |
LinearProgram * | linear_program ) |
Definition at line 59 of file model_reader.cc.
bool operations_research::glop::LoadMPModelProtoFromModelOrRequest | ( | const std::string & | input_file_path, |
MPModelProto * | model ) |
Helper function to read data from model files into MPModelProto and LinearProgram.
If the input proto is in binary format, both ReadFileToProto could return true. Instead use the actual number of variables found to test the correct format of the input.
Definition at line 27 of file model_reader.cc.
void operations_research::glop::MPModelProtoToLinearProgram | ( | const MPModelProto & | input, |
LinearProgram * | output ) |
Converts a MPModelProto to a LinearProgram.
Definition at line 58 of file proto_utils.cc.
absl::StatusOr< MPModelProto > operations_research::glop::MpsDataToMPModelProto | ( | absl::string_view | mps_data | ) |
Parses an MPS model from a string.
Definition at line 360 of file mps_reader.cc.
absl::StatusOr< MPModelProto > operations_research::glop::MpsFileToMPModelProto | ( | absl::string_view | mps_file | ) |
Parses an MPS model from a file.
Definition at line 370 of file mps_reader.cc.
|
inline |
Definition at line 247 of file lp_types.h.
|
inline |
Definition at line 174 of file lp_types.h.
|
inline |
Definition at line 225 of file lp_types.h.
|
inline |
Definition at line 191 of file lp_types.h.
Fractional operations_research::glop::PartialScalarProduct | ( | const DenseRowOrColumn & | u, |
const SparseColumn & | v, | ||
int | max_index ) |
Computes a scalar product for entries with index not greater than max_index.
Definition at line 134 of file lp_utils.h.
|
inline |
Same as PermuteAndComputeNonZeros() except that we assume that the given non-zeros are the initial non-zeros positions of output.
Definition at line 266 of file lp_utils.h.
|
inline |
Permutes the given dense vector. It uses for this an all zero scratchpad.
Definition at line 244 of file lp_utils.h.
Fractional operations_research::glop::PreciseScalarProduct | ( | const DenseRowOrColumn & | u, |
const DenseRowOrColumn2 & | v ) |
Definition at line 111 of file lp_utils.h.
Fractional operations_research::glop::PreciseScalarProduct | ( | const DenseRowOrColumn & | u, |
const SparseColumn & | v ) |
Definition at line 122 of file lp_utils.h.
Fractional operations_research::glop::PreciseSquaredNorm | ( | const DenseColumn & | column | ) |
Definition at line 143 of file lp_utils.cc.
Fractional operations_research::glop::PreciseSquaredNorm | ( | const ScatteredColumn & | v | ) |
Definition at line 63 of file lp_utils.cc.
Fractional operations_research::glop::PreciseSquaredNorm | ( | const SparseColumn & | v | ) |
Definition at line 44 of file lp_utils.cc.
void operations_research::glop::RemoveNearZeroEntries | ( | Fractional | threshold, |
DenseRow * | row ) |
Sets to 0.0 all entries of the given row whose fabs() is lower than the given threshold.
Definition at line 185 of file lp_utils.cc.
Fractional operations_research::glop::RestrictedInfinityNorm | ( | const ColumnView & | column, |
const DenseBooleanColumn & | rows_to_consider, | ||
RowIndex * | row_index ) |
Returns the maximum of the coefficients
of the given column restricted to the rows_to_consider. Also returns the first RowIndex 'row' that attains this maximum. If the maximum is 0.0, then row_index is left untouched.
Definition at line 203 of file lp_utils.cc.
|
inline |
Get the ColIndex corresponding to the column # row.
Definition at line 54 of file lp_types.h.
|
inline |
Get the integer index corresponding to the row.
Definition at line 63 of file lp_types.h.
Fractional operations_research::glop::ScalarProduct | ( | const DenseRowOrColumn & | u, |
const ScatteredColumn & | v ) |
Definition at line 97 of file lp_utils.h.
Fractional operations_research::glop::ScalarProduct | ( | const DenseRowOrColumn & | u, |
const SparseColumn & | v ) |
Definition at line 87 of file lp_utils.h.
Fractional operations_research::glop::ScalarProduct | ( | const DenseRowOrColumn1 & | u, |
const DenseRowOrColumn2 & | v ) |
Returns the scalar product between u and v. The precise versions use KahanSum and are about two times slower.
Computing the sum of 4 elements at once may allow the compiler to generate more efficient code, e.g. using SIMD and checking the loop condition much less frequently.
This produces different results from the case where each multiplication is added to sum separately. An extreme example of this can be derived using the fact that 1e11 + 2e-6 == 1e11, but 1e11 + 8e-6 > 1e11.
While the results are different, they aren't necessarily better or worse. Typically, sum will be of larger magnitude than any individual multiplication, so one might expect, in practice, this method to yield more accurate results. However, if accuracy is vital, use the precise version.
Definition at line 52 of file lp_utils.h.
void operations_research::glop::Scale | ( | LinearProgram * | lp, |
SparseMatrixScaler * | scaler ) |
This is separated from the LinearProgram class because of a cyclic dependency when scaling as an LP.
A convenience method for above providing a default algorithm for callers that don't specify one.
Create GlopParameters proto to get default scaling algorithm.
Definition at line 60 of file lp_data_utils.cc.
void operations_research::glop::Scale | ( | LinearProgram * | lp, |
SparseMatrixScaler * | scaler, | ||
GlopParameters::ScalingAlgorithm | scaling_method ) |
This is separated from LinearProgram class because of a cyclic dependency when scaling as an LP.
Definition at line 68 of file lp_data_utils.cc.
void operations_research::glop::SetSupportToFalse | ( | const ColumnView & | column, |
DenseBooleanColumn * | b ) |
Sets to false the entry b[row] if column[row] is non null.
Definition at line 216 of file lp_utils.cc.
|
inline |
Returns the square of a Fractional. Useful to shorten the code when f is an expression or a long name.
Definition at line 41 of file lp_utils.h.
Fractional operations_research::glop::SquaredNorm | ( | absl::Span< const Fractional > | data | ) |
We expand ourselves since we don't really care about the floating point order of operation and this seems faster.
Definition at line 74 of file lp_utils.cc.
Fractional operations_research::glop::SquaredNorm | ( | const ColumnView & | v | ) |
Definition at line 40 of file lp_utils.cc.
Fractional operations_research::glop::SquaredNorm | ( | const DenseColumn & | column | ) |
Definition at line 139 of file lp_utils.cc.
Fractional operations_research::glop::SquaredNorm | ( | const ScatteredColumn & | v | ) |
Definition at line 52 of file lp_utils.cc.
Fractional operations_research::glop::SquaredNorm | ( | const SparseColumn & | v | ) |
Returns the norm^2 (sum of the square of the entries) of the given column. The precise version uses KahanSum and are about two times slower.
Definition at line 36 of file lp_utils.cc.
Fractional operations_research::glop::SquaredNormAndResetToZero | ( | absl::Span< Fractional > | data | ) |
We expand ourselves since we don't really care about the floating point order of operation and this seems faster.
Definition at line 103 of file lp_utils.cc.
Fractional operations_research::glop::SquaredNormTemplate | ( | const SparseColumnLike & | column | ) |
Definition at line 28 of file lp_utils.cc.
|
inline |
Definition at line 35 of file lp_print_utils.h.
|
inline |
Returns a string representing a floating-point number in decimal, with a precision corresponding to the type of the argument.
Definition at line 31 of file lp_print_utils.h.
std::string operations_research::glop::Stringify | ( | Fractional | x, |
bool | fraction ) |
If fraction is true, returns a string corresponding to the rational approximation or a decimal approximation otherwise. Note that the absolute difference between the output fraction and "x" will never exceed std::numeric_limits<T>::epsilon().
Definition at line 46 of file lp_print_utils.cc.
|
inline |
Definition at line 39 of file lp_print_utils.h.
std::string operations_research::glop::StringifyMonomial | ( | const Fractional | a, |
absl::string_view | x, | ||
bool | fraction ) |
Returns a string that pretty-prints a monomial ax with coefficient a and variable name x
Pretty prints a monomial a*x using Stringify(x, fraction) to display a, taking care of the sign of x, whether a is 0, 1, -1, integer. Note that the absolute difference between the output fraction and "x" will never exceed std::numeric_limits<T>::epsilon().
Definition at line 54 of file lp_print_utils.cc.
std::string operations_research::glop::StringifyRational | ( | const double | x, |
const double | precision ) |
Returns a string "num/den" representing the rational approximation of x. The absolute difference between the output fraction and the input "x" will not exceed "precision".
Definition at line 33 of file lp_print_utils.cc.
|
inlinestatic |
Definition at line 74 of file lp_types.h.
|
inlinestatic |
Definition at line 76 of file lp_types.h.
const DenseRow & operations_research::glop::Transpose | ( | const DenseColumn & | col | ) |
Similar comment as the other Transpose() implementation above.
Transposition functions implemented below with a cast so it should actually have no complexity cost.
This cast based implementation should be safe, as long as DenseRow and DenseColumn are implemented by the same underlying type. We still do some DCHECK to be sure it works as expected in addition to the unit tests.
Definition at line 199 of file lp_utils.h.
|
inline |
Definition at line 197 of file scattered_vector.h.
|
inline |
Definition at line 200 of file scattered_vector.h.
std::string operations_research::glop::ValidateParameters | ( | const GlopParameters & | params | ) |
Verifies that the given parameters are correct. Returns an empty string if it is the case, or an human-readable error message otherwise.
Definition at line 52 of file parameters_validation.cc.
ConstraintStatus operations_research::glop::VariableToConstraintStatus | ( | VariableStatus | status | ) |
Returns the ConstraintStatus corresponding to a given VariableStatus.
Fallback. We don't use "default:" so the compiler will return an error if we forgot one enum case above.
This will never be reached and is here only to guarantee compilation.
Definition at line 113 of file lp_types.cc.
operations_research::glop::e_ |
An eta matrix E corresponds to the identity matrix except for one column e of index j. In particular, B.E is the matrix of the new basis obtained from B by replacing the j-th vector of B by B.e, note that this is exactly what happens during a "pivot" of the current basis in the simplex algorithm.
E = [ 1 ... 0 e_0 0 ... 0 ... ... ... ... ... ... ...
Definition at line 41 of file basis_representation.h.
|
constexpr |
Definition at line 95 of file revised_simplex.cc.
|
constexpr |
Epsilon for type Fractional, i.e. the smallest e such that 1.0 + e != 1.0 .
Definition at line 92 of file lp_types.h.
|
constexpr |
Infinity for type Fractional.
Definition at line 89 of file lp_types.h.
|
constexpr |
Range max for type Fractional. DBL_MAX for double for example.
Definition at line 86 of file lp_types.h.