CouenneExprOp.hpp

Go to the documentation of this file.
00001 /* $Id: CouenneExprOp.hpp 490 2011-01-14 16:07:12Z pbelotti $
00002  *
00003  * Name:    exprOp.hpp
00004  * Author:  Pietro Belotti
00005  * Purpose: definition of the n-ary expression class
00006  *
00007  * (C) Carnegie-Mellon University, 2006-08.
00008  * This file is licensed under the Eclipse Public License (EPL)
00009  */
00010 
00011 #ifndef COUENNE_EXPROP_HPP
00012 #define COUENNE_EXPROP_HPP
00013 
00014 #include <iostream>
00015 
00016 #include "CouenneExpression.hpp"
00017 #include "CouenneTypes.hpp"
00018 
00019 namespace Couenne {
00020 
00021 #define MAX_ARG_LINE 10
00022 
00023 class CouenneProblem;
00024 class Domain;
00025 
00030 
00031 class exprOp: public expression {
00032 
00033  protected:
00034 
00035   expression **arglist_; 
00036   int          nargs_;   
00037 
00038  public:
00039 
00041   virtual inline enum nodeType Type () const
00042     {return N_ARY;}
00043 
00045   exprOp (expression **arglist, int nargs):  //< non-leaf expression, with argument list 
00046     arglist_ (arglist),
00047     nargs_   (nargs)
00048     {}
00049 
00051   exprOp (expression *arg0, expression *arg1):  //< two arguments 
00052     arglist_ (new expression * [2]),
00053     nargs_   (2)
00054     {arglist_ [0] = arg0; arglist_ [1] = arg1;}
00055 
00057   virtual ~exprOp ();
00058 
00061   exprOp (const exprOp &e, Domain *d = NULL):
00062     arglist_ (new expression * [e.nArgs ()]),
00063     nargs_   (e.nArgs ()) {}
00064 
00066   inline expression **ArgList () const 
00067   {return arglist_;}
00068 
00070   virtual inline void ArgList (expression **al) 
00071   {arglist_ = al;}
00072 
00074   inline int nArgs () const 
00075   {return nargs_;}
00076 
00078   virtual void print (std::ostream &out = std::cout,
00079                       bool = false) const;
00080 
00082   virtual enum pos printPos () const
00083   {return INSIDE;}
00084 
00086   virtual std::string printOp () const
00087   {return "??";}
00088 
00091   virtual int DepList (std::set <int> &deplist, enum dig_type type = ORIG_ONLY);
00092 
00094   virtual expression *simplify ();
00095 
00097   expression **clonearglist (Domain *d = NULL) const {
00098     if (nargs_) {
00099       expression **al = new expression * [nargs_];
00100       for (register int i=0; i<nargs_; i++)
00101         al [i] = arglist_ [i] -> clone (d);
00102       return al;
00103     } else return NULL;
00104   }
00105 
00107   int shrink_arglist (CouNumber, CouNumber);
00108 
00110   virtual inline int Linearity ()
00111   {return NONLINEAR;}
00112 
00114   virtual exprAux *standardize (CouenneProblem *, bool addAux = true);
00115 
00117   virtual inline enum expr_type code ()
00118   {return COU_EXPROP;}
00119 
00121   virtual bool isInteger ();
00122 
00124   virtual int compare (exprOp &);
00125 
00127   virtual int rank ();
00128 
00131   virtual void fillDepSet (std::set <DepNode *, compNode> *dep, DepGraph *g) {
00132     for (int i=nargs_; i--;)
00133       arglist_ [i] -> fillDepSet (dep, g);
00134   }
00135 
00137   virtual void replace (exprVar *, exprVar *);
00138 
00140   virtual void realign (const CouenneProblem *p);
00141 };
00142 
00143 }
00144 
00145 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 2 Aug 2012 for Couenne by  doxygen 1.6.1