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
17namespace Couenne {
18
19#define BR_NEXT_ZERO 1e-3
20#define BR_MULT 1e-3
21
23
24class 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
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
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
124inline 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
#define SAFE_COEFFICIENT
#define COUENNE_INFINITY
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.
class for divisions,
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.
expression * differentiate(int index)
Differentiation.
expression * simplify()
Simplification.
std::string printOp() const
Print operator.
exprDiv(expression **al, int n=2)
Constructor.
bool impliedBound(int, CouNumber *, CouNumber *, t_chg_bounds *, enum auxSign=expression::AUX_EQ)
Implied bound processing.
exprDiv(expression *arg0, expression *arg1)
Constructor with two arguments given explicitly.
virtual enum expr_type code()
Code for comparisons.
virtual bool isCuttable(CouenneProblem *problem, int index) const
can this expression be further linearized or are we on its concave ("bad") side
bool isInteger()
is this expression integer?
int Linearity()
Get a measure of "how linear" the expression is (see CouenneTypes.h)
CouNumber operator()()
Function for the evaluation of the expression.
exprAux * standardize(CouenneProblem *p, bool addAux=true)
Reduce expression in standard form, creating additional aux variables (and constraints)
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's arguments.
expression * clone(Domain *d=NULL) const
Cloning method.
void getBounds(CouNumber &lb, CouNumber &ub)
Get value of lower and upper bound of an expression (if any)
CouNumber gradientNorm(const double *x)
return l-2 norm of gradient at given point
virtual void closestFeasible(expression *varind, expression *vardep, CouNumber &left, CouNumber &right) const
compute $y^{lv}$ and $y^{uv}$ for Violation Transfer algorithm
general n-ary operator-type expression: requires argument list.
int nargs_
number of arguments (cardinality of arglist)
virtual enum nodeType Type() const
Node type.
expression ** arglist_
argument list is an array of pointers to other expressions
expression ** clonearglist(Domain *d=NULL) const
clone argument list (for use with clone method)
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
bool is_boundbox_regular(register CouNumber b1, register CouNumber b2)
check if bounding box is suitable for a multiplication/division convexification constraint
double CouNumber
main number type in Couenne
expr_type
code returned by the method expression::code()