Limbo 3.5.4
Loading...
Searching...
No Matches
limbo::solvers::LinearExpression< T > Class Template Reference

Describe linear expressions in optimization problem. More...

#include <Solvers.h>

Public Types

typedef T coefficient_value_type
 coefficient type
typedef LinearTerm< coefficient_value_typeterm_type
 term type
typedef Variable< coefficient_value_typevariable_type
 variable type

Public Member Functions

 LinearExpression ()
 constructor
 LinearExpression (term_type const &term, coefficient_value_type constant=0)
 constructor
 LinearExpression (LinearExpression const &rhs)
 copy constructor
LinearExpressionoperator= (LinearExpression const &rhs)
 assignment
 ~LinearExpression ()
 destructor
void swap (LinearExpression &rhs)
 swap with an expression
std::vector< term_type > const & terms () const
void clear ()
 clear expression
void reserve (unsigned int n)
 reserve space for terms
coefficient_value_type constant () const
LinearExpressionsetConstant (coefficient_value_type constant)
 set constant term
LinearExpressionincrementConstant (coefficient_value_type constant)
 increment constant term
LinearExpressionoperator+= (coefficient_value_type constant)
LinearExpressionoperator+= (term_type const &term)
LinearExpressionoperator+= (LinearExpression const &expr)
LinearExpressionoperator-= (coefficient_value_type constant)
LinearExpressionoperator-= (term_type term)
LinearExpressionoperator-= (LinearExpression const &expr)
LinearExpressionoperator*= (coefficient_value_type c)
LinearExpressionoperator/= (coefficient_value_type c)
LinearExpression operator- () const
LinearExpressionnegate ()
void simplify ()
 simplify expression by merge terms of the same variables and remove terms with zero coefficients

Protected Member Functions

void copy (LinearExpression const &rhs)
 copy object

Protected Attributes

std::vector< term_typem_vTerm
 linear expression with terms
coefficient_value_type m_constant
 constant term for the linear expression

Friends

LinearExpression operator+ (LinearExpression const &expr, coefficient_value_type constant)
LinearExpression operator+ (LinearExpression const &expr, term_type const &term)
LinearExpression operator+ (coefficient_value_type constant, LinearExpression const &expr)
LinearExpression operator+ (term_type const &term, LinearExpression const &expr)
LinearExpression operator+ (LinearExpression const &expr1, LinearExpression const &expr2)
LinearExpression operator- (LinearExpression const &expr, coefficient_value_type constant)
LinearExpression operator- (LinearExpression const &expr, term_type const &term)
LinearExpression operator- (coefficient_value_type constant, LinearExpression const &expr)
LinearExpression operator- (term_type const &term, LinearExpression const &expr)
LinearExpression operator- (LinearExpression const &expr1, LinearExpression const &expr2)
LinearExpression operator* (LinearExpression const &expr, coefficient_value_type c)
LinearExpression operator* (coefficient_value_type c, LinearExpression const &expr)
LinearExpression operator/ (LinearExpression const &expr, coefficient_value_type c)
LinearConstraint< coefficient_value_typeoperator< (LinearExpression const &expr, coefficient_value_type rhs)
 overload <
LinearConstraint< coefficient_value_typeoperator<= (LinearExpression const &expr, coefficient_value_type rhs)
 overload <=, same as <
LinearConstraint< coefficient_value_typeoperator> (LinearExpression const &expr, coefficient_value_type rhs)
 overload >
LinearConstraint< coefficient_value_typeoperator>= (LinearExpression const &expr, coefficient_value_type rhs)
 overload >=, same as >
LinearConstraint< coefficient_value_typeoperator== (LinearExpression const &expr, coefficient_value_type rhs)

Detailed Description

template<typename T>
class limbo::solvers::LinearExpression< T >

Describe linear expressions in optimization problem.

Template Parameters
Tcoefficient type

Definition at line 606 of file Solvers.h.

Member Typedef Documentation

◆ coefficient_value_type

