42#ifndef __LP_INTERFACE__H__
43#define __LP_INTERFACE__H__
67 template <
typename GUM_SCALAR >
89 explicit LpCol(
unsigned int id);
106 unsigned int id()
const;
231 template <
typename GUM_SCALAR >
260 LpExpr(
const LpExpr& expr,
bool copyLeft,
bool copyMiddle,
bool copyRight);
291 LpExpr(
LpExpr&& expr,
bool copyLeft,
bool copyMiddle,
bool copyRight);
331 template <
typename SCALAR >
372 template <
typename T >
405 template <
typename T >
423 template <
typename T1,
typename T2 >
425 template <
typename SCALAR >
508 template <
typename SCALAR >
522 template <
typename GUM_SCALAR >
538 LpRow(
const LpExpr& expr,
const std::vector< LpCol >& cols);
549 LpRow(
LpExpr&& expr,
const std::vector< LpCol >& cols);
593 friend std::ostream&
operator<<(std::ostream& out,
623 template <
typename GUM_SCALAR >
675 template <
typename T >
693 std::vector< LpCol >
addCols(
const unsigned int& cols);
742 std::vector< std::vector< GUM_SCALAR > >
solve();
748 std::vector< LpCol >
getCols()
const;
819 template <
typename T2 >
821 template <
typename T2 >
853 template <
typename T1, forb
idden_type< T1, LpExpr > = 0 >
855 template <
typename T1, forb
idden_type< T1, LpExpr > = 0 >
861 template <
typename T2, forb
idden_type< T2, LpExpr > = 0 >
867 template <
typename T1, forb
idden_type< T1, LpExpr > = 0, forb
idden_type< T1, LpCol > = 0 >
891 template <
typename T2 >
893 template <
typename T2 >
925 template <
typename T1, forb
idden_type< T1, LpExpr > = 0 >
927 template <
typename T1, forb
idden_type< T1, LpExpr > = 0 >
940 template <
typename T2, forb
idden_type< T2, LpExpr > = 0 >
953 template <
typename T1, forb
idden_type< T1, LpExpr > = 0, forb
idden_type< T1, LpCol > = 0 >
971 template <
typename SCALAR >
985 template <
typename SCALAR >
1014 template <
typename T2 >
1016 template <
typename T2 >
1018 template <
typename T1, forb
idden_type< T1, LpExpr& > = 0, forb
idden_type< T1, LpCol& > = 0 >
1020 template <
typename T1, forb
idden_type< T1, LpExpr& > = 0, forb
idden_type< T1, LpCol& > = 0 >
1023 template <
typename T2 >
1025 template <
typename T2 >
1027 template <
typename T1, forb
idden_type< T1, LpExpr > = 0, forb
idden_type< T1, LpCol > = 0 >
1029 template <
typename T1, forb
idden_type< T1, LpExpr > = 0, forb
idden_type< T1, LpCol > = 0 >
1042#ifndef GUM_NO_INLINE
Class to include at least once this header.
All hash functions should inherit from this class.
virtual Size operator()(const credal::lp::LpCol &key) const override final
Overload of operator () to compute hash of a variable LpCol.
static Size castToSize(const credal::lp::LpCol &key)
Returns the value of a key as a Size.
This class should be useless as only its specializations should be used.
The class for generic Hash Tables.
Class representing a variable ( a column ) of a linear program, i.e.
LpCol(unsigned int id)
Default constructor.
bool operator!=(const LpCol &col) const
Opposite of equality != test between two variables.
LpCol & operator=(const LpCol &col)
Assignment operator = by copy.
bool operator<(const LpCol &col) const
Test of ordering < between two variables.
std::string toString() const
Get the string representation of a calling variable.
friend std::ostream & operator<<(std::ostream &out, const LpCol &col)
Overload of << to use with output streams ( such as std::cout << ).
unsigned int id() const
Variable id accessor.
~LpCol()
Default destructor.
unsigned int _id_
Variable id.
bool operator==(const LpCol &col) const
Test of equality == between two variables.
Class representing a linear expression.
LpExpr & operator+=(const LpCol &rhs)
Compound assignment operator += with a variable.
double _rValue_
The constant on the right side L : L <= M <= R.
bool _ileft_
True if this expression has a non-empty left side L : L <= M <= R .
bool _imiddle_
True if this expression has a non-empty middle side M ( the default ) : L <= M <= R .
LpExpr & operator-=(const LpCol &rhs)
Compound assignment operator -= with a variable.
HashTable< LpCol, double > * _lCoeffs_
The coefficients of each variable on the left side L : L <= M <= R.
LpExpr()
Default constructor.
std::string toString() const
Get the string representation of a calling expression.
void clear()
Clear all data of the calling expression as if it was constructed.
static LpExpr multiply(const SCALAR &lhs, const LpCol &rhs)
bool _iright_
True if this expression has a non-empty right side R : L <= M <= R .
static LpExpr lessThan(T1 &&lhs, T2 &&rhs)
HashTable< LpCol, double > * _mCoeffs_
The coefficients of each variable on the middle side L : L <= M <= R.
~LpExpr()
Default destructor.
HashTable< LpCol, double > * _rCoeffs_
The coefficients of each variable on the right side L : L <= M <= R.
double _mValue_
The constant on the middle side L : L <= M <= R.
double _lValue_
The constant on the left side L : L <= M <= R.
LpExpr & operator=(const LpCol &rhs)
Assignment operator = with a variable.
void _addSide_(const LpCol &from)
Set the side of the calling expression, from LEFT TO RIGHT : L <= M <= R.
Class representing a linear program.
bool _sumIsOne_
true if addSumIsOne() has been called, false otherwise.
std::string toString() const
Get the string representation of a calling linear program.
void addSumIsOne()
Add sum of variables is 1 constraints.
void clear()
Reset the rows (inequalities) and columns (variables) of the LP as if it was created.
std::vector< LpCol > getCols() const
Get the variables of the LP.
void clearRows()
Reset the rows (inequalities) of the LP but not the columns (variables are kept).
std::vector< LpCol > _cols_
Variables of the problem.
std::vector< LpRow * > _rows_
Rows of the problem.
LpInterface< GUM_SCALAR > & operator=(const LpInterface< GUM_SCALAR > &from)
Copy compound assignment.
LpInterface()
Default constructor, empty problem.
void addPositivity()
Add positivity constraints for all variables.
std::vector< std::vector< GUM_SCALAR > > solve()
Solve the linear program (H-representation of the polytope) by enumeration (of the polytope vertices)...
std::vector< LpCol > addCols(const unsigned int &cols)
Insert new columns, i.e.
LpCol addCol()
Insert a new column, i.e.
void addProba()
Add positivity constraints and sum of variables is 1 ( probability constraints ).
friend std::ostream & operator<<(std::ostream &out, const LpInterface< T > &lpi)
Overload of << to use with output streams ( such as std::cout << ).
void addRow(const LpExpr &expr)
Add rows to the linear program according to a given expression ( which must be at least an inequality...
~LpInterface()
Default destructor.
bool _positivity_
true if addPositivity() has been called, false otherwise.
Class representing a row of the linear program, i.e.
std::string toString() const
Get the string representation of a calling row.
LpRow & operator=(const LpRow &row)
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.
double _cste_
The constant of the linear inequality.
friend std::ostream & operator<<(std::ostream &out, const LpRow &row)
Overload of << to use with output streams ( such as std::cout << ).
~LpRow()
Default destructor.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Class hash tables iterators.
namespace for constraint-based description of credal sets
LpExpr operator+(LpExpr &&lhs, const T2 &rhs)
Overload of operator + between anything ( a scalar, a variable or an expression ) and anything except...
LpExpr operator<=(const LpExpr &lhs, T2 &&rhs)
Overload of operator <= between anything and anything.
LpExpr operator-(LpExpr &&lhs, const T2 &rhs)
Overload of operator - between anything ( a scalar, a variable or an expression ) and anything except...
void swap(HashTable< LpCol, double > *&a, HashTable< LpCol, double > *&b)
Swap the addresses of two pointers to hashTables.
namespace for all credal networks entities
gum is the global namespace for all aGrUM entities
value_type & operator*()
Returns the value pointed to by the iterator.