00001 /* $Id: conv-exprQuad.cpp 141 2009-06-03 04:19:19Z pbelotti $ */ 00002 /* 00003 * Name: conv-exprQuad.cpp 00004 * Authors: Pierre Bonami 00005 * Stefan Vigerske 00006 * Pietro Belotti 00007 * Purpose: implementation of convexification methods for exprQuad 00008 * 00009 * (C) Carnegie-Mellon University, 2006-08. 00010 * This file is licensed under the Common Public License (CPL) 00011 */ 00012 00013 #include "OsiRowCut.hpp" 00014 #include "OsiCuts.hpp" 00015 00016 #include "exprAux.hpp" 00017 #include "exprQuad.hpp" 00018 #include "exprBQuad.hpp" 00019 #include "CouenneCutGenerator.hpp" 00020 00022 void exprQuad::getBounds (expression *&lb, expression *&ub) { 00023 00024 lb = new exprLBQuad (this); 00025 ub = new exprUBQuad (this); 00026 00027 /*printf ("generated quad bounds:\n "); 00028 lb -> print (); printf (" [%g]\n ", (*lb) ()); 00029 ub -> print (); printf (" [%g]\n", (*ub) ());*/ 00030 } 00031 00032 00034 void exprQuad::getBounds (CouNumber &lb, CouNumber &ub) { 00035 expression::getBounds (lb, ub); 00036 } 00037 00038 00039 00040 // generate equality between *this and *w 00041 void exprQuad::generateCuts (expression *w, const OsiSolverInterface &si, 00042 OsiCuts &cs, const CouenneCutGenerator *cg, 00043 t_chg_bounds *chg, 00044 int wind, CouNumber lb, CouNumber ub) { 00045 00046 if ((!(cg -> isFirst ())) && // unless a convexification was never created, 00047 (fabs ((*this) () - (*w) ()) < COUENNE_EPS) // do we really need a convexification cut? 00048 || !alphaConvexify (cg -> Problem (), si)) // ... or a new alpha-convexification? 00049 return; 00050 00051 /*int 00052 nrc = cs.sizeRowCuts (), 00053 ncc = cs.sizeColCuts ();*/ 00054 00055 // generate linear cuts for convex quadratic [upper|lower]-envelope 00056 // of this expression 00057 quadCuts (w, cs, cg); 00058 00059 /*if (cs.sizeRowCuts () > nrc) { 00060 printf ("------------------ constraint row cuts\n"); 00061 for (int i=nrc; i<cs.sizeRowCuts (); i++) 00062 cs.rowCutPtr (i) -> print (); 00063 } 00064 if (cs.sizeColCuts () > nrc) { 00065 printf ("================== constraint col cuts\n"); 00066 for (int i=ncc; i<cs.sizeColCuts (); i++) 00067 cs.colCutPtr (i) -> print (); 00068 }*/ 00069 }