22 #ifndef __LP_INTERFACE__H__ 23 #define __LP_INTERFACE__H__ 36 #include <agrum/CN/polytope/LrsWrapper.h> 37 #include <agrum/tools/core/hashFunc.h> 38 #include <agrum/tools/core/hashTable.h> 39 #include <agrum/tools/core/utils_misc.h> 47 template <
typename GUM_SCALAR >
69 explicit LpCol(
unsigned int id);
75 LpCol(
const LpCol& col);
86 unsigned int id()
const;
100 bool operator<(
const LpCol& col)
const;
111 bool operator==(
const LpCol& col)
const;
123 bool operator!=(
const LpCol& col)
const;
132 LpCol& operator=(
const LpCol& col);
144 friend std::ostream& operator<<(std::ostream& out,
156 std::string toString()
const;
180 class HashFunc< credal::lp::LpCol >:
public HashFuncBase< credal::lp::LpCol > {
187 static Size castToSize(
const credal::lp::LpCol& key);
194 virtual Size operator()(
const credal::lp::LpCol& key)
const override final;
210 template <
typename GUM_SCALAR >
211 friend class LpInterface;
224 LpExpr(
const LpExpr& expr);
239 LpExpr(
const LpExpr& expr,
bool copyLeft,
bool copyMiddle,
bool copyRight);
249 LpExpr(LpExpr&& expr);
270 LpExpr(LpExpr&& expr,
bool copyLeft,
bool copyMiddle,
bool copyRight);
287 LpExpr& operator=(
const LpCol& rhs);
294 LpExpr& operator=(
const LpExpr& rhs);
301 LpExpr& operator=(LpExpr&& rhs);
310 template <
typename SCALAR >
311 LpExpr& operator=(
const SCALAR& rhs);
325 LpExpr& operator+=(
const LpCol& rhs);
334 LpExpr& operator+=(
const LpExpr& rhs);
342 LpExpr& operator+=(LpExpr&& rhs);
351 template <
typename T >
352 LpExpr& operator+=(
const T& rhs);
366 LpExpr& operator-=(
const LpCol& rhs);
375 LpExpr& operator-=(
const LpExpr& rhs);
384 template <
typename T >
385 LpExpr& operator-=(
const T& rhs);
398 std::string toString()
const;
402 template <
typename T1,
typename T2 >
403 static LpExpr lessThan(T1&& lhs, T2&& rhs);
404 template <
typename SCALAR >
405 static LpExpr multiply(
const SCALAR& lhs,
const LpCol& rhs);
433 HashTable< LpCol,
double >* _lCoeffs_;
437 HashTable< LpCol,
double >* _mCoeffs_;
441 HashTable< LpCol,
double >* _rCoeffs_;
455 void _addSide_(
const LpCol& from);
465 void _addSide_(
const LpExpr& from);
475 void _addSide_(LpExpr&& from);
486 template <
typename SCALAR >
487 void _addSide_(
const SCALAR& from);
500 template <
typename GUM_SCALAR >
501 friend class LpInterface;
516 LpRow(
const LpExpr& expr,
const std::vector< LpCol >& cols);
527 LpRow(LpExpr&& expr,
const std::vector< LpCol >& cols);
533 LpRow(
const LpRow& row);
553 LpRow& operator=(
const LpRow& row);
558 LpRow& operator=(LpRow&& row);
571 friend std::ostream& operator<<(std::ostream& out,
581 std::string toString()
const;
590 HashTable< LpCol,
double >* _coeffs_;
600 template <
typename GUM_SCALAR >
613 LpInterface(
const LpInterface< GUM_SCALAR >& from);
619 LpInterface(LpInterface< GUM_SCALAR >&& from);
633 LpInterface< GUM_SCALAR >& operator=(
const LpInterface< GUM_SCALAR >& from);
639 LpInterface< GUM_SCALAR >& operator=(LpInterface< GUM_SCALAR >&& from);
652 template <
typename T >
654 operator<<(std::ostream& out,
655 const LpInterface< T >& lpi);
670 std::vector< LpCol > addCols(
const unsigned int& cols);
679 void addRow(
const LpExpr& expr);
687 void addRow(LpExpr&& expr);
692 void addPositivity();
719 std::vector< std::vector< GUM_SCALAR > > solve();
725 std::vector< LpCol > getCols()
const;
731 std::string toString()
const;
748 std::vector< LpRow* > _rows_;
750 std::vector< LpCol > _cols_;
772 void swap(HashTable< LpCol,
double >*& a, HashTable< LpCol,
double >*& b);
795 template <
typename T2 >
796 LpExpr operator+(LpExpr&& lhs,
const T2& rhs);
797 template <
typename T2 >
798 LpExpr operator+(LpExpr& lhs,
const T2& rhs);
829 template <
typename T1, forbidden_type< T1, LpExpr > = 0 >
830 LpExpr operator+(
const T1& lhs, LpExpr&& rhs);
831 template <
typename T1, forbidden_type< T1, LpExpr > = 0 >
832 LpExpr operator+(
const T1& lhs, LpExpr& rhs);
837 template <
typename T2, forbidden_type< T2, LpExpr > = 0 >
838 LpExpr operator+(
const LpCol& lhs,
const T2& rhs);
843 template <
typename T1, forbidden_type< T1, LpExpr > = 0, forbidden_type< T1, LpCol > = 0 >
844 LpExpr operator+(
const T1& lhs,
const LpCol& rhs);
867 template <
typename T2 >
868 LpExpr operator-(LpExpr&& lhs,
const T2& rhs);
869 template <
typename T2 >
870 LpExpr operator-(LpExpr& lhs,
const T2& rhs);
901 template <
typename T1, forbidden_type< T1, LpExpr > = 0 >
902 LpExpr operator-(
const T1& lhs, LpExpr&& rhs);
903 template <
typename T1, forbidden_type< T1, LpExpr > = 0 >
904 LpExpr operator-(
const T1& lhs, LpExpr& rhs);
916 template <
typename T2, forbidden_type< T2, LpExpr > = 0 >
917 LpExpr operator-(
const LpCol& lhs,
const T2& rhs);
929 template <
typename T1, forbidden_type< T1, LpExpr > = 0, forbidden_type< T1, LpCol > = 0 >
930 LpExpr operator-(
const T1& lhs,
const LpCol& rhs);
947 template <
typename SCALAR >
948 LpExpr operator*(
const SCALAR& lhs,
const LpCol& rhs);
961 template <
typename SCALAR >
962 LpExpr operator*(
const LpCol& lhs,
const SCALAR& rhs);
990 template <
typename T2 >
991 LpExpr operator<=(
const LpExpr& lhs, T2&& rhs);
992 template <
typename T2 >
993 LpExpr operator<=(
const LpCol& lhs, T2&& rhs);
994 template <
typename T1, forbidden_type< T1, LpExpr& > = 0, forbidden_type< T1, LpCol& > = 0 >
995 LpExpr operator<=(T1&& lhs,
const LpExpr& rhs);
996 template <
typename T1, forbidden_type< T1, LpExpr& > = 0, forbidden_type< T1, LpCol& > = 0 >
997 LpExpr operator<=(T1&& lhs,
const LpCol& rhs);
999 template <
typename T2 >
1000 LpExpr operator<=(LpExpr&& lhs, T2&& rhs);
1001 template <
typename T2 >
1002 LpExpr operator<=(LpCol&& lhs, T2&& rhs);
1003 template <
typename T1, forbidden_type< T1, LpExpr > = 0, forbidden_type< T1, LpCol > = 0 >
1004 LpExpr operator<=(T1&& lhs, LpExpr&& rhs);
1005 template <
typename T1, forbidden_type< T1, LpExpr > = 0, forbidden_type< T1, LpCol > = 0 >
1006 LpExpr operator<=(T1&& lhs, LpCol&& rhs);
1016 #include <agrum/CN/polytope/LpInterface_tpl.h> 1018 #ifndef GUM_NO_INLINE 1019 # include <agrum/CN/polytope/LpInterface_inl.h>