00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef COUENNE_EXPRCOS_HPP
00012 #define COUENNE_EXPRCOS_HPP
00013
00014 #include "CouenneExprSin.hpp"
00015
00016 namespace Couenne {
00017
00019
00020 class exprCos: public exprUnary {
00021
00022 public:
00023
00025 exprCos (expression *al):
00026 exprUnary (al) {}
00027
00029 expression *clone (Domain *d = NULL) const
00030 {return new exprCos (argument_ -> clone (d));}
00031
00033 inline unary_function F ()
00034 {return cos;}
00035
00037 std::string printOp () const
00038 {return "cos";}
00039
00041 inline CouNumber gradientNorm (const double *x) {
00042 return (argument_ -> Index () < 0) ?
00043 0. : fabs (sin (x [argument_ -> Index ()]));
00044 }
00045
00047 expression *differentiate (int index);
00048
00050 void getBounds (expression *&, expression *&);
00051
00053 void getBounds (CouNumber &lb, CouNumber &ub);
00054
00056 void generateCuts (expression *w,
00057 OsiCuts &cs, const CouenneCutGenerator *cg,
00058 t_chg_bounds * = NULL, int = -1,
00059 CouNumber = -COUENNE_INFINITY,
00060 CouNumber = COUENNE_INFINITY);
00061
00063 virtual enum expr_type code ()
00064 {return COU_EXPRCOS;}
00065
00067 bool impliedBound (int index, CouNumber *l, CouNumber *u, t_chg_bounds *chg, enum auxSign = expression::AUX_EQ) {
00068
00069 bool impl = trigImpliedBound (COU_COSINE, index, argument_ -> Index (), l, u, chg);
00070
00071 if (impl && argument_ -> isInteger ()) {
00072
00073 int ind = argument_ -> Index ();
00074 assert (ind >= 0);
00075 l [ind] = ceil (l [ind] - COUENNE_EPS);
00076 u [ind] = floor (u [ind] + COUENNE_EPS);
00077 }
00078
00079 return impl;
00080 }
00081
00084 virtual CouNumber selectBranch (const CouenneObject *obj,
00085 const OsiBranchingInformation *info,
00086 expression * &var,
00087 double * &brpts,
00088 double * &brDist,
00089
00090 int &way)
00091 {return trigSelBranch (obj, info, var, brpts, brDist, way, COU_COSINE);}
00092
00094 virtual void closestFeasible (expression *varind, expression *vardep,
00095 CouNumber& left, CouNumber& right) const;
00096
00099 virtual bool isCuttable (CouenneProblem *problem, int index) const
00100 {return false;}
00101
00103
00104 };
00105
00106
00108 CouNumber trigNewton (CouNumber, CouNumber, CouNumber);
00109
00110 }
00111
00112 #endif