Couenne  0.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CouenneExprDiv.hpp
Go to the documentation of this file.
1 /* $Id: CouenneExprDiv.hpp 615 2011-06-08 20:36:24Z pbelotti $
2  *
3  * Name: exprDiv.hpp
4  * Author: Pietro Belotti
5  * Purpose: definition of divisions
6  *
7  * (C) Carnegie-Mellon University, 2006-10.
8  * This file is licensed under the Eclipse Public License (EPL)
9  */
10 
11 #ifndef COUENNE_EXPRDIV_HPP
12 #define COUENNE_EXPRDIV_HPP
13 
14 #include "CouenneExprOp.hpp"
15 #include "CouennePrecisions.hpp"
16 
17 namespace Couenne {
18 
19 #define BR_NEXT_ZERO 1e-3
20 #define BR_MULT 1e-3
21 
23 
24 class exprDiv: public exprOp {
25 
26  public:
27 
29  exprDiv (expression **al, int n = 2):
30  exprOp (al, n) {} //< non-leaf expression, with argument list
31 
33  exprDiv (expression *arg0, expression *arg1):
34  exprOp (arg0, arg1) {}
35 
37  expression *clone (Domain *d = NULL) const
38  {return new exprDiv (clonearglist (d), nargs_);}
39 
41  std::string printOp () const
42  {return "/";}
43 
45  inline CouNumber operator () ();
46 
48  CouNumber gradientNorm (const double *x);
49 
51  expression *differentiate (int index);
52 
54  expression *simplify ();
55 
57  inline int Linearity () {
58 
59  if (arglist_ [1] -> Type () == CONST)
60  return arglist_ [0] -> Linearity ();
61  else return NONLINEAR;
62  }
63 
65  void getBounds (expression *&lb, expression *&ub);
66 
68  void getBounds (CouNumber &lb, CouNumber &ub);
69 
72  exprAux *standardize (CouenneProblem *p, bool addAux = true);
73 
75  void generateCuts (expression *w, //const OsiSolverInterface &si,
76  OsiCuts &cs, const CouenneCutGenerator *cg,
77  t_chg_bounds * = NULL, int = -1,
80 
82  virtual enum expr_type code () {return COU_EXPRDIV;}
83 
85  bool isInteger ();
86 
89 
92  virtual CouNumber selectBranch (const CouenneObject *obj,
93  const OsiBranchingInformation *info,
94  expression * &var,
95  double * &brpts,
96  double * &brDist, // distance of current LP
97  // point to new convexifications
98  int &way);
99 
101  virtual void closestFeasible (expression *varind,
102  expression *vardep,
103  CouNumber &left,
104  CouNumber &right) const;
105 
108  virtual bool isCuttable (CouenneProblem *problem, int index) const
109  {return false;} // concave on both sides, as for products
110 };
111 
112 
114 
116  {return ((*(*arglist_)) () / (*(arglist_ [1])) ());}
117 
118 
119 #define SAFE_COEFFICIENT 1e9
120 
123 
124 inline bool is_boundbox_regular (register CouNumber b1, register CouNumber b2) {
125 
126  // Why SAFE_COEFFICIENT and not COUENNE_INFINITY? Because
127  // OsiRowCut::set[LU]b do not work for values more than
128  // SAFE_COEFFICIENT and apparently makes the convexification
129  // infeasible.
130  return
131  (fabs (b1) < SAFE_COEFFICIENT) &&
132  (fabs (b2) < SAFE_COEFFICIENT) &&
133  (fabs (b1*b2) < SAFE_COEFFICIENT);
134  // && ((fabs (b1) > COUENNE_EPS) || (fabs (b2) > COUENNE_EPS));
135 }
136 
137 }
138 
139 #endif
Cut Generator for linear convexifications.
exprDiv(expression **al, int n=2)
Constructor.
int Linearity()
Get a measure of &quot;how linear&quot; the expression is (see CouenneTypes.h)
expression * simplify()
Simplification.
bool impliedBound(int, CouNumber *, CouNumber *, t_chg_bounds *, enum auxSign=expression::AUX_EQ)
Implied bound processing.
OsiObject for auxiliary variables $w=f(x)$.
status of lower/upper bound of a variable, to be checked/modified in bound tightening ...
bool is_boundbox_regular(register CouNumber b1, register CouNumber b2)
check if bounding box is suitable for a multiplication/division convexification constraint ...
expression * clone(Domain *d=NULL) const
Cloning method.
exprDiv(expression *arg0, expression *arg1)
Constructor with two arguments given explicitly.
virtual enum expr_type code()
Code for comparisons.
CouNumber operator()()
Function for the evaluation of the expression.
CouNumber gradientNorm(const double *x)
return l-2 norm of gradient at given point
class for divisions,
std::string printOp() const
Print operator.
virtual enum nodeType Type() const
Node type.
auxSign
&quot;sign&quot; of the constraint defining an auxiliary.
expression ** clonearglist(Domain *d=NULL) const
clone argument list (for use with clone method)
virtual bool isCuttable(CouenneProblem *problem, int index) const
can this expression be further linearized or are we on its concave (&quot;bad&quot;) side
Class for MINLP problems with symbolic information.
virtual void closestFeasible(expression *varind, expression *vardep, CouNumber &left, CouNumber &right) const
compute $y^{lv}$ and $y^{uv}$ for Violation Transfer algorithm
bool isInteger()
is this expression integer?
expression ** arglist_
argument list is an array of pointers to other expressions
double CouNumber
main number type in Couenne
int nargs_
number of arguments (cardinality of arglist)
general n-ary operator-type expression: requires argument list.
#define COUENNE_INFINITY
Auxiliary variable.
void generateCuts(expression *w, OsiCuts &cs, const CouenneCutGenerator *cg, t_chg_bounds *=NULL, int=-1, CouNumber=-COUENNE_INFINITY, CouNumber=COUENNE_INFINITY)
Generate equality between *this and *w.
expr_type
code returned by the method expression::code()
#define SAFE_COEFFICIENT
Expression base class.
void getBounds(expression *&lb, expression *&ub)
Get lower and upper bound of an expression (if any)
virtual 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...
Define a dynamic point+bounds, with a way to save and restore previous points+bounds through a LIFO s...
expression * differentiate(int index)
Differentiation.
exprAux * standardize(CouenneProblem *p, bool addAux=true)
Reduce expression in standard form, creating additional aux variables (and constraints) ...