6#include "scippp/var.hpp"
9namespace LinExpression {
10struct CheckInternalsUsingFriendStruct;
20 friend struct LinExpression::CheckInternalsUsingFriendStruct;
22 double m_constant { 0.0 };
24 std::vector<Var> m_vars {};
26 std::vector<double> m_coeffs {};
42 template <
typename Arithmetic, std::enable_if_t<std::is_arithmetic_v<Arithmetic>,
bool> = true>
44 : m_constant { static_cast<double>(constant) }
68 LinExpr(std::initializer_list<Var> vars, std::initializer_list<double> coeffs);
76 template <std::
size_t N>
78 : m_vars { vars.begin(), vars.end() }
79 , m_coeffs(vars.size(), 1)
89 template <std::
size_t N>
90 LinExpr(
const std::array<Var, N>& vars, std::array<double, N>& coeffs)
91 : m_vars { vars.begin(), vars.end() }
92 , m_coeffs { coeffs.begin(), coeffs.end() }
108 LinExpr(
const std::vector<Var>& vars,
const std::vector<double>& coeffs);
Represents a linear combination of variables plus a constant term.
LinExpr & operator*=(double factor)
Multiply all coefficients.
LinExpr(const Var &var)
Creates a linear expression with zero as constant and the given variable with coefficient one.
LinExpr(const std::array< Var, N > &vars, std::array< double, N > &coeffs)
Creates a linear expression with zero as constant and the given variables with the provided coefficie...
LinExpr & operator+=(const LinExpr &expr)
Add another linear expression to this.
LinExpr(const std::vector< Var > &vars)
Creates a linear expression with zero as constant and the given variables with coefficient one.
LinExpr(std::initializer_list< Var > vars, std::initializer_list< double > coeffs)
Creates a linear expression with zero as constant and the given variables with the provided coefficie...
LinExpr(const std::array< Var, N > &vars)
Creates a linear expression with zero as constant and the given variables with coefficient one.
LinExpr(Arithmetic constant)
Creates a linear expression with no variables.
LinExpr & operator-=(const LinExpr &expr)
Subtract another expression from this.
LinExpr()=default
Sets constant term and linear combination to zero.
double getConstant() const
Returns the constant term of the expression.
LinExpr(std::initializer_list< Var > vars)
Creates a linear expression with zero as constant and the given variables with coefficient one.
LinExpr(const std::vector< Var > &vars, const std::vector< double > &coeffs)
Creates a linear expression with zero as constant and the given variables with the provided coefficie...
A SCIP optimization model.
LinExpr operator*(double factor, LinExpr rhs)
Scales a linear expression by a factor.
LinExpr operator+(LinExpr lhs, const LinExpr &rhs)
Creates a new linear expression as the sum of two.
LinExpr operator-(LinExpr lhs, const LinExpr &rhs)
Creates the new linear expression lhs - rhs.
Wrapper for a SCIP variable.