template<typename T>
typedef T limbo::solvers::LinearExpression< T >::coefficient_value_type

coefficient type

Definition at line 610 of file Solvers.h.

◆ term_type

template<typename T>
typedef LinearTerm<coefficient_value_type> limbo::solvers::LinearExpression< T >::term_type

term type

Definition at line 612 of file Solvers.h.

◆ variable_type

template<typename T>
typedef Variable<coefficient_value_type> limbo::solvers::LinearExpression< T >::variable_type

variable type

Definition at line 614 of file Solvers.h.

Constructor & Destructor Documentation

◆ LinearExpression() [1/3]

template<typename T>
limbo::solvers::LinearExpression< T >::LinearExpression ( )
inline

constructor

Definition at line 617 of file Solvers.h.

◆ LinearExpression() [2/3]

template<typename T>
limbo::solvers::LinearExpression< T >::LinearExpression ( term_type const & term,
coefficient_value_type constant = 0 )
inline

constructor

Definition at line 623 of file Solvers.h.

◆ LinearExpression() [3/3]

template<typename T>
limbo::solvers::LinearExpression< T >::LinearExpression ( LinearExpression< T > const & rhs)
inline

copy constructor

Parameters
rhsright hand side

Definition at line 630 of file Solvers.h.

◆ ~LinearExpression()

template<typename T>
limbo::solvers::LinearExpression< T >::~LinearExpression ( )
inline

destructor

Definition at line 643 of file Solvers.h.

Member Function Documentation

◆ clear()

template<typename T>
void limbo::solvers::LinearExpression< T >::clear ( )
inline

clear expression

Definition at line 657 of file Solvers.h.

◆ constant()

template<typename T>
coefficient_value_type limbo::solvers::LinearExpression< T >::constant ( ) const
inline
Returns
constant term

Definition at line 666 of file Solvers.h.

◆ copy()

template<typename T>
void limbo::solvers::LinearExpression< T >::copy ( LinearExpression< T > const & rhs)
inlineprotected

copy object

Parameters
rhsright hand side

Definition at line 969 of file Solvers.h.

◆ incrementConstant()

template<typename T>
LinearExpression & limbo::solvers::LinearExpression< T >::incrementConstant ( coefficient_value_type constant)
inline

increment constant term

Parameters
constantconstant
Returns
result object

Definition at line 678 of file Solvers.h.

◆ negate()

template<typename T>
LinearExpression & limbo::solvers::LinearExpression< T >::negate ( )
inline

self-negation

Returns
the object

Definition at line 884 of file Solvers.h.

◆ operator*=()

template<typename T>
LinearExpression & limbo::solvers::LinearExpression< T >::operator*= ( coefficient_value_type c)
inline

overload multiply assignment

Parameters
cconstant value
Returns
the object

Definition at line 848 of file Solvers.h.

◆ operator+=() [1/3]

template<typename T>
LinearExpression & limbo::solvers::LinearExpression< T >::operator+= ( coefficient_value_type constant)
inline

overload plus assignment

Parameters
constantright hand side is a constant
Returns
the object

Definition at line 733 of file Solvers.h.

◆ operator+=() [2/3]

template<typename T>
LinearExpression & limbo::solvers::LinearExpression< T >::operator+= ( LinearExpression< T > const & expr)
inline

overload plus assignment for expression

Parameters
exprright hand side is an expression
Returns
the object

Definition at line 749 of file Solvers.h.

◆ operator+=() [3/3]

template<typename T>
LinearExpression & limbo::solvers::LinearExpression< T >::operator+= ( term_type const & term)
inline

overload plus assignment

Parameters
termright hand side is a term
Returns
the object

Definition at line 741 of file Solvers.h.

◆ operator-()

template<typename T>
LinearExpression limbo::solvers::LinearExpression< T >::operator- ( ) const
inline

overload negation

Returns
a copy of new object

Definition at line 877 of file Solvers.h.

◆ operator-=() [1/3]

