00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "CglCutGenerator.hpp"
00012 #include "CouenneCutGenerator.hpp"
00013 #include "CouenneProblem.hpp"
00014
00015
00016
00018 void CouenneCutGenerator::genColCuts (const OsiSolverInterface &si,
00019 OsiCuts &cs,
00020 int nchanged,
00021 int *changed) const {
00022
00023 #ifdef DEBUG
00024 int nrc = cs.sizeRowCuts ();
00025 #endif
00026
00027 int ncols = problem_ -> nVars (),
00028 *indLow = new int [ncols],
00029 *indUpp = new int [ncols],
00030 nLow, nUpp = nLow = 0;
00031
00032
00033
00034 CouNumber *bndLow = new CouNumber [ncols],
00035 *bndUpp = new CouNumber [ncols];
00036
00037 const CouNumber
00038 *oldLow = si.getColLower (),
00039 *oldUpp = si.getColUpper (),
00040 *newLow = problem_ -> Lb (),
00041 *newUpp = problem_ -> Ub ();
00042
00043 #ifdef DEBUG
00044 for (int i=0; i < problem_ -> nVars (); i++)
00045 if ((newLow [i] > oldLow [i] + COUENNE_EPS) ||
00046 (newUpp [i] < oldUpp [i] - COUENNE_EPS))
00047 printf ("x%-3d. [%-10g , %10g] ---> [%-10g , %10g]\n",
00048 i, oldLow [i], oldUpp [i], newLow [i], newUpp [i]);*/
00049 #endif
00050
00051
00052 for (int i = 0; i < nchanged; i++) {
00053
00054 int index = changed [i];
00055
00056
00057
00058
00059 if (
00060 (problem_ -> Var (index) -> Multiplicity () <= 0))
00061 continue;
00062
00063 if (newLow [index] > newUpp [index])
00064 problem_ -> Lb (index) = problem_ -> Ub (index);
00065
00066 CouNumber bd;
00067
00068 if ((((bd = newLow [index]) > oldLow [index] + COUENNE_EPS) || firstcall_)
00069 && (bd > -COUENNE_INFINITY / 10)) {
00070
00071
00072 if (problem_ -> Var (index) -> isInteger ())
00073 bd = ceil (bd);
00074 indLow [nLow] = index;
00075 bndLow [nLow++] = bd;
00076 }
00077
00078 if ((((bd = newUpp [index]) < oldUpp [index] - COUENNE_EPS) || firstcall_)
00079 && (bd < COUENNE_INFINITY / 10)) {
00080
00081
00082 if (problem_ -> Var (index) -> isInteger ())
00083 bd = floor (bd);
00084 indUpp [nUpp] = index;
00085 bndUpp [nUpp++] = bd;
00086 }
00087 }
00088
00089
00090
00091 if (nUpp || nLow) {
00092
00093 OsiColCut *cut = new OsiColCut;
00094
00095 if (cut) {
00096 cut -> setLbs (nLow, indLow, bndLow);
00097 cut -> setUbs (nUpp, indUpp, bndUpp);
00098
00099 cs.insert (cut);
00100 delete cut;
00101 }
00102 }
00103
00104 #ifdef DEBUG
00105 printf ("column cuts\n");
00106 for (int jj = nrc; jj < cs.sizeRowCuts (); jj++) cs.rowCutPtr (jj) -> print ();
00107 #endif
00108
00109 delete [] bndLow; delete [] indLow;
00110 delete [] bndUpp; delete [] indUpp;
00111 }