16#ifndef OR_TOOLS_LP_DATA_LP_TYPES_H_
17#define OR_TOOLS_LP_DATA_LP_TYPES_H_
21#include <initializer_list>
28#include "absl/log/check.h"
54inline ColIndex
RowToColIndex(RowIndex row) {
return ColIndex(row.value()); }
57inline RowIndex
ColToRowIndex(ColIndex col) {
return RowIndex(col.value()); }
68#if defined(__ANDROID__)
74static inline double ToDouble(
double f) {
return f; }
255template <
typename IntType,
typename T>
265 return data_[
static_cast<size_t>(i.value())];
268 IntType
size()
const {
return size_; }
272 auto begin()
const {
return data_; }
273 auto end()
const {
return data_ +
static_cast<size_t>(size_.value()); }
285template <
typename IntType,
typename T,
typename Alloc = std::allocator<T>>
301#if !defined(__ANDROID__) && (!defined(_MSC_VER) || (_MSC_VER >= 1800))
303 const Alloc& a = Alloc())
307 template <
typename InputIteratorType>
309 const Alloc& a = Alloc())
319 IntType
size()
const {
return IntType(ParentType::size()); }
321 IntType
capacity()
const {
return IntType(ParentType::capacity()); }
335 DCHECK_GE(
size, IntType(0));
336 DCHECK_LE(
size, IntType(ParentType::size()));
407template <
typename EntryType>
410 using Index =
typename EntryType::Index;
411 using Entry = EntryType;
415 : EntryType(indices, coefficients, i) {}
423 return this->
i_ < other.i_;
425 const Entry&
operator*()
const {
return *
this; }
432 const double kConversionFactor = 2e-9;
433 return kConversionFactor *
static_cast<double>(n);
StrictITISpan(T *data, IntType size)
reference operator[](IntType i) const
StrictITIVector(std::initializer_list< T > init_list, const Alloc &a=Alloc())
StrictITISpan< IntType, T > View
void assign(IntType size, const T &v)
void AssignToZero(IntType size)
util_intops::StrongVector< IntType, T, Alloc > ParentType
StrictITIVector(IntType size)
StrictITIVector & operator=(ConstView data)
StrictITIVector()=default
void reserve(IntType size)
void resize(IntType size, const T &v)
StrictITISpan< IntType, const T > ConstView
StrictITIVector(const Alloc &a)
void resize_down(IntType size)
StrictITIVector(InputIteratorType first, InputIteratorType last, const Alloc &a=Alloc())
ConstView const_view() const
StrictITIVector(IntType n, const T &v, const Alloc &a=Alloc())
void resize(IntType size)
const Entry & operator*() const
bool operator!=(const VectorIterator &other) const
VectorIterator(const Index *indices, const Fractional *coefficients, EntryIndex i)
typename EntryType::Index Index
void assign(size_type n, const value_type &val)
value_type * data()
– Pass-through methods to STL vector ----------------------------------—
void reserve(size_type n)
void resize(size_type new_size)
constexpr ColIndex kInvalidCol(-1)
std::string GetVariableTypeString(VariableType variable_type)
Returns the string representation of the VariableType enum.
StrictITIVector< RowIndex, ColIndex > RowToColMapping
std::vector< RowIndex > RowIndexVector
StrictITIVector< ColIndex, RowIndex > ColToRowMapping
StrictITIVector< RowIndex, bool > DenseBooleanColumn
Column of booleans.
std::vector< ColIndex > ColIndexVector
Vector of row or column indices. Useful to list the non-zero positions.
StrictITIVector< ColIndex, ColIndex > ColMapping
Row of column indices. Used to represent mappings between columns.
StrictITIVector< RowIndex, ConstraintStatus > ConstraintStatusColumn
Column of constraints (slack variables) statuses.
Bitset64< ColIndex > DenseBitRow
Row of bits.
std::string GetVariableStatusString(VariableStatus status)
Returns the string representation of the VariableStatus enum.
Index ColToIntIndex(ColIndex col)
Get the integer index corresponding to the col.
Bitset64< RowIndex > DenseBitColumn
Column of bits.
constexpr Fractional kEpsilon
Epsilon for type Fractional, i.e. the smallest e such that 1.0 + e != 1.0 .
ColIndex RowToColIndex(RowIndex row)
Get the ColIndex corresponding to the column # row.
bool IsFinite(Fractional value)
constexpr RowIndex kInvalidRow(-1)
StrictITIVector< RowIndex, RowIndex > RowMapping
Column of row indices. Used to represent mappings between rows.
VariableType
Different types of variables.
@ UPPER_AND_LOWER_BOUNDED
StrictITIVector< ColIndex, VariableType > VariableTypeRow
Row of variable types.
RowIndex ColToRowIndex(ColIndex col)
Get the RowIndex corresponding to the row # col.
std::string GetConstraintStatusString(ConstraintStatus status)
Returns the string representation of the ConstraintStatus enum.
StrictITIVector< ColIndex, VariableStatus > VariableStatusRow
Row of variable statuses.
constexpr Fractional kInfinity
Infinity for type Fractional.
StrictITIVector< RowIndex, Fractional > DenseColumn
Column-vector types. Column-vector types are indexed by a row index.
StrictITIVector< ColIndex, Fractional > DenseRow
Row-vector types. Row-vector types are indexed by a column index.
StrictITIVector< ColIndex, bool > DenseBooleanRow
Row of booleans.
std::ostream & operator<<(std::ostream &os, ProblemStatus status)
ProblemStatus
Different statuses for a given problem.
@ INFEASIBLE_OR_UNBOUNDED
@ ABNORMAL
An error occurred during the solving process.
@ INVALID_PROBLEM
The input problem was invalid (see LinearProgram.IsValid()).
@ INIT
The solver didn't had a chance to prove anything.
ConstraintStatus VariableToConstraintStatus(VariableStatus status)
Returns the ConstraintStatus corresponding to a given VariableStatus.
static double DeterministicTimeForFpOperations(int64_t n)
std::string GetProblemStatusString(ProblemStatus problem_status)
Returns the string representation of the ProblemStatus enum.
Index RowToIntIndex(RowIndex row)
Get the integer index corresponding to the row.
constexpr Fractional kRangeMax
Range max for type Fractional. DBL_MAX for double for example.
static double ToDouble(double f)
In SWIG mode, we don't want anything besides these top-level includes.
ClosedInterval::Iterator end(ClosedInterval interval)
ClosedInterval::Iterator begin(ClosedInterval interval)
#define DEFINE_STRONG_INT64_TYPE(integer_type_name)
#define DEFINE_STRONG_INDEX_TYPE(index_type_name)