template<typename T>
LinearExpression & limbo::solvers::LinearExpression< T >::operator-= ( coefficient_value_type constant)
inline

overload minus assignment

Parameters
constantright hand side is a constant
Returns
the object

Definition at line 804 of file Solvers.h.

◆ operator-=() [2/3]

template<typename T>
LinearExpression & limbo::solvers::LinearExpression< T >::operator-= ( LinearExpression< T > const & expr)
inline

overload minus assignment for expression

Parameters
exprright hand side is an expression
Returns
the object

Definition at line 820 of file Solvers.h.

◆ operator-=() [3/3]

template<typename T>
LinearExpression & limbo::solvers::LinearExpression< T >::operator-= ( term_type term)
inline

overload minus assignment

Parameters
termright hand side is a term
Returns
the object

Definition at line 812 of file Solvers.h.

◆ operator/=()

template<typename T>
LinearExpression & limbo::solvers::LinearExpression< T >::operator/= ( coefficient_value_type c)
inline

overload divide assignment

Parameters
cconstant value
Returns
the object

Definition at line 868 of file Solvers.h.

◆ operator=()

template<typename T>
LinearExpression & limbo::solvers::LinearExpression< T >::operator= ( LinearExpression< T > const & rhs)
inline

assignment

Parameters
rhsright hand side

Definition at line 636 of file Solvers.h.

◆ reserve()

template<typename T>
void limbo::solvers::LinearExpression< T >::reserve ( unsigned int n)
inline

reserve space for terms

Parameters
nnumber of terms

Definition at line 664 of file Solvers.h.

◆ setConstant()

template<typename T>
LinearExpression & limbo::solvers::LinearExpression< T >::setConstant ( coefficient_value_type constant)
inline

set constant term

Parameters
constantconstant
Returns
result object

Definition at line 670 of file Solvers.h.

◆ simplify()

template<typename T>
void limbo::solvers::LinearExpression< T >::simplify ( )
inline

simplify expression by merge terms of the same variables and remove terms with zero coefficients

Definition at line 929 of file Solvers.h.

◆ swap()

template<typename T>
void limbo::solvers::LinearExpression< T >::swap ( LinearExpression< T > & rhs)
inline

swap with an expression

Parameters
rhsright hand side

Definition at line 649 of file Solvers.h.

◆ terms()

template<typename T>
std::vector< term_type > const & limbo::solvers::LinearExpression< T >::terms ( ) const
inline
Returns
terms

Definition at line 655 of file Solvers.h.

◆ operator* [1/2]

template<typename T>
LinearExpression operator* ( coefficient_value_type c,
LinearExpression< T > const & expr )
friend

overload multiply in case of c*expr

Parameters
cconstant value
exprexpression
Returns
the object of expr

Definition at line 841 of file Solvers.h.

◆ operator* [2/2]

template<typename T>
LinearExpression operator* ( LinearExpression< T > const & expr,
coefficient_value_type c )
friend

overload multiply

Parameters
exprexpression
cconstant value
Returns
the object

Definition at line 831 of file Solvers.h.

◆ operator+ [1/5]

template<typename T>
LinearExpression operator+ ( coefficient_value_type constant,
LinearExpression< T > const & expr )
friend

overload plus constant+expr

Parameters
constantconstant
exprexpression
Returns
result object

Definition at line 708 of file Solvers.h.

◆ operator+ [2/5]

template<typename T>
LinearExpression operator+ ( LinearExpression< T > const & expr,
coefficient_value_type constant )
friend

overload plus

Parameters
exprexpression
constantright hand side is a constant
Returns
result object

Definition at line 688 of file Solvers.h.

◆ operator+ [3/5]

template<typename T>
LinearExpression operator+ ( LinearExpression< T > const & expr,
term_type const & term )
friend

overload plus

Parameters
exprexpression
termright hand side is a term
Returns
result object

Definition at line 698 of file Solvers.h.

◆ operator+ [4/5]

template<typename T>
LinearExpression operator+ ( LinearExpression< T > const & expr1,
LinearExpression< T > const & expr2 )
friend

