00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "CouenneTypes.hpp"
00012 #include "expression.hpp"
00013 #include "exprAux.hpp"
00014 #include "exprOp.hpp"
00015 #include "exprDiv.hpp"
00016 #include "exprClone.hpp"
00017 #include "exprMul.hpp"
00018 #include "CouenneProblem.hpp"
00019 #include "CouenneCutGenerator.hpp"
00020
00021
00022
00023 exprAux *exprDiv::standardize (CouenneProblem *p, bool addAux) {
00024
00025 exprOp::standardize (p);
00026 return (addAux ? (p -> addAuxiliary (this)) : new exprAux (this, p -> domain ()));
00027 }
00028
00029
00030
00031 void exprDiv::generateCuts (expression *w, const OsiSolverInterface &si,
00032 OsiCuts &cs, const CouenneCutGenerator *cg,
00033 t_chg_bounds *chg, int wind,
00034 CouNumber lbw, CouNumber ubw) {
00035
00036
00037 CouNumber yl, yu;
00038 arglist_ [1] -> getBounds (yl, yu);
00039
00040 int xi = arglist_ [0] -> Index (),
00041 yi = arglist_ [1] -> Index (),
00042 wi = w -> Index ();
00043
00044 bool cLW, cRW, cLY, cRY =
00045 cLW = cRW = cLY = true;
00046
00047 if (!(cg -> isFirst ()) && chg) {
00048 cLW = chg [wi].lower() != t_chg_bounds::UNCHANGED;
00049 cRW = chg [wi].upper() != t_chg_bounds::UNCHANGED;
00050 cLY = chg [yi].lower() != t_chg_bounds::UNCHANGED;
00051 cRY = chg [yi].upper() != t_chg_bounds::UNCHANGED;
00052 }
00053
00054 if ((yl < -0) && (yu > 0)) return;
00055
00056
00057
00058
00059 CouNumber k;
00060
00061 if ((fabs (yl-yu) < COUENNE_EPS) &&
00062 ((fabs (k = ((yl+yu) / 2)) > COUENNE_EPS))) {
00063 if (cLY || cRY)
00064 cg -> createCut (cs, 0., 0, wi, -1, xi, 1/k);
00065 return;
00066 }
00067
00068 CouNumber wl, wu;
00069 w -> getBounds (wl, wu);
00070
00071 if (lbw > wl) wl = lbw;
00072 if (ubw < wu) wu = ubw;
00073
00074
00075
00076
00077 if ((fabs (wl-wu) < COUENNE_EPS) &&
00078 ((k = fabs (wl+wu) / 2) > COUENNE_EPS)) {
00079 if (cLW || cRW)
00080 cg -> createCut (cs, 0., 0, yi, k, xi, -1.);
00081 return;
00082 }
00083
00084 CouNumber xl, xu;
00085 arglist_ [0] -> getBounds (xl, xu);
00086
00087
00088
00089
00090 CouNumber *x = cg -> Problem () -> X ();
00091
00092 unifiedProdCuts (cg, cs,
00093 wi, x [wi], wl, wu,
00094 yi, x [yi], yl, yu,
00095 xi, x [xi], xl, xu, chg);
00096
00097
00098 }