Class representing a row of the linear program, i.e.
More...
#include <agrum/CN/LpInterface.h>
|
template<typename GUM_SCALAR > |
class | LpInterface |
|
std::ostream & | operator<< (std::ostream &out, const LpRow &row) |
| Overload of << to use with output streams ( such as std::cout << ). More...
|
|
Class representing a row of the linear program, i.e.
an inequality.
- Author
- Matthieu HOURBRACQ and Pierre-Henri WUILLEMIN()
Definition at line 499 of file LpInterface.h.
◆ LpRow() [1/4]
gum::credal::lp::LpRow::LpRow |
( |
const LpExpr & |
expr, |
|
|
const std::vector< LpCol > & |
cols |
|
) |
| |
Constructor from an expression and the address of the vector of variables of the problem.
class LpRow
- Parameters
-
expr | the constant reference to the expression to convert into rows ( inequalities ). |
cols | the constant reference to the vector of variables of the problem. |
Definition at line 513 of file LpInterface.cpp.
515 if (expr._ileft_ && !expr._iright_) {
516 _coeffs_ =
new HashTable< LpCol, double >(*expr._mCoeffs_);
518 for (
const auto& col: cols) {
519 double col_coeff = 0.;
522 if (expr._lCoeffs_->exists(col)) col_coeff = expr._lCoeffs_->operator[](col);
524 _coeffs_->getWithDefault(col, 0.) -= col_coeff;
527 _cste_ = expr._mValue_ - expr._lValue_;
528 }
else if (expr._iright_ && !expr._ileft_) {
529 _coeffs_ =
new HashTable< LpCol, double >(*expr._rCoeffs_);
531 for (
const auto& col: cols) {
532 double col_coeff = 0;
535 if (expr._mCoeffs_->exists(col)) col_coeff = expr._mCoeffs_->operator[](col);
537 _coeffs_->getWithDefault(col, 0.) -= col_coeff;
540 _cste_ = expr._rValue_ - expr._mValue_;
543 "expr : " << expr.toString() <<
"is not a valid inequality; no <= detected");
547 "expr : " << expr.toString()
548 <<
"is not a valid inequality; " 549 "no variable in inequality, " 552 GUM_CONSTRUCTOR(
LpRow);
double _cste_
The constant of the linear inequality.
LpRow(const LpExpr &expr, const std::vector< LpCol > &cols)
Constructor from an expression and the address of the vector of variables of the problem.
HashTable< LpCol, double > * _coeffs_
The coefficients of the variables of the linear inequality.
#define GUM_ERROR(type, msg)
◆ LpRow() [2/4]
gum::credal::lp::LpRow::LpRow |
( |
LpExpr && |
expr, |
|
|
const std::vector< LpCol > & |
cols |
|
) |
| |
Move constructor from a temporary expression and the address of the vector of variables of the problem.
- Parameters
-
expr | the temporary expression to move into rows ( inequalities ). |
cols | the constant reference to the vector of variables of the problem. |
Definition at line 555 of file LpInterface.cpp.
557 if (expr._ileft_ && !expr._iright_) {
560 for (
const auto& col: cols) {
561 double col_coeff = 0;
563 if (expr._lCoeffs_->exists(col)) col_coeff = expr._lCoeffs_->operator[](col);
565 _coeffs_->getWithDefault(col, 0.) -= col_coeff;
568 _cste_ = expr._mValue_ - expr._lValue_;
569 }
else if (expr._iright_ && !expr._ileft_) {
572 for (
const auto& col: cols) {
573 double col_coeff = 0;
575 if (expr._mCoeffs_->exists(col)) col_coeff = expr._mCoeffs_->operator[](col);
577 _coeffs_->getWithDefault(col, 0.) -= col_coeff;
580 _cste_ = expr._rValue_ - expr._mValue_;
583 "expr : " << expr.toString() <<
"is not a valid inequality; no <= detected");
587 "expr : " << expr.toString()
588 <<
"is not a valid inequality; " 589 "no variable in inequality, " 592 GUM_CONSTRUCTOR(
LpRow);
void swap(HashTable< LpCol, double > *&a, HashTable< LpCol, double > *&b)
Swap the addresses of two pointers to hashTables.
double _cste_
The constant of the linear inequality.
LpRow(const LpExpr &expr, const std::vector< LpCol > &cols)
Constructor from an expression and the address of the vector of variables of the problem.
HashTable< LpCol, double > * _coeffs_
The coefficients of the variables of the linear inequality.
#define GUM_ERROR(type, msg)
◆ LpRow() [3/4]
gum::credal::lp::LpRow::LpRow |
( |
const LpRow & |
row | ) |
|
Copy constructor.
- Parameters
-
row | The constant reference to the row to be copied. |
Definition at line 595 of file LpInterface.cpp.
596 _cste_(row._cste_),
_coeffs_(
new HashTable< LpCol, double >(*row._coeffs_)) {
double _cste_
The constant of the linear inequality.
LpRow(const LpExpr &expr, const std::vector< LpCol > &cols)
Constructor from an expression and the address of the vector of variables of the problem.
HashTable< LpCol, double > * _coeffs_
The coefficients of the variables of the linear inequality.
◆ LpRow() [4/4]
gum::credal::lp::LpRow::LpRow |
( |
LpRow && |
row | ) |
|
Move copy constructor from temporary.
- Parameters
-
row | The temporary row to be copied. |
Definition at line 600 of file LpInterface.cpp.
601 row._coeffs_ =
nullptr;
double _cste_
The constant of the linear inequality.
LpRow(const LpExpr &expr, const std::vector< LpCol > &cols)
Constructor from an expression and the address of the vector of variables of the problem.
HashTable< LpCol, double > * _coeffs_
The coefficients of the variables of the linear inequality.
◆ ~LpRow()
gum::credal::lp::LpRow::~LpRow |
( |
| ) |
|
Default destructor.
Definition at line 606 of file LpInterface.cpp.
609 GUM_DESTRUCTOR(
LpRow);
LpRow(const LpExpr &expr, const std::vector< LpCol > &cols)
Constructor from an expression and the address of the vector of variables of the problem.
HashTable< LpCol, double > * _coeffs_
The coefficients of the variables of the linear inequality.
◆ operator=() [1/2]
LpRow & gum::credal::lp::LpRow::operator= |
( |
const LpRow & |
row | ) |
|
- Parameters
-
row | The constant reference to the row to be copied. |
Definition at line 612 of file LpInterface.cpp.
double _cste_
The constant of the linear inequality.
HashTable< LpCol, double > * _coeffs_
The coefficients of the variables of the linear inequality.
◆ operator=() [2/2]
LpRow & gum::credal::lp::LpRow::operator= |
( |
LpRow && |
row | ) |
|
- Parameters
-
row | The temporary row to be moved to this. |
Definition at line 618 of file LpInterface.cpp.
void swap(HashTable< LpCol, double > *&a, HashTable< LpCol, double > *&b)
Swap the addresses of two pointers to hashTables.
double _cste_
The constant of the linear inequality.
HashTable< LpCol, double > * _coeffs_
The coefficients of the variables of the linear inequality.
◆ toString()
std::string gum::credal::lp::LpRow::toString |
( |
| ) |
const |
Get the string representation of a calling row.
- Returns
- The string representation of the calling row.
Definition at line 629 of file LpInterface.cpp.
630 std::ostringstream s;
636 if (elt.second > 0) {
637 if (elt.second != 1) {
638 s <<
" +" << elt.second <<
"*" << elt.first.toString();
640 s <<
" +" << elt.first.toString();
643 if (elt.second < 0) {
644 if (elt.second != -1) {
645 s <<
" " << elt.second <<
"*" << elt.first.toString();
647 s <<
" -" << elt.first.toString();
double _cste_
The constant of the linear inequality.
HashTable< LpCol, double > * _coeffs_
The coefficients of the variables of the linear inequality.
◆ LpInterface
template<typename GUM_SCALAR >
◆ operator<<
std::ostream& operator<< |
( |
std::ostream & |
out, |
|
|
const LpRow & |
row |
|
) |
| |
|
friend |
Overload of <<
to use with output streams ( such as std::cout << ).
- Parameters
-
out | the reference to the caller, i.e. left side of << . |
row | the constant reference to the row whose representation we want. |
- Returns
- The address of the caller.
Definition at line 624 of file LpInterface.cpp.
625 out << row.toString();
◆ _coeffs_
The coefficients of the variables of the linear inequality.
Definition at line 590 of file LpInterface.h.
◆ _cste_
double gum::credal::lp::LpRow::_cste_ |
|
private |
The constant of the linear inequality.
Definition at line 586 of file LpInterface.h.
The documentation for this class was generated from the following files: