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 500 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 521 of file LpInterface.cpp.
524 if (expr.ileft__ && !expr.iright__) {
525 coeffs__ =
new HashTable< LpCol, double >(*expr.mCoeffs__);
527 for (
const auto& col: cols) {
528 double col_coeff = 0.;
531 if (expr.lCoeffs__->exists(col))
532 col_coeff = expr.lCoeffs__->operator[](col);
534 coeffs__->getWithDefault(col, 0.) -= col_coeff;
537 cste__ = expr.mValue__ - expr.lValue__;
538 }
else if (expr.iright__ && !expr.ileft__) {
539 coeffs__ =
new HashTable< LpCol, double >(*expr.rCoeffs__);
541 for (
const auto& col: cols) {
542 double col_coeff = 0;
545 if (expr.mCoeffs__->exists(col))
546 col_coeff = expr.mCoeffs__->operator[](col);
548 coeffs__->getWithDefault(col, 0.) -= col_coeff;
551 cste__ = expr.rValue__ - expr.mValue__;
554 "expr : " << expr.toString()
555 <<
"is not a valid inequality; no <= detected");
559 "expr : " << expr.toString()
560 <<
"is not a valid inequality; " 561 "no variable in inequality, " 564 GUM_CONSTRUCTOR(
LpRow);
HashTable< LpCol, double > * coeffs__
The coefficients of the variables 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.
double cste__
The constant 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 567 of file LpInterface.cpp.
570 if (expr.ileft__ && !expr.iright__) {
573 for (
const auto& col: cols) {
574 double col_coeff = 0;
576 if (expr.lCoeffs__->exists(col))
577 col_coeff = expr.lCoeffs__->operator[](col);
579 coeffs__->getWithDefault(col, 0.) -= col_coeff;
582 cste__ = expr.mValue__ - expr.lValue__;
583 }
else if (expr.iright__ && !expr.ileft__) {
586 for (
const auto& col: cols) {
587 double col_coeff = 0;
589 if (expr.mCoeffs__->exists(col))
590 col_coeff = expr.mCoeffs__->operator[](col);
592 coeffs__->getWithDefault(col, 0.) -= col_coeff;
595 cste__ = expr.rValue__ - expr.mValue__;
598 "expr : " << expr.toString()
599 <<
"is not a valid inequality; no <= detected");
603 "expr : " << expr.toString()
604 <<
"is not a valid inequality; " 605 "no variable in inequality, " 608 GUM_CONSTRUCTOR(
LpRow);
void swap(HashTable< LpCol, double > *&a, HashTable< LpCol, double > *&b)
Swap the addresses of two pointers to hashTables.
HashTable< LpCol, double > * coeffs__
The coefficients of the variables 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.
double cste__
The constant 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 611 of file LpInterface.cpp.
613 coeffs__(
new HashTable< LpCol, double >(*row.coeffs__)) {
HashTable< LpCol, double > * coeffs__
The coefficients of the variables 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.
double cste__
The constant 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 617 of file LpInterface.cpp.
618 row.coeffs__ =
nullptr;
HashTable< LpCol, double > * coeffs__
The coefficients of the variables 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.
double cste__
The constant of the linear inequality.
◆ ~LpRow()
gum::credal::lp::LpRow::~LpRow |
( |
| ) |
|
Default destructor.
Definition at line 623 of file LpInterface.cpp.
626 GUM_DESTRUCTOR(
LpRow);
HashTable< LpCol, double > * coeffs__
The coefficients of the variables 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.
◆ 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 629 of file LpInterface.cpp.
HashTable< LpCol, double > * coeffs__
The coefficients of the variables of the linear inequality.
double cste__
The constant 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 635 of file LpInterface.cpp.
void swap(HashTable< LpCol, double > *&a, HashTable< LpCol, double > *&b)
Swap the addresses of two pointers to hashTables.
HashTable< LpCol, double > * coeffs__
The coefficients of the variables of the linear inequality.
double cste__
The constant 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 646 of file LpInterface.cpp.
647 std::ostringstream s;
653 if (elt.second > 0) {
654 if (elt.second != 1) {
655 s <<
" +" << elt.second <<
"*" << elt.first.toString();
657 s <<
" +" << elt.first.toString();
660 if (elt.second < 0) {
661 if (elt.second != -1) {
662 s <<
" " << elt.second <<
"*" << elt.first.toString();
664 s <<
" -" << elt.first.toString();
HashTable< LpCol, double > * coeffs__
The coefficients of the variables of the linear inequality.
double cste__
The constant 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 641 of file LpInterface.cpp.
642 out << row.toString();
◆ coeffs__
The coefficients of the variables of the linear inequality.
Definition at line 592 of file LpInterface.h.
◆ cste__
double gum::credal::lp::LpRow::cste__ |
|
private |
The constant of the linear inequality.
Definition at line 588 of file LpInterface.h.
The documentation for this class was generated from the following files: