LinExpr¶
This class is used to represent linear expressions in the modeling interface of idol.
It consists in a set of linear terms which represent products of keys (typically, variables) and scalars.
Example
In this example, we create a linear expression representing the following linear expression.
\[3 x_0 + 2 x_1\]
auto x = model.add_vars(Dim<1>(2), 0, Inf, Continuous, "x");
LinExpr lin_expr = 3 * x[0] + 2 * x[1];
Doxygen¶
-
template<class KeyT = idol::Var, class ValueT = double>
class LinExpr : public idol::SparseVector<idol::Var, double>¶ - Template Parameters:
KeyT – the class representing keys
Subclassed by idol::QuadExpr< idol::Var, idol::QuadExpr< idol::Var > >, idol::QuadExpr< idol::Var >, idol::QuadExpr< idol::Var, double >, idol::QuadExpr< KeyT, ValueT >
Public Types
-
using iterator = typename map_t::iterator¶
-
using const_iterator = typename map_t::const_iterator¶
Public Functions
-
LinExpr() = default¶
-
virtual SparseVector &operator+=(const SparseVector &t_vector)¶
-
virtual SparseVector &operator-=(const SparseVector &t_vector)¶
-
virtual SparseVector &operator*=(std::conditional_t<std::is_arithmetic_v<ValueT>, ValueT, double> t_scalar)¶
-
virtual SparseVector &operator/=(std::conditional_t<std::is_arithmetic_v<ValueT>, ValueT, double> t_scalar)¶
-
SparseVector operator-() const¶
-
inline unsigned int size() const¶
-
inline bool empty() const¶
-
inline bool has_index(const IndexT &t_index) const¶
-
virtual bool is_zero(double t_tolerance) const¶
-
inline void remove(const IndexT &t_index)¶
-
inline void clear()¶
-
inline void reserve(unsigned int t_capacity)¶
-
inline const_iterator begin() const¶
-
inline const_iterator end() const¶
-
inline const_iterator cbegin() const¶
-
inline const_iterator cend() const¶
-
SparseVector &merge_without_conflict(const SparseVector &t_vec)¶