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 1080 2014-10-30 20:06:40Z 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 
17 #include "CouenneExprVar.hpp"
18 
19 namespace Couenne {
20 
21 class CouenneCutGenerator;
22 
31 class exprAux: public exprVar {
32 
33  public:
34 
37 
38  protected:
39 
42 
46 
50 
54  int rank_;
55 
60 
63 
66  bool top_level_;
67 
69  enum auxSign sign_;
70 
71  public:
72 
74  inline enum nodeType Type () const
75  {return AUX;}
76 
78  exprAux (expression *, int, int, intType = Unset, Domain * = NULL, enum auxSign = expression::AUX_EQ);
79 
81  exprAux (expression *, Domain * = NULL, enum auxSign = expression::AUX_EQ);
82 
84  virtual ~exprAux ();
85 
87  exprAux (const exprAux &, Domain *d = NULL);
88 
90  virtual inline exprVar *clone (Domain *d = NULL) const
91  {return new exprAux (*this, d);}
92 
93  inline expression *Lb () {return lb_;}
94  inline expression *Ub () {return ub_;}
95 
97  virtual void print (std::ostream & = std::cout,
98  bool = false) const;
99 
101  inline expression *Image () const
102  {return image_;}
103 
105  inline void Image (expression *image)
106  {image_ = image;}
107 
110  {return domain_ -> x (varIndex_);}
111 
114  int DepList (std::set <int> &deplist,
115  enum dig_type type = ORIG_ONLY);
116 
118  expression *simplify ();
119 
121  inline int Linearity ()
122  {return LINEAR;}
123  /*return image_ -> Linearity ();*/
124 
126  //virtual void getBounds (expression *&lb, expression *&ub);
127 
130  void crossBounds ();
131 
133  void generateCuts (//const OsiSolverInterface &,
134  OsiCuts &, const CouenneCutGenerator *,
135  t_chg_bounds * = NULL, int = -1,
138 
140  virtual inline int rank ()
141  {return rank_;}
142 
144  virtual inline bool isDefinedInteger () {
145 
146  return ((integer_ == Integer) ||
147  ((integer_ == Unset) &&
148  ((integer_ = ((image_ != NULL) && (image_ -> isInteger ())) ?
149  Integer : Continuous) == Integer)));
150  }
151 
153  virtual inline bool isInteger () {
154 
155  if (isDefinedInteger ())
156  return true;
157 
158  register CouNumber l = lb ();
159  return ((l == ub ()) && (COUENNE_round (l) == l));
160  //CouNumber l = (*(Lb ())) ();
161  //return (::isInteger (l) && (fabs (l - (*(Ub ())) ()) < COUENNE_EPS));
162  }
163 
165  virtual inline void setInteger (bool value)
166  {integer_ = value ? Integer : Continuous;}
167 
169  inline void increaseMult () {++multiplicity_;}
170 
173  inline void decreaseMult () {--multiplicity_;}
174 
176  inline void zeroMult () {multiplicity_ = 0;}
177 
179  inline int Multiplicity () {return multiplicity_;}
180 
182  inline void linkDomain (Domain *d) {
183  domain_ = d;
184  if (lb_) lb_ -> linkDomain (d);
185  if (ub_) ub_ -> linkDomain (d);
186  }
187 
189  bool &top_level ()
190  {return top_level_;}
191 
195  CouenneProblem *p,
196  Bonmin::BabSetupBase *base,
197  JnlstPtr jnlst);
198 
200  virtual inline enum auxSign sign () const
201  {return sign_;}
202 };
203 
204 
210 struct compExpr {
211  inline bool operator () (exprAux* e0, exprAux* e1) const
212  {
213  return ((e0 -> sign () < e1 -> sign ()) ||
214  ((e0 -> Image () != NULL) && (e1 -> Image () != NULL) && (e0 -> Image () -> compare (*(e1 -> Image ())) < 0)));
215  }
216 };
217 
218 
220 void draw_cuts (OsiCuts &, const CouenneCutGenerator *,
221  int, expression *, expression *);
222 
223 }
224 
225 #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.