14 #include "CoinHelperFunctions.hpp"
15 #include "CoinFinite.hpp"
17 using namespace Couenne;
78 nlin += eg -> lcoeff (). size ();
89 int *I1 = (
int *) malloc (nterms *
sizeof (
int)),
90 *I2 = (
int *) malloc (nlin *
sizeof (
int));
92 int ipos, ineg = ipos = 0;
94 std::set <int> intSet;
98 for (
int i =
nargs_; i--;) {
110 intSet.insert (index);
120 for (
register exprGroup::lincoeff::iterator el = lcoe.begin ();
121 el != lcoe.end (); ++el) {
124 register int ind = el -> first ->
Index ();
126 if (coe > 0.) {I1 [ipos] = ind; C1 [ipos++] = coe;}
127 else if (coe < -0.) {I2 [ineg] = ind; C2 [ineg++] = coe;}
145 int infLo1 = -1, infLo2 = -1,
146 infUp1 = -1, infUp2 = -1;
159 lower = a0 +
scanBounds (ipos, -1, I1, C1, l, &infLo1)
162 upper = a0 +
scanBounds (ipos, +1, I1, C1, u, &infUp1)
170 bool tighter =
false;
193 if (intSet.find (wind)!= intSet.end ())
205 if (intSet.find (wind)!= intSet.end ())
209 free (I1); free (I2);
210 free (C1); free (C2);
215 else if ((slackU > 0.) &&
223 if (intSet.find (wind)!= intSet.end ())
236 for (
register int i=ipos; i--; I1++)
if (*I1 > maxind) maxind = *I1;
237 for (
register int i=ineg; i--; I2++)
if (*I2 > maxind) maxind = *I2;
245 CoinCopyN (l, maxind, lc);
246 CoinCopyN (u, maxind, uc);
254 for (
register int i=ipos; i--;) {
256 if ((tighter = (
updateBound (+1, u + ind, (wu - lower) / C1 [i] + lc [ind]) || tighter))) {
258 if (intSet.find (ind)!= intSet.end ())
264 for (
register int i=ineg; i--;) {
266 if ((tighter = (
updateBound (-1, l + ind, (wu - lower) / C2 [i] + uc [ind]) || tighter))) {
268 if (intSet.find (ind)!= intSet.end ())
274 if ((infLo1 >= 0) && (infUp2 == -1)) {
275 int ind = I1 [infLo1];
276 if ((tighter = (
updateBound (+1, u + ind, (wu - lower) / C1 [infLo1]) || tighter))) {
278 if (intSet.find (ind)!= intSet.end ())
283 if ((infLo1 == -1) && (infUp2 >= 0)) {
284 int ind = I2 [infUp2];
285 if ((tighter = (
updateBound (-1, l + ind, (wu - lower) / C2 [infUp2]) || tighter))) {
287 if (intSet.find (ind)!= intSet.end ())
297 for (
register int i=ipos; i--;) {
299 if ((tighter = (
updateBound (-1, l + ind, (wl - upper) / C1 [i] + uc [ind]) || tighter))) {
301 if (intSet.find (ind) != intSet.end ())
306 for (
register int i=ineg; i--;) {
308 if ((tighter = (
updateBound (+1, u + ind, (wl - upper) / C2 [i] + lc [ind]) || tighter))) {
310 if (intSet.find (ind) != intSet.end ())
316 if ((infUp1 >= 0) && (infLo2 == -1)) {
317 int ind = I1 [infUp1];
318 if ((tighter = (
updateBound (-1, l + ind, (wl - upper) / C1 [infUp1]) || tighter))) {
320 if (intSet.find (ind) != intSet.end ())
325 if ((infUp1 == -1) && (infLo2 >= 0)) {
326 int ind = I2 [infLo2];
327 if ((tighter = (
updateBound (+1, u + ind, (wl - upper) / C2 [infLo2]) || tighter))) {
329 if (intSet.find (ind) != intSet.end ())
336 free (I1); free (I2);
337 free (C1); free (C2);
338 free (lc); free (uc);
355 for (
register int i = num; i--;) {
363 bounds [indices [i]] = (sign > 0) ? COIN_DBL_MAX : -COIN_DBL_MAX;
367 if (*infnum == -1) *infnum = i;
368 else if (*infnum >= 0) *infnum = -2;
370 else bound += coeff [i] * bd;
class Group, with constant, linear and nonlinear terms:
bool updateBound(register int sign, register CouNumber *dst, register CouNumber src)
updates maximum violation.
virtual bool isDefinedInteger()
is this expression defined as an integer?
status of lower/upper bound of a variable, to be checked/modified in bound tightening ...
void setLower(ChangeStatus lower)
void setUpper(ChangeStatus upper)
virtual int Index() const
Return index of variable (only valid for exprVar and exprAux)
auxSign
"sign" of the constraint defining an auxiliary.
expression ** arglist_
argument list is an array of pointers to other expressions
std::vector< std::pair< exprVar *, CouNumber > > lincoeff
double CouNumber
main number type in Couenne
int nargs_
number of arguments (cardinality of arglist)
static CouNumber scanBounds(int, int, int *, CouNumber *, CouNumber *, int *)
vector operation to find bound to variable in a sum
virtual bool impliedBound(int, CouNumber *, CouNumber *, t_chg_bounds *, enum auxSign=expression::AUX_EQ)
Implied bound.
virtual enum expr_type code()
Code for comparison.
virtual CouNumber Value() const
value (empty)