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 "exprSum.hpp"
00017 #include "exprVar.hpp"
00018
00019 class Domain;
00020
00022
00023 class exprGroup: public exprSum {
00024
00025 public:
00026
00027 typedef std::vector <std::pair <exprVar *, CouNumber> > lincoeff;
00028
00029 protected:
00030
00031 mutable lincoeff lcoeff_;
00032 CouNumber c0_;
00033
00034 public:
00035
00038 static expression *genExprGroup (CouNumber,
00039 lincoeff &,
00040 expression ** = NULL,
00041 int = 0);
00042
00044 exprGroup (CouNumber,
00045 lincoeff &,
00046 expression ** = NULL,
00047 int = 0);
00048
00050 exprGroup (const exprGroup &src, Domain *d = NULL);
00051
00053 ~exprGroup ();
00054
00056 virtual expression *clone (Domain *d = NULL) const
00057 {return new exprGroup (*this, d);}
00058
00059
00060 CouNumber getc0 () {return c0_;}
00061 lincoeff &lcoeff () const {return lcoeff_;}
00062
00064 virtual void print (std::ostream & = std::cout,
00065 bool = false) const;
00066
00068 virtual CouNumber operator () ();
00069
00071 virtual CouNumber gradientNorm (const double *x);
00072
00075 virtual int DepList (std::set <int> &deplist,
00076 enum dig_type type = ORIG_ONLY);
00077
00079 virtual expression *differentiate (int index);
00080
00082 virtual expression *simplify ();
00083
00085 virtual int Linearity ();
00086
00088 virtual void getBounds (expression *&, expression *&);
00089
00091 virtual void getBounds (CouNumber &, CouNumber &);
00092
00094 virtual void generateCuts (expression *, const OsiSolverInterface &,
00095 OsiCuts &, const CouenneCutGenerator *,
00096 t_chg_bounds * = NULL, int = -1,
00097 CouNumber = -COUENNE_INFINITY,
00098 CouNumber = COUENNE_INFINITY);
00099
00101 virtual int compare (exprGroup &);
00102
00104 virtual enum expr_type code () {return COU_EXPRGROUP;}
00105
00107 virtual bool isInteger ();
00108
00110 virtual int rank ();
00111
00113 virtual void fillDepSet (std::set <DepNode *, compNode> *, DepGraph *);
00114
00116 virtual void replace (exprVar *x, exprVar *w);
00117
00119 virtual void realign (const CouenneProblem *p);
00120 };
00121
00122
00124
00125 inline CouNumber exprGroup::operator () () {
00126
00127 CouNumber ret = c0_ + exprSum::operator () ();
00128
00129
00130 for (lincoeff::iterator el = lcoeff_.begin (); el != lcoeff_.end (); ++el)
00131 ret += el -> second * (*(el -> first)) ();
00132
00133 return (CouNumber) ret;
00134 }
00135
00136 #endif