Couenne 0.5.8
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
19namespace Couenne {
20
21class CouenneObject;
22
23// expression copy (points to VALUE of another expression)
24
25class 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
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
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
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
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
#define COUENNE_INFINITY
Cut Generator for linear convexifications.
OsiObject for auxiliary variables $w=f(x)$.
Class for MINLP problems with symbolic information.
Dependence graph.
Define a dynamic point+bounds, with a way to save and restore previous points+bounds through a LIFO s...
Auxiliary variable.
virtual CouNumber Value() const
value
int Multiplicity()
multiplicity of a variable: how many times this variable occurs in expressions throughout the problem
exprCopy(const exprCopy &e, Domain *d=NULL)
Copy constructor.
const expression * Original() const
If this is an exprClone of a exprClone of an expr???, point to the original expr??...
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's arguments.
virtual CouNumber operator()()
null function for evaluating the expression
bool isBijective() const
indicating if function is monotonically increasing
virtual bool isDefinedInteger()
is this expression DEFINED as integer?
int nArgs() const
Return number of arguments (when applicable, that is, with N-ary functions)
int Linearity()
get a measure of "how linear" the expression is (see CouenneTypes.h)
enum convexity convexity() const
either CONVEX, CONCAVE, AFFINE, or NONCONVEX
enum expr_type code()
code for comparisons
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
virtual void print(std::ostream &out=std::cout, bool descend=false) const
I/O.
expression ** ArgPtr()
return pointer to argument (when applicable, i.e., with univariate functions)
expression * Image() const
return pointer to corresponding expression (for auxiliary variables only)
virtual expression * clone(Domain *d=NULL) const
Cloning method.
void fillDepSet(std::set< DepNode *, compNode > *dep, DepGraph *g)
fill in dependence structure
int compare(expression &e)
compare this with other expression
expression ** ArgList() const
return arglist (when applicable, that is, with N-ary functions)
enum nodeType Type() const
node type
expression * Copy() const
return copy of this expression (only makes sense in exprCopy)
expression * differentiate(int index)
differentiation
virtual ~exprCopy()
Destructor – CAUTION: this is the only destructive destructor, exprClone and exprStore do not destroy...
void replace(exprVar *, exprVar *)
replace occurrence of a variable with another variable
exprCopy(expression *copy)
Empty constructor - used in cloning method of exprClone.
exprAux * standardize(CouenneProblem *p, bool addAux=true)
Create standard formulation of this expression.
void getBounds(CouNumber &lower, CouNumber &upper)
Get value of lower and upper bound of an expression (if any)
void getBounds(expression *&lower, expression *&upper)
Get lower and upper bound of an expression (if any)
CouNumber value_
saved value to be used by exprStore expressions
void ArgList(expression **al)
set arglist (used in deleting nodes without deleting children)
int rank()
used in rank-based branching variable choice
bool impliedBound(int wind, CouNumber *l, CouNumber *u, t_chg_bounds *chg)
implied bound processing
void closestFeasible(expression *varind, expression *vardep, CouNumber &left, CouNumber &right) const
closest feasible points in function in both directions
int Index() const
Get variable index in problem.
bool isCuttable(CouenneProblem *problem, int index) const
can this expression be further linearized or are we on its concave ("bad") side
CouNumber gradientNorm(const double *x)
return l-2 norm of gradient at given point
bool isaCopy() const
return true if this is a copy of something, i.e.
CouNumber inverse(expression *vardep) const
compute the inverse function
void realign(const CouenneProblem *p)
redirect variables to proper variable vector
expression * simplify()
simplify expression (useful for derivatives)
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
bool isInteger()
is this expression integer?
expression * Argument() const
return argument (when applicable, i.e., with univariate functions)
expression * copy_
the expression this object is a (reference) copy of
variable-type operator
Expression base class.
status of lower/upper bound of a variable, to be checked/modified in bound tightening
general include file for different compilers
nodeType
type of a node in an expression tree
dig_type
type of digging when filling the dependence list
double CouNumber
main number type in Couenne
convexity
convexity type of an expression
expr_type
code returned by the method expression::code()