Couenne  0.5.8
CouenneExprCos.hpp
Go to the documentation of this file.
1 /* $Id: CouenneExprCos.hpp 615 2011-06-08 20:36:24Z pbelotti $
2  *
3  * Name: exprCos.hpp
4  * Author: Pietro Belotti
5  * Purpose: definition of cosine
6  *
7  * (C) Carnegie-Mellon University, 2006-10.
8  * This file is licensed under the Eclipse Public License (EPL)
9  */
10 
11 #ifndef COUENNE_EXPRCOS_HPP
12 #define COUENNE_EXPRCOS_HPP
13 
14 #include "CouenneExprSin.hpp"
15 
16 namespace Couenne {
17 
19 
20 class exprCos: public exprUnary {
21 
22  public:
23 
26  exprUnary (al) {}
27 
29  expression *clone (Domain *d = NULL) const
30  {return new exprCos (argument_ -> clone (d));}
31 
33  inline unary_function F ()
34  {return cos;}
35 
37  std::string printOp () const
38  {return "cos";}
39 
41  inline CouNumber gradientNorm (const double *x) {
42  return (argument_ -> Index () < 0) ?
43  0. : fabs (sin (x [argument_ -> Index ()]));
44  }
45 
47  expression *differentiate (int index);
48 
51 
53  void getBounds (CouNumber &lb, CouNumber &ub);
54 
56  void generateCuts (expression *w, //const OsiSolverInterface &si,
57  OsiCuts &cs, const CouenneCutGenerator *cg,
58  t_chg_bounds * = NULL, int = -1,
61 
63  virtual enum expr_type code ()
64  {return COU_EXPRCOS;}
65 
67  bool impliedBound (int index, CouNumber *l, CouNumber *u, t_chg_bounds *chg, enum auxSign = expression::AUX_EQ) {
68 
69  bool impl = trigImpliedBound (COU_COSINE, index, argument_ -> Index (), l, u, chg);
70 
71  if (impl && argument_ -> isInteger ()) {
72 
73  int ind = argument_ -> Index ();
74  assert (ind >= 0);
75  l [ind] = ceil (l [ind] - COUENNE_EPS);
76  u [ind] = floor (u [ind] + COUENNE_EPS);
77  }
78 
79  return impl;
80  }
81 
84  virtual CouNumber selectBranch (const CouenneObject *obj,
85  const OsiBranchingInformation *info,
86  expression * &var,
87  double * &brpts,
88  double * &brDist, // distance of current LP
89  // point to new convexifications
90  int &way)
91  {return trigSelBranch (obj, info, var, brpts, brDist, way, COU_COSINE);}
92 
94  virtual void closestFeasible (expression *varind, expression *vardep,
95  CouNumber& left, CouNumber& right) const;
96 
99  virtual bool isCuttable (CouenneProblem *problem, int index) const
100  {return false;}
101 
103  //virtual enum convexity convexity () const;
104 };
105 
106 
109 
110 }
111 
112 #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::unary_function
CouNumber(* unary_function)(CouNumber)
unary function, used in all exprUnary
Definition: CouenneTypes.hpp:103
Couenne::sin
CouExpr & sin(CouExpr &e)
Couenne::exprCos::closestFeasible
virtual void closestFeasible(expression *varind, expression *vardep, CouNumber &left, CouNumber &right) const
closest feasible points in function in both directions
Couenne::exprCos
class cosine,
Definition: CouenneExprCos.hpp:20
Couenne::exprCos::printOp
std::string printOp() const
print operator
Definition: CouenneExprCos.hpp:37
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::exprCos::exprCos
exprCos(expression *al)
constructor, destructor
Definition: CouenneExprCos.hpp:25
Couenne::exprUnary
expression class for unary functions (sin, log, etc.)
Definition: CouenneExprUnary.hpp:33
Couenne::expression::AUX_EQ
@ AUX_EQ
Definition: CouenneExpression.hpp:55
Couenne::exprUnary::isInteger
virtual bool isInteger()
is this expression integer?
Couenne::CouenneCutGenerator
Cut Generator for linear convexifications.
Definition: CouenneCutGenerator.hpp:49
Couenne::exprCos::code
virtual enum expr_type code()
code for comparisons
Definition: CouenneExprCos.hpp:63
Couenne::exprCos::getBounds
void getBounds(expression *&, expression *&)
Get lower and upper bound of an expression (if any)
Couenne
general include file for different compilers
Definition: CouenneAggrProbing.hpp:24
Couenne::trigImpliedBound
bool trigImpliedBound(enum cou_trig, int, int, CouNumber *, CouNumber *, t_chg_bounds *)
generalized implied bound procedure for sine/cosine
Couenne::CouenneObject
OsiObject for auxiliary variables $w=f(x)$.
Definition: CouenneObject.hpp:57
COUENNE_EPS
#define COUENNE_EPS
Definition: CouennePrecisions.hpp:19
Index
int Index
Couenne::exprCos::impliedBound
bool impliedBound(int index, CouNumber *l, CouNumber *u, t_chg_bounds *chg, enum auxSign=expression::AUX_EQ)
implied bound processing
Definition: CouenneExprCos.hpp:67
Couenne::CouNumber
double CouNumber
main number type in Couenne
Definition: CouenneTypes.hpp:100
Couenne::trigNewton
CouNumber trigNewton(CouNumber, CouNumber, CouNumber)
common convexification method used by both cos and sin
OsiCuts
Couenne::COU_COSINE
@ COU_COSINE
Definition: CouenneExprSin.hpp:23
Couenne::expression::auxSign
auxSign
"sign" of the constraint defining an auxiliary.
Definition: CouenneExpression.hpp:55
Couenne::trigSelBranch
CouNumber trigSelBranch(const CouenneObject *obj, const OsiBranchingInformation *info, expression *&var, double *&brpts, double *&brDist, int &way, enum cou_trig type)
generalized procedure for both sine and cosine
CouenneExprSin.hpp
OsiBranchingInformation
Couenne::exprCos::differentiate
expression * differentiate(int index)
obtain derivative of expression
Couenne::exprCos::getBounds
void getBounds(CouNumber &lb, CouNumber &ub)
Get value of lower and upper bound of an expression.
Couenne::COU_EXPRCOS
@ COU_EXPRCOS
Definition: CouenneTypes.hpp:49
Couenne::cos
CouExpr & cos(CouExpr &e)
Couenne::exprCos::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.
Definition: CouenneExprCos.hpp:84
Couenne::exprCos::F
unary_function F()
the operator itself (e.g. sin, log...)
Definition: CouenneExprCos.hpp:33
Couenne::exprCos::gradientNorm
CouNumber gradientNorm(const double *x)
return l-2 norm of gradient at given point
Definition: CouenneExprCos.hpp:41
Couenne::exprCos::clone
expression * clone(Domain *d=NULL) const
cloning method
Definition: CouenneExprCos.hpp:29
Couenne::exprCos::isCuttable
virtual bool isCuttable(CouenneProblem *problem, int index) const
can this expression be further linearized or are we on its concave ("bad") side
Definition: CouenneExprCos.hpp:99
Couenne::exprCos::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::CouenneProblem
Class for MINLP problems with symbolic information.
Definition: CouenneProblem.hpp:169
Couenne::expression
Expression base class.
Definition: CouenneExpression.hpp:48
Couenne::expression::Index
virtual int Index() const
Return index of variable (only valid for exprVar and exprAux)
Definition: CouenneExpression.hpp:73
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