Couenne  0.5.8
CouenneExprInv.hpp
Go to the documentation of this file.
1 /* $Id: CouenneExprInv.hpp 615 2011-06-08 20:36:24Z pbelotti $
2  *
3  * Name: exprInv.hpp
4  * Author: Pietro Belotti
5  * Purpose: definition of inverse of a function (1/f(x))
6  *
7  * (C) Carnegie-Mellon University, 2006-10.
8  * This file is licensed under the Eclipse Public License (EPL)
9  */
10 
11 #ifndef COUENNE_EXPRINV_H
12 #define COUENNE_EXPRINV_H
13 
14 #include "CouenneExprUnary.hpp"
15 
16 namespace Couenne {
17 
19 inline CouNumber inv (register CouNumber arg)
20 {return 1. / arg;}
21 
22 
24 inline CouNumber oppInvSqr (register CouNumber x)
25 {return (- inv (x*x));}
26 
27 
29 inline CouNumber inv_dblprime (register CouNumber x)
30 {return (2 * inv (x*x*x));}
31 
32 
34 
35 class exprInv: public exprUnary {
36 
37  public:
38 
41  exprUnary (al) {} //< non-leaf expression, with argument list
42 
44  expression *clone (Domain *d = NULL) const
45  {return new exprInv (argument_ -> clone (d));}
46 
48  inline unary_function F () {return inv;}
49 
51  virtual void print (std::ostream &out = std::cout, bool = false) const;
52 
54  CouNumber gradientNorm (const double *x);
55 
57  expression *differentiate (int index);
58 
60  virtual inline int Linearity () {
61  if (argument_ -> Type () == CONST) return CONSTANT;
62  else return NONLINEAR;
63  }
64 
66  void getBounds (expression *&, expression *&);
67 
69  void getBounds (CouNumber &lb, CouNumber &ub);
70 
72  void generateCuts (expression *w, //const OsiSolverInterface &si,
73  OsiCuts &cs, const CouenneCutGenerator *cg,
74  t_chg_bounds * = NULL, int = -1,
77 
79  virtual enum expr_type code () {return COU_EXPRINV;}
80 
83 
86  virtual CouNumber selectBranch (const CouenneObject *obj,
87  const OsiBranchingInformation *info,
88  expression * &var,
89  double * &brpts,
90  double * &brDist, // distance of current LP
91  // point to new convexifications
92  int &way);
93 
95  virtual bool isBijective() const {return true;}
96 
98  virtual CouNumber inverse(expression *vardep) const
99  {
100  return 1./((*vardep)());
101  }
102 
105  virtual bool isCuttable (CouenneProblem *problem, int index) const;
106 };
107 
108 }
109 
110 #endif
Couenne::t_chg_bounds
status of lower/upper bound of a variable, to be checked/modified in bound tightening
Definition: CouenneTypes.hpp:66
Couenne::oppInvSqr
CouNumber oppInvSqr(register CouNumber x)
derivative of inv (x)
Definition: CouenneExprInv.hpp:24
Couenne::unary_function
CouNumber(* unary_function)(CouNumber)
unary function, used in all exprUnary
Definition: CouenneTypes.hpp:103
Couenne::inv_dblprime
CouNumber inv_dblprime(register CouNumber x)
inv_dblprime, second derivative of inv (x)
Definition: CouenneExprInv.hpp:29
Couenne::exprInv::isCuttable
virtual bool isCuttable(CouenneProblem *problem, int index) const
can this expression be further linearized or are we on its concave ("bad") side
Couenne::exprUnary::argument_
expression * argument_
single argument taken by this expression
Definition: CouenneExprUnary.hpp:38
Couenne::expr_type
expr_type
code returned by the method expression::code()
Definition: CouenneTypes.hpp:40
COUENNE_INFINITY
#define COUENNE_INFINITY
Definition: CouennePrecisions.hpp:32
Couenne::exprUnary
expression class for unary functions (sin, log, etc.)
Definition: CouenneExprUnary.hpp:33
Couenne::exprInv::differentiate
expression * differentiate(int index)
differentiation
Couenne::expression::AUX_EQ
@ AUX_EQ
Definition: CouenneExpression.hpp:55
Couenne::CouenneCutGenerator
Cut Generator for linear convexifications.
Definition: CouenneCutGenerator.hpp:49
Couenne::exprInv::Linearity
virtual int Linearity()
get a measure of "how linear" the expression is (see CouenneTypes.h)
Definition: CouenneExprInv.hpp:60
Couenne::CONST
@ CONST
Definition: CouenneTypes.hpp:20
Couenne::exprInv
class inverse:
Definition: CouenneExprInv.hpp:35
Couenne::exprInv::isBijective
virtual bool isBijective() const
return true if bijective
Definition: CouenneExprInv.hpp:95
Couenne
general include file for different compilers
Definition: CouenneAggrProbing.hpp:24
Couenne::exprInv::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::exprInv::gradientNorm
CouNumber gradientNorm(const double *x)
return l-2 norm of gradient at given point
Couenne::exprInv::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::exprInv::exprInv
exprInv(expression *al)
Constructors, destructor.
Definition: CouenneExprInv.hpp:40
Couenne::CouenneObject
OsiObject for auxiliary variables $w=f(x)$.
Definition: CouenneObject.hpp:57
Couenne::exprInv::getBounds
void getBounds(expression *&, expression *&)
Get lower and upper bound of an expression (if any)
Couenne::inv
CouNumber inv(register CouNumber arg)
the operator itself
Definition: CouenneExprInv.hpp:19
Couenne::CONSTANT
@ CONSTANT
Definition: CouenneTypes.hpp:23
Couenne::CouNumber
double CouNumber
main number type in Couenne
Definition: CouenneTypes.hpp:100
OsiCuts
Couenne::exprInv::print
virtual void print(std::ostream &out=std::cout, bool=false) const
output "1/argument"
CouenneExprUnary.hpp
Couenne::expression::auxSign
auxSign
"sign" of the constraint defining an auxiliary.
Definition: CouenneExpression.hpp:55
Couenne::exprInv::clone
expression * clone(Domain *d=NULL) const
cloning method
Definition: CouenneExprInv.hpp:44
Couenne::exprInv::inverse
virtual CouNumber inverse(expression *vardep) const
return inverse of y=f(x)=1/x, i.e., x=1/y
Definition: CouenneExprInv.hpp:98
OsiBranchingInformation
Couenne::exprInv::impliedBound
bool impliedBound(int, CouNumber *, CouNumber *, t_chg_bounds *, enum auxSign=expression::AUX_EQ)
implied bound processing
Couenne::exprUnary::Type
virtual enum nodeType Type() const
node type
Definition: CouenneExprUnary.hpp:43
Couenne::COU_EXPRINV
@ COU_EXPRINV
Definition: CouenneTypes.hpp:50
Couenne::exprInv::F
unary_function F()
the operator's function
Definition: CouenneExprInv.hpp:48
Couenne::NONLINEAR
@ NONLINEAR
Definition: CouenneTypes.hpp:23
Couenne::CouenneProblem
Class for MINLP problems with symbolic information.
Definition: CouenneProblem.hpp:169
Couenne::expression
Expression base class.
Definition: CouenneExpression.hpp:48
Couenne::exprInv::code
virtual enum expr_type code()
code for comparisons
Definition: CouenneExprInv.hpp:79
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