00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef COUENNE_EXPRCOS_HPP
00012 #define COUENNE_EXPRCOS_HPP
00013
00014 #include "exprSin.hpp"
00015
00017
00018 class exprCos: public exprUnary {
00019
00020 public:
00021
00023 exprCos (expression *al):
00024 exprUnary (al) {}
00025
00027 expression *clone (Domain *d = NULL) const
00028 {return new exprCos (argument_ -> clone (d));}
00029
00031 inline unary_function F ()
00032 {return cos;}
00033
00035 std::string printOp () const
00036 {return "cos";}
00037
00039 inline CouNumber gradientNorm (const double *x) {
00040 return (argument_ -> Index () < 0) ?
00041 0. : fabs (sin (x [argument_ -> Index ()]));
00042 }
00043
00045 expression *differentiate (int index);
00046
00048 void getBounds (expression *&, expression *&);
00049
00051 void getBounds (CouNumber &lb, CouNumber &ub);
00052
00054 void generateCuts (expression *w, const OsiSolverInterface &si,
00055 OsiCuts &cs, const CouenneCutGenerator *cg,
00056 t_chg_bounds * = NULL, int = -1,
00057 CouNumber = -COUENNE_INFINITY,
00058 CouNumber = COUENNE_INFINITY);
00059
00061 virtual enum expr_type code ()
00062 {return COU_EXPRCOS;}
00063
00065 bool impliedBound (int index, CouNumber *l, CouNumber *u, t_chg_bounds *chg) {
00066
00067 bool impl = trigImpliedBound (COU_COSINE, index, argument_ -> Index (), l, u, chg);
00068
00069 if (impl && argument_ -> isInteger ()) {
00070
00071 int ind = argument_ -> Index ();
00072 assert (ind >= 0);
00073 l [ind] = ceil (l [ind] - COUENNE_EPS);
00074 u [ind] = floor (u [ind] + COUENNE_EPS);
00075 }
00076
00077 return impl;
00078 }
00079
00082 virtual CouNumber selectBranch (const CouenneObject *obj,
00083 const OsiBranchingInformation *info,
00084 expression * &var,
00085 double * &brpts,
00086 double * &brDist,
00087
00088 int &way)
00089 {return trigSelBranch (obj, info, var, brpts, brDist, way, COU_COSINE);}
00090
00092 virtual void closestFeasible (expression *varind, expression *vardep,
00093 CouNumber& left, CouNumber& right) const;
00094
00097 virtual bool isCuttable (CouenneProblem *problem, int index) const
00098 {return false;}
00099
00101
00102 };
00103
00104
00106 CouNumber trigNewton (CouNumber, CouNumber, CouNumber);
00107
00108 #endif