overload plus expr+expr

Parameters
expr1expression
expr2expression
Returns
result object

Definition at line 724 of file Solvers.h.

◆ operator+ [5/5]

template<typename T>
LinearExpression operator+ ( term_type const & term,
LinearExpression< T > const & expr )
friend

overload plus term+expr

Parameters
terma term
exprexpression
Returns
result object

Definition at line 716 of file Solvers.h.

◆ operator- [1/5]

template<typename T>
LinearExpression operator- ( coefficient_value_type constant,
LinearExpression< T > const & expr )
friend

overload minus constant-expr

Parameters
constantconstant
exprexpression
Returns
the object

Definition at line 779 of file Solvers.h.

◆ operator- [2/5]

template<typename T>
LinearExpression operator- ( LinearExpression< T > const & expr,
coefficient_value_type constant )
friend

overload minus

Parameters
exprexpression
constantright hand side is a constant
Returns
the object

Definition at line 759 of file Solvers.h.

◆ operator- [3/5]

template<typename T>
LinearExpression operator- ( LinearExpression< T > const & expr,
term_type const & term )
friend

overload minus

Parameters
exprexpression
termright hand side is a term
Returns
the object

Definition at line 769 of file Solvers.h.

◆ operator- [4/5]

template<typename T>
LinearExpression operator- ( LinearExpression< T > const & expr1,
LinearExpression< T > const & expr2 )
friend

overload minus

Parameters
expr1expression
expr2expression
Returns
the object

Definition at line 795 of file Solvers.h.

◆ operator- [5/5]

template<typename T>
LinearExpression operator- ( term_type const & term,
LinearExpression< T > const & expr )
friend

overload minus term-expr

Parameters
termterm
exprexpression
Returns
the object

Definition at line 787 of file Solvers.h.

◆ operator/

template<typename T>
LinearExpression operator/ ( LinearExpression< T > const & expr,
coefficient_value_type c )
friend

overload divide

Parameters
exprexpression
cconstant value
Returns
the object

Definition at line 859 of file Solvers.h.

◆ operator<

template<typename T>
LinearConstraint< coefficient_value_type > operator< ( LinearExpression< T > const & expr,
coefficient_value_type rhs )
friend

overload <

Parameters
exprlinear expression
rhsright hand side constant

Definition at line 894 of file Solvers.h.

◆ operator<=

template<typename T>
LinearConstraint< coefficient_value_type > operator<= ( LinearExpression< T > const & expr,
coefficient_value_type rhs )
friend

overload <=, same as <

Parameters
exprlinear expression
rhsright hand side constant

Definition at line 901 of file Solvers.h.

◆ operator==

template<typename T>
LinearConstraint< coefficient_value_type > operator== ( LinearExpression< T > const & expr,
coefficient_value_type rhs )
friend

overload ==

Parameters
exprlinear expression
rhsright hand side constant

Definition at line 922 of file Solvers.h.

◆ operator>

template<typename T>
LinearConstraint< coefficient_value_type > operator> ( LinearExpression< T > const & expr,
coefficient_value_type rhs )
friend

overload >

Parameters
exprlinear expression
rhsright hand side constant

Definition at line 908 of file Solvers.h.

◆ operator>=

template<typename T>
LinearConstraint< coefficient_value_type > operator>= ( LinearExpression< T > const & expr,
coefficient_value_type rhs )
friend

overload >=, same as >

Parameters
exprlinear expression
rhsright hand side constant

Definition at line 915 of file Solvers.h.

Member Data Documentation

◆ m_constant

template<typename T>
coefficient_value_type limbo::solvers::LinearExpression< T >::m_constant
protected

constant term for the linear expression

Definition at line 976 of file Solvers.h.

◆ m_vTerm

template<typename T>
std::vector<term_type> limbo::solvers::LinearExpression< T >::m_vTerm
protected

linear expression with terms

Definition at line 975 of file Solvers.h.


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