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

Go to the documentation of this file.
00001 /* $Id: conv-exprSum.cpp 217 2009-07-08 17:02:07Z 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-09.
00008  * This file is licensed under the Common Public License (CPL)
00009  */
00010 
00011 #include "CouenneTypes.hpp"
00012 
00013 #include "exprSum.hpp"
00014 #include "exprConst.hpp"
00015 
00016 #include "CouenneProblem.hpp"
00017 #include "CouenneCutGenerator.hpp"
00018 
00019 
00020 // generate equality between *this and *w
00021 void exprSum::generateCuts (expression *w, //const OsiSolverInterface &si, 
00022                             OsiCuts &cs, const CouenneCutGenerator *cg,
00023                             t_chg_bounds *chg, 
00024                             int wind, CouNumber lb, CouNumber ub) {
00025   if (!(cg -> isFirst ()))
00026     return;
00027 
00028   CouNumber *coeff = new CouNumber [nargs_ + 1];
00029   int       *index = new int       [nargs_ + 1];
00030   OsiRowCut *cut   = new OsiRowCut;
00031 
00033 
00034   int nv = 0;
00035 
00036   if (wind < 0) {
00037     coeff [0] = -1.; index [0] = w -> Index ();
00038     nv++;
00039     lb = ub = 0;
00040   }
00041 
00043   for (int i=0; i<nargs_; i++) {
00044 
00045     if (arglist_ [i] -> Type () == CONST) {
00046 
00047       CouNumber val = arglist_ [i] -> Value ();
00048 
00049       lb -= val;
00050       ub -= val;
00051     }
00052     else {
00053       coeff [nv]   = 1.; 
00054       index [nv++] = arglist_ [i] -> Index ();
00055     }
00056   }
00057 
00058   cut -> setRow (nv, index, coeff);
00059 
00060   delete [] index;
00061   delete [] coeff;
00062 
00063   if (lb > -COUENNE_INFINITY) cut -> setLb (lb);
00064   if (ub <  COUENNE_INFINITY) cut -> setUb (ub);
00065 
00067   cut -> setGloballyValid ();
00068 
00069   cs.insert (cut);
00070   delete cut;
00071 }

Generated on Mon May 3 03:05:19 2010 by  doxygen 1.4.7