Couenne  0.5.8
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 
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
Couenne::t_chg_bounds
status of lower/upper bound of a variable, to be checked/modified in bound tightening
Definition: CouenneTypes.hpp:67
Couenne::exprDiv::impliedBound
bool impliedBound(int, CouNumber *, CouNumber *, t_chg_bounds *, enum auxSign=expression::AUX_EQ)
Implied bound processing.
Couenne::exprDiv::operator()
CouNumber operator()()
Function for the evaluation of the expression.
Definition: CouenneExprDiv.hpp:115
Couenne::exprOp::nargs_
int nargs_
number of arguments (cardinality of arglist)
Definition: CouenneExprOp.hpp:36
Couenne::exprDiv::printOp
std::string printOp() const
Print operator.
Definition: CouenneExprDiv.hpp:41
Couenne::expr_type
expr_type
code returned by the method expression::code()
Definition: CouenneTypes.hpp:40
CouennePrecisions.hpp
Couenne::exprOp
general n-ary operator-type expression: requires argument list.
Definition: CouenneExprOp.hpp:31
Couenne::exprDiv::simplify
expression * simplify()
Simplification.
COUENNE_INFINITY
#define COUENNE_INFINITY
Definition: CouennePrecisions.hpp:32
Couenne::exprDiv::clone
expression * clone(Domain *d=NULL) const
Cloning method.
Definition: CouenneExprDiv.hpp:37
Couenne::exprDiv::gradientNorm
CouNumber gradientNorm(const double *x)
return l-2 norm of gradient at given point
Couenne::exprDiv::isInteger
bool isInteger()
is this expression integer?
Couenne::expression::AUX_EQ
@ AUX_EQ
Definition: CouenneExpression.hpp:55
Couenne::exprOp::clonearglist
expression ** clonearglist(Domain *d=NULL) const
clone argument list (for use with clone method)
Definition: CouenneExprOp.hpp:97
Couenne::CouenneCutGenerator
Cut Generator for linear convexifications.
Definition: CouenneCutGenerator.hpp:49
Couenne::CONST
@ CONST
Definition: CouenneTypes.hpp:20
Couenne::exprDiv::differentiate
expression * differentiate(int index)
Differentiation.
Couenne::exprDiv::exprDiv
exprDiv(expression *arg0, expression *arg1)
Constructor with two arguments given explicitly.
Definition: CouenneExprDiv.hpp:33
Couenne
general include file for different compilers
Definition: CouenneAggrProbing.hpp:24
Couenne::exprDiv::Linearity
int Linearity()
Get a measure of "how linear" the expression is (see CouenneTypes.h)
Definition: CouenneExprDiv.hpp:57
Couenne::exprDiv::isCuttable
virtual bool isCuttable(CouenneProblem *problem, int index) const
can this expression be further linearized or are we on its concave ("bad") side
Definition: CouenneExprDiv.hpp:108
Couenne::CouenneObject
OsiObject for auxiliary variables $w=f(x)$.
Definition: CouenneObject.hpp:57
Couenne::exprDiv::selectBranch
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's arguments.
Couenne::CouNumber
double CouNumber
main number type in Couenne
Definition: CouenneTypes.hpp:100
Couenne::exprDiv::closestFeasible
virtual void closestFeasible(expression *varind, expression *vardep, CouNumber &left, CouNumber &right) const
compute $y^{lv}$ and $y^{uv}$ for Violation Transfer algorithm
SAFE_COEFFICIENT
#define SAFE_COEFFICIENT
Definition: CouenneExprDiv.hpp:119
Couenne::exprDiv::exprDiv
exprDiv(expression **al, int n=2)
Constructor.
Definition: CouenneExprDiv.hpp:29
OsiCuts
Couenne::exprDiv
class for divisions,
Definition: CouenneExprDiv.hpp:24
Couenne::expression::auxSign
auxSign
"sign" of the constraint defining an auxiliary.
Definition: CouenneExpression.hpp:55
Couenne::COU_EXPRDIV
@ COU_EXPRDIV
Definition: CouenneTypes.hpp:46
Couenne::is_boundbox_regular
bool is_boundbox_regular(register CouNumber b1, register CouNumber b2)
check if bounding box is suitable for a multiplication/division convexification constraint
Definition: CouenneExprDiv.hpp:124
Couenne::exprDiv::getBounds
void getBounds(expression *&lb, expression *&ub)
Get lower and upper bound of an expression (if any)
Couenne::exprDiv::getBounds
void getBounds(CouNumber &lb, CouNumber &ub)
Get value of lower and upper bound of an expression (if any)
OsiBranchingInformation
Couenne::exprDiv::generateCuts
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.
Couenne::exprDiv::code
virtual enum expr_type code()
Code for comparisons.
Definition: CouenneExprDiv.hpp:82
Couenne::NONLINEAR
@ NONLINEAR
Definition: CouenneTypes.hpp:23
Couenne::exprDiv::standardize
exprAux * standardize(CouenneProblem *p, bool addAux=true)
Reduce expression in standard form, creating additional aux variables (and constraints)
Couenne::CouenneProblem
Class for MINLP problems with symbolic information.
Definition: CouenneProblem.hpp:169
CouenneExprOp.hpp
Couenne::exprOp::arglist_
expression ** arglist_
argument list is an array of pointers to other expressions
Definition: CouenneExprOp.hpp:35
Couenne::exprAux
Auxiliary variable.
Definition: CouenneExprAux.hpp:32
Couenne::exprOp::Type
virtual enum nodeType Type() const
Node type.
Definition: CouenneExprOp.hpp:41
Couenne::expression
Expression base class.
Definition: CouenneExpression.hpp:48
Couenne::Domain
Define a dynamic point+bounds, with a way to save and restore previous points+bounds through a LIFO s...
Definition: CouenneDomain.hpp:104