# CouenneExprGroup.hpp

Go to the documentation of this file.

    00001 /* $Id: CouenneExprGroup.hpp 615 2011-06-08 20:36:24Z pbelotti $
    00002  *
    00003  * Name:    exprGroup.hpp
    00004  * Author:  Pietro Belotti
    00005  * Purpose: definition of mixed sum expressions (constant+linear+nonlinear)
    00006  *
    00007  * (C) Carnegie-Mellon University, 2006-09.
    00008  * This file is licensed under the Eclipse Public License (EPL)
    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   // Get constant, indices, and coefficients vectors, and number of linear terms
    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 *, //const OsiSolverInterface &,
    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 () (); // add constant and nonlinear part
    00130
    00131   // add linear part
    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

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines