1 /* $Id$
2 *
3 * Name: conv-exprQuad.cpp
4 * Authors: Pierre Bonami
5 * Stefan Vigerske
6 * Pietro Belotti
7 * Purpose: implementation of convexification methods for exprQuad
8 *
9 * (C) Carnegie-Mellon University, 2006-09.
10 * This file is licensed under the Eclipse Public License (EPL)
11 */
12
13 #include "OsiRowCut.hpp"
14 #include "OsiCuts.hpp"
15
16 #include "CouenneCutGenerator.hpp"
17
18 #include "CouenneExprAux.hpp"
19 #include "CouenneExprQuad.hpp"
20 #include "CouenneExprBQuad.hpp"
21
22 using namespace Couenne;
23
24 /// Get lower and upper bound of an expression (if any)
getBounds(expression * & lb,expression * & ub)25 void exprQuad::getBounds (expression *&lb, expression *&ub) {
26
27 lb = new exprLBQuad (this);
28 ub = new exprUBQuad (this);
29
30 /*printf ("generated quad bounds:\n ");
31 lb -> print (); printf (" [%g]\n ", (*lb) ());
32 ub -> print (); printf (" [%g]\n", (*ub) ());*/
33 }
34
35
36 /// Get lower and upper bound of an expression (if any)
getBounds(CouNumber & lb,CouNumber & ub)37 void exprQuad::getBounds (CouNumber &lb, CouNumber &ub) {
38 expression::getBounds (lb, ub);
39 }
40
41
42
43 // generate equality between *this and *w
generateCuts(expression * w,OsiCuts & cs,const CouenneCutGenerator * cg,t_chg_bounds * chg,int wind,CouNumber lb,CouNumber ub)44 void exprQuad::generateCuts (expression *w, //const OsiSolverInterface &si,
45 OsiCuts &cs, const CouenneCutGenerator *cg,
46 t_chg_bounds *chg,
47 int wind, CouNumber lb, CouNumber ub) {
48
49 if (((!(cg -> isFirst ())) && // unless a convexification was never created,
50 (fabs ((*this) () - (*w) ()) < COUENNE_EPS)) // do we really need a convexification cut?
51 || !alphaConvexify (cg -> Problem ())) // ... or a new alpha-convexification?
52 return;
53
54 /*int
55 nrc = cs.sizeRowCuts (),
56 ncc = cs.sizeColCuts ();*/
57
58 // generate linear cuts for convex quadratic [upper|lower]-envelope
59 // of this expression
60 quadCuts (w, cs, cg);
61
62 /*if (cs.sizeRowCuts () > nrc) {
63 printf ("------------------ constraint row cuts\n");
64 for (int i=nrc; i<cs.sizeRowCuts (); i++)
65 cs.rowCutPtr (i) -> print ();
66 }
67 if (cs.sizeColCuts () > nrc) {
68 printf ("================== constraint col cuts\n");
69 for (int i=ncc; i<cs.sizeColCuts (); i++)
70 cs.colCutPtr (i) -> print ();
71 }*/
72 }
73