Couenne 0.5.8
Loading...
Searching...
No Matches
CouenneExprSin.hpp
Go to the documentation of this file.
1/* $Id: CouenneExprSin.hpp 615 2011-06-08 20:36:24Z pbelotti $
2 *
3 * Name: exprSin.hpp
4 * Author: Pietro Belotti
5 * Purpose: definition of the sine of a function
6 *
7 * (C) Carnegie-Mellon University, 2006-10.
8 * This file is licensed under the Eclipse Public License (EPL)
9 */
10
11#ifndef COUENNE_EXPRSIN_HPP
12#define COUENNE_EXPRSIN_HPP
13
14#include <math.h>
15#include <assert.h>
16
17#include "CouenneExprUnary.hpp"
18#include "CouenneExprConst.hpp"
19
20namespace Couenne {
21
24
25
27inline CouNumber modulo (register CouNumber a, register CouNumber b)
28 {return a - b * floor (a/b);}
29
30
33 const OsiBranchingInformation *info,
34 expression * &var,
35 double * &brpts,
36 double * &brDist, // distance of current LP
37 // point to new convexifications
38 int &way,
39 enum cou_trig type);
40
41
44
45
47class exprSin: public exprUnary {
48
49 public:
50
53 exprUnary (al) {} //< non-leaf expression, with argument list
54
56 expression *clone (Domain *d = NULL) const
57 {return new exprSin (argument_ -> clone (d));}
58
60 inline unary_function F ()
61 {return sin;}
62
64 std::string printOp () const
65 {return "sin";}
66
68 inline CouNumber gradientNorm (const double *x) {
69 return (argument_ -> Index () < 0) ?
70 0. : fabs (cos (x [argument_ -> Index ()]));
71 }
72
75
78
80 void getBounds (CouNumber &lb, CouNumber &ub);
81
83 void generateCuts (expression *w, //const OsiSolverInterface &si,
84 OsiCuts &cs, const CouenneCutGenerator *cg,
85 t_chg_bounds * = NULL, int = -1,
88
90 virtual enum expr_type code ()
91 {return COU_EXPRSIN;}
92
94 bool impliedBound (int index, CouNumber *l, CouNumber *u, t_chg_bounds *chg, enum auxSign = expression::AUX_EQ) {
95
96 bool impl = trigImpliedBound (COU_SINE, index, argument_ -> Index (), l, u, chg);
97
98 if (impl && argument_ -> isInteger ()) {
99
100 int ind = argument_ -> Index ();
101 assert (ind >= 0);
102 l [ind] = ceil (l [ind] - COUENNE_EPS);
103 u [ind] = floor (u [ind] + COUENNE_EPS);
104 }
105
106 return impl;
107 }
108
112 const OsiBranchingInformation *info,
113 expression * &var,
114 double * &brpts,
115 double * &brDist, // distance of current LP
116 // point to new convexifications
117 int &way)
118
119 {return trigSelBranch (obj, info, var, brpts, brDist, way, COU_SINE);}
120
122 virtual void closestFeasible (expression *varind, expression *vardep,
123 CouNumber& left, CouNumber& right) const;
124
127 virtual bool isCuttable (CouenneProblem *problem, int index) const
128 {return false;}
129};
130
131}
132
133#endif
#define COUENNE_EPS
#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...
expression * clone(Domain *d=NULL) const
cloning method
std::string printOp() const
print operator
virtual enum expr_type code()
code for comparisons
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.
CouNumber gradientNorm(const double *x)
return l-2 norm of gradient at given point
bool impliedBound(int index, CouNumber *l, CouNumber *u, t_chg_bounds *chg, enum auxSign=expression::AUX_EQ)
implied bound processing
exprSin(expression *al)
Constructors, destructor.
virtual void closestFeasible(expression *varind, expression *vardep, CouNumber &left, CouNumber &right) const
closest feasible points in function in both directions
unary_function F()
the operator itself (e.g. sin, log...)
void getBounds(expression *&, expression *&)
Get lower and upper bound of an expression (if any)
expression * differentiate(int index)
differentiation
void getBounds(CouNumber &lb, CouNumber &ub)
Get value of lower and upper bound of an expression (if any)
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
virtual bool isCuttable(CouenneProblem *problem, int index) const
can this expression be further linearized or are we on its concave ("bad") side
virtual bool isInteger()
is this expression integer?
expression * argument_
single argument taken by this expression
exprUnary(expression *argument)
Constructor.
Expression base class.
virtual int Index() const
Return index of variable (only valid for exprVar and exprAux)
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
CouExpr & cos(CouExpr &e)
double CouNumber
main number type in Couenne
cou_trig
specify which trigonometric function is dealt with in trigEnvelope
CouNumber(* unary_function)(CouNumber)
unary function, used in all exprUnary
CouExpr & sin(CouExpr &e)
bool trigImpliedBound(enum cou_trig, int, int, CouNumber *, CouNumber *, t_chg_bounds *)
generalized implied bound procedure for sine/cosine
expr_type
code returned by the method expression::code()
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
CouNumber modulo(register CouNumber a, register CouNumber b)
normalize angle within [0,b] (typically, pi or 2pi)