00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef COUENNE_EXPRGROUP_H
00012 #define COUENNE_EXPRGROUP_H
00013
00014 #include <vector>
00015
00016 #include "CouenneExprSum.hpp"
00017 #include "CouenneExprVar.hpp"
00018
00019 namespace Couenne {
00020
00021 class Domain;
00022
00024
00025 class exprGroup: public exprSum {
00026
00027 public:
00028
00029 typedef std::vector <std::pair <exprVar *, CouNumber> > lincoeff;
00030
00031 protected:
00032
00033 mutable lincoeff lcoeff_;
00034 CouNumber c0_;
00035
00036 public:
00037
00040 static expression *genExprGroup (CouNumber,
00041 lincoeff &,
00042 expression ** = NULL,
00043 int = 0);
00044
00046 exprGroup (CouNumber,
00047 lincoeff &,
00048 expression ** = NULL,
00049 int = 0);
00050
00052 exprGroup (const exprGroup &src, Domain *d = NULL);
00053
00055 virtual ~exprGroup ();
00056
00058 virtual expression *clone (Domain *d = NULL) const
00059 {return new exprGroup (*this, d);}
00060
00061
00062 CouNumber getc0 () {return c0_;}
00063 lincoeff &lcoeff () const {return lcoeff_;}
00064
00066 virtual void print (std::ostream & = std::cout,
00067 bool = false) const;
00068
00070 virtual CouNumber operator () ();
00071
00073 virtual CouNumber gradientNorm (const double *x);
00074
00077 virtual int DepList (std::set <int> &deplist,
00078 enum dig_type type = ORIG_ONLY);
00079
00081 virtual expression *differentiate (int index);
00082
00084 virtual expression *simplify ();
00085
00087 virtual int Linearity ();
00088
00090 virtual void getBounds (expression *&, expression *&);
00091
00093 virtual void getBounds (CouNumber &, CouNumber &);
00094
00096 virtual void generateCuts (expression *,
00097 OsiCuts &, const CouenneCutGenerator *,
00098 t_chg_bounds * = NULL, int = -1,
00099 CouNumber = -COUENNE_INFINITY,
00100 CouNumber = COUENNE_INFINITY);
00101
00103 virtual int compare (exprGroup &);
00104
00106 virtual enum expr_type code () {return COU_EXPRGROUP;}
00107
00109 virtual bool isInteger ();
00110
00112 virtual int rank ();
00113
00115 virtual void fillDepSet (std::set <DepNode *, compNode> *, DepGraph *);
00116
00118 virtual void replace (exprVar *x, exprVar *w);
00119
00121 virtual void realign (const CouenneProblem *p);
00122 };
00123
00124
00126
00127 inline CouNumber exprGroup::operator () () {
00128
00129 CouNumber ret = c0_ + exprSum::operator () ();
00130
00131
00132 for (lincoeff::iterator el = lcoeff_.begin (); el != lcoeff_.end (); ++el)
00133 ret += el -> second * (*(el -> first)) ();
00134
00135 return (CouNumber) ret;
00136 }
00137
00138 }
00139
00140 #endif