11 #include "OsiRowCut.hpp"
18 using namespace Ipopt;
19 using namespace Couenne;
32 int CouenneCutGenerator::createCut (OsiCuts &cs,
37 bool is_global)
const {
38 bool numerics =
false;
47 if ((i1 != -1) && (i1 == i3)) {i3 = -1; c1 += c3; c3 = 0;}
48 if ((i2 != -1) && (i2 == i3)) {i3 = -1; c2 += c3; c3 = 0;}
49 if ((i1 != -1) && (i1 == i2)) {i2 = -1; c1 += c2; c2 = 0;}
52 if (fabs (c3) <= 1.
e-21) { i3 = -1;}
53 if (fabs (c2) <= 1.
e-21) { c2 = c3; i2 = i3; i3 = -1;}
54 if (fabs (c1) <= 1.
e-21) {c1 = c2; i1 = i2; c2 = c3; i2 = i3; i3 = -1;}
58 if (i1 >= 0) {
if (fabs (c1) >
COU_MAX_COEFF) numerics =
true; nterms++;}
else c1 = 0;
59 if (i2 >= 0) {
if (fabs (c2) >
COU_MAX_COEFF) numerics =
true; nterms++;}
else c2 = 0;
60 if (i3 >= 0) {
if (fabs (c3) >
COU_MAX_COEFF) numerics =
true; nterms++;}
else c3 = 0;
62 if (i1 >= 0) {
if (
badCoeff (c1)) numerics =
true; nterms++;}
else c1 = 0;
63 if (i2 >= 0) {
if (
badCoeff (c2)) numerics =
true; nterms++;}
else c2 = 0;
64 if (i3 >= 0) {
if (
badCoeff (c3)) numerics =
true; nterms++;}
else c3 = 0;
78 "### Discarding cut, large coeff/rhs: %g (%d), %g (%d), %g (%d); [%g,%g]\n",
79 c1, i1, c2, i2, c3, i3, lb, ub);
83 if (!firstcall_ && addviolated_) {
90 if (i1 >= 0) violation += c1 * x [i1];
91 if (i2 >= 0) violation += c2 * x [i2];
92 if (i3 >= 0) violation += c3 * x [i3];
104 CouNumber *best = problem_ -> bestSol ();
107 ((i1 < 0) || ((best [i1] >= problem_ -> Lb (i1)) && (best [i1] <= problem_ -> Ub (i1)))) &&
108 ((i2 < 0) || ((best [i2] >= problem_ -> Lb (i2)) && (best [i2] <= problem_ -> Ub (i2)))) &&
109 ((i3 < 0) || ((best [i3] >= problem_ -> Lb (i3)) && (best [i3] <= problem_ -> Ub (i3))))) {
113 if (i1 >= 0) lhs += c1 * best [i1];
114 if (i2 >= 0) lhs += c2 * best [i2];
115 if (i3 >= 0) lhs += c3 * best [i3];
119 "### cut (%d,%d,%d) (%g,%g,%g) cuts optimum: %g >= %g [%g]\n",
120 i1,i2,i3, c1,c2,c3, lhs, ub, lhs - ub);
124 "### cut (%d,%d,%d) (%g,%g,%g) cuts optimum: %g <= %g [%g]\n",
125 i1,i2,i3, c1,c2,c3, lhs, lb, lb - lhs);
138 if ((i2 < 0) && (i3 < 0)) {
145 "#### nonsense column cut: %e <= %e w_%d <= %e\n",
150 OsiColCut *cut =
new OsiColCut;
163 &curU = problem_ -> Ub (i1);
166 (uu < curU - COUENNE_EPS)) {
168 cut -> setUbs (1, &i1, &uu);
173 (ll > curL + COUENNE_EPS)) {
174 cut -> setLbs (1, &i1, &ll);
178 cut -> setGloballyValid (is_global);
188 int *index =
new int [nterms];
189 OsiRowCut *cut =
new OsiRowCut;
193 if (i1 >= 0) {coeff [
nt] = c1; index [nt++] = i1;}
194 if (i2 >= 0) {coeff [
nt] = c2; index [nt++] = i2;}
195 if (i3 >= 0) {coeff [
nt] = c3; index [nt++] = i3;}
200 cut -> setRow (nterms, index, coeff);
205 cut -> setGloballyValid (is_global);
218 int CouenneCutGenerator::createCut (OsiCuts &cs,
223 bool is_global)
const {
225 return createCut (cs, (sign >= 0) ? rhs : - COIN_DBL_MAX,
226 (sign <= 0) ? rhs : COIN_DBL_MAX,
227 i1, c1, i2, c2, i3, c3, is_global);
bool badCoeff(CouNumber coe)
checks if very large or very small nonzero
const Ipopt::EJournalCategory J_CONVEXIFYING(Ipopt::J_USER3)
void fint fint fint real fint real real real real real real real real real * e
double CouNumber
main number type in Couenne
void fint fint fint real fint real * x