/home/coin/SVN-release/OS-2.4.2/Couenne/src/convex/operators/conv-exprSum.cpp

Go to the documentation of this file.
00001 /* $Id: conv-exprSum.cpp 490 2011-01-14 16:07:12Z pbelotti $
00002  *
00003  * Name:    conv-exprSum.cpp
00004  * Author:  Pietro Belotti
00005  * Purpose: methods to standardize/convexify sum expressions
00006  *
00007  * (C) Carnegie-Mellon University, 2006-10.
00008  * This file is licensed under the Eclipse Public License (EPL)
00009  */
00010 
00011 #include "CouenneCutGenerator.hpp"
00012 
00013 #include "CouenneTypes.hpp"
00014 
00015 #include "CouenneExprAux.hpp"
00016 #include "CouenneExprSum.hpp"
00017 #include "CouenneExprConst.hpp"
00018 
00019 #include "CouenneProblem.hpp"
00020 
00021 using namespace Couenne;
00022 
00023 // generate equality between *this and *w
00024 void exprSum::generateCuts (expression *w, //const OsiSolverInterface &si, 
00025                             OsiCuts &cs, const CouenneCutGenerator *cg,
00026                             t_chg_bounds *chg, 
00027                             int wind, CouNumber lb, CouNumber ub) {
00028   if (!(cg -> isFirst ()))
00029     return;
00030 
00031   CouNumber *coeff = new CouNumber [nargs_ + 1];
00032   int       *index = new int       [nargs_ + 1];
00033   OsiRowCut *cut   = new OsiRowCut;
00034 
00036 
00037   int nv = 0;
00038 
00039   // If this aux is fixed, don't write 
00040   //
00041   // "- w + ax = -b" but just
00042   // 
00043   // "ax = -b+ w0" 
00044   //
00045   // with w0 its constant value
00046 
00047   CouNumber vlb, vub;
00048   w -> getBounds (vlb, vub);
00049   bool uselessAux = (vub < vlb + COUENNE_EPS); 
00050 
00051   // TODO: generalize to sign!= ::EQ
00052 
00053   if (wind < 0 && !uselessAux) {
00054     coeff [0] = -1.; index [0] = w -> Index ();
00055     nv++;
00056     lb = ub = 0;
00057   }
00058 
00059   if (uselessAux)
00060     lb = ub = vlb;
00061 
00063   for (int i=0; i<nargs_; i++) {
00064 
00065     if (arglist_ [i] -> Type () == CONST) {
00066 
00067       CouNumber val = arglist_ [i] -> Value ();
00068 
00069       lb -= val;
00070       ub -= val;
00071     }
00072     else {
00073       coeff [nv]   = 1.; 
00074       index [nv++] = arglist_ [i] -> Index ();
00075     }
00076   }
00077 
00078   cut -> setRow (nv, index, coeff);
00079 
00080   delete [] index;
00081   delete [] coeff;
00082 
00083   enum auxSign sign = cg -> Problem () -> Var (w -> Index ()) -> sign ();
00084 
00085   if (lb > -COUENNE_INFINITY && (sign != expression::AUX_GEQ)) cut -> setLb (lb);
00086   if (ub <  COUENNE_INFINITY && (sign != expression::AUX_LEQ)) cut -> setUb (ub);
00087 
00089   cut -> setGloballyValid ();
00090 
00091   cs.insert (cut);
00092   delete cut;
00093 }

Generated on Wed Nov 30 03:03:59 2011 by  doxygen 1.4.7