SCIP++ refs/heads/main
 
Loading...
Searching...
No Matches
scippp::LinExpr Class Reference

Represents a linear combination of variables plus a constant term. More...

#include <lin_expr.hpp>

Public Member Functions

 LinExpr ()=default
 Sets constant term and linear combination to zero.
 
template<typename Arithmetic , std::enable_if_t< std::is_arithmetic_v< Arithmetic >, bool > = true>
 LinExpr (Arithmetic constant)
 Creates a linear expression with no variables.
 
 LinExpr (const Var &var)
 Creates a linear expression with zero as constant the given variable with coefficient one.
 
double getConstant () const
 Returns the constant term of the expression.
 
LinExproperator*= (double factor)
 Multiply all coefficients.
 
LinExproperator+= (const LinExpr &expr)
 Add another linear expression to this.
 
LinExproperator-= (const LinExpr &expr)
 Subtract another expression from this.
 

Friends

class Model
 

Detailed Description

Represents a linear combination of variables plus a constant term.

Since
1.0.0

Definition at line 13 of file lin_expr.hpp.

Constructor & Destructor Documentation

◆ LinExpr() [1/3]

scippp::LinExpr::LinExpr ( )
default

Sets constant term and linear combination to zero.

Since
1.0.0

◆ LinExpr() [2/3]

template<typename Arithmetic , std::enable_if_t< std::is_arithmetic_v< Arithmetic >, bool > = true>
scippp::LinExpr::LinExpr ( Arithmetic  constant)
inline

Creates a linear expression with no variables.

Since
1.0.0
Remarks
This is on purpose not an explicit c'tor to allow expressions like x <= 1.
Template Parameters
Arithmetictype that will be casted to double.
Warning
Arithmetic is casted to double without creating a narrowing warning!
Parameters
constantConstant term to set.

Definition at line 37 of file lin_expr.hpp.

◆ LinExpr() [3/3]

scippp::LinExpr::LinExpr ( const Var var)

Creates a linear expression with zero as constant the given variable with coefficient one.

Since
1.0.0
Remarks
This is on purpose not an explicit c'tor to allow expressions like x <= 1.
Parameters
varVariable to store with coefficient one in the expression.

Member Function Documentation

◆ getConstant()

double scippp::LinExpr::getConstant ( ) const

Returns the constant term of the expression.

Since
1.0.0
Returns
the constant term of the expression.

◆ operator*=()

LinExpr & scippp::LinExpr::operator*= ( double  factor)

Multiply all coefficients.

Since
1.0.0
Parameters
factorto multiply all coefficients with.
Returns
Scaled expression.

◆ operator+=()

LinExpr & scippp::LinExpr::operator+= ( const LinExpr expr)

Add another linear expression to this.

Since
1.0.0
Parameters
exprOther linear expression to add.
Returns
Updated sum.

◆ operator-=()

LinExpr & scippp::LinExpr::operator-= ( const LinExpr expr)

Subtract another expression from this.

Since
1.0.0
Parameters
exprRight-hand-side of the subtraction.
Returns
Updated expression.

Friends And Related Function Documentation

◆ Model

friend class Model
friend

Definition at line 14 of file lin_expr.hpp.


The documentation for this class was generated from the following file: