00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef COUENNE_EXPRSIN_HPP
00012 #define COUENNE_EXPRSIN_HPP
00013
00014 #include <math.h>
00015 #include <assert.h>
00016
00017 #include "exprUnary.hpp"
00018 #include "exprConst.hpp"
00019
00020
00022 enum cou_trig {COU_SINE, COU_COSINE};
00023
00024
00026 inline CouNumber modulo (register CouNumber a, register CouNumber b)
00027 {return a - b * floor (a/b);}
00028
00029
00031 CouNumber trigSelBranch (const CouenneObject *obj,
00032 const OsiBranchingInformation *info,
00033 expression * &var,
00034 double * &brpts,
00035 double * &brDist,
00036
00037 int &way,
00038 enum cou_trig type);
00039
00040
00042 bool trigImpliedBound (enum cou_trig, int, int, CouNumber *, CouNumber *, t_chg_bounds *);
00043
00044
00046 class exprSin: public exprUnary {
00047
00048 public:
00049
00051 exprSin (expression *al):
00052 exprUnary (al) {}
00053
00055 expression *clone (Domain *d = NULL) const
00056 {return new exprSin (argument_ -> clone (d));}
00057
00059 inline unary_function F ()
00060 {return sin;}
00061
00063 std::string printOp () const
00064 {return "sin";}
00065
00067 inline CouNumber gradientNorm (const double *x) {
00068 return (argument_ -> Index () < 0) ?
00069 0. : fabs (cos (x [argument_ -> Index ()]));
00070 }
00071
00073 expression *differentiate (int index);
00074
00076 void getBounds (expression *&, expression *&);
00077
00079 void getBounds (CouNumber &lb, CouNumber &ub);
00080
00082 void generateCuts (expression *w,
00083 OsiCuts &cs, const CouenneCutGenerator *cg,
00084 t_chg_bounds * = NULL, int = -1,
00085 CouNumber = -COUENNE_INFINITY,
00086 CouNumber = COUENNE_INFINITY);
00087
00089 virtual enum expr_type code ()
00090 {return COU_EXPRSIN;}
00091
00093 bool impliedBound (int index, CouNumber *l, CouNumber *u, t_chg_bounds *chg) {
00094
00095 bool impl = trigImpliedBound (COU_SINE, index, argument_ -> Index (), l, u, chg);
00096
00097 if (impl && argument_ -> isInteger ()) {
00098
00099 int ind = argument_ -> Index ();
00100 assert (ind >= 0);
00101 l [ind] = ceil (l [ind] - COUENNE_EPS);
00102 u [ind] = floor (u [ind] + COUENNE_EPS);
00103 }
00104
00105 return impl;
00106 }
00107
00110 virtual CouNumber selectBranch (const CouenneObject *obj,
00111 const OsiBranchingInformation *info,
00112 expression * &var,
00113 double * &brpts,
00114 double * &brDist,
00115
00116 int &way)
00117
00118 {return trigSelBranch (obj, info, var, brpts, brDist, way, COU_SINE);}
00119
00121 virtual void closestFeasible (expression *varind, expression *vardep,
00122 CouNumber& left, CouNumber& right) const;
00123
00126 virtual bool isCuttable (CouenneProblem *problem, int index) const
00127 {return false;}
00128 };
00129
00130 #endif