Limbo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
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_type
term_type
 term type
 
typedef Variable
< coefficient_value_type
variable_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 More...
 
LinearExpressionoperator= (LinearExpression const &rhs)
 assignment More...
 
 ~LinearExpression ()
 destructor
 
void swap (LinearExpression &rhs)
 swap with an expression More...
 
std::vector< term_type > const & terms () const
 
void clear ()
 clear expression
 
void reserve (unsigned int n)
 reserve space for terms More...
 
coefficient_value_type constant () const
 
LinearExpressionsetConstant (coefficient_value_type constant)
 set constant term More...
 
LinearExpressionincrementConstant (coefficient_value_type constant)
 increment constant term More...
 
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 More...
 

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_type
operator< (LinearExpression const &expr, coefficient_value_type rhs)
 overload < More...
 
LinearConstraint
< coefficient_value_type
operator<= (LinearExpression const &expr, coefficient_value_type rhs)
 overload <=, same as < More...
 
LinearConstraint
< coefficient_value_type
operator> (LinearExpression const &expr, coefficient_value_type rhs)
 overload > More...
 
LinearConstraint
< coefficient_value_type
operator>= (LinearExpression const &expr, coefficient_value_type rhs)
 overload >=, same as > More...
 
LinearConstraint
< coefficient_value_type
operator== (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 76 of file Solvers.h.

Constructor & Destructor Documentation

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.

Member Function Documentation

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

Definition at line 666 of file Solvers.h.

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.

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.

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

self-negation

Returns
the object

Definition at line 884 of file Solvers.h.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

Friends And Related Function Documentation

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.


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