![]() |
Google OR-Tools v9.12
a fast and portable software suite for combinatorial optimization
|
#include <linear_programming_constraint.h>
Public Member Functions | |
void | ClearAndResize (int size) |
bool | Add (glop::ColIndex col, IntegerValue value) |
Does vector[col] += value and return false in case of overflow. | |
template<bool check_overflow = true> | |
bool | AddLinearExpressionMultiple (IntegerValue multiplier, absl::Span< const glop::ColIndex > cols, absl::Span< const IntegerValue > coeffs, IntegerValue max_coeff_magnitude) |
Force instantations for tests. | |
LinearConstraint | ConvertToLinearConstraint (absl::Span< const IntegerVariable > integer_variables, IntegerValue upper_bound, std::optional< std::pair< IntegerVariable, IntegerValue > > extra_term=std::nullopt) |
void | ConvertToCutData (absl::int128 rhs, absl::Span< const IntegerVariable > integer_variables, absl::Span< const double > lp_solution, IntegerTrail *integer_trail, CutData *result) |
std::vector< std::pair< glop::ColIndex, IntegerValue > > | GetTerms () |
Similar to ConvertToLinearConstraint(). | |
IntegerValue | operator[] (glop::ColIndex col) const |
We only provide the const []. | |
bool | IsSparse () const |
Simple class to combine linear expression efficiently. First in a sparse way that switch to dense when the number of non-zeros grows.
Definition at line 60 of file linear_programming_constraint.h.
bool operations_research::sat::ScatteredIntegerVector::Add | ( | glop::ColIndex | col, |
IntegerValue | value ) |
Does vector[col] += value and return false in case of overflow.
Definition at line 96 of file linear_programming_constraint.cc.
template bool operations_research::sat::ScatteredIntegerVector::AddLinearExpressionMultiple< false > | ( | IntegerValue | multiplier, |
absl::Span< const glop::ColIndex > | cols, | ||
absl::Span< const IntegerValue > | coeffs, | ||
IntegerValue | max_coeff_magnitude ) |
Force instantations for tests.
Similar to Add() but for multiplier * terms.
Returns false if we encountered any integer overflow. If the template bool is false, we do not check for a bit of extra speed.
Since we have the norm, this avoid checking each products below.
Definition at line 110 of file linear_programming_constraint.cc.
void operations_research::sat::ScatteredIntegerVector::ClearAndResize | ( | int | size | ) |
This must be called with the correct size before any other functions are used.
Definition at line 79 of file linear_programming_constraint.cc.
void operations_research::sat::ScatteredIntegerVector::ConvertToCutData | ( | absl::int128 | rhs, |
absl::Span< const IntegerVariable > | integer_variables, | ||
absl::Span< const double > | lp_solution, | ||
IntegerTrail * | integer_trail, | ||
CutData * | result ) |
Definition at line 228 of file linear_programming_constraint.cc.
LinearConstraint operations_research::sat::ScatteredIntegerVector::ConvertToLinearConstraint | ( | absl::Span< const IntegerVariable > | integer_variables, |
IntegerValue | upper_bound, | ||
std::optional< std::pair< IntegerVariable, IntegerValue > > | extra_term = std::nullopt ) |
This is not const only because non_zeros is sorted. Note that sorting the non-zeros make the result deterministic whether or not we were in sparse mode.
We first do one pass to compute the exact size and not overallocate.
Allocate once.
Copy terms.
Definition at line 169 of file linear_programming_constraint.cc.
std::vector< std::pair< glop::ColIndex, IntegerValue > > operations_research::sat::ScatteredIntegerVector::GetTerms | ( | ) |
Similar to ConvertToLinearConstraint().
Definition at line 258 of file linear_programming_constraint.cc.
|
inline |
Definition at line 104 of file linear_programming_constraint.h.
|
inline |
We only provide the const [].
Definition at line 100 of file linear_programming_constraint.h.