CouenneExprCopy.hpp
Go to the documentation of this file.
1 /* $Id: CouenneExprCopy.hpp 490 2011-01-14 16:07:12Z pbelotti $
2  *
3  * Name: exprCopy.hpp
4  * Author: Pietro Belotti
5  * Purpose: definition of the class exprCopy
6  *
7  * (C) Carnegie-Mellon University, 2006-10.
8  * This file is licensed under the Eclipse Public License (EPL)
9  */
10 
11 #ifndef COUENNE_EXPRCOPY_HPP
12 #define COUENNE_EXPRCOPY_HPP
13 
14 #include <iostream>
15 
16 #include "CouenneTypes.hpp"
17 #include "CouenneExpression.hpp"
18 
19 namespace Couenne {
20 
21 class CouenneObject;
22 
23 // expression copy (points to VALUE of another expression)
24 
25 class exprCopy: public expression {
26 
27  protected:
28 
31 
34 
35  public:
36 
38  inline enum nodeType Type () const
39  {return copy_ -> Type ();}
40 
42  //exprCopy () {}
43 
46  //copy_ (getOriginal (copy)),// -> Original ()),
47  copy_ (copy),// -> Original ()),
48  value_ (0.) {}
49 
51  exprCopy (const exprCopy &e, Domain *d = NULL);
52 
55  virtual ~exprCopy () {
56  if (copy_)
57  delete copy_;
58  }
59 
61  virtual inline expression *clone (Domain *d = NULL) const
62  {return new exprCopy (*this, d);}
63 
67  inline const expression *Original () const
68  {return copy_ -> Original ();}
69 
72  inline bool isaCopy () const
73  {return true;}
74 
76  inline expression *Copy () const
77  {return (copy_ -> isaCopy ()) ? copy_ -> Copy () : copy_;}
78 
80  inline expression *Image () const
81  {return copy_ -> Image ();}
82 
84  inline int Index () const
85  {return copy_ -> Index ();}
86 
88  inline int nArgs () const
89  {return copy_ -> nArgs ();}
90 
92  inline expression **ArgList () const
93  {return copy_ -> ArgList ();}
94 
96  inline void ArgList (expression **al)
97  {copy_ -> ArgList (al);}
98 
100  inline expression *Argument () const
101  {return copy_ -> Argument ();}
102 
104  inline expression **ArgPtr ()
105  {return copy_ -> ArgPtr ();}
106 
108  virtual void print (std::ostream &out = std::cout,
109  bool descend = false) const;
110 
112  virtual inline CouNumber Value () const
113  {return value_;}
114 
116  virtual inline CouNumber operator () ()
117  {return (value_ = (*copy_) ());}
118  // {return (*copy_) ();}
119  // {return (copy_ -> Value ());}
120 
122  inline CouNumber gradientNorm (const double *x)
123  {return copy_ -> gradientNorm (x);}
124 
126  inline expression *differentiate (int index)
127  {return copy_ -> differentiate (index);}
128 
131  inline int DepList (std::set <int> &deplist,
132  enum dig_type type = ORIG_ONLY)
133  {return copy_ -> DepList (deplist, type);}
134 
136  inline expression *simplify ()
137  {return copy_ -> simplify ();}
138 
140  inline int Linearity ()
141  {return copy_ -> Linearity ();}
142 
143  inline bool isInteger ()
144  {return copy_ -> isInteger ();}
145 
147  virtual inline bool isDefinedInteger ()
148  {return copy_ -> isDefinedInteger ();}
149 
151  inline void getBounds (expression *&lower, expression *&upper)
152  {copy_ -> getBounds (lower, upper);}
153 
155  inline void getBounds (CouNumber &lower, CouNumber &upper)
156  {copy_ -> getBounds (lower, upper);}
157 
158 
160  inline exprAux *standardize (CouenneProblem *p, bool addAux = true)
161  {return copy_ -> standardize (p, addAux);}
162 
164  inline void generateCuts (expression *w, //const OsiSolverInterface &si,
165  OsiCuts &cs, const CouenneCutGenerator *cg,
166  t_chg_bounds *chg = NULL, int wind= -1,
169 
170  {copy_ -> generateCuts (w, /*si,*/ cs, cg, chg, wind, lb, ub);}
171 
173  inline enum expr_type code ()
174  {return copy_ -> code ();}
175 
177  inline enum convexity convexity () const
178  {return copy_ -> convexity ();}
179 
182  {return copy_ -> compare (e);}
183 
185  inline int rank ()
186  {return copy_ -> rank ();}
187 
189  inline bool impliedBound (int wind, CouNumber *l, CouNumber *u, t_chg_bounds *chg)
190  {return copy_ -> impliedBound (wind, l, u, chg);}
191 
194  inline int Multiplicity ()
195  {return copy_ -> Multiplicity ();}
196 
199  inline CouNumber selectBranch (const CouenneObject *obj,
200  const OsiBranchingInformation *info,
201  expression * &var,
202  double * &brpts,
203  double * &brDist, // distance of current LP
204  // point to new convexifications
205  int &way)
206 
207  {return copy_ -> selectBranch (obj, info, var, brpts, brDist, way);}
208 
210  void replace (exprVar *, exprVar *);
211 
213  inline void fillDepSet (std::set <DepNode *, compNode> *dep, DepGraph *g)
214  {copy_ -> fillDepSet (dep, g);}
215 
217  void realign (const CouenneProblem *p);
218  //{copy_ -> realign (p);}
219 
221  bool isBijective() const
222  {return copy_ -> isBijective ();}
223 
225  CouNumber inverse (expression *vardep) const
226  {return copy_ -> inverse (vardep);}
227 
229  void closestFeasible (expression *varind, expression *vardep,
230  CouNumber& left, CouNumber& right) const
231  {copy_ -> closestFeasible (varind, vardep, left, right);}
232 
235  bool isCuttable (CouenneProblem *problem, int index) const
236  {return copy_ -> isCuttable (problem, index);}
237 };
238 
239 }
240 
241 #endif
Cut Generator for linear convexifications.
CouNumber inverse(expression *vardep) const
compute the inverse function
void replace(exprVar *, exprVar *)
replace occurrence of a variable with another variable
Definition: expression.cpp:143
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
CouNumber gradientNorm(const double *x)
return l-2 norm of gradient at given point
CouNumber value_
saved value to be used by exprStore expressions
expression * Image() const
return pointer to corresponding expression (for auxiliary variables only)
void getBounds(CouNumber &lower, CouNumber &upper)
Get value of lower and upper bound of an expression (if any)
void generateCuts(expression *w, OsiCuts &cs, const CouenneCutGenerator *cg, t_chg_bounds *chg=NULL, int wind=-1, CouNumber lb=-COUENNE_INFINITY, CouNumber ub=COUENNE_INFINITY)
generate convexification cut for constraint w = this
expression * simplify()
simplify expression (useful for derivatives)
const expression * Original() const
If this is an exprClone of a exprClone of an expr???, point to the original expr??? instead of an exprClone – improves computing efficiency.
bool isInteger()
is this expression integer?
void fint fint fint real fint real real real real real real real real real fint real fint fint fint real fint fint fint fint * info
OsiObject for auxiliary variables $w=f(x)$.
status of lower/upper bound of a variable, to be checked/modified in bound tightening ...
virtual expression * clone(Domain *d=NULL) const
Cloning method.
CouNumber selectBranch(const CouenneObject *obj, const OsiBranchingInformation *info, expression *&var, double *&brpts, double *&brDist, int &way)
Set up branching object by evaluating many branching points for each expression&#39;s arguments...
virtual ~exprCopy()
Destructor – CAUTION: this is the only destructive destructor, exprClone and exprStore do not destroy...
void closestFeasible(expression *varind, expression *vardep, CouNumber &left, CouNumber &right) const
closest feasible points in function in both directions
virtual void print(std::ostream &out=std::cout, bool descend=false) const
I/O.
Definition: expression.cpp:226
int compare(expression &e)
compare this with other expression
bool isBijective() const
indicating if function is monotonically increasing
int Linearity()
get a measure of &quot;how linear&quot; the expression is (see CouenneTypes.h)
exprCopy(expression *copy)
Empty constructor - used in cloning method of exprClone.
bool isaCopy() const
return true if this is a copy of something, i.e.
int rank()
used in rank-based branching variable choice
enum expr_type code()
code for comparisons
enum convexity convexity() const
either CONVEX, CONCAVE, AFFINE, or NONCONVEX
expression * Argument() const
return argument (when applicable, i.e., with univariate functions)
void fint fint fint real fint real real real real real real real real real * e
int Index() const
Get variable index in problem.
expression ** ArgPtr()
return pointer to argument (when applicable, i.e., with univariate functions)
expression * differentiate(int index)
differentiation
void ArgList(expression **al)
set arglist (used in deleting nodes without deleting children)
Class for MINLP problems with symbolic information.
virtual CouNumber operator()()
null function for evaluating the expression
expression ** ArgList() const
return arglist (when applicable, that is, with N-ary functions)
exprAux * standardize(CouenneProblem *p, bool addAux=true)
Create standard formulation of this expression.
expression * copy_
the expression this object is a (reference) copy of
convexity
convexity type of an expression
void fillDepSet(std::set< DepNode *, compNode > *dep, DepGraph *g)
fill in dependence structure
void getBounds(expression *&lower, expression *&upper)
Get lower and upper bound of an expression (if any)
double CouNumber
main number type in Couenne
nodeType
type of a node in an expression tree
bool impliedBound(int wind, CouNumber *l, CouNumber *u, t_chg_bounds *chg)
implied bound processing
int Multiplicity()
multiplicity of a variable: how many times this variable occurs in expressions throughout the problem...
#define COUENNE_INFINITY
Dependence graph.
expression * Copy() const
return copy of this expression (only makes sense in exprCopy)
enum nodeType Type() const
node type
Auxiliary variable.
dig_type
type of digging when filling the dependence list
variable-type operator
void realign(const CouenneProblem *p)
redirect variables to proper variable vector
Definition: expression.cpp:207
expr_type
code returned by the method expression::code()
bool isCuttable(CouenneProblem *problem, int index) const
can this expression be further linearized or are we on its concave (&quot;bad&quot;) side
void fint fint fint real fint real real real real real real * g
Expression base class.
void fint fint fint real fint real real real real real real real real * w
virtual CouNumber Value() const
value
virtual bool isDefinedInteger()
is this expression DEFINED as integer?
int nArgs() const
Return number of arguments (when applicable, that is, with N-ary functions)
Define a dynamic point+bounds, with a way to save and restore previous points+bounds through a LIFO s...
void fint fint fint real fint real * x