Couenne  0.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CouenneExprOp.hpp
Go to the documentation of this file.
1 /* $Id: CouenneExprOp.hpp 490 2011-01-14 16:07:12Z pbelotti $
2  *
3  * Name: exprOp.hpp
4  * Author: Pietro Belotti
5  * Purpose: definition of the n-ary expression class
6  *
7  * (C) Carnegie-Mellon University, 2006-08.
8  * This file is licensed under the Eclipse Public License (EPL)
9  */
10 
11 #ifndef COUENNE_EXPROP_HPP
12 #define COUENNE_EXPROP_HPP
13 
14 #include <iostream>
15 
16 #include "CouenneExpression.hpp"
17 #include "CouenneTypes.hpp"
18 
19 namespace Couenne {
20 
21 #define MAX_ARG_LINE 10
22 
23 class CouenneProblem;
24 class Domain;
25 
30 
31 class exprOp: public expression {
32 
33  protected:
34 
36  int nargs_;
37 
38  public:
39 
41  virtual inline enum nodeType Type () const
42  {return N_ARY;}
43 
45  exprOp (expression **arglist, int nargs): //< non-leaf expression, with argument list
46  arglist_ (arglist),
47  nargs_ (nargs)
48  {}
49 
51  exprOp (expression *arg0, expression *arg1): //< two arguments
52  arglist_ (new expression * [2]),
53  nargs_ (2)
54  {arglist_ [0] = arg0; arglist_ [1] = arg1;}
55 
57  virtual ~exprOp ();
58 
61  exprOp (const exprOp &e, Domain *d = NULL):
62  arglist_ (new expression * [e.nArgs ()]),
63  nargs_ (e.nArgs ()) {}
64 
66  inline expression **ArgList () const
67  {return arglist_;}
68 
70  virtual inline void ArgList (expression **al)
71  {arglist_ = al;}
72 
74  inline int nArgs () const
75  {return nargs_;}
76 
78  virtual void print (std::ostream &out = std::cout,
79  bool = false) const;
80 
82  virtual enum pos printPos () const
83  {return INSIDE;}
84 
86  virtual std::string printOp () const
87  {return "??";}
88 
91  virtual int DepList (std::set <int> &deplist, enum dig_type type = ORIG_ONLY);
92 
94  virtual expression *simplify ();
95 
97  expression **clonearglist (Domain *d = NULL) const {
98  if (nargs_) {
99  expression **al = new expression * [nargs_];
100  for (register int i=0; i<nargs_; i++)
101  al [i] = arglist_ [i] -> clone (d);
102  return al;
103  } else return NULL;
104  }
105 
108 
110  virtual inline int Linearity ()
111  {return NONLINEAR;}
112 
114  virtual exprAux *standardize (CouenneProblem *, bool addAux = true);
115 
117  virtual inline enum expr_type code ()
118  {return COU_EXPROP;}
119 
121  virtual bool isInteger ();
122 
124  virtual int compare (exprOp &);
125 
127  virtual int rank ();
128 
131  virtual void fillDepSet (std::set <DepNode *, compNode> *dep, DepGraph *g) {
132  for (int i=nargs_; i--;)
133  arglist_ [i] -> fillDepSet (dep, g);
134  }
135 
137  virtual void replace (exprVar *, exprVar *);
138 
140  virtual void realign (const CouenneProblem *p);
141 };
142 
143 }
144 
145 #endif
virtual void ArgList(expression **al)
set arglist (used in deleting nodes without deleting children)
virtual expression * clone(Domain *d=NULL) const
Cloning method.
pos
position where the operator should be printed when printing the expression
virtual void replace(exprVar *, exprVar *)
replace variable with other
virtual enum pos printPos() const
print position (PRE, INSIDE, POST)
exprOp(const exprOp &e, Domain *d=NULL)
Copy constructor: only allocate space for argument list, which will be copied with clonearglist() ...
int shrink_arglist(CouNumber, CouNumber)
compress argument list
virtual exprAux * standardize(CouenneProblem *, bool addAux=true)
generate auxiliary variable
int nArgs() const
return number of arguments
virtual enum nodeType Type() const
Node type.
virtual void realign(const CouenneProblem *p)
empty function to redirect variables to proper variable vector
virtual int Linearity()
get a measure of &quot;how linear&quot; the expression is (see CouenneTypes.h)
expression ** clonearglist(Domain *d=NULL) const
clone argument list (for use with clone method)
virtual ~exprOp()
Destructor.
Class for MINLP problems with symbolic information.
virtual int compare(exprOp &)
compare with other generic exprOp
exprOp(expression *arg0, expression *arg1)
Constructor with two arguments (for convenience)
virtual int DepList(std::set< int > &deplist, enum dig_type type=ORIG_ONLY)
fill in the set with all indices of variables appearing in the expression
virtual enum expr_type code()
return code to classify type of expression
expression ** ArgList() const
return argument list
expression ** arglist_
argument list is an array of pointers to other expressions
double CouNumber
main number type in Couenne
int nargs_
number of arguments (cardinality of arglist)
exprOp(expression **arglist, int nargs)
Constructor.
general n-ary operator-type expression: requires argument list.
nodeType
type of a node in an expression tree
Dependence graph.
Auxiliary variable.
dig_type
type of digging when filling the dependence list
virtual std::string printOp() const
print operator
variable-type operator
expr_type
code returned by the method expression::code()
virtual bool isInteger()
is this expression integer?
virtual expression * simplify()
simplification
virtual void print(std::ostream &out=std::cout, bool=false) const
I/O.
Expression base class.
virtual void fillDepSet(std::set< DepNode *, compNode > *dep, DepGraph *g)
fill in dependence structure update dependence set with index of this variable
virtual int rank()
used in rank-based branching variable choice
Define a dynamic point+bounds, with a way to save and restore previous points+bounds through a LIFO s...