Couenne  0.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
20 namespace Couenne {
21 
22 class CouenneCutGenerator;
23 
32 class exprAux: public exprVar {
33 
34  public:
35 
38 
39  protected:
40 
43 
47 
51 
55  int rank_;
56 
61 
64 
67  bool top_level_;
68 
70  enum auxSign sign_;
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 
82  exprAux (expression *, Domain * = NULL, enum auxSign = expression::AUX_EQ);
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 
119  expression *simplify ();
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,
197  Bonmin::BabSetupBase *base,
198  JnlstPtr jnlst);
199 
201  virtual inline enum auxSign sign () const
202  {return sign_;}
203 };
204 
205 
211 struct 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 
229 void draw_cuts (OsiCuts &, const CouenneCutGenerator *,
230  int, expression *, expression *);
231 
232 }
233 
234 #endif
Cut Generator for linear convexifications.
void increaseMult()
Tell this variable appears once more.
#define COUENNE_round(x)
enum intType integer_
is this variable integer?
int multiplicity_
number of appearances of this aux in the formulation.
OsiObject for auxiliary variables $w=f(x)$.
bool & top_level()
return top_level_
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.
status of lower/upper bound of a variable, to be checked/modified in bound tightening ...
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
enum auxSign sign_
&quot;sign&quot; of the defining constraint
void draw_cuts(OsiCuts &, const CouenneCutGenerator *, int, expression *, expression *)
allow to draw function within intervals and cuts introduced
virtual int rank()
used in rank-based branching variable choice
Domain * domain_
Pointer to a descriptor of the current point/bounds.
virtual void setInteger(bool value)
Set this variable as integer.
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
Structure for comparing expressions.
expression * Image() const
The expression associated with this auxiliary variable.
void crossBounds()
Get lower and upper bound of an expression (if any)
expression * Ub()
get upper bound expression
virtual void print(std::ostream &=std::cout, bool=false) const
Print expression.
auxSign
&quot;sign&quot; of the constraint defining an auxiliary.
void zeroMult()
Disable this auxiliary variable.
virtual CouNumber & ub()
Get/set upper bound value.
enum nodeType Type() const
Node type.
Class for MINLP problems with symbolic information.
intType
integrality type of an auxiliary variable: unset, continuous, integer
expression * simplify()
simplify
expression * lb_
lower bound, a function of the associated expression and the bounds on the variables in the expressio...
bool operator()(exprAux *e0, exprAux *e1) const
exprAux(expression *, int, int, intType=Unset, Domain *=NULL, enum auxSign=expression::AUX_EQ)
Constructor.
virtual enum auxSign sign() const
return its sign in the definition constraint
double CouNumber
main number type in Couenne
virtual exprVar * clone(Domain *d=NULL) const
Cloning method.
nodeType
type of a node in an expression tree
int Linearity()
Get a measure of &quot;how linear&quot; the expression is (see CouenneTypes.h)
void linkDomain(Domain *d)
link this variable to a domain
#define COUENNE_INFINITY
Auxiliary variable.
dig_type
type of digging when filling the dependence list
virtual bool isInteger()
is this expression integer?
variable-type operator
virtual bool isDefinedInteger()
is this expression defined as integer?
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 * Lb()
get lower bound expression
Expression base class.
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...
void decreaseMult()
Tell this variable appears once less (standardized within exprSum, for instance)
expression * ub_
upper bound, a function of the associated expression and the bounds on the variables in the expressio...
int varIndex_
The index of the variable.
expression * image_
The expression associated with this auxiliary variable.
void Image(expression *image)
Sets expression associated with this auxiliary variable.
int Multiplicity()
How many times this variable appears.
Define a dynamic point+bounds, with a way to save and restore previous points+bounds through a LIFO s...
virtual CouNumber & lb()
Get/set lower bound value.
virtual ~exprAux()
Destructor.