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);
145 operator<<(std::ostream& out,
157 std::string toString()
const;
181 class HashFunc< credal::lp::LpCol >:
public HashFuncBase< credal::lp::LpCol > {
188 static Size castToSize(
const credal::lp::LpCol& key);
195 virtual Size operator()(
const credal::lp::LpCol& key)
const override final;
211 template <
typename GUM_SCALAR >
212 friend class LpInterface;
225 LpExpr(
const LpExpr& expr);
240 LpExpr(
const LpExpr& expr,
bool copyLeft,
bool copyMiddle,
bool copyRight);
250 LpExpr(LpExpr&& expr);
271 LpExpr(LpExpr&& expr,
bool copyLeft,
bool copyMiddle,
bool copyRight);
288 LpExpr& operator=(
const LpCol& rhs);
295 LpExpr& operator=(
const LpExpr& rhs);
302 LpExpr& operator=(LpExpr&& rhs);
311 template <
typename SCALAR >
312 LpExpr& operator=(
const SCALAR& rhs);
326 LpExpr& operator+=(
const LpCol& rhs);
335 LpExpr& operator+=(
const LpExpr& rhs);
343 LpExpr& operator+=(LpExpr&& rhs);
352 template <
typename T >
353 LpExpr& operator+=(
const T& rhs);
367 LpExpr& operator-=(
const LpCol& rhs);
376 LpExpr& operator-=(
const LpExpr& rhs);
385 template <
typename T >
386 LpExpr& operator-=(
const T& rhs);
399 std::string toString()
const;
403 template <
typename T1,
typename T2 >
404 static LpExpr lessThan(T1&& lhs, T2&& rhs);
405 template <
typename SCALAR >
406 static LpExpr multiply(
const SCALAR& lhs,
const LpCol& rhs);
434 HashTable< LpCol,
double >* lCoeffs__;
438 HashTable< LpCol,
double >* mCoeffs__;
442 HashTable< LpCol,
double >* rCoeffs__;
456 void addSide__(
const LpCol& from);
466 void addSide__(
const LpExpr& from);
476 void addSide__(LpExpr&& from);
487 template <
typename SCALAR >
488 void addSide__(
const SCALAR& from);
501 template <
typename GUM_SCALAR >
502 friend class LpInterface;
517 LpRow(
const LpExpr& expr,
const std::vector< LpCol >& cols);
528 LpRow(LpExpr&& expr,
const std::vector< LpCol >& cols);
534 LpRow(
const LpRow& row);
554 LpRow& operator=(
const LpRow& row);
559 LpRow& operator=(LpRow&& row);
573 operator<<(std::ostream& out,
583 std::string toString()
const;
592 HashTable< LpCol,
double >* coeffs__;
602 template <
typename GUM_SCALAR >
615 LpInterface(
const LpInterface< GUM_SCALAR >& from);
621 LpInterface(LpInterface< GUM_SCALAR >&& from);
635 LpInterface< GUM_SCALAR >&
636 operator=(
const LpInterface< GUM_SCALAR >& from);
642 LpInterface< GUM_SCALAR >& operator=(LpInterface< GUM_SCALAR >&& from);
655 template <
typename T >
657 operator<<(std::ostream& out,
658 const LpInterface< T >& lpi);
673 std::vector< LpCol > addCols(
const unsigned int& cols);
682 void addRow(
const LpExpr& expr);
690 void addRow(LpExpr&& expr);
695 void addPositivity();
722 std::vector< std::vector< GUM_SCALAR > > solve();
728 std::vector< LpCol > getCols()
const;
734 std::string toString()
const;
751 std::vector< LpRow* > rows__;
753 std::vector< LpCol > cols__;
775 void swap(HashTable< LpCol,
double >*& a, HashTable< LpCol,
double >*& b);
798 template <
typename T2 >
799 LpExpr operator+(LpExpr&& lhs,
const T2& rhs);
800 template <
typename T2 >
801 LpExpr operator+(LpExpr& lhs,
const T2& rhs);
832 template <
typename T1, forbidden_type< T1, LpExpr > = 0 >
833 LpExpr operator+(
const T1& lhs, LpExpr&& rhs);
834 template <
typename T1, forbidden_type< T1, LpExpr > = 0 >
835 LpExpr operator+(
const T1& lhs, LpExpr& rhs);
840 template <
typename T2, forbidden_type< T2, LpExpr > = 0 >
841 LpExpr operator+(
const LpCol& lhs,
const T2& rhs);
846 template <
typename T1,
847 forbidden_type< T1, LpExpr > = 0,
848 forbidden_type< T1, LpCol > = 0 >
849 LpExpr operator+(
const T1& lhs,
const LpCol& rhs);
872 template <
typename T2 >
873 LpExpr operator-(LpExpr&& lhs,
const T2& rhs);
874 template <
typename T2 >
875 LpExpr operator-(LpExpr& lhs,
const T2& rhs);
906 template <
typename T1, forbidden_type< T1, LpExpr > = 0 >
907 LpExpr operator-(
const T1& lhs, LpExpr&& rhs);
908 template <
typename T1, forbidden_type< T1, LpExpr > = 0 >
909 LpExpr operator-(
const T1& lhs, LpExpr& rhs);
921 template <
typename T2, forbidden_type< T2, LpExpr > = 0 >
922 LpExpr operator-(
const LpCol& lhs,
const T2& rhs);
934 template <
typename T1,
935 forbidden_type< T1, LpExpr > = 0,
936 forbidden_type< T1, LpCol > = 0 >
937 LpExpr operator-(
const T1& lhs,
const LpCol& rhs);
954 template <
typename SCALAR >
955 LpExpr operator*(
const SCALAR& lhs,
const LpCol& rhs);
968 template <
typename SCALAR >
969 LpExpr operator*(
const LpCol& lhs,
const SCALAR& rhs);
997 template <
typename T2 >
998 LpExpr operator<=(
const LpExpr& lhs, T2&& rhs);
999 template <
typename T2 >
1000 LpExpr operator<=(
const LpCol& lhs, T2&& rhs);
1001 template <
typename T1,
1002 forbidden_type< T1, LpExpr& > = 0,
1003 forbidden_type< T1, LpCol& > = 0 >
1004 LpExpr operator<=(T1&& lhs,
const LpExpr& rhs);
1005 template <
typename T1,
1006 forbidden_type< T1, LpExpr& > = 0,
1007 forbidden_type< T1, LpCol& > = 0 >
1008 LpExpr operator<=(T1&& lhs,
const LpCol& rhs);
1010 template <
typename T2 >
1011 LpExpr operator<=(LpExpr&& lhs, T2&& rhs);
1012 template <
typename T2 >
1013 LpExpr operator<=(LpCol&& lhs, T2&& rhs);
1014 template <
typename T1,
1015 forbidden_type< T1, LpExpr > = 0,
1016 forbidden_type< T1, LpCol > = 0 >
1017 LpExpr operator<=(T1&& lhs, LpExpr&& rhs);
1018 template <
typename T1,
1019 forbidden_type< T1, LpExpr > = 0,
1020 forbidden_type< T1, LpCol > = 0 >
1021 LpExpr operator<=(T1&& lhs, LpCol&& rhs);
1031 #include <agrum/CN/polytope/LpInterface_tpl.h> 1033 #ifndef GUM_NO_INLINE 1034 # include <agrum/CN/polytope/LpInterface_inl.h>