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"
68#if defined(__ANDROID__)
74static inline double ToDouble(
double f) {
return f; }
76static inline double ToDouble(
long double f) {
return static_cast<double>(f); }
86constexpr double kRangeMax = std::numeric_limits<double>::max();
89constexpr double kInfinity = std::numeric_limits<double>::infinity();
92constexpr double kEpsilon = std::numeric_limits<double>::epsilon();
257template <
typename IntType,
typename T>
267 return data_[
static_cast<size_t>(i.value())];
270 IntType
size()
const {
return size_; }
274 auto begin()
const {
return data_; }
275 auto end()
const {
return data_ +
static_cast<size_t>(size_.value()); }
287template <
typename IntType,
typename T,
typename Alloc = std::allocator<T>>
303#if !defined(__ANDROID__) && (!defined(_MSC_VER) || (_MSC_VER >= 1800))
305 const Alloc&
a = Alloc())
309 template <
typename InputIteratorType>
311 const Alloc&
a = Alloc())
321 IntType
size()
const {
return IntType(ParentType::size()); }
323 IntType
capacity()
const {
return IntType(ParentType::capacity()); }
337 DCHECK_GE(
size, IntType(0));
338 DCHECK_LE(
size, IntType(ParentType::size()));
409template <
typename EntryType>
412 using Index =
typename EntryType::Index;
413 using Entry = EntryType;
425 return this->i_ < other.i_;
434 const double kConversionFactor = 2e-9;
435 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)
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)
absl::Span< const double > coefficients
constexpr ColIndex kInvalidCol(-1)
constexpr double kInfinity
Infinity for type Fractional.
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 double kRangeMax
Range max for type Fractional. DBL_MAX for double for example.
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 double kEpsilon
Epsilon for type Fractional, i.e. the smallest e such that 1.0 + e != 1.0 .
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.
static double ToDouble(double f)
In SWIG mode, we don't want anything besides these top-level includes.
std::optional< int64_t > end
#define DEFINE_STRONG_INT64_TYPE(integer_type_name)
#define DEFINE_STRONG_INDEX_TYPE(index_type_name)