Couenne 0.5.8
CouenneExprAux.hpp
Go to the documentation of this file.
1/* $Id: CouenneExprAux.hpp 1195 2015-11-24 23:25:31Z pbelotti $
2 *
3 * Name: exprAux.hpp
4 * Author: Pietro Belotti
5 * Purpose: definition of the auxiliary variable class (used in
6 * standardization and convexification)
7 *
8 * (C) Carnegie-Mellon University, 2006-10.
9 * This file is licensed under the Eclipse Public License (EPL)
10 */
11
12#ifndef COUENNE_EXPRAUX_HPP
13#define COUENNE_EXPRAUX_HPP
14
15#include <iostream>
16#include <assert.h>
17
18#include "CouenneExprVar.hpp"
19
20namespace Couenne {
21
22class CouenneCutGenerator;
23
32class exprAux: public exprVar {
33
34 public:
35
38
39 protected:
40
43
47
51
55 int rank_;
56
61
64
68
71
72 public:
73
75 inline enum nodeType Type () const
76 {return AUX;}
77
79 exprAux (expression *, int, int, intType = Unset, Domain * = NULL, enum auxSign = expression::AUX_EQ);
80
83
85 virtual ~exprAux ();
86
88 exprAux (const exprAux &, Domain *d = NULL);
89
91 virtual inline exprVar *clone (Domain *d = NULL) const
92 {return new exprAux (*this, d);}
93
94 inline expression *Lb () {return lb_;}
95 inline expression *Ub () {return ub_;}
96
98 virtual void print (std::ostream & = std::cout,
99 bool = false) const;
100
102 inline expression *Image () const
103 {return image_;}
104
106 inline void Image (expression *image)
107 {image_ = image;}
108
111 {return domain_ -> x (varIndex_);}
112
115 int DepList (std::set <int> &deplist,
116 enum dig_type type = ORIG_ONLY);
117
120
122 inline int Linearity ()
123 {return LINEAR;}
124 /*return image_ -> Linearity ();*/
125
127 //virtual void getBounds (expression *&lb, expression *&ub);
128
131 void crossBounds ();
132
134 void generateCuts (//const OsiSolverInterface &,
135 OsiCuts &, const CouenneCutGenerator *,
136 t_chg_bounds * = NULL, int = -1,
139
141 virtual inline int rank ()
142 {return rank_;}
143
145 virtual inline bool isDefinedInteger () {
146
147 return ((integer_ == Integer) ||
148 ((integer_ == Unset) &&
149 ((integer_ = ((image_ != NULL) && (image_ -> isInteger ())) ?
150 Integer : Continuous) == Integer)));
151 }
152
154 virtual inline bool isInteger () {
155
156 if (isDefinedInteger ())
157 return true;
158
159 register CouNumber l = lb ();
160 return ((l == ub ()) && (COUENNE_round (l) == l));
161 //CouNumber l = (*(Lb ())) ();
162 //return (::isInteger (l) && (fabs (l - (*(Ub ())) ()) < COUENNE_EPS));
163 }
164
166 virtual inline void setInteger (bool value)
167 {integer_ = value ? Integer : Continuous;}
168
170 inline void increaseMult () {++multiplicity_;}
171
174 inline void decreaseMult () {--multiplicity_;}
175
177 inline void zeroMult () {multiplicity_ = 0;}
178
180 inline int Multiplicity () {return multiplicity_;}
181
183 inline void linkDomain (Domain *d) {
184 domain_ = d;
185 if (lb_) lb_ -> linkDomain (d);
186 if (ub_) ub_ -> linkDomain (d);
187 }
188
190 bool &top_level ()
191 {return top_level_;}
192
196 CouenneProblem *p,
198 JnlstPtr jnlst);
199
201 virtual inline enum auxSign sign () const
202 {return sign_;}
203};
204
205
211struct compExpr {
212 inline bool operator () (exprAux* e0, exprAux* e1) const
213 {
214 int signDiff = (e0 -> sign () - e1 -> sign ());
215
216 assert (e0 -> Image () != NULL);
217 assert (e1 -> Image () != NULL);
218
219 return ((signDiff < 0) ||
220 ((signDiff == 0) &&
221 ((e0 -> Image () != NULL) &&
222 (e1 -> Image () != NULL) &&
223 (e0 -> Image () -> compare (*(e1 -> Image ())) < 0))));
224 }
225};
226
227
230 int, expression *, expression *);
231
232}
233
234#endif
#define COUENNE_INFINITY
#define COUENNE_round(x)
Cut Generator for linear convexifications.
OsiObject for auxiliary variables $w=f(x)$.
Class for MINLP problems with symbolic information.
Define a dynamic point+bounds, with a way to save and restore previous points+bounds through a LIFO s...
Auxiliary variable.
expression * Lb()
get lower bound expression
virtual ~exprAux()
Destructor.
virtual bool isInteger()
is this expression integer?
virtual int rank()
used in rank-based branching variable choice
void Image(expression *image)
Sets expression associated with this auxiliary variable.
enum auxSign sign_
"sign" of the defining constraint
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
expression * Image() const
The expression associated with this auxiliary variable.
virtual void print(std::ostream &=std::cout, bool=false) const
Print expression.
enum intType integer_
is this variable integer?
void decreaseMult()
Tell this variable appears once less (standardized within exprSum, for instance)
void generateCuts(OsiCuts &, const CouenneCutGenerator *, t_chg_bounds *=NULL, int=-1, CouNumber=-COUENNE_INFINITY, CouNumber=COUENNE_INFINITY)
generate cuts for expression associated with this auxiliary
int Linearity()
Get a measure of "how linear" the expression is (see CouenneTypes.h)
void crossBounds()
Get lower and upper bound of an expression (if any)
exprAux(expression *, int, int, intType=Unset, Domain *=NULL, enum auxSign=expression::AUX_EQ)
Constructor.
exprAux(expression *, Domain *=NULL, enum auxSign=expression::AUX_EQ)
Constructor to be used with standardize ([...], false)
intType
integrality type of an auxiliary variable: unset, continuous, integer
enum nodeType Type() const
Node type.
expression * Ub()
get upper bound expression
exprAux(const exprAux &, Domain *d=NULL)
Copy constructor.
virtual enum auxSign sign() const
return its sign in the definition constraint
expression * ub_
upper bound, a function of the associated expression and the bounds on the variables in the expressio...
expression * simplify()
simplify
int multiplicity_
number of appearances of this aux in the formulation.
void linkDomain(Domain *d)
link this variable to a domain
void increaseMult()
Tell this variable appears once more.
int Multiplicity()
How many times this variable appears.
int rank_
used in rank-based branching variable choice: original variables have rank 1; auxiliary w=f(x) has ra...
CouNumber operator()()
Null function for evaluating the expression.
virtual void setInteger(bool value)
Set this variable as integer.
bool top_level_
True if this variable replaces the lhs of a constraint, i.e., if it is a top level variable in the DA...
bool & top_level()
return top_level_
void zeroMult()
Disable this auxiliary variable.
virtual exprVar * clone(Domain *d=NULL) const
Cloning method.
CouenneObject * properObject(CouenneCutGenerator *c, CouenneProblem *p, Bonmin::BabSetupBase *base, JnlstPtr jnlst)
return proper object to handle expression associated with this variable (NULL if this is not an auxil...
expression * image_
The expression associated with this auxiliary variable.
virtual bool isDefinedInteger()
is this expression defined as integer?
expression * lb_
lower bound, a function of the associated expression and the bounds on the variables in the expressio...
variable-type operator
virtual CouNumber & ub()
Get/set upper bound value.
int varIndex_
The index of the variable.
virtual CouNumber & lb()
Get/set lower bound value.
Domain * domain_
Pointer to a descriptor of the current point/bounds.
Expression base class.
auxSign
"sign" of the constraint defining an auxiliary.
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
void draw_cuts(OsiCuts &, const CouenneCutGenerator *, int, expression *, expression *)
allow to draw function within intervals and cuts introduced
double CouNumber
main number type in Couenne
Structure for comparing expressions.
bool operator()(exprAux *e0, exprAux *e1) const