39 #define SCIP_EXPRESSION_MAXCHILDEST 16 40 #define DEFAULT_RANDSEED 73 46 #define SIGN(x) ((x) >= 0.0 ? 1.0 : -1.0) 52 #define ensureBlockMemoryArraySize(blkmem, array1, cursize, minsize) \ 55 assert((blkmem) != NULL); \ 56 if( *(cursize) >= (minsize) ) \ 58 __newsize = calcGrowSize(minsize); \ 59 assert(__newsize >= (minsize)); \ 60 SCIP_ALLOC( BMSreallocBlockMemoryArray(blkmem, array1, *(cursize), __newsize) ); \ 61 *(cursize) = __newsize; \ 64 #ifdef SCIP_DISABLED_CODE 69 #define ensureBlockMemoryArraySize2(blkmem, array1, array2, cursize, minsize) \ 72 assert((blkmem) != NULL); \ 73 if( *(cursize) >= (minsize) ) \ 75 __newsize = calcGrowSize(minsize); \ 76 assert(__newsize >= (minsize)); \ 77 SCIP_ALLOC( BMSreallocBlockMemoryArray(blkmem, array1, *(cursize), __newsize) ); \ 78 SCIP_ALLOC( BMSreallocBlockMemoryArray(blkmem, array2, *(cursize), __newsize) ); \ 79 *(cursize) = __newsize; \ 87 #define ensureBlockMemoryArraySize3(blkmem, array1, array2, array3, cursize, minsize) \ 90 assert((blkmem) != NULL); \ 91 if( *(cursize) >= (minsize) ) \ 93 __newsize = calcGrowSize(minsize); \ 94 assert(__newsize >= (minsize)); \ 95 SCIP_ALLOC( BMSreallocBlockMemoryArray(blkmem, array1, *(cursize), __newsize) ); \ 96 SCIP_ALLOC( BMSreallocBlockMemoryArray(blkmem, array2, *(cursize), __newsize) ); \ 97 SCIP_ALLOC( BMSreallocBlockMemoryArray(blkmem, array3, *(cursize), __newsize) ); \ 98 *(cursize) = __newsize; \ 115 size = (int)(1.2 * size + 4);
147 eps =
MIN(oldub - oldlb, eps);
148 return EPSGT(newlb, oldlb, minstrength *
MAX(eps, 1e-3));
167 eps =
MIN(oldub - oldlb, eps);
168 return EPSLT(newub, oldub, minstrength *
MAX(eps, 1e-3));
186 #undef SCIPexprcurvAdd 245 assert(basebounds.
inf <= basebounds.
sup);
247 if( exponent == 0.0 )
250 if( exponent == 1.0 )
258 if( !expisint && basebounds.
inf < 0.0 )
260 basebounds.
inf = 0.0;
261 if( basebounds.
sup < 0.0 )
266 if( basebounds.
inf < 0.0 && basebounds.
sup > 0.0 )
280 assert(basebounds.
inf >= 0.0 || basebounds.
sup <= 0.0);
310 sign = exponent * (exponent - 1.0);
311 assert(basebounds.
inf >= 0.0 || expisint);
312 if( basebounds.
inf < 0.0 && ((
int)exponent)%2 != 0 )
321 if( basebounds.
sup <= 0.0 && exponent < 0.0 && expisint )
323 if( basebounds.
inf >= 0.0 && exponent > 1.0 )
330 if( basebounds.
sup <= 0.0 && exponent > 1.0 && expisint )
332 if( basebounds.
inf >= 0.0 && exponent < 1.0 )
365 assert(nfactors >= 0);
366 assert(factorcurv !=
NULL || nfactors == 0);
367 assert(factorbounds !=
NULL || nfactors == 0);
374 f = factoridxs !=
NULL ? factoridxs[0] : 0;
375 e = exponents !=
NULL ? exponents[0] : 1.0;
390 for( j = 0; j < nfactors; ++j )
392 f = factoridxs !=
NULL ? factoridxs[j] : j;
395 if( factorbounds[f].inf < 0.0 && factorbounds[f].sup > 0.0 )
398 e = exponents !=
NULL ? exponents[j] : 1.0;
405 if( factorbounds[f].inf < 0.0 )
416 if( (
int)e % 2 != 0 )
421 fcurv = factorcurv[f];
444 if( nnegative == nfactors && expcurvpos )
446 else if( nnegative == nfactors-1 &&
EPSGE(sum, 1.0, 1e-9) && expcurvpos )
448 else if( npositive == nfactors &&
EPSLE(sum, 1.0, 1e-9) && expcurvneg )
484 assert(blkmem !=
NULL);
485 assert(quadraticdata !=
NULL);
486 assert(quadelems !=
NULL || nquadelems == 0);
487 assert(nchildren >= 0);
491 (*quadraticdata)->constant = constant;
492 (*quadraticdata)->lincoefs =
NULL;
493 (*quadraticdata)->nquadelems = nquadelems;
494 (*quadraticdata)->quadelems =
NULL;
495 (*quadraticdata)->sorted = (nquadelems <= 1);
497 if( lincoefs !=
NULL )
516 assert(quadraticdata !=
NULL);
518 if( quadraticdata->
sorted )
522 for( i = 1; i < quadraticdata->
nquadelems; ++i )
555 assert(elem1 !=
NULL);
556 assert(elem2 !=
NULL);
593 assert(blkmem !=
NULL);
594 assert(monomialdata !=
NULL);
605 assert(minsize <= monomialdata->factorssize);
621 assert(blkmem !=
NULL);
622 assert(polynomialdata !=
NULL);
623 assert(monomials !=
NULL || nmonomials == 0);
627 (*polynomialdata)->constant = constant;
628 (*polynomialdata)->nmonomials = nmonomials;
629 (*polynomialdata)->monomialssize = nmonomials;
630 (*polynomialdata)->monomials =
NULL;
631 (*polynomialdata)->sorted = (nmonomials <= 1);
641 for( i = 0; i < nmonomials; ++i )
643 assert(monomials[i] !=
NULL);
665 assert(blkmem !=
NULL);
666 assert(polynomialdata !=
NULL);
667 assert(sourcepolynomialdata !=
NULL);
671 (*polynomialdata)->monomialssize = sourcepolynomialdata->
nmonomials;
678 for( i = 0; i < sourcepolynomialdata->
nmonomials; ++i )
683 (*polynomialdata)->monomials[i]->sorted = sourcepolynomialdata->
monomials[i]->
sorted;
688 (*polynomialdata)->monomials =
NULL;
701 assert(blkmem !=
NULL);
702 assert(polynomialdata !=
NULL);
703 assert(*polynomialdata !=
NULL);
705 if( (*polynomialdata)->monomialssize > 0 )
709 for( i = 0; i < (*polynomialdata)->nmonomials; ++i )
711 assert((*polynomialdata)->monomials[i] !=
NULL);
713 assert((*polynomialdata)->monomials[i] ==
NULL);
718 assert((*polynomialdata)->monomials ==
NULL);
731 assert(blkmem !=
NULL);
732 assert(polynomialdata !=
NULL);
735 assert(minsize <= polynomialdata->monomialssize);
752 assert(blkmem !=
NULL);
753 assert(polynomialdata !=
NULL);
754 assert(monomials !=
NULL || nmonomials == 0);
756 if( nmonomials == 0 )
764 for( i = 0; i < nmonomials; ++i )
766 assert(monomials[i] !=
NULL);
788 assert(polynomialdata !=
NULL);
790 if( polynomialdata->
sorted )
796 for( i = 1; i < polynomialdata->
nmonomials; ++i )
800 assert(monomialdataCompare(polynomialdata->
monomials[i-1], polynomialdata->
monomials[i]) <= 0);
828 assert(polynomialdata !=
NULL);
836 while( i + offset < polynomialdata->nmonomials )
858 while( i+offset+1 < polynomialdata->
nmonomials )
870 if( monomialdataCompare((
void*)polynomialdata->
monomials[i], (
void*)polynomialdata->
monomials[i+offset+1]) != 0 )
917 assert(polynomialdata !=
NULL);
924 for( i = 0; i < polynomialdata->
nmonomials; ++i )
930 for( i = 0; i < polynomialdata->
nmonomials; ++i )
948 assert(blkmem !=
NULL);
949 assert(factor !=
NULL);
950 assert(polynomialdata !=
NULL);
959 for( i = 0; i < polynomialdata->
nmonomials; ++i )
965 if( polynomialdata->
constant != 0.0 )
994 assert(blkmem !=
NULL);
995 assert(polynomialdata !=
NULL);
996 assert(factordata !=
NULL);
997 assert(polynomialdata != factordata);
1012 if( polynomialdata->
constant != 0.0 )
1026 for( i2 = 0; i2 < factordata->
nmonomials; ++i2 )
1029 assert(polynomialdata->
nmonomials + orignmonomials <= polynomialdata->monomialssize);
1031 assert(polynomialdata->
nmonomials == (i2+2) * orignmonomials);
1034 for( i1 = (i2+1) * orignmonomials; i1 < (i2+2) * orignmonomials; ++i1 )
1050 for( i1 = 0; i1 < orignmonomials; ++i1 )
1057 for( i1 = 0; i1 < orignmonomials; ++i1 )
1081 assert(blkmem !=
NULL);
1082 assert(polynomialdata !=
NULL);
1095 for( i = 0; i < polynomialdata->
nmonomials; ++i )
1120 assert(exponent >= 2);
1128 for( i = 2; i <= exponent; ++i )
1151 assert(polynomialdata !=
NULL);
1153 for( i = 0; i < polynomialdata->
nmonomials; ++i )
1155 monomial = polynomialdata->
monomials[i];
1156 assert(monomial !=
NULL);
1158 for( j = 0; j < monomial->
nfactors; ++j )
1179 int maxexpansionexponent,
1187 assert(blkmem !=
NULL);
1188 assert(polynomialdata !=
NULL);
1189 assert(factorpolynomial !=
NULL);
1191 assert(success !=
NULL);
1192 assert(monomialpos >= 0);
1193 assert(monomialpos < polynomialdata->nmonomials);
1194 assert(factorpos >= 0);
1196 monomial = polynomialdata->
monomials[monomialpos];
1197 assert(monomial !=
NULL);
1198 assert(factorpos < monomial->nfactors);
1216 if( factorpos < monomial->nfactors-1 )
1235 factormonomial = factorpolynomial->
monomials[0];
1236 assert(factormonomial !=
NULL);
1240 if( factormonomial->
coef < 0.0 )
1262 for( i = 0; i < factormonomial->
nfactors; ++i )
1264 childidx = childmap[factormonomial->
childidxs[i]];
1275 if( factorpos < monomial->nfactors-1 )
1295 if( monomial->
exponents[factorpos] > maxexpansionexponent )
1306 if( maxexpansionexponent < INT_MAX && (monomial->
nfactors > 1 || monomial->
exponents[factorpos] != 1.0) )
1312 restdegree = -monomial->
exponents[factorpos];
1313 for( i = 0; i < monomial->
nfactors; ++i )
1318 SCIPdebugMessage(
"skip expansion because factor %d in monomial has negative exponent\n", i);
1325 for( i = 0; i < factorpolynomial->
nmonomials; ++i )
1333 SCIPdebugMessage(
"skip expansion because %d'th factor in %d'th monomial of factorpolynomial is negative\n", i, j);
1339 if( degree * monomial->
exponents[factorpos] + restdegree > maxexpansionexponent )
1342 SCIPdebugMessage(
"skip expansion because degree of %d'th monomial would yield degree %g > max = %d in expansion\n",
1343 i, degree * monomial->
exponents[factorpos] + restdegree, maxexpansionexponent);
1358 if( factorpos < monomial->nfactors-1 )
1371 if( monomialpos < polynomialdata->nmonomials-1 )
1413 assert(result !=
NULL);
1414 assert(varvals !=
NULL);
1416 *result = varvals[opdata.intval];
1425 assert(result !=
NULL);
1426 assert(varvals !=
NULL);
1428 *result = varvals[opdata.intval];
1437 assert(result !=
NULL);
1448 assert(result !=
NULL);
1450 *result = opdata.dbl;
1459 assert(result !=
NULL);
1470 assert(result !=
NULL);
1481 assert(result !=
NULL);
1482 assert(paramvals !=
NULL );
1484 *result = paramvals[opdata.intval];
1493 assert(result !=
NULL);
1494 assert(paramvals !=
NULL );
1505 assert(result !=
NULL);
1516 assert(result !=
NULL);
1517 assert(argvals !=
NULL);
1519 *result = argvals[0] + argvals[1];
1528 assert(result !=
NULL);
1529 assert(argvals !=
NULL);
1540 assert(result !=
NULL);
1541 assert(argcurv !=
NULL);
1552 assert(result !=
NULL);
1553 assert(argvals !=
NULL);
1555 *result = argvals[0] - argvals[1];
1564 assert(result !=
NULL);
1565 assert(argvals !=
NULL);
1576 assert(result !=
NULL);
1577 assert(argcurv !=
NULL);
1588 assert(result !=
NULL);
1589 assert(argvals !=
NULL);
1591 *result = argvals[0] * argvals[1];
1600 assert(result !=
NULL);
1601 assert(argvals !=
NULL);
1612 assert(result !=
NULL);
1613 assert(argcurv !=
NULL);
1614 assert(argbounds !=
NULL);
1623 if( argbounds[1].inf == argbounds[1].sup )
1625 else if( argbounds[0].inf == argbounds[0].sup )
1635 #if defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ * 10 >= 490 && !defined(__INTEL_COMPILER) 1636 __attribute__((no_sanitize_undefined))
1640 assert(result !=
NULL);
1641 assert(argvals !=
NULL);
1643 *result = argvals[0] / argvals[1];
1652 assert(result !=
NULL);
1653 assert(argvals !=
NULL);
1664 assert(result !=
NULL);
1665 assert(argcurv !=
NULL);
1666 assert(argbounds !=
NULL);
1680 if( argbounds[1].inf == argbounds[1].sup )
1685 else if( argbounds[0].inf == argbounds[0].sup )
1708 assert(result !=
NULL);
1709 assert(argvals !=
NULL);
1711 *result = argvals[0] * argvals[0];
1720 assert(result !=
NULL);
1721 assert(argvals !=
NULL);
1732 assert(result !=
NULL);
1733 assert(argcurv !=
NULL);
1734 assert(argbounds !=
NULL);
1745 assert(result !=
NULL);
1746 assert(argvals !=
NULL);
1748 *result =
sqrt(argvals[0]);
1757 assert(result !=
NULL);
1758 assert(argvals !=
NULL);
1769 assert(result !=
NULL);
1770 assert(argcurv !=
NULL);
1788 assert(result !=
NULL);
1789 assert(argvals !=
NULL);
1791 *result =
pow(argvals[0], opdata.dbl);
1800 assert(result !=
NULL);
1801 assert(argvals !=
NULL);
1812 assert(result !=
NULL);
1813 assert(argcurv !=
NULL);
1814 assert(argbounds !=
NULL);
1823 #if defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ * 10 >= 490 && !defined(__INTEL_COMPILER) 1824 __attribute__((no_sanitize_undefined))
1828 assert(result !=
NULL);
1829 assert(argvals !=
NULL);
1831 switch( opdata.intval )
1834 *result = 1.0 / argvals[0];
1842 *result = argvals[0];
1846 *result = argvals[0] * argvals[0];
1860 assert(result !=
NULL);
1861 assert(argvals !=
NULL);
1872 assert(result !=
NULL);
1873 assert(argcurv !=
NULL);
1874 assert(argbounds !=
NULL);
1885 assert(result !=
NULL);
1886 assert(argvals !=
NULL);
1888 if( argvals[0] > 0 )
1889 *result =
pow( argvals[0], opdata.dbl);
1891 *result = -
pow(-argvals[0], opdata.dbl);
1900 assert(result !=
NULL);
1901 assert(argvals !=
NULL);
1916 assert(result !=
NULL);
1917 assert(argcurv !=
NULL);
1918 assert(argbounds !=
NULL);
1926 if( argbounds[0].inf < 0 )
1936 if( argbounds[0].sup > 0 )
1955 assert(result !=
NULL);
1956 assert(argvals !=
NULL);
1958 *result =
exp(argvals[0]);
1967 assert(result !=
NULL);
1968 assert(argvals !=
NULL);
1979 assert(result !=
NULL);
1980 assert(argcurv !=
NULL);
1997 assert(result !=
NULL);
1998 assert(argvals !=
NULL);
2000 *result =
log(argvals[0]);
2009 assert(result !=
NULL);
2010 assert(argvals !=
NULL);
2021 assert(result !=
NULL);
2022 assert(argcurv !=
NULL);
2039 assert(result !=
NULL);
2040 assert(argvals !=
NULL);
2042 *result =
sin(argvals[0]);
2051 assert(result !=
NULL);
2052 assert(argvals !=
NULL);
2061 #define exprcurvSin exprcurvDefault 2067 assert(result !=
NULL);
2068 assert(argvals !=
NULL);
2070 *result =
cos(argvals[0]);
2079 assert(result !=
NULL);
2080 assert(argvals !=
NULL);
2089 #define exprcurvCos exprcurvDefault 2095 assert(result !=
NULL);
2096 assert(argvals !=
NULL);
2098 *result = tan(argvals[0]);
2104 #define exprevalIntTan exprevalIntDefault 2107 #define exprcurvTan exprcurvDefault 2110 #ifdef SCIP_DISABLED_CODE 2114 assert(result !=
NULL);
2115 assert(argvals !=
NULL);
2117 *result = erf(argvals[0]);
2123 #define exprevalIntErf exprevalIntDefault 2126 #define exprcurvErf exprcurvDefault 2131 assert(result !=
NULL);
2132 assert(argvals !=
NULL);
2141 #define exprevalIntErfi NULL 2143 #define exprcurvErfi exprcurvDefault 2150 assert(result !=
NULL);
2151 assert(argvals !=
NULL);
2153 *result =
MIN(argvals[0], argvals[1]);
2162 assert(result !=
NULL);
2163 assert(argvals !=
NULL);
2174 assert(result !=
NULL);
2175 assert(argcurv !=
NULL);
2193 assert(result !=
NULL);
2194 assert(argvals !=
NULL);
2196 *result =
MAX(argvals[0], argvals[1]);
2205 assert(result !=
NULL);
2206 assert(argvals !=
NULL);
2217 assert(result !=
NULL);
2218 assert(argcurv !=
NULL);
2235 assert(result !=
NULL);
2236 assert(argvals !=
NULL);
2238 *result = ABS(argvals[0]);
2247 assert(result !=
NULL);
2248 assert(argvals !=
NULL);
2259 assert(result !=
NULL);
2260 assert(argcurv !=
NULL);
2261 assert(argbounds !=
NULL);
2268 if( argbounds[0].sup <= 0.0 )
2270 else if( argbounds[0].inf >= 0.0 )
2271 *result = argcurv[0];
2284 assert(result !=
NULL);
2285 assert(argvals !=
NULL);
2287 *result =
SIGN(argvals[0]);
2296 assert(result !=
NULL);
2297 assert(argvals !=
NULL);
2308 assert(result !=
NULL);
2309 assert(argbounds !=
NULL);
2312 if( argbounds[0].sup <= 0.0 || argbounds[0].inf >= 0.0 )
2326 assert(result !=
NULL);
2327 assert(argvals !=
NULL);
2330 for( i = 0; i < nargs; ++i )
2331 *result += argvals[i];
2342 assert(result !=
NULL);
2343 assert(argvals !=
NULL);
2347 for( i = 0; i < nargs; ++i )
2359 assert(result !=
NULL);
2360 assert(argcurv !=
NULL);
2364 for( i = 0; i < nargs; ++i )
2376 assert(result !=
NULL);
2377 assert(argvals !=
NULL);
2380 for( i = 0; i < nargs; ++i )
2381 *result *= argvals[i];
2392 assert(result !=
NULL);
2393 assert(argvals !=
NULL);
2397 for( i = 0; i < nargs; ++i )
2411 assert(result !=
NULL);
2412 assert(argcurv !=
NULL);
2413 assert(argbounds !=
NULL);
2419 hadnonconst =
FALSE;
2422 for( i = 0; i < nargs; ++i )
2424 if( argbounds[i].inf == argbounds[i].sup )
2426 constants *= argbounds[i].inf;
2428 else if( !hadnonconst )
2431 *result = argcurv[i];
2454 assert(result !=
NULL);
2455 assert(argvals !=
NULL || nargs == 0);
2456 assert(opdata.data !=
NULL);
2458 coef = &((
SCIP_Real*)opdata.data)[nargs];
2461 for( i = nargs-1, --coef; i >= 0; --i, --coef )
2462 *result += *coef * argvals[i];
2464 assert(++coef == (
SCIP_Real*)opdata.data);
2473 assert(result !=
NULL);
2474 assert(argvals !=
NULL || nargs == 0);
2475 assert(opdata.data !=
NULL);
2490 assert(result !=
NULL);
2491 assert(argcurv !=
NULL);
2494 assert(data !=
NULL);
2498 for( i = 0; i < nargs; ++i )
2510 assert(blkmem !=
NULL);
2511 assert(nchildren >= 0);
2512 assert(opdatatarget !=
NULL);
2515 assert(opdatasource.data !=
NULL);
2517 opdatatarget->data = targetdata;
2528 assert(blkmem !=
NULL);
2529 assert(nchildren >= 0);
2532 assert(freedata !=
NULL);
2547 assert(result !=
NULL);
2548 assert(argvals !=
NULL || nargs == 0);
2551 assert(quaddata !=
NULL);
2557 assert(quadelems !=
NULL || nquadelems == 0);
2558 assert(argvals !=
NULL || nquadelems == 0);
2562 if( lincoefs !=
NULL )
2564 for( i = nargs-1; i >= 0; --i )
2565 *result += lincoefs[i] * argvals[i];
2568 for( i = 0; i < nquadelems; ++i, ++quadelems )
2569 *result += quadelems->
coef * argvals[quadelems->
idx1] * argvals[quadelems->
idx2];
2588 assert(result !=
NULL);
2589 assert(argvals !=
NULL || nargs == 0);
2592 assert(quaddata !=
NULL);
2598 assert(quadelems !=
NULL || nquadelems == 0);
2599 assert(argvals !=
NULL || nargs == 0);
2607 for( i = 0; i < nquadelems; ++i )
2609 assert(quadelems[i].idx1 == 0);
2610 assert(quadelems[i].idx2 == 0);
2611 sqrcoef += quadelems[i].
coef;
2620 if( nargs == 2 && nquadelems > 0 )
2630 for( i = 0; i < nquadelems; ++i )
2631 if( quadelems[i].idx1 == 0 && quadelems[i].idx2 == 0 )
2632 ax += quadelems[i].
coef;
2633 else if( quadelems[i].idx1 == 1 && quadelems[i].idx2 == 1 )
2634 ay += quadelems[i].
coef;
2636 axy += quadelems[i].
coef;
2639 lincoefs !=
NULL ? lincoefs[0] : 0.0, lincoefs !=
NULL ? lincoefs[1] : 0.0,
2640 argvals[0], argvals[1]);
2641 SCIPdebugMessage(
"%g x^2 + %g y^2 + %g x y + %g x + %g y = [%g,%g] for x = [%g,%g], y = [%g,%g]\n",
2642 ax, ay, axy, lincoefs !=
NULL ? lincoefs[0] : 0.0, lincoefs !=
NULL ? lincoefs[1] : 0.0,
2643 result->inf, result->sup, argvals[0].inf, argvals[0].sup, argvals[1].inf, argvals[1].sup);
2660 for( argidx = 0; argidx < nargs; ++argidx )
2662 if( i == nquadelems || quadelems[i].idx1 > argidx )
2665 if( lincoefs !=
NULL )
2676 assert(i < nquadelems && quadelems[i].idx1 == argidx);
2679 if( quadelems[i].idx2 == argidx )
2681 sqrcoef += quadelems[i].
coef;
2690 while( i < nquadelems && quadelems[i].idx1 == argidx );
2691 assert(i == nquadelems || quadelems[i].idx1 > argidx);
2696 assert(i == nquadelems);
2711 assert(result !=
NULL);
2712 assert(argcurv !=
NULL);
2713 assert(argbounds !=
NULL);
2716 assert(data !=
NULL);
2724 if( lincoefs !=
NULL )
2725 for( i = 0; i < nargs; ++i )
2733 if( quadelems[i].coef == 0.0 )
2736 if( argbounds[quadelems[i].idx1].inf == argbounds[quadelems[i].idx1].sup &&
2737 +argbounds[quadelems[i].idx2].inf == argbounds[quadelems[i].idx2].sup
2744 if( argbounds[quadelems[i].idx1].inf == argbounds[quadelems[i].idx1].sup )
2749 else if( argbounds[quadelems[i].idx2].inf == argbounds[quadelems[i].idx2].sup )
2754 else if( quadelems[i].idx1 == quadelems[i].idx2 )
2775 assert(blkmem !=
NULL);
2776 assert(opdatatarget !=
NULL);
2779 assert(sourcedata !=
NULL);
2793 assert(blkmem !=
NULL);
2794 assert(nchildren >= 0);
2797 assert(quadraticdata !=
NULL);
2825 assert(result !=
NULL);
2826 assert(argvals !=
NULL || nargs == 0);
2827 assert(opdata.data !=
NULL);
2830 assert(polynomialdata !=
NULL);
2832 *result = polynomialdata->
constant;
2834 for( i = 0; i < polynomialdata->
nmonomials; ++i )
2836 monomialdata = polynomialdata->
monomials[i];
2837 assert(monomialdata !=
NULL);
2839 monomialval = monomialdata->
coef;
2840 for( j = 0; j < monomialdata->
nfactors; ++j )
2842 assert(monomialdata->
childidxs[j] >= 0);
2843 assert(monomialdata->
childidxs[j] < nargs);
2845 childval = argvals[monomialdata->
childidxs[j]];
2846 if( childval == 1.0 )
2851 if( childval == 0.0 )
2853 if( exponent > 0.0 )
2859 else if( exponent < 0.0 )
2866 *result =
pow(0.0, -1.0);
2875 if( exponent == 0.0 )
2877 if( exponent == 1.0 )
2879 monomialval *= childval;
2882 if( exponent == 2.0 )
2884 monomialval *= childval * childval;
2887 if( exponent == 0.5 )
2889 monomialval *=
sqrt(childval);
2892 if( exponent == -1.0 )
2894 monomialval /= childval;
2897 if( exponent == -2.0 )
2899 monomialval /= childval * childval;
2902 monomialval *=
pow(childval, exponent);
2905 *result += monomialval;
2923 assert(result !=
NULL);
2924 assert(argvals !=
NULL || nargs == 0);
2925 assert(opdata.data !=
NULL);
2928 assert(polynomialdata !=
NULL);
2932 for( i = 0; i < polynomialdata->
nmonomials; ++i )
2934 monomialdata = polynomialdata->
monomials[i];
2935 assert(monomialdata !=
NULL);
2940 assert(monomialdata->
childidxs[j] >= 0);
2941 assert(monomialdata->
childidxs[j] < nargs);
2943 childval = argvals[monomialdata->
childidxs[j]];
2948 if( exponent == 0.0 )
2951 if( exponent == 1.0 )
2957 if( exponent == 2.0 )
2964 if( exponent == 0.5 )
2975 else if( exponent == -1.0 )
2979 else if( exponent == -2.0 )
3015 assert(result !=
NULL);
3016 assert(argcurv !=
NULL);
3017 assert(argbounds !=
NULL);
3020 assert(data !=
NULL);
3032 monomial = monomials[i];
3046 assert(blkmem !=
NULL);
3047 assert(opdatatarget !=
NULL);
3050 assert(sourcepolynomialdata !=
NULL);
3054 opdatatarget->data = (
void*)targetpolynomialdata;
3065 assert(blkmem !=
NULL);
3068 assert(polynomialdata !=
NULL);
3094 if( exprdata->inteval !=
NULL )
3115 if( exprdata->curv !=
NULL )
3135 assert(blkmem !=
NULL);
3136 assert(opdatatarget !=
NULL);
3139 assert(exprdatasource !=
NULL);
3145 if( exprdatasource->copydata !=
NULL )
3155 opdatatarget->data = (
void*)exprdatatarget;
3166 assert(blkmem !=
NULL);
3171 if( exprdata->freedata !=
NULL )
3173 exprdata->freedata(blkmem, nchildren, exprdata->
userdata);
3185 struct exprOpTableElement
3196 #define EXPROPEMPTY {NULL, -1, NULL, NULL, NULL, NULL, NULL} 3203 {
"variable", 0, exprevalVar, exprevalIntVar, exprcurvVar,
NULL, NULL },
3204 {
"constant", 0, exprevalConst, exprevalIntConst, exprcurvConst,
NULL, NULL },
3205 {
"parameter", 0, exprevalParam, exprevalIntParam, exprcurvParam,
NULL, NULL },
3207 {
"plus", 2, exprevalPlus, exprevalIntPlus, exprcurvPlus,
NULL, NULL },
3208 {
"minus", 2, exprevalMinus, exprevalIntMinus, exprcurvMinus,
NULL, NULL },
3209 {
"mul", 2, exprevalMult, exprevalIntMult, exprcurvMult,
NULL, NULL },
3210 {
"div", 2, exprevalDiv, exprevalIntDiv, exprcurvDiv,
NULL, NULL },
3211 {
"sqr", 1, exprevalSquare, exprevalIntSquare, exprcurvSquare,
NULL, NULL },
3212 {
"sqrt", 1, exprevalSquareRoot, exprevalIntSquareRoot, exprcurvSquareRoot,
NULL, NULL },
3213 {
"realpower", 1, exprevalRealPower, exprevalIntRealPower, exprcurvRealPower,
NULL, NULL },
3214 {
"intpower", 1, exprevalIntPower, exprevalIntIntPower, exprcurvIntPower,
NULL, NULL },
3215 {
"signpower", 1, exprevalSignPower, exprevalIntSignPower, exprcurvSignPower,
NULL, NULL },
3216 {
"exp", 1, exprevalExp, exprevalIntExp, exprcurvExp,
NULL, NULL },
3217 {
"log", 1, exprevalLog, exprevalIntLog, exprcurvLog,
NULL, NULL },
3224 {
"min", 2, exprevalMin, exprevalIntMin, exprcurvMin,
NULL, NULL },
3225 {
"max", 2, exprevalMax, exprevalIntMax, exprcurvMax,
NULL, NULL },
3226 {
"abs", 1, exprevalAbs, exprevalIntAbs, exprcurvAbs,
NULL, NULL },
3227 {
"sign", 1, exprevalSign, exprevalIntSign, exprcurvSign,
NULL, NULL },
3229 EXPROPEMPTY,
EXPROPEMPTY,
EXPROPEMPTY,
EXPROPEMPTY,
EXPROPEMPTY,
EXPROPEMPTY,
EXPROPEMPTY,
EXPROPEMPTY,
EXPROPEMPTY,
EXPROPEMPTY,
3230 EXPROPEMPTY,
EXPROPEMPTY,
EXPROPEMPTY,
EXPROPEMPTY,
EXPROPEMPTY,
EXPROPEMPTY,
EXPROPEMPTY,
EXPROPEMPTY,
EXPROPEMPTY,
EXPROPEMPTY,
3231 EXPROPEMPTY,
EXPROPEMPTY,
EXPROPEMPTY,
EXPROPEMPTY,
EXPROPEMPTY,
EXPROPEMPTY,
EXPROPEMPTY,
EXPROPEMPTY,
EXPROPEMPTY,
EXPROPEMPTY,
3233 {
"sum", -2, exprevalSum, exprevalIntSum, exprcurvSum,
NULL, NULL },
3234 {
"prod", -2, exprevalProduct, exprevalIntProduct, exprcurvProduct,
NULL, NULL },
3235 {
"linear", -2, exprevalLinear, exprevalIntLinear, exprcurvLinear, exprCopyDataLinear, exprFreeDataLinear },
3236 {
"quadratic", -2, exprevalQuadratic, exprevalIntQuadratic, exprcurvQuadratic, exprCopyDataQuadratic, exprFreeDataQuadratic },
3237 {
"polynomial", -2, exprevalPolynomial, exprevalIntPolynomial, exprcurvPolynomial, exprCopyDataPolynomial, exprFreeDataPolynomial },
3238 {
"user", -2, exprevalUser, exprevalIntUser, exprcurvUser, exprCopyDataUser, exprFreeDataUser }
3253 return exprOpTable[op].name;
3263 return exprOpTable[op].nargs;
3285 assert(blkmem !=
NULL);
3286 assert(expr !=
NULL);
3287 assert(children !=
NULL || nchildren == 0);
3288 assert(children ==
NULL || nchildren > 0);
3293 (*expr)->nchildren = nchildren;
3294 (*expr)->children = children;
3295 (*expr)->
data = opdata;
3314 assert(blkmem !=
NULL);
3316 assert(data !=
NULL);
3332 assert(nchildren == 2);
3348 data->data = (
void*)polynomialdata;
3360 assert(nchildren == 2);
3376 data->data = (
void*)polynomialdata;
3388 assert(nchildren == 2);
3401 data->data = (
void*)polynomialdata;
3413 assert(nchildren == 2);
3426 data->data = (
void*)polynomialdata;
3438 assert(nchildren == 1);
3449 data->data = (
void*)polynomialdata;
3461 assert(nchildren == 1);
3472 data->data = (
void*)polynomialdata;
3483 assert(nchildren == 1);
3495 data->data = (
void*)polynomialdata;
3504 assert(nchildren == 1);
3507 exponent = data->dbl;
3508 if(
EPSISINT(exponent, 0.0) && (
int)exponent % 2 != 0 )
3523 data->data = (
void*)polynomialdata;
3536 assert(nchildren == 1);
3540 exponent = data->intval;
3547 data->data = (
void*)polynomialdata;
3583 for( i = 0; i < nchildren; ++i )
3591 data->data = (
void*)polynomialdata;
3608 for( i = 0; i < nchildren; ++i )
3618 data->data = (
void*)polynomialdata;
3634 assert(lineardata !=
NULL);
3646 for( i = 0; i < nchildren; ++i )
3648 monomial->
coef = lineardata[i];
3655 exprFreeDataLinear(blkmem, nchildren, *data);
3658 data->data = (
void*)polynomialdata;
3676 assert(quaddata !=
NULL);
3697 for( i = 0; i < nchildren; ++i )
3727 exprFreeDataQuadratic(blkmem, nchildren, *data);
3730 data->data = (
void*)polynomialdata;
3760 assert(blkmem !=
NULL);
3763 assert(data !=
NULL);
3764 assert(children !=
NULL || nchildren == 0);
3767 assert(polynomialdata !=
NULL);
3780 for( i = 0; i < polynomialdata->
nmonomials; ++i )
3784 monomial = polynomialdata->
monomials[i];
3785 assert(monomial !=
NULL);
3788 for(j = 0; j < monomial->
nfactors; ++j )
3805 if( monomialdegree == 1 )
3808 if( monomialdegree > maxdegree )
3809 maxdegree = monomialdegree;
3811 assert(maxdegree > 0 );
3813 if( maxdegree == 1 )
3818 assert(polynomialdata->
nmonomials == nchildren);
3819 assert(polynomialdata->
nmonomials == nlinmonomials);
3870 children[1] = children[0];
3879 if( polynomialdata->
constant == 0.0 )
3882 for( i = 0; i < polynomialdata->
nmonomials; ++i )
3911 for( i = 0; i < polynomialdata->
nmonomials; ++i )
3917 lindata[i] = polynomialdata->
constant;
3921 data->data = (
void*)lindata;
3939 if( nlinmonomials > 0 )
3948 for( i = 0; i < polynomialdata->
nmonomials; ++i )
3963 assert(quadelemidx < quaddata->nquadelems);
3975 assert(quadelemidx < quaddata->nquadelems);
3987 data->data = (
void*)quaddata;
3995 monomial = polynomialdata->
monomials[0];
3996 assert(monomial->
nfactors == nchildren);
4026 data->intval = exponent;
4052 data->dbl = exponent;
4058 if( maxdegree == 2 && monomial->
nfactors == 2 )
4072 if( maxdegree == monomial->
nfactors )
4111 children[1] = children[0];
4142 assert(blkmem !=
NULL);
4143 assert(expr !=
NULL);
4145 assert(exprs !=
NULL || nexprs == 0);
4156 for( i = 0; i < nexprs; ++i )
4159 if( childmap !=
NULL )
4178 for( i = 0; i < nexprs; ++i )
4180 existsalready =
FALSE;
4181 if( comparechildren )
4182 for( j = 0; j < orignchildren; ++j )
4186 existsalready =
TRUE;
4190 if( !existsalready )
4194 if( childmap !=
NULL )
4200 if( childmap !=
NULL )
4211 assert(comparechildren || expr->
nchildren == orignchildren + nexprs);
4221 data[expr->
nchildren] = data[orignchildren];
4222 for( i = orignchildren; i < expr->
nchildren; ++i )
4224 expr->
data.data = (
void*)data;
4240 SCIPerrorMessage(
"exprsimplifyAddChildren cannot be called for operand %d\n", expr->
op);
4256 assert(expr !=
NULL);
4284 assert(blkmem !=
NULL);
4285 assert(expr !=
NULL);
4293 foundduplicates =
FALSE;
4300 for( j = i+1; j < expr->
nchildren; ++j )
4310 foundduplicates =
TRUE;
4316 if( foundduplicates )
4336 assert(blkmem !=
NULL);
4337 assert(expr !=
NULL);
4347 while( lastnonnull >= 0 && expr->
children[lastnonnull] ==
NULL )
4349 for( i = 0; i <= lastnonnull; ++i )
4361 childmap[lastnonnull] = i;
4365 while( lastnonnull >= 0 && expr->
children[lastnonnull] ==
NULL )
4368 assert(i > lastnonnull);
4371 if( lastnonnull < expr->nchildren-1 )
4377 if( lastnonnull >= 0 )
4404 assert(blkmem !=
NULL);
4405 assert(expr !=
NULL);
4411 assert(polynomialdata !=
NULL);
4416 for( i = 0; i < polynomialdata->
nmonomials; ++i )
4418 monomial = polynomialdata->
monomials[i];
4419 assert(monomial !=
NULL);
4421 for( j = 0; j < monomial->
nfactors; ++j )
4449 int maxexpansionexponent
4454 assert(expr !=
NULL);
4504 expr->
data.data = (
void*)polynomialdata;
4536 expr->
data.data = (
void*)polynomialdata;
4569 assert(polynomialdata !=
NULL);
4592 if( childmapsize < expr->children[i]->nchildren )
4598 childmapsize = newsize;
4602 for( j = 0; j < polynomialdata->
nmonomials; ++j )
4607 monomial = polynomialdata->
monomials[j];
4613 assert(factorpos >= 0);
4614 assert(factorpos < monomial->nfactors);
4616 assert(factorpos == 0 || monomial->
childidxs[factorpos-1] != i);
4617 assert(factorpos == monomial->
nfactors-1 || monomial->
childidxs[factorpos+1] != i);
4635 if( factorpos < monomial->nfactors-1 )
4648 removechild =
FALSE;
4671 if( childmapsize < expr->children[i]->nchildren )
4677 childmapsize = newsize;
4685 while( j < polynomialdata->nmonomials )
4690 monomial = polynomialdata->
monomials[j];
4696 assert(factorpos >= 0);
4697 assert(factorpos < monomial->nfactors);
4699 assert(factorpos == 0 || monomial->
childidxs[factorpos-1] != i);
4700 assert(factorpos == monomial->
nfactors-1 || monomial->
childidxs[factorpos+1] != i);
4711 removechild =
FALSE;
4751 expr->
data.dbl = val;
4791 assert(blkmem !=
NULL);
4792 assert(expr !=
NULL);
4793 assert(nlinvars !=
NULL);
4794 assert(linidxs !=
NULL);
4795 assert(lincoefs !=
NULL);
4806 assert(polynomialdata !=
NULL);
4816 for( i = 0; i < polynomialdata->
nmonomials; ++i )
4818 monomial = polynomialdata->
monomials[i];
4819 assert(monomial !=
NULL);
4820 for( j = 0; j < monomial->
nfactors; ++j )
4829 for( i = 0; i < polynomialdata->
nmonomials; ++i )
4831 monomial = polynomialdata->
monomials[i];
4832 assert(monomial !=
NULL);
4850 lincoefs[*nlinvars] = monomial->
coef;
4854 monomial->
coef = 0.0;
4881 assert(blkmem !=
NULL);
4882 assert(expr !=
NULL);
4900 return (
void*)((
char*)elem +
sizeof(
int));
4916 const char* varnameendptr
4926 assert(blkmem !=
NULL);
4927 assert(str !=
NULL);
4928 assert(expr !=
NULL);
4929 assert(nvars !=
NULL);
4930 assert(varnames !=
NULL);
4931 assert(vartable !=
NULL);
4933 if( varnameendptr ==
NULL )
4936 varnameendptr = *str;
4937 while( varnameendptr[0] !=
'>' )
4941 namelength = varnameendptr - *str;
4944 SCIPerrorMessage(
"Variable name %.*s is too long for buffer in exprparseReadVariable.\n", namelength, str);
4948 memcpy(varname, *str, namelength *
sizeof(
char));
4949 varname[namelength] =
'\0';
4952 if( element !=
NULL )
4955 assert(strcmp((
char*)element +
sizeof(
int), varname) == 0);
4957 varidx = *(
int*)element;
4965 **varnames = varidx;
4966 strcpy((
char*)(*varnames + 1), varname);
4972 *varnames += 1 + (strlen(varname) + 1) /
sizeof(
int) + 1;
4977 if( coefficient != 1.0 )
4983 *str = varnameendptr + 1;
4986 if( (*str)[0] ==
'[' && (*str)[2] ==
']' &&
5003 const char** endptr,
5009 assert(str[0] ==
'(');
5015 while( (*endptr - str ) < length && !(nopenbrackets == 1 && *endptr[0] ==
')') )
5017 if( *endptr[0] ==
'(')
5019 if( *endptr[0] ==
')')
5024 if( *endptr[0] !=
')' )
5026 SCIPerrorMessage(
"unable to find closing parenthesis in unbalanced expression %.*s\n", length, str);
5042 const char** endptr,
5052 while( (*endptr - str ) < length && !(nopenbrackets == 0 && *endptr[0] ==
',') )
5054 if( *endptr[0] ==
'(')
5056 if( *endptr[0] ==
')')
5061 if( *endptr[0] !=
',' )
5063 SCIPerrorMessage(
"unable to find separating comma in unbalanced expression %.*s\n", length, str);
5078 const char* lastchar,
5087 const char* subexpptr;
5088 const char* subexpendptr;
5089 const char* strstart;
5091 char* nonconstendptr;
5096 assert(blkmem !=
NULL);
5097 assert(expr !=
NULL);
5098 assert(str !=
NULL);
5099 assert(lastchar >= str);
5100 assert(nvars !=
NULL);
5101 assert(varnames !=
NULL);
5102 assert(vartable !=
NULL);
5104 assert(recursiondepth < 100);
5108 SCIPdebugMessage(
"exprParse (%i): parsing %.*s\n", recursiondepth, (
int) (lastchar-str + 1), str);
5111 while( isspace((
unsigned char)*str) )
5121 while( subexpptr != lastchar && !(nopenbrackets == 0 && (subexpptr[0] ==
'+' || subexpptr[0] ==
'-') && subexpptr != str) )
5123 if( subexpptr[0] ==
'(')
5125 if( subexpptr[0] ==
')')
5130 if( subexpptr != lastchar )
5132 SCIP_CALL(
exprParse(blkmem, messagehdlr, &arg1, str, (
int) ((subexpptr - 1) - str + 1), subexpptr - 1, nvars, varnames, vartable, recursiondepth + 1) );
5134 if( subexpptr[0] ==
'+' )
5136 SCIP_CALL(
exprParse(blkmem, messagehdlr, &arg2, subexpptr , (
int) (lastchar - (subexpptr ) + 1), lastchar, nvars, varnames, vartable, recursiondepth + 1) );
5158 subexpptr = str + 1;
5161 while( subexplength < length && !(nopenbrackets == 1 && str[0] ==
')') )
5170 subexpendptr = str - 1;
5172 SCIP_CALL(
exprParse(blkmem, messagehdlr, expr, subexpptr, subexplength, subexpendptr, nvars, varnames, vartable, recursiondepth + 1) );
5175 else if( isdigit((
unsigned char)str[0]) || ((str[0] ==
'-' || str[0] ==
'+')
5176 && (isdigit((
unsigned char)str[1]) || str[1] ==
' ')) )
5179 if( str[0] ==
'-' && str[1] ==
' ' )
5182 nonconstendptr = (
char*) str + 1;
5190 str = nonconstendptr;
5193 while( isspace((
unsigned char)*str) && str != lastchar )
5196 if( str[0] !=
'*' && str[0] !=
'/' && str[0] !=
'+' && str[0] !=
'-' && str[0] !=
'^' )
5198 if( str < lastchar )
5200 SCIP_CALL(
exprParse(blkmem, messagehdlr, expr, str, (
int)(lastchar - str) + 1, lastchar, nvars, varnames, vartable, recursiondepth + 1) );
5214 else if( str[0] ==
'<' )
5220 else if( strncmp(str,
"sqrt", 4) == 0 )
5224 SCIP_CALL(
exprParse(blkmem, messagehdlr, &arg1, str + 1, endptr - str - 1, endptr -1, nvars, varnames, vartable, recursiondepth + 1) );
5231 strncmp(str,
"abs", 3) == 0 ||
5232 strncmp(str,
"cos", 3) == 0 ||
5233 strncmp(str,
"exp", 3) == 0 ||
5234 strncmp(str,
"log", 3) == 0 ||
5235 strncmp(str,
"sin", 3) == 0 ||
5236 strncmp(str,
"sqr", 3) == 0 ||
5237 strncmp(str,
"tan", 3) == 0 )
5239 const char* opname = str;
5243 SCIP_CALL(
exprParse(blkmem, messagehdlr, &arg1, str + 1, endptr - str - 1, endptr -1, nvars, varnames, vartable, recursiondepth + 1) );
5246 if( strncmp(opname,
"abs", 3) == 0 )
5250 else if( strncmp(opname,
"cos", 3) == 0 )
5254 else if( strncmp(opname,
"exp", 3) == 0 )
5258 else if( strncmp(opname,
"log", 3) == 0 )
5262 else if( strncmp(opname,
"sin", 3) == 0 )
5266 else if( strncmp(opname,
"sqr", 3) == 0 )
5272 assert(strncmp(opname,
"tan", 3) == 0);
5278 strncmp(str,
"max", 3) == 0 ||
5279 strncmp(str,
"min", 3) == 0 )
5295 SCIP_CALL(
exprParse(blkmem, messagehdlr, &arg1, str + 1, comma - str - 1, comma - 1, nvars, varnames, vartable, recursiondepth + 1) );
5299 while( comma < endptr && *comma ==
' ' )
5302 SCIP_CALL(
exprParse(blkmem, messagehdlr, &arg2, comma, endptr - comma, endptr - 1, nvars, varnames, vartable, recursiondepth + 1) );
5308 else if( strncmp(str,
"power", 5) == 0 )
5322 SCIP_CALL(
exprParse(blkmem, messagehdlr, &arg1, str + 1, comma - str - 1, comma - 1, nvars, varnames, vartable, recursiondepth + 1) );
5326 while( comma < endptr && *comma ==
' ' )
5328 if( !isdigit((
unsigned char)comma[0]) && !((comma[0] ==
'-' || comma[0] ==
'+') && isdigit((
unsigned char)comma[1])) )
5342 else if( strncmp(str,
"realpower", 9) == 0 || strncmp(str,
"signpower", 9) == 0 )
5347 const char* opname = str;
5356 SCIP_CALL(
exprParse(blkmem, messagehdlr, &arg1, str + 1, comma - str - 1, comma - 1, nvars, varnames, vartable, recursiondepth + 1) );
5360 while( comma < endptr && *comma ==
' ' )
5362 if( !isdigit((
unsigned char)comma[0]) && !((comma[0] ==
'-' || comma[0] ==
'+') && isdigit((
unsigned char)comma[1])) )
5372 if( strncmp(opname,
"realpower", 9) == 0 )
5378 assert(strncmp(opname,
"signpower", 9) == 0);
5384 else if( isalpha(*str) || *str ==
'_' || *str ==
'#' )
5390 const char* varnamestartptr = str;
5393 while( isalnum(str[0]) || str[0] ==
'_' || str[0] ==
'#' )
5400 SCIPerrorMessage(
"parsing of invalid expression %.*s.\n", (
int) (lastchar - str + 1), str);
5405 if( str == lastchar + 1)
5415 if( str > lastchar + 1)
5417 SCIPerrorMessage(
"error finding first expression in \"%.*s\" took us outside of given subexpression length\n", length, strstart);
5422 while( isspace((
unsigned char)*str) && str != lastchar + 1 )
5426 if( str >= lastchar + 1)
5442 while( isspace((
unsigned char)*str) && str != lastchar + 1 )
5445 if( isdigit((
unsigned char)str[0]) || ((str[0] ==
'-' || str[0] ==
'+') && isdigit((
unsigned char)str[1])) )
5455 str = nonconstendptr;
5470 else if( str[0] ==
'(' )
5475 SCIP_CALL(
exprParse(blkmem, messagehdlr, &arg2, str + 1, endptr - str - 1, endptr -1, nvars, varnames, vartable, recursiondepth + 1) );
5507 while( isspace((
unsigned char)*str) && str != lastchar + 1 )
5512 if( str <= lastchar && (str[0] ==
'+' || str[0] ==
'-' || str[0] ==
'/') )
5522 SCIP_CALL(
exprParse(blkmem, messagehdlr, &arg2, str, (
int) (lastchar - str + 1), lastchar, nvars, varnames, vartable, recursiondepth + 1) );
5534 else if( op ==
'*' )
5566 while( isspace((
unsigned char)*str) )
5570 if( str >= lastchar + 1 )
5587 else if( str[0] !=
'(' )
5589 SCIPdebugMessage(
"No operator found, assuming a multiplication before %.*s\n", (
int) (lastchar - str + 1), str);
5592 SCIP_CALL(
exprParse(blkmem, messagehdlr, &arg2, str, (
int) (lastchar - str + 1), lastchar, nvars, varnames, vartable, recursiondepth + 1) );
5627 #undef SCIPexprGetOperator 5628 #undef SCIPexprGetNChildren 5629 #undef SCIPexprGetChildren 5630 #undef SCIPexprGetOpIndex 5631 #undef SCIPexprGetOpReal 5632 #undef SCIPexprGetOpData 5633 #undef SCIPexprGetRealPowerExponent 5634 #undef SCIPexprGetIntPowerExponent 5635 #undef SCIPexprGetSignPowerExponent 5636 #undef SCIPexprGetLinearCoefs 5637 #undef SCIPexprGetLinearConstant 5638 #undef SCIPexprGetQuadElements 5639 #undef SCIPexprGetQuadConstant 5640 #undef SCIPexprGetQuadLinearCoefs 5641 #undef SCIPexprGetNQuadElements 5642 #undef SCIPexprGetMonomials 5643 #undef SCIPexprGetNMonomials 5644 #undef SCIPexprGetPolynomialConstant 5645 #undef SCIPexprGetMonomialCoef 5646 #undef SCIPexprGetMonomialNFactors 5647 #undef SCIPexprGetMonomialChildIndices 5648 #undef SCIPexprGetMonomialExponents 5649 #undef SCIPexprGetUserData 5650 #undef SCIPexprHasUserEstimator 5651 #undef SCIPexprGetUserEvalCapability 5658 assert(expr !=
NULL);
5668 assert(expr !=
NULL);
5678 assert(expr !=
NULL);
5688 assert(expr !=
NULL);
5691 return expr->
data.intval;
5699 assert(expr !=
NULL);
5702 return expr->
data.dbl;
5710 assert(expr !=
NULL);
5713 return expr->
data.data;
5721 assert(expr !=
NULL);
5724 return expr->
data.dbl;
5732 assert(expr !=
NULL);
5735 return expr->
data.intval;
5743 assert(expr !=
NULL);
5746 return expr->
data.dbl;
5754 assert(expr !=
NULL);
5767 assert(expr !=
NULL);
5780 assert(expr !=
NULL);
5792 assert(expr !=
NULL);
5805 assert(expr !=
NULL);
5817 assert(expr !=
NULL);
5829 assert(expr !=
NULL);
5841 assert(expr !=
NULL);
5853 assert(expr !=
NULL);
5865 assert(monomial !=
NULL);
5867 return monomial->
coef;
5875 assert(monomial !=
NULL);
5885 assert(monomial !=
NULL);
5895 assert(monomial !=
NULL);
5905 assert(expr !=
NULL);
5916 assert(expr !=
NULL);
5927 assert(expr !=
NULL);
5945 assert(blkmem !=
NULL);
5946 assert(expr !=
NULL);
5954 opdata.intval = va_arg( ap,
int );
5957 assert( opdata.intval >= 0 );
5986 assert(children[0] !=
NULL);
5987 assert(children[1] !=
NULL);
6012 assert(children[0] !=
NULL);
6027 assert(children[0] !=
NULL);
6041 assert(children[0] !=
NULL);
6042 opdata.intval = va_arg( ap,
int);
6060 nchildren = va_arg( ap,
int );
6061 assert(nchildren >= 0);
6064 if( nchildren == 0 )
6072 childrenarg = va_arg( ap,
SCIP_EXPR** );
6073 assert(childrenarg !=
NULL);
6087 SCIPerrorMessage(
"cannot create complex expression linear, quadratic, polynomial, or user with SCIPexprCreate\n");
6106 assert(blkmem !=
NULL);
6107 assert(targetexpr !=
NULL);
6108 assert(sourceexpr !=
NULL);
6120 for( i = 0; i < sourceexpr->
nchildren; ++i )
6127 assert((*targetexpr)->children ==
NULL);
6133 if( exprOpTable[sourceexpr->
op].copydata !=
NULL )
6135 SCIP_CALL( exprOpTable[sourceexpr->
op].copydata(blkmem, sourceexpr->
nchildren, sourceexpr->
data, &(*targetexpr)->data) );
6147 assert(blkmem !=
NULL);
6148 assert(expr !=
NULL);
6149 assert(*expr !=
NULL);
6152 if( exprOpTable[(*expr)->op].freedata !=
NULL )
6154 exprOpTable[(*expr)->op].freedata(blkmem, (*expr)->nchildren, (*expr)->data);
6157 if( (*expr)->nchildren )
6161 assert( (*expr)->children !=
NULL );
6163 for( i = 0; i < (*expr)->nchildren; ++i )
6166 assert((*expr)->children[i] ==
NULL);
6173 assert( (*expr)->children ==
NULL );
6185 assert(blkmem !=
NULL);
6186 assert(expr !=
NULL);
6187 assert(*expr !=
NULL);
6190 if( exprOpTable[(*expr)->op].freedata !=
NULL )
6192 exprOpTable[(*expr)->op].freedata(blkmem, (*expr)->nchildren, (*expr)->data);
6215 assert(blkmem !=
NULL);
6216 assert(expr !=
NULL);
6232 if( term1 ==
NULL && term2 ==
NULL )
6245 assert(data !=
NULL);
6248 for( i = 0; i <= term1->
nchildren; ++i )
6261 assert(data !=
NULL);
6264 for( i = 0; i <= term2->
nchildren; ++i )
6270 if( term1 ==
NULL || term2 ==
NULL )
6277 if( constant != 0.0 || coef1 != 1.0 )
6281 assert(coef1 == 1.0);
6295 assert(constant == 0.0);
6296 assert(coef1 == 1.0);
6306 assert(coef1 == 1.0);
6307 assert(coef2 == 1.0);
6323 assert(coef2 == 1.0);
6334 assert(coef1 == 1.0);
6349 children[0] = term1;
6350 children[1] = term2;
6370 assert(blkmem !=
NULL);
6371 assert(expr !=
NULL);
6372 assert(term !=
NULL);
6403 assert(data !=
NULL);
6426 for( i = 0; i < data->nquadelems; ++i )
6442 for( i = 0; i < data->nmonomials; ++i )
6474 assert(nchildren >= 0);
6475 assert(children !=
NULL || nchildren == 0);
6476 assert(coefs !=
NULL || nchildren == 0);
6483 childrencopy =
NULL;
6488 data[nchildren] = constant;
6490 opdata.data = (
void*)data;
6509 assert(blkmem !=
NULL);
6510 assert(expr !=
NULL);
6512 assert(nchildren >= 0);
6513 assert(coefs !=
NULL || nchildren == 0);
6514 assert(children !=
NULL || nchildren == 0);
6517 assert(data !=
NULL);
6520 if( nchildren == 0 )
6535 expr->
data.data = (
void*)data;
6558 assert(nchildren >= 0);
6559 assert(children !=
NULL || nchildren == 0);
6560 assert(quadelems !=
NULL || nquadelems == 0);
6567 childrencopy =
NULL;
6571 opdata.data = (
void*)data;
6583 assert(expr !=
NULL);
6606 assert(nchildren >= 0);
6607 assert(children !=
NULL || nchildren == 0);
6608 assert(monomials !=
NULL || nmonomials == 0);
6615 childrencopy =
NULL;
6618 opdata.data = (
void*)data;
6634 assert(blkmem !=
NULL);
6635 assert(expr !=
NULL);
6637 assert(monomials !=
NULL || nmonomials == 0);
6639 if( nmonomials == 0 )
6653 assert(expr !=
NULL);
6667 assert(expr !=
NULL);
6682 assert(blkmem !=
NULL);
6683 assert(factor !=
NULL);
6684 assert(expr !=
NULL);
6705 assert(blkmem !=
NULL);
6706 assert(expr !=
NULL);
6709 assert(factor !=
NULL);
6712 assert(expr != factor);
6715 if( childmap ==
NULL )
6719 for( i = 0; i < factor->
nchildren; ++i )
6725 for( i = 0; i < factor->
nchildren; ++i )
6727 assert(childmap[i] >= 0);
6750 assert(blkmem !=
NULL);
6751 assert(expr !=
NULL);
6771 assert(expr !=
NULL);
6787 assert(monomial1 !=
NULL);
6788 assert(monomial2 !=
NULL);
6799 for( i = 0; i < monomial1->
nfactors; ++i )
6815 assert(monomial !=
NULL);
6817 monomial->
coef = newcoef;
6829 assert(monomial !=
NULL);
6830 assert(nfactors >= 0);
6831 assert(childidxs !=
NULL || nfactors == 0);
6832 assert(exponents !=
NULL || nfactors == 0);
6838 assert(monomial->
nfactors + nfactors <= monomial->factorssize);
6857 assert(monomial !=
NULL);
6858 assert(factor !=
NULL);
6860 if( factor->
coef == 0.0 )
6863 monomial->
coef = 0.0;
6869 if( childmap !=
NULL )
6872 for( i = monomial->
nfactors - factor->
nfactors; i < monomial->nfactors; ++i )
6892 assert(monomial !=
NULL);
6900 if( monomial->
coef != 0.0 )
6901 monomial->
coef = 1.0;
6907 for( i = 0; i < monomial->
nfactors; ++i )
6923 assert(monomial !=
NULL);
6932 while( i + offset < monomial->nfactors )
6937 assert(monomial->
childidxs[i+offset] >= 0);
6969 for( ; i < monomial->
nfactors; ++i )
6976 monomial->
coef = 1.0;
6977 else if(
EPSEQ(monomial->
coef, -1.0, eps) )
6978 monomial->
coef = -1.0;
6986 assert(expr !=
NULL);
7003 assert(blkmem !=
NULL);
7004 assert(monomial !=
NULL);
7008 (*monomial)->coef = coef;
7009 (*monomial)->nfactors = nfactors;
7010 (*monomial)->factorssize = nfactors;
7011 (*monomial)->sorted = (nfactors <= 1);
7015 if( childidxs !=
NULL )
7024 for( i = 0; i < nfactors; ++i )
7025 (*monomial)->childidxs[i] = i;
7028 if( exponents !=
NULL )
7037 for( i = 0; i < nfactors; ++i )
7038 (*monomial)->exponents[i] = 1.0;
7043 (*monomial)->childidxs =
NULL;
7044 (*monomial)->exponents =
NULL;
7056 assert(blkmem !=
NULL);
7057 assert( monomial !=
NULL);
7058 assert(*monomial !=
NULL);
7060 if( (*monomial)->factorssize > 0 )
7062 assert((*monomial)->childidxs !=
NULL);
7063 assert((*monomial)->exponents !=
NULL);
7068 assert((*monomial)->childidxs ==
NULL);
7069 assert((*monomial)->exponents ==
NULL);
7079 assert(monomial !=
NULL);
7101 assert(monomial !=
NULL);
7133 assert(blkmem !=
NULL);
7134 assert(expr !=
NULL);
7138 assert(curv !=
NULL);
7139 assert(copydata !=
NULL || data ==
NULL);
7140 assert(freedata !=
NULL || data ==
NULL);
7146 userexprdata->eval =
eval;
7147 userexprdata->inteval = inteval;
7148 userexprdata->curv = curv;
7149 userexprdata->prop = prop;
7150 userexprdata->estimate = estimate;
7151 userexprdata->copydata = copydata;
7152 userexprdata->freedata = freedata;
7153 userexprdata->print = print;
7155 opdata.data = (
void*) userexprdata;
7157 if( nchildren == 0 )
7162 assert(children !=
NULL);
7178 assert(expr !=
NULL);
7199 assert(expr !=
NULL);
7200 assert(maxdegree !=
NULL);
7222 *maxdegree =
MAX(child1, child2);
7234 *maxdegree = child1 + child2;
7257 *maxdegree = 2 * child1;
7295 if( expr->
data.dbl == 0.0 )
7297 else if( expr->
data.dbl > 0.0 && (
int)expr->
data.dbl == expr->
data.dbl )
7298 *maxdegree = child1 * (int)expr->
data.dbl;
7312 if( child1 == 0 || expr->
data.intval == 0 )
7326 *maxdegree = child1 * expr->
data.intval;
7385 if( child1 > *maxdegree )
7386 *maxdegree = child1;
7405 *maxdegree += child1;
7424 for( childidx = 0; childidx < expr->
nchildren; ++childidx )
7438 while( quadidx < quadraticdata->nquadelems && quadraticdata->
quadelems[quadidx].
idx1 == childidx )
7443 if( 2*child1 > *maxdegree )
7444 *maxdegree = 2*child1;
7455 if( child1 + child2 > *maxdegree )
7456 *maxdegree = child1 + child2;
7480 monomialdata = polynomialdata->
monomials[i];
7481 assert(monomialdata !=
NULL);
7485 for( j = 0; j < monomialdata->
nfactors; ++j )
7497 monomialdegree += child1 * (int)monomialdata->
exponents[j];
7500 if( monomialdegree > *maxdegree )
7501 *maxdegree = monomialdegree;
7523 assert(expr !=
NULL);
7524 assert(varsusage !=
NULL);
7528 ++varsusage[expr->
data.intval];
7545 assert(expr1 !=
NULL);
7546 assert(expr2 !=
NULL);
7548 if( expr1 == expr2 )
7551 if( expr1->
op != expr2->
op )
7558 return expr1->
data.intval == expr2->
data.intval;
7628 for( i = 0; i < expr1->
nchildren + 1; ++i )
7629 if( !
EPSEQ(data1[i], data2[i], eps) )
7759 int maxexpansionexponent,
7766 assert(blkmem !=
NULL);
7767 assert(expr !=
NULL);
7786 if( nlinvars !=
NULL )
7814 assert(expr !=
NULL);
7818 assert( exprOpTable[expr->
op].eval !=
NULL );
7853 assert( exprOpTable[expr->
op].eval !=
NULL );
7857 if( staticbuf != buf )
7875 assert(expr !=
NULL);
7879 assert( exprOpTable[expr->
op].inteval !=
NULL );
7915 assert( exprOpTable[expr->
op].inteval !=
NULL );
7919 if( staticbuf != buf )
7938 assert(expr !=
NULL);
7943 assert(exprdata->eval !=
NULL);
7962 assert(expr !=
NULL);
7968 if( exprdata->inteval ==
NULL )
7999 assert(expr !=
NULL);
8000 assert(curv !=
NULL);
8001 assert(bounds !=
NULL);
8011 childbounds = childboundsbuf;
8012 childcurv = childcurvbuf;
8020 if( childbounds[i].inf == childbounds[i].sup )
8025 assert(exprOpTable[expr->
op].curv !=
NULL);
8026 assert(exprOpTable[expr->
op].inteval !=
NULL);
8029 SCIP_CALL( exprOpTable[expr->
op].inteval(infinity, expr->
data, expr->
nchildren, childbounds, varbounds, param, bounds) );
8032 if( childboundsbuf != childbounds )
8055 assert(expr !=
NULL);
8062 if( exprdata->estimate !=
NULL )
8064 SCIP_CALL( exprdata->estimate(infinity, exprdata->
userdata, expr->
nchildren, argvals, argbounds, overestimate, coeffs, constant, success ) );
8088 assert(blkmem !=
NULL);
8089 assert(expr !=
NULL);
8090 assert(substexprs !=
NULL);
8099 assert(varidx >= 0);
8100 if( substexprs[varidx] !=
NULL )
8125 assert(expr !=
NULL);
8126 assert(newindices !=
NULL);
8130 expr->
data.intval = newindices[expr->
data.intval];
8131 assert(expr->
data.intval >= 0);
8146 assert(expr !=
NULL);
8147 assert(newindices !=
NULL);
8151 expr->
data.intval = newindices[expr->
data.intval];
8152 assert(expr->
data.intval >= 0);
8164 const char** varnames,
8165 const char** paramnames,
8169 assert( expr !=
NULL );
8178 if( varnames !=
NULL )
8180 assert(varnames[expr->
data.intval] !=
NULL);
8190 if( paramnames !=
NULL )
8192 assert(paramnames[expr->
data.intval] !=
NULL);
8199 if( paramvals !=
NULL )
8206 if (expr->
data.dbl < 0.0 )
8334 if( constant != 0.0 )
8355 assert(quadraticdata !=
NULL);
8359 if( quadraticdata->
constant != 0.0 )
8365 if( quadraticdata->
lincoefs[i] == 0.0 )
8371 for( i = 0; i < quadraticdata->
nquadelems; ++i )
8400 assert(polynomialdata !=
NULL);
8407 for( i = 0; i < polynomialdata->
nmonomials; ++i )
8409 monomialdata = polynomialdata->
monomials[i];
8412 for( j = 0; j < monomialdata->
nfactors; ++j )
8421 else if( monomialdata->
exponents[j] != 1.0 )
8438 assert(exprdata !=
NULL);
8440 if( exprdata->print !=
NULL )
8442 exprdata->print(exprdata->
userdata, messagehdlr, file);
8477 const char* lastchar,
8485 assert(blkmem !=
NULL);
8486 assert(expr !=
NULL);
8487 assert(str !=
NULL);
8488 assert(lastchar !=
NULL);
8489 assert(nvars !=
NULL);
8490 assert(varnames !=
NULL);
8499 retcode =
exprParse(blkmem, messagehdlr, expr, str, (
int) (lastchar - str + 1), lastchar, nvars, &varnames, vartable, 0);
8518 #undef SCIPexprtreeGetRoot 8519 #undef SCIPexprtreeGetNVars 8520 #undef SCIPexprtreeGetNParams 8521 #undef SCIPexprtreeGetParamVals 8522 #undef SCIPexprtreeSetParamVal 8523 #undef SCIPexprtreeGetInterpreterData 8524 #undef SCIPexprtreeSetInterpreterData 8525 #undef SCIPexprtreeFreeInterpreterData 8526 #undef SCIPexprtreeHasParam 8527 #undef SCIPexprtreeGetMaxDegree 8528 #undef SCIPexprtreeEval 8529 #undef SCIPexprtreeEvalInt 8530 #undef SCIPexprtreePrint 8537 assert(tree !=
NULL);
8547 assert(tree !=
NULL);
8557 assert(tree !=
NULL);
8567 assert(tree !=
NULL);
8579 assert(tree !=
NULL);
8580 assert(paramidx >= 0);
8581 assert(paramidx < tree->nparams);
8584 tree->
params[paramidx] = paramval;
8592 assert(tree !=
NULL);
8603 assert(tree !=
NULL);
8604 assert(interpreterdata !=
NULL);
8629 assert(tree !=
NULL);
8646 assert(tree !=
NULL);
8660 assert(tree !=
NULL);
8661 assert(varvals !=
NULL || tree->
nvars == 0);
8662 assert(val !=
NULL);
8677 assert(tree !=
NULL);
8678 assert(varvals !=
NULL || tree->
nvars == 0);
8679 assert(val !=
NULL);
8691 const char** varnames,
8692 const char** paramnames
8695 assert(tree !=
NULL);
8711 assert(blkmem !=
NULL);
8712 assert(tree !=
NULL);
8716 (*tree)->blkmem = blkmem;
8717 (*tree)->root = root;
8718 (*tree)->nvars = nvars;
8719 (*tree)->vars =
NULL;
8720 (*tree)->nparams = nparams;
8721 (*tree)->interpreterdata =
NULL;
8723 if( params !=
NULL )
8725 assert(nparams > 0);
8728 else if( nparams > 0 )
8735 assert(nparams == 0);
8736 (*tree)->params =
NULL;
8749 assert(blkmem !=
NULL);
8750 assert(targettree !=
NULL);
8751 assert(sourcetree !=
NULL);
8757 (*targettree)->blkmem = blkmem;
8758 (*targettree)->interpreterdata =
NULL;
8763 assert(sourcetree->
nvars > 0);
8771 assert(sourcetree->
nparams > 0);
8787 assert( tree !=
NULL);
8788 assert(*tree !=
NULL);
8792 if( (*tree)->root !=
NULL )
8795 assert((*tree)->root ==
NULL);
8813 assert(tree !=
NULL);
8814 assert(paramvals !=
NULL || nparams == 0);
8843 assert(tree !=
NULL);
8844 assert(varsusage !=
NULL);
8846 if( tree->
nvars == 0 )
8861 int maxexpansionexponent,
8875 assert(tree !=
NULL);
8893 if( nlinvars !=
NULL && testval_before == testval_before )
8894 for( i = 0; i < *nlinvars; ++i )
8895 testval_after += lincoefs[i] * testx[linidxs[i]];
8896 assert(testval_before != testval_before || testval_before == testval_after ||
EPSZ(
SCIPrelDiff(testval_before, testval_after), eps));
8901 if( nlinvars !=
NULL && *nlinvars > 0 )
8917 assert(tree !=
NULL);
8944 assert(tree !=
NULL);
8949 if( bounds !=
NULL )
8950 *bounds = exprbounds;
8965 assert(tree !=
NULL);
8973 assert(varidx >= 0);
8974 if( substexprs[varidx] !=
NULL )
9002 #define QUADELEMS_ISBETTER(a, b) ( ((a).idx1 < (b).idx1) || ((a).idx1 == (b).idx1 && (a).idx2 < (b).idx2) ) 9005 #define QUADELEMS_SWAP(x,y) \ 9007 SCIP_QUADELEM temp = x; \ 9020 assert(start <= end);
9023 while( end - start >= 25 )
9031 mid = (start+end)/2;
9032 pivotkey = elems[mid];
9052 assert(hi == lo-1 || hi == start);
9069 if( hi - start <= end - lo )
9090 if( end - start >= 1 )
9092 static const int incs[3] = {1, 5, 19};
9095 for( k = 2; k >= 0; --k )
9100 for( h = incs[k], i = h + start; i <= end; ++i )
9108 elems[j] = elems[j-h];
9129 if( nquadelems == 0 )
9135 for( i = 0; i < nquadelems; ++i )
9136 assert(quadelems[i].idx1 <= quadelems[i].idx2);
9160 assert(quadelems !=
NULL || nquadelems == 0);
9161 assert(idx1 <= idx2);
9163 if( nquadelems == 0 )
9171 right = nquadelems - 1;
9172 while( left <= right )
9176 middle = (left+right)/2;
9177 assert(0 <= middle && middle < nquadelems);
9179 if( idx1 < quadelems[middle].idx1 || (idx1 == quadelems[middle].idx1 && idx2 < quadelems[middle].idx2) )
9181 else if( quadelems[middle].idx1 < idx1 || (quadelems[middle].idx1 == idx1 && quadelems[middle].idx2 < idx2) )
9190 assert(left == right+1);
9210 assert(quadelems !=
NULL);
9211 assert(nquadelemsnew !=
NULL);
9212 assert(nquadelems >= 0);
9216 while( next < nquadelems )
9220 (quadelems[i].idx1 == quadelems[next].idx1 && quadelems[i].idx2 == quadelems[next].idx2));
9223 if( quadelems[next].coef == 0.0 )
9231 quadelems[i-1].idx1 == quadelems[next].idx1 &&
9232 quadelems[i-1].idx2 == quadelems[next].idx2 )
9234 quadelems[i-1].
coef += quadelems[next].
coef;
9240 quadelems[i] = quadelems[next];
9244 assert(next == nquadelems);
9263 assert(blkmem !=
NULL);
9264 assert(node !=
NULL);
9265 assert(node->
depth >= 0);
9266 assert(node->
pos >= 0);
9267 assert(parent !=
NULL);
9268 assert(parent->
depth >= 0);
9269 assert(parent->
pos >= 0);
9290 assert(node !=
NULL);
9296 for( i = 1; i < node->
nparents; ++i )
9297 assert(ptrcomp((
void*)node->
parents[i-1], (
void*)node->
parents[i]) <= 0);
9321 assert(exprgraph !=
NULL);
9322 assert(node !=
NULL);
9323 assert(*node !=
NULL);
9324 assert((*node)->depth >= 0);
9325 assert((*node)->pos >= 0);
9326 assert((*node)->nparents > 0);
9327 assert(parent !=
NULL);
9328 assert(parent->
depth >= 0);
9329 assert(parent->
pos >= 0);
9330 assert(parent->
depth > (*node)->depth);
9336 assert(pos < (*node)->nparents);
9337 assert((*node)->parents[pos] == parent);
9341 if( pos < (*node)->nparents-1 )
9343 (*node)->parents[pos] = (*node)->parents[(*node)->nparents-1];
9344 (*node)->parentssorted = ((*node)->nparents <= 2);
9346 --(*node)->nparents;
9349 node_ = (*node)->
nuses > 0 ? *node :
NULL;
9370 assert(node !=
NULL);
9371 assert(parent !=
NULL);
9407 assert(blkmem !=
NULL);
9408 assert(node !=
NULL);
9409 assert(node->
depth > 0);
9410 assert(node->
pos >= 0);
9412 assert(exprs !=
NULL || nexprs == 0);
9420 for( i = 0; i < nexprs; ++i )
9422 assert(exprs[i]->depth >= 0);
9423 assert(exprs[i]->pos >= 0);
9424 assert(exprs[i]->depth < node->depth);
9427 existsalready =
FALSE;
9429 for( j = 0; j < orignchildren; ++j )
9433 existsalready =
TRUE;
9437 if( !existsalready )
9442 if( childmap !=
NULL )
9448 if( childmap !=
NULL )
9468 data[node->
nchildren] = data[orignchildren];
9469 for( i = orignchildren; i < node->
nchildren; ++i )
9471 node->
data.data = (
void*)data;
9504 assert(exprgraph !=
NULL);
9505 assert(node !=
NULL);
9506 assert(oldchild !=
NULL);
9507 assert(*oldchild !=
NULL);
9508 assert(newchild !=
NULL);
9510 if( *oldchild == newchild )
9513 SCIPdebugMessage(
"replace child %p in node %p by %p\n", (
void*)*oldchild, (
void*)node, (
void*)newchild);
9516 for( i = 0; i < node->nchildren; ++i )
9518 if( node->children[i] == *oldchild )
9527 node->children[i] = newchild;
9533 assert(i < node->nchildren);
9535 node->simplified =
FALSE;
9547 assert(elem1 !=
NULL);
9548 assert(elem2 !=
NULL);
9568 assert(exprgraph !=
NULL);
9590 assert(exprgraph !=
NULL);
9591 assert(node !=
NULL);
9593 assert(node->
depth == 0);
9594 assert(node->
pos >= 0);
9595 assert(pos !=
NULL);
9604 while( left <= right )
9606 middle = (left+right)/2;
9607 assert(0 <= middle && middle < exprgraph->nconsts);
9619 assert(left == right+1 || *pos >= 0);
9620 if( left == right+1 )
9627 while( exprgraph->
constnodes[*pos] != node && *pos < exprgraph->nconsts-1 && exprgraph->
constnodes[*pos+1]->
data.dbl == node->
data.dbl )
9642 assert(blkmem !=
NULL);
9643 assert(node !=
NULL);
9649 (*node)->data = opdata;
9652 (*node)->depth = -1;
9656 (*node)->parentssorted =
TRUE;
9672 (*node)->enabled =
TRUE;
9683 const char** varnames,
9689 assert(node !=
NULL);
9694 if( varnames !=
NULL )
9711 if( printchildrenbounds )
9714 if( printchildrenbounds )
9719 if( printchildrenbounds )
9722 if( printchildrenbounds )
9727 if( printchildrenbounds )
9730 if( printchildrenbounds )
9735 if( printchildrenbounds )
9738 if( printchildrenbounds )
9743 if( printchildrenbounds )
9749 if( printchildrenbounds )
9755 if( printchildrenbounds )
9764 if( printchildrenbounds )
9782 if( printchildrenbounds )
9792 if( printchildrenbounds )
9804 if( printchildrenbounds )
9821 if( constant != 0.0 || node->
nchildren == 0 )
9833 if( printchildrenbounds )
9845 assert(quadraticdata !=
NULL);
9847 if( quadraticdata->
constant != 0.0 )
9853 if( quadraticdata->
lincoefs[i] == 0.0 )
9856 if( printchildrenbounds )
9860 for( i = 0; i < quadraticdata->
nquadelems; ++i )
9869 if( printchildrenbounds )
9876 if( printchildrenbounds )
9891 assert(polynomialdata !=
NULL);
9898 for( i = 0; i < polynomialdata->
nmonomials; ++i )
9900 monomialdata = polynomialdata->
monomials[i];
9901 if( monomialdata->
coef == 1.0 )
9903 else if( monomialdata->
coef == -1.0 )
9908 for( j = 0; j < monomialdata->
nfactors; ++j )
9911 if( printchildrenbounds )
9915 else if( monomialdata->
exponents[j] != 1.0 )
9940 const char** varnames
9946 assert(exprgraph !=
NULL);
9947 assert(node !=
NULL);
9948 assert(file !=
NULL);
9951 SCIPmessageFPrintInfo(messagehdlr, file,
"n%d_%d [fillcolor=\"%g,%g,%g\", label=\"", node->
depth, node->
pos, color, color, color);
9986 assert(node !=
NULL);
10006 assert(exprOpTable[node->
op].eval !=
NULL);
10011 if( staticbuf != buf )
10028 assert(node !=
NULL);
10054 assert(node !=
NULL);
10055 assert(node->
depth >= 1);
10056 assert(node->
pos >= 0);
10072 childbounds = childboundsstatic;
10086 assert( exprOpTable[node->
op].inteval !=
NULL );
10091 if( childbounds != childboundsstatic )
10108 for( i = 0; i < node->
nparents; ++i )
10111 node->
bounds = newbounds;
10116 for( i = 0; i < node->
nparents; ++i )
10119 node->
bounds = newbounds;
10147 assert(exprgraph !=
NULL);
10148 assert(node !=
NULL);
10149 assert(node->
depth >= 0);
10150 assert(node->
pos >= 0);
10151 assert(minstrength >= 0.0);
10152 assert(cutoff !=
NULL);
10166 minstrength = -1.0;
10304 if( node->
data.dbl != 0.0 )
10468 int minlinactivityinf;
10469 int maxlinactivityinf;
10477 minlinactivity = 0.0;
10478 maxlinactivity = 0.0;
10479 minlinactivityinf = 0;
10480 maxlinactivityinf = 0;
10494 ++minlinactivityinf;
10510 ++maxlinactivityinf;
10519 maxlinactivity = -maxlinactivity;
10522 if( (minlinactivityinf >= 2 || node->
bounds.
sup >= infinity) &&
10523 ( maxlinactivityinf >= 2 || node->
bounds.
inf <= -infinity)
10530 for( i = 0; i < node->
nchildren && !*cutoff; ++i )
10542 assert(minlinactivityinf == 1);
10545 else if( minlinactivityinf == 0 )
10559 assert(maxlinactivityinf == 1);
10562 else if( maxlinactivityinf == 0 )
10589 for( i = 0; i < node->
nchildren && !*cutoff; ++i )
10600 if( childbounds.
inf <= 0.0 && childbounds.
sup >= 0.0 )
10623 int minlinactivityinf;
10624 int maxlinactivityinf;
10634 minlinactivity = coefs[node->
nchildren];
10635 maxlinactivity = -coefs[node->
nchildren];
10636 minlinactivityinf = 0;
10637 maxlinactivityinf = 0;
10649 if( coefs[i] >= 0.0 )
10653 ++minlinactivityinf;
10665 ++minlinactivityinf;
10680 if( coefs[i] >= 0.0 )
10684 ++maxlinactivityinf;
10696 ++maxlinactivityinf;
10711 if( (minlinactivityinf >= 2 || node->
bounds.
sup >= infinity) &&
10712 (maxlinactivityinf >= 2 || node->
bounds.
inf <= -infinity)
10719 for( i = 0; i < node->
nchildren && !*cutoff; ++i )
10723 if( coefs[i] == 0.0 )
10728 if( coefs[i] >= 0.0 )
10744 if( coefs[i] > 0.0 )
10755 assert(minlinactivityinf == 1);
10758 else if( minlinactivityinf == 0 )
10772 assert(maxlinactivityinf == 1);
10773 childbounds.
inf = (node->
bounds.
inf - maxlinactivity)/coefs[i];
10775 else if( maxlinactivityinf == 0 )
10777 childbounds.
inf = (node->
bounds.
inf - maxlinactivity + ac.
sup)/coefs[i];
10794 assert(minlinactivityinf == 1);
10797 else if( minlinactivityinf == 0 )
10812 assert(maxlinactivityinf == 1);
10815 else if( maxlinactivityinf == 0 )
10852 if( nquadelems > 10 )
10858 if( node->
nchildren == 2 && nquadelems > 0 )
10868 for( i = 0; i < nquadelems; ++i )
10869 if( quadelems[i].idx1 == 0 && quadelems[i].idx2 == 0 )
10870 ax += quadelems[i].
coef;
10871 else if( quadelems[i].idx1 == 1 && quadelems[i].idx2 == 1 )
10872 ay += quadelems[i].
coef;
10874 axy += quadelems[i].
coef;
10881 infinity, &childbounds, ax, ay, axy,
10882 lincoefs !=
NULL ? lincoefs[0] : 0.0, lincoefs !=
NULL ? lincoefs[1] : 0.0,
10887 SCIPdebugMessage(
"%g x^2 + %g y^2 + %g xy + %g x + %g y in [%g,%g], x = [%g,%g], y = [%g,%g] -> x in [%g,%g], cutoff = %d\n",
10888 ax, ay, axy, lincoefs !=
NULL ? lincoefs[0] : 0.0, lincoefs !=
NULL ? lincoefs[1] : 0.0,
10903 infinity, &childbounds, ay, ax, axy,
10904 lincoefs !=
NULL ? lincoefs[1] : 0.0, lincoefs !=
NULL ? lincoefs[0] : 0.0,
10910 SCIPdebugMessage(
"%g x^2 + %g y^2 + %g xy + %g x + %g y in [%g,%g], x = [%g,%g], y = [%g,%g] -> y in [%g,%g], cutoff = %d\n",
10911 ax, ay, axy, lincoefs !=
NULL ? lincoefs[0] : 0.0, lincoefs !=
NULL ? lincoefs[1] : 0.0,
10927 for( i = 0; i < node->
nchildren && !*cutoff; ++i )
10937 if( lincoefs !=
NULL )
10939 if( i != k && lincoefs[k] != 0.0 )
10945 for( k = 0; k < nquadelems; ++k )
10947 if( quadelems[k].idx1 == i && quadelems[k].idx2 == i )
10951 else if( quadelems[k].idx1 == i )
10956 else if( quadelems[k].idx2 == i )
10961 else if( quadelems[k].idx1 == quadelems[k].idx2 )
11021 for( i = 0; i < node->
nchildren && !*cutoff; ++i )
11026 for( j = 0; j < nmonomials; ++j )
11028 monomial = monomials[j];
11029 for( k = 0; k < monomial->
nfactors; ++k )
11035 else if( n == 2*monomial->
exponents[k] )
11037 else if( 2*n == monomial->
exponents[k] )
11050 if( nexpishalfn > nexpisdoublen )
11057 for( j = 0; j < nmonomials; ++j )
11059 monomial = monomials[j];
11062 for( k = 0; k < monomial->
nfactors; ++k )
11066 assert(abc_flag ==
'c');
11075 else if( monomial->
exponents[k] == 2*n )
11104 else if( monomial->
exponents[k] == 2*n )
11132 if( abc_flag ==
'a' )
11136 if( a.
inf >= infinity || a.
sup <= -infinity )
11139 else if( abc_flag ==
'b' )
11143 if( b.
inf >= infinity || b.
sup <= -infinity )
11150 if( c.
inf >= infinity || c.
sup <= -infinity )
11156 if( j < nmonomials )
11162 SCIPdebugMessage(
"solve [%10g,%10g]c%d^%g + [%10g,%10g]c%d^%g = [%10g,%10g]",
11201 if( exprdata->prop ==
NULL )
11222 for( c = 0; !*cutoff && c < node->
nchildren; ++c )
11253 assert(exprgraph !=
NULL);
11254 assert(node !=
NULL);
11262 foundduplicates =
FALSE;
11269 for( j = i+1; j < node->
nchildren; ++j )
11284 foundduplicates =
TRUE;
11290 if( foundduplicates )
11310 assert(blkmem !=
NULL);
11311 assert(node !=
NULL);
11321 while( lastnonnull >= 0 && node->
children[lastnonnull] ==
NULL )
11323 for( i = 0; i <= lastnonnull; ++i )
11335 childmap[lastnonnull] = i;
11339 while( lastnonnull >= 0 && node->
children[lastnonnull] ==
NULL )
11342 assert(i > lastnonnull);
11345 if( lastnonnull < node->nchildren-1 )
11351 if( lastnonnull >= 0 )
11375 int maxexpansionexponent,
11390 assert(exprgraph !=
NULL);
11391 assert(node !=
NULL);
11392 assert(node->
depth > 0);
11393 assert(havechange !=
NULL);
11395 blkmem = exprgraph->
blkmem;
11396 assert(blkmem !=
NULL);
11398 SCIPdebugMessage(
"attempt simplification of node %p (%d,%d)\n", (
void*)node, node->
depth, node->pos);
11401 for( i = 0; i < node->nchildren; ++i )
11404 if( node->nchildren > 0 && i == node->nchildren )
11410 SCIPdebugMessage(
"turn node %p (%d,%d) into constant %g\n", (
void*)node, node->depth, node->pos, node->value);
11415 if( exprOpTable[node->op].freedata !=
NULL )
11416 exprOpTable[node->op].freedata(blkmem, node->nchildren, node->data);
11419 for( i = 0; i < node->nchildren; ++i )
11424 node->nchildren = 0;
11428 node->data.dbl = node->value;
11430 *havechange =
TRUE;
11431 node->simplified =
TRUE;
11447 node->simplified =
TRUE;
11452 assert(polynomialdata !=
NULL);
11454 orignchildren = node->nchildren;
11471 for( i = 0; i < node->nchildren; ++i )
11473 if( node->children[i] ==
NULL )
11489 removechild =
TRUE;
11494 for( j = 0; j < polynomialdata->
nmonomials; ++j )
11498 monomial = polynomialdata->
monomials[j];
11504 assert(factorpos >= 0);
11505 assert(factorpos < monomial->nfactors);
11507 assert(factorpos == 0 || monomial->
childidxs[factorpos-1] != i);
11508 assert(factorpos == monomial->
nfactors-1 || monomial->
childidxs[factorpos+1] != i);
11510 SCIPdebugMessage(
"attempt expanding child %d at monomial %d factor %d\n", i, j, factorpos);
11512 if( !
EPSISINT(monomial->
exponents[factorpos], 0.0) && node->children[i]->data.dbl < 0.0 )
11515 SCIPmessagePrintWarning(messagehdlr,
"got negative constant %g to the power of a noninteger exponent %g\n", node->children[i]->data.dbl, monomial->
exponents[factorpos]);
11516 removechild =
FALSE;
11520 monomial->
coef *=
pow(node->children[i]->data.dbl, monomial->
exponents[factorpos]);
11523 if( factorpos < monomial->nfactors-1 )
11532 *havechange =
TRUE;
11542 node->children[i] =
NULL;
11550 for( i = 0; i < node->nchildren; ++i )
11552 if( node->children[i] ==
NULL )
11570 removechild =
TRUE;
11579 while( j < polynomialdata->nmonomials )
11584 monomial = polynomialdata->
monomials[j];
11594 assert(factorpos >= 0);
11595 assert(factorpos < monomial->nfactors);
11597 assert(factorpos == 0 || monomial->
childidxs[factorpos-1] != i);
11598 assert(factorpos == monomial->
nfactors-1 || monomial->
childidxs[factorpos+1] != i);
11600 SCIPdebugMessage(
"attempt expanding child %d at monomial %d factor %d\n", i, j, factorpos);
11607 removechild =
FALSE;
11611 *havechange =
TRUE;
11623 node->children[i] =
NULL;
11635 for( i = 0; i < polynomialdata->
nmonomials; ++i )
11637 monomial = polynomialdata->
monomials[i];
11638 assert(monomial !=
NULL);
11640 for( j = 0; j < monomial->
nfactors; ++j )
11643 assert(monomial->
childidxs[j] < node->nchildren);
11649 for( i = 0; i < node->nchildren; ++i )
11650 if( node->children[i] !=
NULL && !childinuse[i] )
11653 node->children[i] =
NULL;
11662 if( node->nchildren == 0 )
11673 node->data.dbl = val;
11680 *havechange |= (node->nchildren < orignchildren);
11682 node->simplified =
TRUE;
11707 assert(exprgraph !=
NULL);
11708 assert(node !=
NULL);
11709 assert(expr !=
NULL);
11710 assert(nexprvars !=
NULL);
11711 assert(*nexprvars >= 0);
11712 assert(varidx !=
NULL);
11731 assert(node->
data.intval >= 0);
11732 assert(node->
data.intval < exprgraph->
nvars);
11733 assert(varidx[node->
data.intval] >= -1);
11734 assert(varidx[node->
data.intval] < *nexprvars);
11735 if( varidx[node->
data.intval] == -1 )
11737 varidx[node->
data.intval] = *nexprvars;
11755 assert(childexprs !=
NULL);
11763 assert(childexprs !=
NULL);
11776 assert(childexprs !=
NULL);
11794 assert(childexprs !=
NULL);
11819 assert(quaddata !=
NULL);
11831 assert(polynomialdata !=
NULL);
11845 assert(exprdata !=
NULL);
11847 if( exprdata->copydata !=
NULL )
11855 userdata, exprdata->
evalcapability, exprdata->eval, exprdata->inteval, exprdata->curv, exprdata->prop, exprdata->estimate, exprdata->copydata, exprdata->freedata, exprdata->print) );
11885 assert(node !=
NULL);
11886 assert(varsusage !=
NULL);
11890 ++varsusage[node->
data.intval];
11915 assert(node !=
NULL);
11916 assert(compnr !=
NULL);
11917 assert(*compnr >= 0);
11918 assert(childcomps !=
NULL);
11919 assert(varcomps !=
NULL);
11928 varidx = node->
data.intval;
11929 assert(varidx >= 0);
11930 assert(varidx < nvars);
11932 if( varcomps[varidx] == -1 )
11935 varcomps[varidx] = *compnr;
11939 if( varcomps[varidx] == *compnr )
11947 for( i = 0; i < nvars; ++i )
11948 if( varcomps[i] == *compnr )
11949 varcomps[i] = varcomps[varidx];
11950 for( i = 0; i < nchildcomps; ++i )
11951 if( childcomps[i] == *compnr )
11952 childcomps[i] = varcomps[varidx];
11953 *compnr = varcomps[varidx];
11970 assert(exprgraph !=
NULL);
11973 if( mindepth <= exprgraph->depth )
11976 olddepth = exprgraph->
depth;
11978 assert(exprgraph->
depth >= mindepth);
11998 assert(exprgraph !=
NULL);
11999 assert(varidx >= 0);
12000 assert(varidx < exprgraph->nvars);
12002 varnode = exprgraph->
varnodes[varidx];
12003 assert(varnode->
data.intval == varidx);
12005 var = exprgraph->
vars[varidx];
12008 if( exprgraph->exprgraphvarremove !=
NULL )
12010 SCIP_CALL( exprgraph->exprgraphvarremove(exprgraph, exprgraph->
userdata, var, varnode) );
12017 if( varidx < exprgraph->nvars-1 )
12020 if( exprgraph->exprgraphvarchgidx !=
NULL )
12025 exprgraph->
vars[varidx] = exprgraph->
vars[exprgraph->
nvars-1];
12031 --exprgraph->
nvars;
12053 assert(exprgraph !=
NULL);
12054 assert(node !=
NULL);
12055 assert(node->
depth >= 0);
12056 assert(newdepth >= 0);
12059 if( node->
depth == newdepth )
12062 SCIPdebugMessage(
"move node %p (%d,%d) to depth %d\n", (
void*)node, node->
depth, node->pos, newdepth);
12066 for( i = 0; i < node->nchildren; ++i )
12067 assert(node->children[i]->depth < newdepth);
12071 for( i = 0; i < node->nparents; ++i )
12073 if( node->parents[i]->depth <= newdepth )
12077 assert(node->parents[i]->depth > newdepth);
12083 assert(exprgraph->
depth > newdepth);
12085 olddepth = node->depth;
12086 oldpos = node->pos;
12090 node->depth = newdepth;
12091 node->pos = exprgraph->
nnodes[newdepth];
12092 exprgraph->
nodes[newdepth][node->pos] = node;
12093 ++exprgraph->
nnodes[newdepth];
12096 if( oldpos < exprgraph->
nnodes[olddepth]-1 )
12098 exprgraph->
nodes[olddepth][oldpos] = exprgraph->
nodes[olddepth][exprgraph->
nnodes[olddepth]-1];
12099 exprgraph->
nodes[olddepth][oldpos]->
pos = oldpos;
12101 --exprgraph->
nnodes[olddepth];
12103 if( node->depth == 0 )
12143 int parentcandssize;
12147 assert(exprgraph !=
NULL);
12148 assert(nchildren > 0);
12149 assert(children !=
NULL);
12150 assert(parent !=
NULL);
12162 parentcandssize = children[0]->
nparents;
12165 for( p = 0; p < children[0]->
nparents; ++p )
12166 if( children[0]->parents[p]->op == op &&
12167 children[0]->parents[p]->nchildren == nchildren &&
12178 parentcands[nparentcands++] = children[0]->
parents[p];
12182 for( i = 1; i < nchildren && nparentcands > 0; ++i )
12185 while( p < nparentcands )
12192 parentcands[p] = parentcands[nparentcands-1];
12200 SCIPdebugMessage(
"check %d parent candidates for expr with operator %d and %d children\n", nparentcands, op, nchildren);
12202 if( nparentcands == 0 )
12233 if( nchildren > 2 )
12234 SCIPsortPtr((
void**)children, ptrcomp, nchildren);
12235 for( p = 0; p < nparentcands; ++p )
12237 assert(parentcands[p]->op == op);
12238 assert(parentcands[p]->nchildren == nchildren);
12240 if( nchildren == 1 )
12242 assert(parentcands[p]->children[0] == children[0]);
12244 *parent = parentcands[p];
12247 else if( nchildren == 2 )
12253 if( (parentcands[p]->children[0] == children[0] && parentcands[p]->children[1] == children[1]) ||
12254 ( parentcands[p]->children[0] == children[1] && parentcands[p]->children[1] == children[0]) )
12256 *parent = parentcands[p];
12265 SCIPsortPtr((
void**)parentcands[p]->children, ptrcomp, nchildren);
12268 for( i = 0; i < nchildren; ++i )
12269 if( children[i] != parentcands[p]->children[i] )
12271 if( i == nchildren )
12274 *parent = parentcands[p];
12287 for( p = 0; p < nparentcands; ++p )
12289 assert(parentcands[p]->op == op);
12290 assert(parentcands[p]->nchildren == 2);
12292 if( parentcands[p]->children[0] == children[0] && parentcands[p]->children[1] == children[1] )
12295 *parent = parentcands[p];
12306 assert(parentcands[0]->op == op);
12307 assert(parentcands[0]->nchildren == 1);
12308 assert(parentcands[0]->children[0] == children[0]);
12309 assert(parentcands[0]->data.intval == opdata.intval);
12312 *parent = parentcands[0];
12320 assert(parentcands[0]->op == op);
12321 assert(parentcands[0]->nchildren == 1);
12322 assert(parentcands[0]->children[0] == children[0]);
12323 assert(parentcands[0]->data.dbl == opdata.dbl);
12326 *parent = parentcands[0];
12339 if( exprchildren !=
NULL )
12340 SCIPsortPtrPtrReal((
void**)children, (
void**)exprchildren, exprcoef, ptrcomp, nchildren);
12343 for( p = 0; p < nparentcands; ++p )
12345 assert(parentcands[p]->op == op);
12346 assert(parentcands[p]->nchildren == nchildren);
12349 assert(exprcoef[nchildren] == candcoef[nchildren]);
12352 SCIPsortPtrReal((
void**)parentcands[p]->children, candcoef, ptrcomp, nchildren);
12355 for( i = 0; i < nchildren; ++i )
12357 if( children[i] != parentcands[p]->children[i] )
12359 if( exprcoef[i] != candcoef[i] )
12362 if( i < nchildren )
12366 *parent = parentcands[p];
12390 for( i = 0; i < nchildren; ++i )
12393 if( exprlincoef !=
NULL )
12394 if( exprchildren !=
NULL )
12395 SCIPsortPtrPtrRealInt((
void**)children, (
void**)exprchildren, exprlincoef, invperm, ptrcomp, nchildren);
12399 if( exprchildren !=
NULL )
12400 SCIPsortPtrPtrInt((
void**)children, (
void**)exprchildren, invperm, ptrcomp, nchildren);
12405 for( i = 0; i < nchildren; ++i )
12406 perm[invperm[i]] = i;
12424 for( p = 0; p < nparentcands; ++p )
12426 assert(parentcands[p]->op == op);
12427 assert(parentcands[p]->nchildren == nchildren);
12435 for( i = 0; i < nchildren; ++i )
12438 if( candlincoef !=
NULL )
12439 SCIPsortPtrRealInt((
void**)parentcands[p]->children, candlincoef, invperm, ptrcomp, parentcands[p]->nchildren);
12441 SCIPsortPtrInt((
void**)parentcands[p]->children, invperm, ptrcomp, nchildren);
12444 for( i = 0; i < nchildren; ++i )
12445 perm[invperm[i]] = i;
12464 for( i = 0; i < nchildren; ++i )
12466 if( children[i] != parentcands[p]->children[i] )
12468 if( (exprlincoef ==
NULL ? 0.0 : exprlincoef[i]) != (candlincoef ==
NULL ? 0.0 : candlincoef[i]) )
12471 if( i < nchildren )
12485 *parent = parentcands[p];
12511 for( i = 0; i < nchildren; ++i )
12514 if( exprchildren !=
NULL )
12515 SCIPsortPtrPtrInt((
void**)children, (
void**)exprchildren, invperm, ptrcomp, nchildren);
12520 for( i = 0; i < nchildren; ++i )
12521 perm[invperm[i]] = i;
12527 for( p = 0; p < nparentcands; ++p )
12529 assert(parentcands[p]->op == op);
12530 assert(parentcands[p]->nchildren == nchildren);
12537 for( i = 0; i < nchildren; ++i )
12540 SCIPsortPtrInt((
void**)parentcands[p]->children, invperm, ptrcomp, nchildren);
12543 for( i = 0; i < nchildren; ++i )
12544 perm[invperm[i]] = i;
12551 for( i = 0; i < nchildren; ++i )
12552 if( children[i] != parentcands[p]->children[i] )
12554 if( i < nchildren )
12564 *parent = parentcands[p];
12614 assert(exprgraph !=
NULL);
12615 assert(expr !=
NULL);
12616 assert(exprnode !=
NULL);
12617 assert(exprnodeisnew !=
NULL);
12625 assert(*exprnode !=
NULL);
12627 assert((*exprnode)->data.intval >= 0);
12628 assert((*exprnode)->data.intval < exprgraph->
nvars);
12629 assert(exprgraph->
vars[(*exprnode)->data.intval] == vars[expr->
data.intval]);
12631 *exprnodeisnew = (*exprnode)->nuses == 0 && (*exprnode)->nparents == 0;
12642 assert(*exprnode !=
NULL);
12644 assert((*exprnode)->data.dbl == expr->
data.dbl);
12646 *exprnodeisnew = (*exprnode)->nuses == 0 && (*exprnode)->nparents == 0;
12655 assert(params !=
NULL);
12658 assert(*exprnode !=
NULL);
12660 assert((*exprnode)->data.dbl == params[expr->
data.intval]);
12662 *exprnodeisnew = (*exprnode)->nuses == 0 && (*exprnode)->nparents == 0;
12674 nochildisnew =
TRUE;
12678 assert(childnodes[i] !=
NULL);
12679 nochildisnew &= !childisnew;
12687 if( *exprnode !=
NULL )
12690 (*exprnode)->enabled =
TRUE;
12691 *exprnodeisnew =
FALSE;
12706 if( exprOpTable[expr->
op].copydata !=
NULL )
12712 opdata = expr->
data;
12717 *exprnodeisnew =
TRUE;
12741 assert(exprgraph !=
NULL);
12742 assert(clearreverseprop !=
NULL);
12743 assert(boundchanged !=
NULL);
12745 *boundchanged =
FALSE;
12746 for( i = 0; i < exprgraph->
nvars; ++i )
12770 for( p = 0; p < node->
nparents; ++p )
12776 *boundchanged =
TRUE;
12779 *clearreverseprop =
TRUE;
12784 for( p = 0; p < node->
nparents; ++p )
12790 *boundchanged =
TRUE;
12813 #undef SCIPexprgraphCaptureNode 12814 #undef SCIPexprgraphIsNodeEnabled 12815 #undef SCIPexprgraphGetNodeNChildren 12816 #undef SCIPexprgraphGetNodeChildren 12817 #undef SCIPexprgraphGetNodeNParents 12818 #undef SCIPexprgraphGetNodeParents 12819 #undef SCIPexprgraphGetNodeDepth 12820 #undef SCIPexprgraphGetNodePosition 12821 #undef SCIPexprgraphGetNodeOperator 12822 #undef SCIPexprgraphGetNodeOperatorIndex 12823 #undef SCIPexprgraphGetNodeOperatorReal 12824 #undef SCIPexprgraphGetNodeVar 12825 #undef SCIPexprgraphGetNodeRealPowerExponent 12826 #undef SCIPexprgraphGetNodeIntPowerExponent 12827 #undef SCIPexprgraphGetNodeSignPowerExponent 12828 #undef SCIPexprgraphGetNodeLinearCoefs 12829 #undef SCIPexprgraphGetNodeLinearConstant 12830 #undef SCIPexprgraphGetNodeQuadraticConstant 12831 #undef SCIPexprgraphGetNodeQuadraticLinearCoefs 12832 #undef SCIPexprgraphGetNodeQuadraticQuadElements 12833 #undef SCIPexprgraphGetNodeQuadraticNQuadElements 12834 #undef SCIPexprgraphGetNodePolynomialMonomials 12835 #undef SCIPexprgraphGetNodePolynomialNMonomials 12836 #undef SCIPexprgraphGetNodePolynomialConstant 12837 #undef SCIPexprgraphGetNodeUserData 12838 #undef SCIPexprgraphHasNodeUserEstimator 12839 #undef SCIPexprgraphGetNodeBounds 12840 #undef SCIPexprgraphGetNodeVal 12841 #undef SCIPexprgraphGetNodeCurvature 12848 assert(node->
nuses >= 0);
12860 assert(node !=
NULL);
12870 assert(node !=
NULL);
12880 assert(node !=
NULL);
12890 assert(node !=
NULL);
12900 assert(node !=
NULL);
12910 assert(node !=
NULL);
12912 return node->
depth;
12920 assert(node !=
NULL);
12930 assert(node !=
NULL);
12940 assert(node !=
NULL);
12943 return node->
data.intval;
12951 assert(node !=
NULL);
12954 return node->
data.dbl;
12963 assert(exprgraph !=
NULL);
12964 assert(node !=
NULL);
12966 assert(node->
data.intval >= 0);
12967 assert(node->
data.intval < exprgraph->
nvars);
12969 return exprgraph->
vars[node->
data.intval];
12977 assert(node !=
NULL);
12980 return node->
data.dbl;
12988 assert(node !=
NULL);
12991 return node->
data.intval;
12999 assert(node !=
NULL);
13002 return node->
data.dbl;
13010 assert(node !=
NULL);
13021 assert(node !=
NULL);
13033 assert(node !=
NULL);
13045 assert(node !=
NULL);
13057 assert(node !=
NULL);
13069 assert(node !=
NULL);
13081 assert(node !=
NULL);
13093 assert(node !=
NULL);
13105 assert(node !=
NULL);
13131 assert(node !=
NULL);
13132 assert(node->
depth >= 0);
13133 assert(node->
pos >= 0);
13138 assert(monomialidx >= 0);
13140 assert(curv !=
NULL);
13149 assert(monomial !=
NULL);
13159 childbounds = childboundsstatic;
13160 childcurv = childcurvstatic;
13164 for( i = 0; i < monomial->
nfactors; ++i )
13167 assert(child !=
NULL);
13175 childbounds[i] = child->
bounds;
13176 childcurv[i] = child->
curv;
13184 if( childbounds != childboundsstatic )
13198 assert(node !=
NULL);
13210 assert(node !=
NULL);
13222 assert(node !=
NULL);
13232 assert(node !=
NULL);
13234 return node->
value;
13242 assert(node !=
NULL);
13258 assert(blkmem !=
NULL);
13259 assert(node !=
NULL);
13273 SCIPerrorMessage(
"cannot create node with operand %d via SCIPexprgraphCreateNode\n");
13298 opdata.data =
NULL;
13314 opdata.intval = va_arg( ap,
int);
13342 assert(blkmem !=
NULL);
13343 assert(node !=
NULL);
13348 data[ncoefs] = constant;
13350 opdata.data = data;
13370 assert(blkmem !=
NULL);
13371 assert(node !=
NULL);
13372 assert(quadelems !=
NULL || nquadelems == 0);
13376 opdata.data = data;
13395 assert(blkmem !=
NULL);
13396 assert(node !=
NULL);
13397 assert(monomials !=
NULL || nmonomials == 0);
13401 opdata.data = data;
13416 assert(blkmem !=
NULL);
13417 assert(node !=
NULL);
13419 assert(monomials !=
NULL || nmonomials == 0);
13445 assert(blkmem !=
NULL);
13446 assert(node !=
NULL);
13450 assert(copydata !=
NULL || data ==
NULL);
13451 assert(freedata !=
NULL || data ==
NULL);
13457 exprdata->eval =
eval;
13458 exprdata->estimate = estimate;
13459 exprdata->inteval = inteval;
13460 exprdata->curv = curv;
13461 exprdata->prop = prop;
13462 exprdata->copydata = copydata;
13463 exprdata->freedata = freedata;
13464 exprdata->print = print;
13466 opdata.data = (
void*) exprdata;
13497 assert(exprgraph !=
NULL);
13498 assert(node !=
NULL);
13499 assert(*node !=
NULL);
13500 assert((*node)->nuses > 0);
13501 assert(nlinvars !=
NULL);
13502 assert(linvars !=
NULL || linvarssize == 0);
13503 assert(lincoefs !=
NULL || linvarssize == 0);
13504 assert(constant !=
NULL);
13512 switch( (*node)->op )
13516 if( linvarssize >= 1 )
13519 linvars[0] = exprgraph->
vars[(*node)->data.intval];
13529 *constant = (*node)->data.dbl;
13538 if( (*node)->data.dbl == 1.0 && (*node)->children[0]->op ==
SCIP_EXPR_VARIDX && linvarssize >= 1 )
13541 linvars[0] = exprgraph->
vars[(*node)->children[0]->data.intval];
13551 if( (*node)->data.intval == 1 && (*node)->children[0]->op ==
SCIP_EXPR_VARIDX && linvarssize >= 1 )
13554 linvars[0] = exprgraph->
vars[(*node)->children[0]->data.intval];
13566 *constant = (*node)->children[0]->data.dbl;
13568 linvars[0] = exprgraph->
vars[(*node)->children[1]->data.intval];
13577 *constant = (*node)->children[1]->data.dbl;
13579 linvars[0] = exprgraph->
vars[(*node)->children[0]->data.intval];
13589 linvars[0] = exprgraph->
vars[(*node)->children[0]->data.intval];
13591 linvars[1] = exprgraph->
vars[(*node)->children[1]->data.intval];
13610 *constant = (*node)->children[0]->data.dbl;
13612 linvars[0] = exprgraph->
vars[(*node)->children[1]->data.intval];
13613 lincoefs[0] = -1.0;
13621 *constant = -(*node)->children[1]->data.dbl;
13623 linvars[0] = exprgraph->
vars[(*node)->children[0]->data.intval];
13633 linvars[0] = exprgraph->
vars[(*node)->children[0]->data.intval];
13635 linvars[1] = exprgraph->
vars[(*node)->children[1]->data.intval];
13636 lincoefs[1] = -1.0;
13655 linvars[0] = exprgraph->
vars[(*node)->children[1]->data.intval];
13656 lincoefs[0] = (*node)->children[0]->data.dbl;
13663 linvars[0] = exprgraph->
vars[(*node)->children[0]->data.intval];
13664 lincoefs[0] = (*node)->children[1]->data.dbl;
13679 linvars[0] = exprgraph->
vars[(*node)->children[0]->data.intval];
13680 lincoefs[0] = 1.0/(*node)->children[1]->data.dbl;
13713 for( i = 0; i < (*node)->nchildren; ++i )
13719 if( i == (*node)->nchildren )
13727 assert(exprgraph->
nvars > 0);
13728 orignvars = exprgraph->
nvars;
13736 if( (*node)->nparents > 0 || (*node)->nuses > 1 )
13742 if( exprOpTable[orignode->
op].copydata !=
NULL )
13747 data = orignode->
data;
13754 havechange =
FALSE;
13756 switch( (*node)->op )
13768 assert(linvarssize >= 1);
13772 varidx = varchild->
data.intval;
13774 if( varsusage[varidx] > 1 )
13779 linvars[0] = exprgraph->
vars[varidx];
13781 lincoefs[0] = -1.0;
13785 if( (*node)->op ==
SCIP_EXPR_PLUS || (*node)->children[0] == otherchild )
13790 *node = otherchild;
13800 (*node)->children[0] = otherchild;
13808 (*node)->data.data = (
void*)lindata;
13824 nchildren = (*node)->nchildren;
13825 while( i < nchildren )
13830 *constant += (*node)->children[i]->data.dbl;
13833 if( i < nchildren-1 )
13835 (*node)->children[i] = (*node)->children[nchildren-1];
13836 (*node)->children[nchildren-1] =
NULL;
13851 if( varsusage[(*node)->children[i]->data.intval] > 1 )
13858 if( *nlinvars < linvarssize )
13860 linvars[*nlinvars] = exprgraph->
vars[(*node)->children[i]->data.intval];
13861 lincoefs[*nlinvars] = 1.0;
13865 if( i < nchildren-1 )
13867 (*node)->children[i] = (*node)->children[nchildren-1];
13868 (*node)->children[nchildren-1] =
NULL;
13875 assert(i == nchildren);
13877 if( nchildren == 0 )
13882 (*node)->nchildren = 0;
13887 if( nchildren < (*node)->nchildren )
13892 (*node)->nchildren = nchildren;
13895 if( havechange && (*node)->nchildren == 1 )
13916 coefs = (
SCIP_Real*)(*node)->data.data;
13917 assert(coefs !=
NULL);
13920 if( coefs[(*node)->nchildren] != 0.0 )
13922 *constant = coefs[(*node)->nchildren];
13923 coefs[(*node)->nchildren] = 0.0;
13928 nchildren = (*node)->nchildren;
13929 while( i < nchildren )
13934 *constant += coefs[i] * (*node)->children[i]->data.dbl;
13937 if( i < nchildren-1 )
13939 (*node)->children[i] = (*node)->children[nchildren-1];
13940 (*node)->children[nchildren-1] =
NULL;
13941 coefs[i] = coefs[nchildren-1];
13942 coefs[nchildren-1] = 0.0;
13957 if( varsusage[(*node)->children[i]->data.intval] > 1 )
13964 if( *nlinvars < linvarssize )
13966 linvars[*nlinvars] = exprgraph->
vars[(*node)->children[i]->data.intval];
13967 lincoefs[*nlinvars] = coefs[i];
13971 if( i < nchildren-1 )
13973 (*node)->children[i] = (*node)->children[nchildren-1];
13974 (*node)->children[nchildren-1] =
NULL;
13975 coefs[i] = coefs[nchildren-1];
13976 coefs[nchildren-1] = 0.0;
13983 assert(i == nchildren);
13985 if( nchildren == 0 )
13991 (*node)->data.data =
NULL;
13992 (*node)->nchildren = 0;
13998 if( nchildren < (*node)->nchildren )
14004 coefs[nchildren] = 0.0;
14005 (*node)->data.data = (
void*)coefs;
14006 (*node)->nchildren = nchildren;
14009 if( havechange && (*node)->nchildren == 1 && coefs[0] == 1.0 )
14033 assert(quaddata !=
NULL);
14060 nchildren = (*node)->nchildren;
14061 for( i = 0; i < nchildren; ++i )
14064 if( *nlinvars >= linvarssize )
14071 if( varsusage[(*node)->children[i]->data.intval] > 1 )
14075 linvars[*nlinvars] = exprgraph->
vars[(*node)->children[i]->data.intval];
14076 lincoefs[*nlinvars] = quaddata->
lincoefs[i];
14083 if( i < nchildren-1 )
14085 (*node)->children[i] = (*node)->children[nchildren-1];
14087 childused[i] = childused[nchildren-1];
14088 childmap[nchildren-1] = i;
14099 if( nchildren < (*node)->nchildren )
14118 if( nchildren == 0 )
14123 exprFreeDataQuadratic(exprgraph->
blkmem, (*node)->nchildren, (*node)->data);
14124 (*node)->data.data =
NULL;
14125 (*node)->nchildren = 0;
14131 if( nchildren < (*node)->nchildren )
14136 (*node)->nchildren = nchildren;
14151 assert(polynomialdata !=
NULL);
14157 if( polynomialdata->
constant != 0.0 )
14159 *constant = polynomialdata->
constant;
14165 if( linvarssize == 0 )
14171 for( i = 0; i < polynomialdata->
nmonomials; ++i )
14173 monomial = polynomialdata->
monomials[i];
14174 assert(monomial !=
NULL);
14177 for( j = 0; j < monomial->
nfactors; ++j )
14180 assert(monomial->
childidxs[j] < (*node)->nchildren);
14186 for( i = 0; i < polynomialdata->
nmonomials && *nlinvars < linvarssize; ++i )
14188 monomial = polynomialdata->
monomials[i];
14189 assert(monomial !=
NULL);
14194 if( monomial->
coef != 0.0 )
14196 *constant += monomial->
coef;
14207 assert((*node)->children[childidx] !=
NULL);
14210 if( childused[childidx] || varsusage[(*node)->children[childidx]->data.intval] > 1 )
14216 linvars[*nlinvars] = exprgraph->
vars[(*node)->children[childidx]->data.intval];
14217 lincoefs[*nlinvars] = monomial->
coef;
14220 monomial->
coef = 0.0;
14225 (*node)->children[childidx] =
NULL;
14232 if( *nlinvars > 0 )
14239 if( (*node)->nchildren == 0 )
14242 assert(polynomialdata->
constant == 0.0);
14256 if( orignode !=
NULL )
14262 assert(*constant == 0.0);
14263 assert(*nlinvars == 0);
14264 assert(*node !=
NULL);
14274 else if( havechange && *node !=
NULL )
14278 (*node)->simplified =
FALSE;
14299 assert(exprgraph !=
NULL);
14300 assert(srcnode !=
NULL);
14301 assert(*srcnode !=
NULL);
14302 assert(targetnode !=
NULL);
14304 while( *srcnode !=
NULL && (*srcnode)->nparents > 0 )
14306 if( (*srcnode)->parents[0]->depth <= targetnode->
depth )
14312 assert(*srcnode ==
NULL || (*srcnode)->nuses > 0);
14332 assert(exprgraph !=
NULL);
14333 assert(node !=
NULL);
14334 assert(*node !=
NULL);
14335 assert((*node)->depth >= 0);
14336 assert((*node)->pos >= 0);
14337 assert((*node)->depth < exprgraph->
depth);
14338 assert((*node)->pos < exprgraph->
nnodes[(*node)->depth]);
14339 assert((*node)->nuses >= 1);
14340 assert(exprgraph->
nodes[(*node)->depth][(*node)->pos] == *node);
14347 if( (*node)->nparents > 0 || (*node)->nuses > 0 )
14349 SCIPdebugMessage(
"skip removing node %p (%d, %d) with %d parents and %d uses from expression graph\n", (
void*)*node, (*node)->depth, (*node)->pos, (*node)->nparents, (*node)->nuses);
14358 for( i = 0; i < (*node)->nchildren; ++i )
14361 (*node)->children[i] =
NULL;
14366 assert((*node)->depth == 0);
14374 assert(constidx >= 0);
14375 assert(constidx < exprgraph->nconsts);
14376 assert(exprgraph->
constnodes[constidx] == *node);
14379 if( constidx < exprgraph->nconsts-1 )
14389 assert((*node)->depth > 0);
14393 if( (*node)->pos < exprgraph->
nnodes[(*node)->depth]-1 )
14396 exprgraph->
nodes[(*node)->depth][(*node)->pos] = exprgraph->
nodes[(*node)->depth][exprgraph->
nnodes[(*node)->depth]-1];
14397 exprgraph->
nodes[(*node)->depth][(*node)->pos]->
pos = (*node)->pos;
14399 --exprgraph->
nnodes[(*node)->depth];
14402 (*node)->depth = -1;
14420 assert(blkmem !=
NULL);
14421 assert( node !=
NULL);
14422 assert(*node !=
NULL);
14423 assert((*node)->depth == -1);
14424 assert((*node)->pos == -1);
14425 assert((*node)->nuses == 0);
14428 if( exprOpTable[(*node)->op].freedata !=
NULL )
14429 exprOpTable[(*node)->op].freedata(blkmem, (*node)->nchildren, (*node)->data);
14447 assert(exprgraph !=
NULL);
14448 assert(node !=
NULL);
14449 assert(node->
depth >= 0);
14450 assert(node->
pos >= 0);
14457 node->enabled =
TRUE;
14458 for( i = 0; i < node->nchildren; ++i )
14474 assert(exprgraph !=
NULL);
14475 assert(node !=
NULL);
14476 assert(node->
depth >= 0);
14477 assert(node->
pos >= 0);
14486 if( node->
nuses > 1 )
14491 for( i = 0; i < node->
nparents; ++i )
14498 SCIPdebugMessage(
"disabled node %p (%d,%d), nuses = %d\n", (
void*)node, node->
depth, node->pos, node->nuses);
14500 for( i = 0; i < node->nchildren; ++i )
14511 assert(node !=
NULL);
14513 for( p = 0; p < node->
nparents; ++p )
14530 assert(node !=
NULL);
14546 for( p = 0; p < node->
nparents; ++p )
14583 assert(node !=
NULL);
14602 assert(exprgraph !=
NULL);
14603 assert(node !=
NULL);
14604 assert(node->
depth >= 0);
14605 assert(node->
pos >= 0);
14607 assert(cutoff !=
NULL);
14614 SCIPdebugMessage(
"ignore bound tightening for node %p (%d,%d)\n", (
void*)node, node->
depth, node->pos);
14618 SCIPdebugMessage(
"tighten bounds of node %p (%d,%d) from [%10g, %10g] by [%10g, %10g]",
14619 (
void*)node, node->
depth, node->pos,
14620 node->bounds.inf, node->bounds.sup, nodebounds.
inf, nodebounds.
sup);
14625 if( nodebounds.
inf > node->bounds.sup || nodebounds.
sup < node->bounds.inf )
14638 if( minstrength < 0.0 )
14641 isLbBetter(minstrength, nodebounds.
inf, node->bounds.inf, node->bounds.sup) ||
14642 isUbBetter(minstrength, nodebounds.
sup, node->bounds.inf, node->bounds.sup) )
14644 else if( nodebounds.
inf > node->bounds.inf || nodebounds.
sup < node->bounds.sup )
14648 SCIPdebugPrintf(
" -> [%10g, %10g] status %d\n", node->bounds.inf, node->bounds.sup, node->boundstatus);
14668 assert(node !=
NULL);
14669 assert(node->
depth >= 0);
14670 assert(node->
pos >= 0);
14673 if( node->
depth == 0 )
14691 childbounds = childboundsstatic;
14692 childcurv = childcurvstatic;
14715 assert( exprOpTable[node->
op].inteval !=
NULL );
14728 for( i = 0; i < node->
nparents; ++i )
14731 node->
bounds = newbounds;
14736 for( i = 0; i < node->
nparents; ++i )
14739 node->
bounds = newbounds;
14757 SCIPdebugMessage(
"node %p(%d,%d) has empty domain in SCIPexprgraphUpdateNodeBoundsCurvature\n", (
void*)node, node->
depth, node->pos);
14770 if( childbounds != childboundsstatic )
14790 #undef SCIPexprgraphGetDepth 14791 #undef SCIPexprgraphGetNNodes 14792 #undef SCIPexprgraphGetNodes 14793 #undef SCIPexprgraphGetNVars 14794 #undef SCIPexprgraphGetVars 14795 #undef SCIPexprgraphGetVarNodes 14796 #undef SCIPexprgraphSetVarNodeValue 14797 #undef SCIPexprgraphSetVarsBounds 14798 #undef SCIPexprgraphSetVarBounds 14799 #undef SCIPexprgraphSetVarNodeBounds 14800 #undef SCIPexprgraphSetVarNodeLb 14801 #undef SCIPexprgraphSetVarNodeUb 14802 #undef SCIPexprgraphGetVarsBounds 14809 assert(exprgraph !=
NULL);
14811 return exprgraph->
depth;
14819 assert(exprgraph !=
NULL);
14821 return exprgraph->
nnodes;
14829 assert(exprgraph !=
NULL);
14831 return exprgraph->
nodes;
14839 assert(exprgraph !=
NULL);
14841 return exprgraph->
nvars;
14849 assert(exprgraph !=
NULL);
14851 return exprgraph->
vars;
14859 assert(exprgraph !=
NULL);
14870 assert(varnode !=
NULL);
14873 varnode->
value = value;
14882 assert(exprgraph !=
NULL);
14883 assert(varbounds !=
NULL || exprgraph->
nvars == 0);
14897 assert(exprgraph !=
NULL);
14898 assert(var !=
NULL);
14902 assert(pos < exprgraph->nvars);
14903 assert(exprgraph->
vars[pos] == var);
14917 assert(exprgraph !=
NULL);
14918 assert(varnode !=
NULL);
14920 pos = varnode->
data.intval;
14922 assert(pos < exprgraph->nvars);
14923 assert(exprgraph->
varnodes[pos] == varnode);
14937 assert(exprgraph !=
NULL);
14938 assert(varnode !=
NULL);
14940 pos = varnode->
data.intval;
14942 assert(pos < exprgraph->nvars);
14943 assert(exprgraph->
varnodes[pos] == varnode);
14957 assert(exprgraph !=
NULL);
14958 assert(varnode !=
NULL);
14960 pos = varnode->
data.intval;
14962 assert(pos < exprgraph->nvars);
14963 assert(exprgraph->
varnodes[pos] == varnode);
14988 assert(blkmem !=
NULL);
14989 assert(exprgraph !=
NULL);
14993 (*exprgraph)->blkmem = blkmem;
14997 assert((*exprgraph)->depth >= 1);
15000 ensureBlockMemoryArraySize3((*exprgraph)->blkmem, &(*exprgraph)->varnodes, &(*exprgraph)->vars, &(*exprgraph)->varbounds, &(*exprgraph)->varssize, varssizeinit);
15004 (*exprgraph)->constssorted =
TRUE;
15007 (*exprgraph)->exprgraphvaradded = exprgraphvaradded;
15008 (*exprgraph)->exprgraphvarremove = exprgraphvarremove;
15009 (*exprgraph)->exprgraphvarchgidx = exprgraphvarchgidx;
15010 (*exprgraph)->userdata = userdata;
15023 assert( exprgraph !=
NULL);
15024 assert(*exprgraph !=
NULL);
15025 assert((*exprgraph)->nvars == 0);
15026 assert((*exprgraph)->nconsts == 0);
15028 blkmem = (*exprgraph)->blkmem;
15029 assert(blkmem !=
NULL);
15032 for( d = 0; d < (*exprgraph)->depth; ++d )
15034 assert((*exprgraph)->nnodes[d] == 0);
15037 assert((*exprgraph)->nodes !=
NULL);
15038 assert((*exprgraph)->nnodes !=
NULL);
15039 assert((*exprgraph)->nodessize !=
NULL);
15077 assert(exprgraph !=
NULL);
15078 assert(node !=
NULL);
15079 assert(node->
pos < 0);
15080 assert(node->
depth < 0);
15084 assert(children !=
NULL || nchildren == 0);
15087 depth =
MAX(0, mindepth);
15088 for( i = 0; i < nchildren; ++i )
15090 if( children[i]->depth >= depth )
15091 depth = children[i]->
depth + 1;
15096 assert(exprgraph->
depth > depth);
15102 node->
depth = depth;
15104 exprgraph->
nodes[depth][node->
pos] = node;
15105 ++exprgraph->
nnodes[depth];
15109 childvalsvalid =
TRUE;
15110 for( i = 0; i < nchildren; ++i )
15116 if( nchildren > 0 )
15160 assert(exprgraph !=
NULL);
15161 assert(exprgraph->
depth >= 1);
15162 assert(vars !=
NULL || nvars == 0);
15165 if( exprgraph->
nvars == 0 )
15171 for( i = 0; i < nvars; ++i )
15177 assert(node !=
NULL);
15182 if( varnodes !=
NULL )
15183 varnodes[i] = node;
15189 opdata.intval = exprgraph->
nvars;
15197 exprgraph->
vars[exprgraph->
nvars] = vars[i];
15201 ++exprgraph->
nvars;
15203 if( varnodes !=
NULL )
15204 varnodes[i] = node;
15206 SCIPdebugMessage(
"added node %p (%d, %d) for new variable %d\n", (
void*)node, node->
depth, node->pos, node->data.intval);
15209 if( exprgraph->exprgraphvaradded !=
NULL )
15211 SCIP_CALL( exprgraph->exprgraphvaradded(exprgraph, exprgraph->
userdata, vars[i], node) );
15230 assert(exprgraph !=
NULL);
15231 assert(constnode !=
NULL);
15236 assert(*constnode !=
NULL);
15238 assert((*constnode)->data.dbl == constant);
15239 (*constnode)->enabled =
TRUE;
15244 opdata.dbl = constant;
15249 assert((*constnode)->depth == 0);
15250 assert((*constnode)->pos == exprgraph->
nnodes[0]-1);
15258 SCIPdebugMessage(
"added node %p (%d, %d) for new constant %g\n", (
void*)constnode, (*constnode)->
depth, (*constnode)->pos, (*constnode)->data.dbl);
15280 assert(exprgraph !=
NULL);
15281 assert(nexprtrees > 0);
15282 assert(exprtrees !=
NULL);
15283 assert(rootnode !=
NULL);
15284 assert(rootnodeisnew !=
NULL);
15288 if( nexprtrees == 1 && (coefs ==
NULL || coefs[0] == 1.0) )
15290 assert(exprtrees[0] !=
NULL);
15291 assert(exprtrees[0]->vars !=
NULL || exprtrees[0]->nvars == 0);
15293 SCIP_CALL(
exprgraphAddExpr(exprgraph, exprtrees[0]->root, exprtrees[0]->vars, exprtrees[0]->params, rootnode, rootnodeisnew) );
15302 *rootnodeisnew =
TRUE;
15306 for( i = 0; i < nexprtrees; ++i )
15308 assert(exprtrees[i] !=
NULL);
15309 assert(exprtrees[i]->vars !=
NULL || exprtrees[i]->nvars == 0);
15311 SCIP_CALL(
exprgraphAddExpr(exprgraph, exprtrees[i]->root, exprtrees[i]->vars, exprtrees[i]->params, &rootnodes[i], &rootnodeisnew_) );
15312 assert(rootnodes[i] !=
NULL);
15313 *rootnodeisnew &= rootnodeisnew_;
15315 allone &= (coefs ==
NULL || coefs[i] == 1.0);
15319 if( coefs ==
NULL || allone )
15321 else if( nexprtrees == 2 && coefs[0] == 1.0 && coefs[1] == -1.0 )
15323 else if( nexprtrees == 2 && coefs[1] == 1.0 && coefs[0] == -1.0 )
15327 tmp = rootnodes[0];
15328 rootnodes[0] = rootnodes[1];
15329 rootnodes[1] = tmp;
15340 if( !*rootnodeisnew )
15346 if( *rootnode ==
NULL )
15351 *rootnodeisnew =
TRUE;
15356 *rootnodeisnew =
FALSE;
15369 lindata[nexprtrees] = 0.0;
15370 data.data = lindata;
15372 if( !*rootnodeisnew )
15378 if( *rootnode ==
NULL )
15383 *rootnodeisnew =
TRUE;
15388 *rootnodeisnew =
FALSE;
15395 assert(*rootnode !=
NULL);
15400 rootnodeisnew ?
"new" :
"old", (
void*)*rootnode, (*rootnode)->
depth, (*rootnode)->pos, nexprtrees);
15423 assert(exprgraph !=
NULL);
15424 assert(var !=
NULL);
15426 assert(coefs !=
NULL || ncoefs == 0);
15427 assert(vars !=
NULL || ncoefs == 0);
15430 assert(varidx < exprgraph->nvars);
15431 assert(exprgraph->
vars[varidx] == var);
15432 varnode = exprgraph->
varnodes[varidx];
15433 assert(varnode !=
NULL);
15434 assert(varnode->
data.intval == varidx);
15436 if( ncoefs == 0 || (ncoefs == 1 && constant == 0.0 && coefs[0] == 1.0) )
15446 assert(node ==
NULL || node->
data.dbl == constant);
15451 assert(node ==
NULL || exprgraph->
vars[node->
data.intval] == vars[0]);
15456 SCIPdebugMessage(
"try to replace varnode %p (%d uses, %d parents) by %p\n", (
void*)varnode, varnode->
nuses, varnode->nparents, (
void*)node);
15462 if( varnode !=
NULL )
15464 assert(varnode->nuses > 0);
15465 assert(varnode->nparents == 0);
15475 varnode->data.data =
NULL;
15477 varnode->children[0] = node;
15478 varnode->nchildren = 1;
15481 varnode->value = node->value;
15482 varnode->bounds = node->bounds;
15486 else if( ncoefs == 0 )
15495 varnode->
data.dbl = constant;
15497 varnode->
value = constant;
15514 varnode->
data.intval = exprgraph->
nvars;
15518 exprgraph->
vars[exprgraph->
nvars] = vars[0];
15522 ++exprgraph->
nvars;
15525 if( exprgraph->exprgraphvaradded !=
NULL )
15527 SCIP_CALL( exprgraph->exprgraphvaradded(exprgraph, exprgraph->
userdata, vars[0], varnode) );
15532 if( varnode !=
NULL )
15535 for( i = 0; i < varnode->
nparents; ++i )
15553 lindata[ncoefs] = constant;
15554 varnode->
data.data = (
void*)lindata;
15563 for( i = 0; i < ncoefs; ++i )
15574 for( i = 0; i < varnode->
nparents; ++i )
15589 assert(exprgraph !=
NULL);
15590 assert(var !=
NULL);
15591 assert(varnode !=
NULL);
15600 assert(pos < exprgraph->nvars);
15602 *varnode = exprgraph->
varnodes[pos];
15603 assert(*varnode !=
NULL);
15620 assert(exprgraph !=
NULL);
15621 assert(constnode !=
NULL);
15622 assert(constant == constant);
15629 right = exprgraph->
nconsts-1;
15632 while( left <= right )
15634 middle = (left+right)/2;
15635 assert(0 <= middle && middle < exprgraph->nconsts);
15637 if( constant < exprgraph->constnodes[middle]->data.dbl )
15638 right = middle - 1;
15647 if( left == right+1 )
15650 assert(*constnode !=
NULL);
15652 assert((*constnode)->data.dbl == constant);
15662 const char** varnames
15668 assert(exprgraph !=
NULL);
15676 for( d = 0; d < exprgraph->
depth; ++d )
15678 if( exprgraph->
nnodes[d] == 0 )
15681 for( i = 0; i < exprgraph->
nnodes[d]; ++i )
15689 for( i = 0; i < exprgraph->
nnodes[0]; ++i )
15695 for( d = 0; d < exprgraph->
depth; ++d )
15696 for( i = 0; i < exprgraph->
nnodes[d]; ++i )
15715 assert(exprgraph !=
NULL);
15716 assert(varvals !=
NULL || exprgraph->
nvars == 0);
15718 for( d = 0; d < exprgraph->
depth; ++d )
15719 for( i = 0; i < exprgraph->
nnodes[d]; ++i )
15740 assert(exprgraph !=
NULL);
15741 assert(domainerror !=
NULL);
15743 *domainerror =
FALSE;
15751 SCIPdebugMessage(
"no bounds changed and clearreverseprop is FALSE -> skip propagation of variable bounds\n");
15756 for( d = 1; d < exprgraph->
depth; ++d )
15758 for( i = 0; i < exprgraph->
nnodes[d]; ++i )
15760 node = exprgraph->
nodes[d][i];
15764 SCIPdebugMessage(
"bounds of node %p(%d,%d) empty, stop bounds propagation\n", (
void*)node, node->
depth, node->pos);
15766 *domainerror =
TRUE;
15793 assert(exprgraph !=
NULL);
15794 assert(cutoff !=
NULL);
15798 for( d = exprgraph->
depth-1; d >= 0 && !*cutoff; --d )
15800 for( i = 0; i < exprgraph->
nnodes[d] && !*cutoff; ++i )
15802 node = exprgraph->
nodes[d][i];
15825 assert(exprgraph !=
NULL);
15831 for( i = 0; i < exprgraph->
nnodes[0]; ++i )
15835 for( d = 1; d < exprgraph->
depth; ++d )
15836 for( i = 0; i < exprgraph->
nnodes[d]; ++i )
15838 node = exprgraph->
nodes[d][i];
15839 assert(node !=
NULL);
15845 SCIPerrorMessage(
"SCIPexprgraphCheckCurvature gets domain error while propagating variables bounds, ignoring...\n");
15861 int maxexpansionexponent,
15882 assert(exprgraph !=
NULL);
15883 assert(eps >= 0.0);
15884 assert(havechange !=
NULL);
15885 assert(domainerror !=
NULL);
15895 for( i = 0; i < exprgraph->
nvars; ++i )
15898 for( d = 1; d < exprgraph->
depth; ++d )
15899 for( i = 0; i < exprgraph->
nnodes[d]; ++i )
15901 node = exprgraph->
nodes[d][i];
15902 assert(node !=
NULL);
15905 if( node->
nuses > 0 )
15920 file = fopen(
"exprgraph_beforesimplify.dot",
"w");
15929 *havechange =
FALSE;
15930 *domainerror =
FALSE;
15931 allsimplified =
TRUE;
15936 for( d = 1; d < exprgraph->
depth && !*domainerror; ++d )
15938 for( i = 0; i < exprgraph->
nnodes[d]; ++i )
15940 node = exprgraph->
nodes[d][i];
15941 assert(node !=
NULL);
15943 havechangenode =
FALSE;
15951 allsimplified =
FALSE;
15956 *havechange |= havechangenode;
15966 SCIPdebugMessage(
"Expression graph simplify turned node into NaN or inf.\n");
15967 *domainerror =
TRUE;
15975 assert(constnode->
data.dbl == node->
value);
15982 assert(node ==
NULL || node->
nuses > 0);
15983 havechangenode =
TRUE;
15992 assert(node !=
NULL);
15993 assert(node->
nuses > 0);
15995 if( constnode->
nuses == 0 )
16002 assert(constnode ==
NULL);
16003 havechangenode =
TRUE;
16021 if( havechangenode )
16022 for( j = 0; j < node->
nparents; ++j )
16028 if( allsimplified || *domainerror )
16029 goto EXPRGRAPHSIMPLIFY_CLEANUP;
16034 for( d = 1; d < exprgraph->
depth; ++d )
16036 for( i = 0; i < exprgraph->
nnodes[d]; ++i )
16038 node = exprgraph->
nodes[d][i];
16039 assert(node !=
NULL);
16057 assert(node ==
NULL || node->
nuses > 0);
16069 file = fopen(
"exprgraph_aftersimplify.dot",
"w");
16079 for( d = 1; d < exprgraph->
depth; ++d )
16080 for( i = 0; i < exprgraph->
nnodes[d]; ++i )
16086 node = exprgraph->
nodes[d][i];
16087 assert(node !=
NULL);
16092 if( node->
nuses > 0 )
16097 assert(idx < ntestvals);
16099 testval_before = testvals[idx];
16107 EXPRGRAPHSIMPLIFY_CLEANUP:
16129 assert(exprgraph !=
NULL);
16130 assert(rootnode !=
NULL);
16131 assert(rootnode->
depth >= 0);
16132 assert(rootnode->
pos >= 0);
16133 assert(exprtree !=
NULL);
16139 for( i = 0; i < exprgraph->
nvars; ++i )
16150 if( nexprvars > 0 )
16153 for( i = 0; i < exprgraph->
nvars; ++i )
16155 assert(varidx[i] >= -1);
16156 assert(varidx[i] < nexprvars);
16157 if( varidx[i] >= 0 )
16158 (*exprtree)->vars[varidx[i]] = exprgraph->
vars[i];
16196 assert(exprgraph !=
NULL);
16197 assert(node !=
NULL);
16198 assert(node->
depth >= 0);
16199 assert(node->
pos >= 0);
16200 assert(exprtreessize > 0);
16201 assert(nexprtrees !=
NULL);
16202 assert(exprtrees !=
NULL);
16203 assert(exprtreecoefs !=
NULL);
16207 if( exprtreessize == 1 || node->
nchildren <= 1 || exprgraph->
nvars <= 1 ||
16216 exprtreecoefs[0] = 1.0;
16225 for( i = 0; i < exprgraph->
nvars; ++i )
16228 haveoverlap =
FALSE;
16233 assert(compnr >= 0);
16234 assert(compnr < node->nchildren);
16235 childcomp[i] = compnr;
16239 haveoverlap =
TRUE;
16250 assert(data !=
NULL);
16258 if( childcomp[j] == compnr )
16261 haveoverlap =
TRUE;
16270 assert(data !=
NULL);
16279 if( childcomp[k] == compnr )
16282 haveoverlap =
TRUE;
16298 if( compmap[childcomp[i]] == -1 )
16299 compmap[childcomp[i]] = ncomponents++;
16300 childcomp[i] = compmap[childcomp[i]];
16310 if( ncomponents == 1 )
16316 exprtreecoefs[0] = 1.0;
16322 if( ncomponents > exprtreessize )
16326 if( childcomp[i] >= exprtreessize )
16327 childcomp[i] = exprtreessize-1;
16328 ncomponents = exprtreessize;
16331 assert(ncomponents >= 2);
16338 for( i = 0; i < ncomponents; ++i )
16341 for( j = 0; j < exprgraph->
nvars; ++j )
16349 assert(childcomp[j] >= 0);
16350 assert(childcomp[j] < ncomponents);
16351 if( childcomp[j] != i )
16356 childmap[j] = nexprs;
16357 childmapinv[nexprs] = j;
16366 assert(ncomponents == 2);
16367 assert(nexprs == 1);
16370 exprtreecoefs[i] = 1.0;
16377 assert(ncomponents == 2);
16378 assert(nexprs == 1);
16382 assert(childmapinv[0] == 0 || childmapinv[0] == 1);
16383 exprtreecoefs[i] = (childmapinv[0] == 0 ? 1.0 : -1.0);
16403 exprtreecoefs[i] = 1.0;
16416 if( nexprs == 1 && (i > 0 || nodecoefs[node->
nchildren] == 0.0) )
16420 exprtreecoefs[i] = nodecoefs[childmapinv[0]];
16422 else if( nexprs == 1 )
16426 assert(nodecoefs[node->
nchildren] != 0.0);
16427 assert(nodecoefs[childmapinv[0]] != 0.0);
16431 exprtreecoefs[i] = nodecoefs[childmapinv[0]];
16437 if( nexprs == 2 && nodecoefs[childmapinv[0]] == nodecoefs[childmapinv[1]] && (i > 0 || nodecoefs[node->
nchildren] == 0.0) )
16441 exprtreecoefs[i] = nodecoefs[childmapinv[0]];
16443 else if( nexprs == 2 && nodecoefs[childmapinv[0]] == -nodecoefs[childmapinv[1]] && (i > 0 || nodecoefs[node->
nchildren] == 0.0) )
16447 exprtreecoefs[i] = nodecoefs[childmapinv[0]];
16456 allcoefsequal =
TRUE;
16457 coefs[0] = nodecoefs[childmapinv[0]];
16458 for( j = 0; j < nexprs; ++j )
16460 coefs[j] = nodecoefs[childmapinv[j]];
16461 allcoefsequal &= (coefs[j] == coefs[0]);
16465 if( allcoefsequal && (i > 0 || nodecoefs[node->
nchildren] == 0.0) )
16468 exprtreecoefs[i] = coefs[0];
16473 exprtreecoefs[i] = 1.0;
16495 exprtreecoefs[i] = 1.0;
16501 for( j = 0; j < nexprs; ++j )
16502 lincoefs[j] = nodedata->
lincoefs[childmapinv[j]];
16541 exprtreecoefs[i] = 1.0;
16558 for( k = 0; k < monomials[nmonomials]->
nfactors; ++k )
16561 monomials[nmonomials]->
childidxs[k] = childmap[monomials[nmonomials]->
childidxs[k]];
16580 if( nexprvars > 0 )
16583 for( j = 0; j < exprgraph->
nvars; ++j )
16585 assert(varidx[j] >= -1);
16586 assert(varidx[j] < nexprvars);
16587 if( varidx[j] >= 0 )
16588 exprtrees[i]->
vars[varidx[j]] = exprgraph->
vars[j];
16599 *nexprtrees = ncomponents;
16611 assert(exprgraph !=
NULL);
16612 assert(node !=
NULL);
16613 assert(varsusage !=
NULL);
16670 assert(exprgraph !=
NULL);
16671 assert(node !=
NULL);
16672 assert(node->
depth >= 0);
16673 assert(node->
pos >= 0);
16674 assert(exprtreessize > 0);
16675 assert(nexprtrees !=
NULL);
16676 assert(exprtrees !=
NULL);
16677 assert(exprtreecoefs !=
NULL);
16688 exprtreecoefs[0] = 1.0;
16698 assert(exprtreessize >= 2);
16703 exprtreecoefs[0] = 1.0;
16704 exprtreecoefs[1] = 1.0;
16712 assert(exprtreessize >= 2);
16717 exprtreecoefs[0] = 1.0;
16718 exprtreecoefs[1] = -1.0;
16726 assert(exprtreessize >= node->
nchildren);
16731 exprtreecoefs[i] = 1.0;
16742 assert(exprtreessize >= node->
nchildren);
16746 assert(nodecoefs !=
NULL);
16751 exprtreecoefs[i] = nodecoefs[i];
16755 if( nodecoefs[node->
nchildren] != 0.0 )
16781 assert(exprtreessize >= (lincoefs !=
NULL ? node->
nchildren : 0) + nquadelems);
16785 if( lincoefs !=
NULL )
16789 if( lincoefs[i] == 0.0 )
16792 exprtreecoefs[*nexprtrees] = lincoefs[i];
16800 for( i = 0; i < nquadelems; ++i )
16803 for( j = 0; j < exprgraph->
nvars; ++j )
16810 if( quadelems[i].idx1 == quadelems[i].idx2 )
16829 if( nexprvars > 0 )
16832 for( j = 0; j < exprgraph->
nvars; ++j )
16834 assert(varidx[j] >= -1);
16835 assert(varidx[j] < nexprvars);
16836 if( varidx[j] >= 0 )
16837 exprtrees[*nexprtrees]->
vars[varidx[j]] = exprgraph->
vars[j];
16841 exprtreecoefs[*nexprtrees] = quadelems[i].
coef;
16851 assert(*nexprtrees > 0);
16876 assert(exprtreessize >= nmonomials);
16884 for( i = 0; i < nmonomials; ++i )
16887 for( j = 0; j < exprgraph->
nvars; ++j )
16891 if( monomials[i]->nfactors == 1 )
16897 if( monomials[i]->exponents[0] == 1.0 )
16899 else if( monomials[i]->exponents[0] == 2.0 )
16903 else if(
EPSISINT(monomials[i]->exponents[0], 0.0) )
16912 else if( monomials[i]->nfactors == 2 && monomials[i]->exponents[0] == 1.0 && monomials[i]->exponents[1] == 1.0 )
16933 for( f = 0; f < monomials[i]->
nfactors; ++f )
16954 if( nexprvars > 0 )
16957 for( j = 0; j < exprgraph->
nvars; ++j )
16959 assert(varidx[j] >= -1);
16960 assert(varidx[j] < nexprvars);
16961 if( varidx[j] >= 0 )
16962 exprtrees[*nexprtrees]->
vars[varidx[j]] = exprgraph->
vars[j];
16966 exprtreecoefs[*nexprtrees] = monomials[i]->
coef;
16972 if( constant != 0.0 )
16976 assert(*nexprtrees > 0);
void SCIPintervalSignPowerScalar(SCIP_Real infinity, SCIP_INTERVAL *resultant, SCIP_INTERVAL operand1, SCIP_Real operand2)
static SCIP_RETCODE exprparseReadVariable(BMS_BLKMEM *blkmem, const char **str, SCIP_EXPR **expr, int *nvars, int **varnames, SCIP_HASHTABLE *vartable, SCIP_Real coefficient, const char *varnameendptr)
#define SCIP_EXPRBOUNDSTATUS_CHILDRELAXED
void SCIPsortPtrInt(void **ptrarray, int *intarray, SCIP_DECL_SORTPTRCOMP((*ptrcomp)), int len)
SCIP_Real SCIPexprgraphGetNodeVal(SCIP_EXPRGRAPHNODE *node)
SCIP_RETCODE SCIPexprgraphPropagateVarBounds(SCIP_EXPRGRAPH *exprgraph, SCIP_Real infinity, SCIP_Bool clearreverseprop, SCIP_Bool *domainerror)
void SCIPexprFreeDeep(BMS_BLKMEM *blkmem, SCIP_EXPR **expr)
void SCIPexprtreeGetVarsUsage(SCIP_EXPRTREE *tree, int *varsusage)
SCIP_RETCODE SCIPrandomCreate(SCIP_RANDNUMGEN **randnumgen, BMS_BLKMEM *blkmem, unsigned int initialseed)
void SCIPquadelemSort(SCIP_QUADELEM *quadelems, int nquadelems)
SCIP_RETCODE SCIPexprgraphReplaceVarByLinearSum(SCIP_EXPRGRAPH *exprgraph, void *var, int ncoefs, SCIP_Real *coefs, void **vars, SCIP_Real constant)
void SCIPexprSortMonomials(SCIP_EXPR *expr)
void SCIPintervalSubScalar(SCIP_Real infinity, SCIP_INTERVAL *resultant, SCIP_INTERVAL operand1, SCIP_Real operand2)
#define QUADELEMS_SWAP(x, y)
void SCIPintervalMax(SCIP_Real infinity, SCIP_INTERVAL *resultant, SCIP_INTERVAL operand1, SCIP_INTERVAL operand2)
#define BMSfreeBlockMemoryArrayNull(mem, ptr, num)
static void exprgraphSortConstNodes(SCIP_EXPRGRAPH *exprgraph)
void SCIPexprgraphSetVarNodeValue(SCIP_EXPRGRAPHNODE *varnode, SCIP_Real value)
static SCIP_RETCODE exprgraphNodeAddParent(BMS_BLKMEM *blkmem, SCIP_EXPRGRAPHNODE *node, SCIP_EXPRGRAPHNODE *parent)
SCIP_RETCODE SCIPexprSubstituteVars(BMS_BLKMEM *blkmem, SCIP_EXPR *expr, SCIP_EXPR **substexprs)
static SCIP_RETCODE exprsimplifyConvertToPolynomials(BMS_BLKMEM *blkmem, SCIP_EXPR *expr)
SCIP_Bool SCIPintervalIsEmpty(SCIP_Real infinity, SCIP_INTERVAL operand)
SCIP_RETCODE SCIPexprgraphAddNode(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE *node, int mindepth, int nchildren, SCIP_EXPRGRAPHNODE **children)
void SCIPintervalSign(SCIP_Real infinity, SCIP_INTERVAL *resultant, SCIP_INTERVAL operand)
#define QUADELEMS_ISBETTER(a, b)
static SCIP_RETCODE eval(SCIP_EXPR *expr, const vector< Type > &x, SCIP_Real *param, Type &val)
static SCIP_RETCODE exprsimplifyRemoveDuplicatePolynomialChildren(BMS_BLKMEM *blkmem, SCIP_EXPR *expr, SCIP_Real eps)
SCIP_RETCODE SCIPexprgraphGetSumTrees(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE *node, int exprtreessize, int *nexprtrees, SCIP_EXPRTREE **exprtrees, SCIP_Real *exprtreecoefs)
SCIP_RETCODE SCIPexprtreeEvalInt(SCIP_EXPRTREE *tree, SCIP_Real infinity, SCIP_INTERVAL *varvals, SCIP_INTERVAL *val)
SCIP_RETCODE SCIPexprgraphAddVars(SCIP_EXPRGRAPH *exprgraph, int nvars, void **vars, SCIP_EXPRGRAPHNODE **varnodes)
methods to interpret (evaluate) an expression tree "fast"
void SCIPexprtreePrint(SCIP_EXPRTREE *tree, SCIP_MESSAGEHDLR *messagehdlr, FILE *file, const char **varnames, const char **paramnames)
int * SCIPexprGetMonomialChildIndices(SCIP_EXPRDATA_MONOMIAL *monomial)
SCIP_RETCODE SCIPexprgraphUpdateNodeBoundsCurvature(SCIP_EXPRGRAPHNODE *node, SCIP_Real infinity, SCIP_Real minstrength, SCIP_Bool clearreverseprop)
static SCIP_RETCODE polynomialdataMultiplyByMonomial(BMS_BLKMEM *blkmem, SCIP_EXPRDATA_POLYNOMIAL *polynomialdata, SCIP_EXPRDATA_MONOMIAL *factor, int *childmap)
static SCIP_RETCODE exprUnconvertPolynomial(BMS_BLKMEM *blkmem, SCIP_EXPROP *op, SCIP_EXPROPDATA *data, int nchildren, void **children)
SCIP_RETCODE SCIPhashtableInsert(SCIP_HASHTABLE *hashtable, void *element)
static SCIP_RETCODE exprgraphNodeAddChildren(BMS_BLKMEM *blkmem, SCIP_EXPRGRAPHNODE *node, int nexprs, SCIP_EXPRGRAPHNODE **exprs, int *childmap)
int SCIPexprgraphGetNodeNChildren(SCIP_EXPRGRAPHNODE *node)
static SCIP_RETCODE exprgraphNodeCreateExpr(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE *node, SCIP_EXPR **expr, int *nexprvars, int *varidx)
SCIP_Real SCIPintervalNegateReal(SCIP_Real x)
SCIP_EXPROP SCIPexprGetOperator(SCIP_EXPR *expr)
struct SCIP_UserExprData SCIP_USEREXPRDATA
void SCIPexprPrint(SCIP_EXPR *expr, SCIP_MESSAGEHDLR *messagehdlr, FILE *file, const char **varnames, const char **paramnames, SCIP_Real *paramvals)
int SCIPexprgraphGetNVars(SCIP_EXPRGRAPH *exprgraph)
static SCIP_RETCODE exprgraphEnsureDepth(SCIP_EXPRGRAPH *exprgraph, int mindepth)
void SCIPsortPtrPtrRealInt(void **ptrarray1, void **ptrarray2, SCIP_Real *realarray, int *intarray, SCIP_DECL_SORTPTRCOMP((*ptrcomp)), int len)
static void polynomialdataSortMonomials(SCIP_EXPRDATA_POLYNOMIAL *polynomialdata)
static SCIP_RETCODE exprgraphNodeSimplify(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE *node, SCIP_MESSAGEHDLR *messagehdlr, SCIP_Real eps, int maxexpansionexponent, SCIP_Bool *havechange)
void SCIPsortPtrPtrReal(void **ptrarray1, void **ptrarray2, SCIP_Real *realarray, SCIP_DECL_SORTPTRCOMP((*ptrcomp)), int len)
#define SCIP_VARTYPE_INTEGER_CHAR
SCIPInterval pow(const SCIPInterval &x, const SCIPInterval &y)
#define SCIP_DECL_USEREXPREVAL(x)
#define SCIP_DECL_USEREXPRPRINT(x)
int SCIPexprgraphGetDepth(SCIP_EXPRGRAPH *exprgraph)
static SCIP_RETCODE polynomialdataMultiplyByPolynomial(BMS_BLKMEM *blkmem, SCIP_EXPRDATA_POLYNOMIAL *polynomialdata, SCIP_EXPRDATA_POLYNOMIAL *factordata, int *childmap)
static SCIP_RETCODE exprparseFindSeparatingComma(const char *str, const char **endptr, int length)
static SCIP_RETCODE exprgraphNodeRemovePolynomialNullChildren(BMS_BLKMEM *blkmem, SCIP_EXPRGRAPHNODE *node)
const char * SCIPexpropGetName(SCIP_EXPROP op)
void SCIPexprChgPolynomialConstant(SCIP_EXPR *expr, SCIP_Real constant)
SCIP_RETCODE SCIPexprgraphAddConst(SCIP_EXPRGRAPH *exprgraph, SCIP_Real constant, SCIP_EXPRGRAPHNODE **constnode)
SCIP_RETCODE SCIPexprtreeGetMaxDegree(SCIP_EXPRTREE *tree, int *maxdegree)
SCIP_Real * SCIPexprtreeGetParamVals(SCIP_EXPRTREE *tree)
void SCIPexprgraphSetVarNodeBounds(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE *varnode, SCIP_INTERVAL varbounds)
SCIP_RETCODE SCIPexprCreateMonomial(BMS_BLKMEM *blkmem, SCIP_EXPRDATA_MONOMIAL **monomial, SCIP_Real coef, int nfactors, int *childidxs, SCIP_Real *exponents)
void SCIPexprgraphCaptureNode(SCIP_EXPRGRAPHNODE *node)
SCIP_RETCODE SCIPexprgraphCreateNodeQuadratic(BMS_BLKMEM *blkmem, SCIP_EXPRGRAPHNODE **node, int nchildren, SCIP_Real *lincoefs, int nquadelems, SCIP_QUADELEM *quadelems, SCIP_Real constant)
static SCIP_DECL_EXPRFREEDATA(exprFreeDataLinear)
SCIP_Real SCIPexprGetRealPowerExponent(SCIP_EXPR *expr)
int SCIPexprGetOpIndex(SCIP_EXPR *expr)
data definitions for expressions and expression trees
SCIP_RETCODE SCIPexprSimplify(BMS_BLKMEM *blkmem, SCIP_MESSAGEHDLR *messagehdlr, SCIP_EXPR *expr, SCIP_Real eps, int maxexpansionexponent, int nvars, int *nlinvars, int *linidxs, SCIP_Real *lincoefs)
SCIP_RETCODE SCIPexprPolynomialPower(BMS_BLKMEM *blkmem, SCIP_EXPR *expr, int exponent)
void SCIPexprChgMonomialCoef(SCIP_EXPRDATA_MONOMIAL *monomial, SCIP_Real newcoef)
SCIP_Bool SCIPexprHasParam(SCIP_EXPR *expr)
SCIPInterval cos(const SCIPInterval &x)
SCIP_Real SCIPexprGetPolynomialConstant(SCIP_EXPR *expr)
SCIP_EXPRBOUNDSTATUS boundstatus
void SCIPintervalSetRoundingMode(SCIP_ROUNDMODE roundmode)
void SCIPexprgraphPropagateNodeBounds(SCIP_EXPRGRAPH *exprgraph, SCIP_Real infinity, SCIP_Real minstrength, SCIP_Bool *cutoff)
void SCIPintervalMul(SCIP_Real infinity, SCIP_INTERVAL *resultant, SCIP_INTERVAL operand1, SCIP_INTERVAL operand2)
SCIP_RETCODE SCIPhashmapCreate(SCIP_HASHMAP **hashmap, BMS_BLKMEM *blkmem, int mapsize)
#define SCIP_EXPRBOUNDSTATUS_TIGHTENEDBYPARENT
SCIP_Bool SCIPexprAreEqual(SCIP_EXPR *expr1, SCIP_EXPR *expr2, SCIP_Real eps)
void SCIPexprMonomialPower(SCIP_EXPRDATA_MONOMIAL *monomial, int exponent)
SCIP_EXPRGRAPHNODE ** SCIPexprgraphGetVarNodes(SCIP_EXPRGRAPH *exprgraph)
SCIP_Real SCIPrelDiff(SCIP_Real val1, SCIP_Real val2)
static void exprgraphNodeCheckSeparabilityComponent(SCIP_EXPRGRAPHNODE *node, int *compnr, int nchildcomps, int *childcomps, int nvars, int *varcomps)
static SCIP_RETCODE exprgraphNodeRemovePolynomialDuplicateChildren(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE *node)
SCIP_Real SCIPexprgraphGetNodeSignPowerExponent(SCIP_EXPRGRAPHNODE *node)
enum SCIP_Retcode SCIP_RETCODE
static int calcGrowSize(int num)
static SCIP_RETCODE exprCreate(BMS_BLKMEM *blkmem, SCIP_EXPR **expr, SCIP_EXPROP op, int nchildren, SCIP_EXPR **children, SCIP_EXPROPDATA opdata)
static SCIP_RETCODE exprParse(BMS_BLKMEM *blkmem, SCIP_MESSAGEHDLR *messagehdlr, SCIP_EXPR **expr, const char *str, int length, const char *lastchar, int *nvars, int **varnames, SCIP_HASHTABLE *vartable, int recursiondepth)
void SCIPsortPtrPtrInt(void **ptrarray1, void **ptrarray2, int *intarray, SCIP_DECL_SORTPTRCOMP((*ptrcomp)), int len)
SCIP_RETCODE SCIPexprtreeCopy(BMS_BLKMEM *blkmem, SCIP_EXPRTREE **targettree, SCIP_EXPRTREE *sourcetree)
int SCIPexprgraphGetNodeNParents(SCIP_EXPRGRAPHNODE *node)
void SCIPexprGetVarsUsage(SCIP_EXPR *expr, int *varsusage)
void SCIPintervalMin(SCIP_Real infinity, SCIP_INTERVAL *resultant, SCIP_INTERVAL operand1, SCIP_INTERVAL operand2)
SCIP_INTERVAL SCIPexprgraphGetNodeBounds(SCIP_EXPRGRAPHNODE *node)
SCIPInterval exp(const SCIPInterval &x)
SCIP_RETCODE SCIPexprgraphEval(SCIP_EXPRGRAPH *exprgraph, SCIP_Real *varvals)
void SCIPexprReindexVars(SCIP_EXPR *expr, int *newindices)
void SCIPintervalSetBounds(SCIP_INTERVAL *resultant, SCIP_Real inf, SCIP_Real sup)
#define SCIP_DECL_USEREXPRINTEVAL(x)
void SCIPintervalPowerScalar(SCIP_Real infinity, SCIP_INTERVAL *resultant, SCIP_INTERVAL operand1, SCIP_Real operand2)
int * SCIPexprgraphGetNNodes(SCIP_EXPRGRAPH *exprgraph)
#define BMSallocMemoryArray(ptr, num)
SCIP_RETCODE SCIPexprEvalInt(SCIP_EXPR *expr, SCIP_Real infinity, SCIP_INTERVAL *varvals, SCIP_Real *param, SCIP_INTERVAL *val)
SCIP_Bool SCIPstrToIntValue(const char *str, int *value, char **endptr)
void SCIPexprSortMonomialFactors(SCIP_EXPRDATA_MONOMIAL *monomial)
static void polynomialdataApplyChildmap(SCIP_EXPRDATA_POLYNOMIAL *polynomialdata, int *childmap)
static SCIP_DECL_EXPRCURV(exprcurvDefault)
SCIP_EXPRDATA_MONOMIAL ** monomials
static struct exprOpTableElement exprOpTable[]
#define BMSduplicateBlockMemory(mem, ptr, source)
SCIP_RETCODE SCIPexprgraphAddExprtreeSum(SCIP_EXPRGRAPH *exprgraph, int nexprtrees, SCIP_EXPRTREE **exprtrees, SCIP_Real *coefs, SCIP_EXPRGRAPHNODE **rootnode, SCIP_Bool *rootnodeisnew)
void * SCIPhashmapGetImage(SCIP_HASHMAP *hashmap, void *origin)
SCIP_RETCODE SCIPexprMultiplyMonomialByMonomial(BMS_BLKMEM *blkmem, SCIP_EXPRDATA_MONOMIAL *monomial, SCIP_EXPRDATA_MONOMIAL *factor, int *childmap)
SCIP_RETCODE SCIPexprtreeCreate(BMS_BLKMEM *blkmem, SCIP_EXPRTREE **tree, SCIP_EXPR *root, int nvars, int nparams, SCIP_Real *params)
SCIP_Bool SCIPquadelemSortedFind(SCIP_QUADELEM *quadelems, int idx1, int idx2, int nquadelems, int *pos)
unsigned int SCIP_EXPRINTCAPABILITY
void SCIPexprtreeSetParamVal(SCIP_EXPRTREE *tree, int paramidx, SCIP_Real paramval)
SCIP_RETCODE SCIPexprgraphFree(SCIP_EXPRGRAPH **exprgraph)
void SCIPintervalDiv(SCIP_Real infinity, SCIP_INTERVAL *resultant, SCIP_INTERVAL operand1, SCIP_INTERVAL operand2)
int SCIPexprgraphGetNodePolynomialNMonomials(SCIP_EXPRGRAPHNODE *node)
static void exprgraphPrintNodeDot(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE *node, SCIP_MESSAGEHDLR *messagehdlr, FILE *file, const char **varnames)
#define SCIP_EXPRESSION_MAXCHILDEST
static void exprgraphUpdateVarNodeBounds(SCIP_EXPRGRAPH *exprgraph, SCIP_Bool *clearreverseprop, SCIP_Bool *boundchanged)
void SCIPintervalSolveUnivariateQuadExpression(SCIP_Real infinity, SCIP_INTERVAL *resultant, SCIP_INTERVAL sqrcoeff, SCIP_INTERVAL lincoeff, SCIP_INTERVAL rhs)
SCIP_RETCODE SCIPexprgraphMoveNodeParents(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE **srcnode, SCIP_EXPRGRAPHNODE *targetnode)
SCIP_EXPRCURV SCIPexprcurvMonomial(int nfactors, SCIP_Real *exponents, int *factoridxs, SCIP_EXPRCURV *factorcurv, SCIP_INTERVAL *factorbounds)
SCIP_EXPRDATA_MONOMIAL ** SCIPexprGetMonomials(SCIP_EXPR *expr)
SCIP_RETCODE SCIPhashtableCreate(SCIP_HASHTABLE **hashtable, BMS_BLKMEM *blkmem, int tablesize, SCIP_DECL_HASHGETKEY((*hashgetkey)), SCIP_DECL_HASHKEYEQ((*hashkeyeq)), SCIP_DECL_HASHKEYVAL((*hashkeyval)), void *userptr)
static SCIP_DECL_EXPREVAL(exprevalVar)
public methods for expressions, expression trees, expression graphs, and related stuff ...
SCIP_EXPRCURV SCIPexprcurvMultiply(SCIP_Real factor, SCIP_EXPRCURV curvature)
int SCIPexprGetMonomialNFactors(SCIP_EXPRDATA_MONOMIAL *monomial)
int SCIPexprGetIntPowerExponent(SCIP_EXPR *expr)
void SCIPintervalSin(SCIP_Real infinity, SCIP_INTERVAL *resultant, SCIP_INTERVAL operand)
SCIP_Bool SCIPhashmapExists(SCIP_HASHMAP *hashmap, void *origin)
#define SCIP_EXPRINTCAPABILITY_INTFUNCVALUE
SCIP_RETCODE SCIPexprtreeCheckCurvature(SCIP_EXPRTREE *tree, SCIP_Real infinity, SCIP_INTERVAL *varbounds, SCIP_EXPRCURV *curv, SCIP_INTERVAL *bounds)
SCIP_EXPROP SCIPexprgraphGetNodeOperator(SCIP_EXPRGRAPHNODE *node)
static SCIP_RETCODE exprgraphCreateNode(BMS_BLKMEM *blkmem, SCIP_EXPRGRAPHNODE **node, SCIP_EXPROP op, SCIP_EXPROPDATA opdata)
SCIP_EXPRDATA_MONOMIAL ** SCIPexprgraphGetNodePolynomialMonomials(SCIP_EXPRGRAPHNODE *node)
SCIP_RETCODE SCIPexprgraphCreate(BMS_BLKMEM *blkmem, SCIP_EXPRGRAPH **exprgraph, int varssizeinit, int depthinit, SCIP_DECL_EXPRGRAPHVARADDED((*exprgraphvaradded)), SCIP_DECL_EXPRGRAPHVARREMOVE((*exprgraphvarremove)), SCIP_DECL_EXPRGRAPHVARCHGIDX((*exprgraphvarchgidx)), void *userdata)
#define SCIP_ALLOC_ABORT(x)
#define SCIP_DECL_EXPRGRAPHVARADDED(x)
int SCIPexprgraphGetNodeOperatorIndex(SCIP_EXPRGRAPHNODE *node)
void SCIPrandomFree(SCIP_RANDNUMGEN **randnumgen)
const char * SCIPexprcurvGetName(SCIP_EXPRCURV curv)
static const NodeData nodedata[]
SCIP_Real SCIPexprgraphGetNodeLinearConstant(SCIP_EXPRGRAPHNODE *node)
#define ensureBlockMemoryArraySize3(blkmem, array1, array2, array3, cursize, minsize)
#define BMSduplicateBlockMemoryArray(mem, ptr, source, num)
SCIP_Real SCIPexprgraphGetNodePolynomialConstant(SCIP_EXPRGRAPHNODE *node)
SCIP_RETCODE SCIPexprAddMonomials(BMS_BLKMEM *blkmem, SCIP_EXPR *expr, int nmonomials, SCIP_EXPRDATA_MONOMIAL **monomials, SCIP_Bool copymonomials)
SCIP_Bool SCIPexprgraphHasNodeNonlinearAncestor(SCIP_EXPRGRAPHNODE *node)
SCIP_EXPRCURV SCIPexprgraphGetNodeCurvature(SCIP_EXPRGRAPHNODE *node)
SCIP_RETCODE SCIPexprCreateQuadratic(BMS_BLKMEM *blkmem, SCIP_EXPR **expr, int nchildren, SCIP_EXPR **children, SCIP_Real constant, SCIP_Real *lincoefs, int nquadelems, SCIP_QUADELEM *quadelems)
SCIP_Bool SCIPexprgraphFindConstNode(SCIP_EXPRGRAPH *exprgraph, SCIP_Real constant, SCIP_EXPRGRAPHNODE **constnode)
SCIP_Bool SCIPintervalIsEntire(SCIP_Real infinity, SCIP_INTERVAL operand)
SCIP_RETCODE SCIPexprEval(SCIP_EXPR *expr, SCIP_Real *varvals, SCIP_Real *param, SCIP_Real *val)
void SCIPexprgraphSetVarsBounds(SCIP_EXPRGRAPH *exprgraph, SCIP_INTERVAL *varbounds)
union SCIP_ExprOpData SCIP_EXPROPDATA
static SCIP_Bool isUbBetter(SCIP_Real minstrength, SCIP_Real newub, SCIP_Real oldlb, SCIP_Real oldub)
#define BMSfreeMemoryArray(ptr)
SCIP_RETCODE SCIPexprgraphCheckCurvature(SCIP_EXPRGRAPH *exprgraph, SCIP_Real infinity, SCIP_Bool clearreverseprop)
SCIP_RETCODE SCIPexprGetMaxDegree(SCIP_EXPR *expr, int *maxdegree)
static void polynomialdataMultiplyByConstant(BMS_BLKMEM *blkmem, SCIP_EXPRDATA_POLYNOMIAL *polynomialdata, SCIP_Real factor)
enum SCIP_ExprOp SCIP_EXPROP
interval arithmetics for provable bounds
void SCIPintervalSetEmpty(SCIP_INTERVAL *resultant)
SCIP_RETCODE SCIPexprgraphCreateNodeUser(BMS_BLKMEM *blkmem, SCIP_EXPRGRAPHNODE **node, SCIP_USEREXPRDATA *data, SCIP_EXPRINTCAPABILITY evalcapability, SCIP_DECL_USEREXPREVAL((*eval)), SCIP_DECL_USEREXPRINTEVAL((*inteval)), SCIP_DECL_USEREXPRCURV((*curv)), SCIP_DECL_USEREXPRPROP((*prop)), SCIP_DECL_USEREXPRESTIMATE((*estimate)), SCIP_DECL_USEREXPRCOPYDATA((*copydata)), SCIP_DECL_USEREXPRFREEDATA((*freedata)), SCIP_DECL_USEREXPRPRINT((*print)))
void SCIPsortPtrRealInt(void **ptrarray, SCIP_Real *realarray, int *intarray, SCIP_DECL_SORTPTRCOMP((*ptrcomp)), int len)
SCIP_Real * SCIPexprGetQuadLinearCoefs(SCIP_EXPR *expr)
SCIP_EXPRGRAPHNODE *** SCIPexprgraphGetNodes(SCIP_EXPRGRAPH *exprgraph)
int SCIPexprgraphGetSumTreesNSummands(SCIP_EXPRGRAPHNODE *node)
static SCIP_RETCODE exprsimplifyRemovePolynomialNullChildren(BMS_BLKMEM *blkmem, SCIP_EXPR *expr)
void SCIPintervalLog(SCIP_Real infinity, SCIP_INTERVAL *resultant, SCIP_INTERVAL operand)
SCIP_RETCODE SCIPexprCopyDeep(BMS_BLKMEM *blkmem, SCIP_EXPR **targetexpr, SCIP_EXPR *sourceexpr)
static const char * curvnames[4]
SCIPInterval sqrt(const SCIPInterval &x)
SCIP_Bool SCIPexprgraphHasNodeUserEstimator(SCIP_EXPRGRAPHNODE *node)
static SCIP_DECL_EXPRCOPYDATA(exprCopyDataLinear)
SCIP_Bool SCIPsortedvecFindPtr(void **ptrarray, SCIP_DECL_SORTPTRCOMP((*ptrcomp)), void *val, int len, int *pos)
static SCIP_RETCODE quadraticdataCreate(BMS_BLKMEM *blkmem, SCIP_EXPRDATA_QUADRATIC **quadraticdata, SCIP_Real constant, int nchildren, SCIP_Real *lincoefs, int nquadelems, SCIP_QUADELEM *quadelems)
SCIPInterval sign(const SCIPInterval &x)
SCIP_EXPRCURV SCIPexprcurvPower(SCIP_INTERVAL basebounds, SCIP_EXPRCURV basecurv, SCIP_Real exponent)
SCIP_Real SCIPexprGetQuadConstant(SCIP_EXPR *expr)
void SCIPhashmapFree(SCIP_HASHMAP **hashmap)
static SCIP_RETCODE exprgraphNodeReplaceChild(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE *node, SCIP_EXPRGRAPHNODE **oldchild, SCIP_EXPRGRAPHNODE *newchild)
void SCIPmessagePrintWarning(SCIP_MESSAGEHDLR *messagehdlr, const char *formatstr,...)
SCIP_EXPRGRAPHNODE *** nodes
static SCIP_Bool exprgraphNodeIsParent(SCIP_EXPRGRAPHNODE *node, SCIP_EXPRGRAPHNODE *parent)
static void polynomialdataFree(BMS_BLKMEM *blkmem, SCIP_EXPRDATA_POLYNOMIAL **polynomialdata)
void SCIPexprMergeMonomials(BMS_BLKMEM *blkmem, SCIP_EXPR *expr, SCIP_Real eps, SCIP_Bool mergefactors)
int SCIPexprtreeGetNVars(SCIP_EXPRTREE *tree)
SCIP_Bool SCIPexprAreMonomialsEqual(SCIP_EXPRDATA_MONOMIAL *monomial1, SCIP_EXPRDATA_MONOMIAL *monomial2, SCIP_Real eps)
SCIP_EXPRGRAPHNODE ** varnodes
SCIP_RETCODE SCIPexprgraphCreateNodeLinear(BMS_BLKMEM *blkmem, SCIP_EXPRGRAPHNODE **node, int ncoefs, SCIP_Real *coefs, SCIP_Real constant)
SCIP_RETCODE SCIPexprgraphGetSeparableTrees(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE *node, int exprtreessize, int *nexprtrees, SCIP_EXPRTREE **exprtrees, SCIP_Real *exprtreecoefs)
void SCIPsortPtr(void **ptrarray, SCIP_DECL_SORTPTRCOMP((*ptrcomp)), int len)
SCIP_Bool SCIPexprgraphIsNodeEnabled(SCIP_EXPRGRAPHNODE *node)
SCIP_INTERVAL * SCIPexprgraphGetVarsBounds(SCIP_EXPRGRAPH *exprgraph)
SCIP_RETCODE SCIPexprParse(BMS_BLKMEM *blkmem, SCIP_MESSAGEHDLR *messagehdlr, SCIP_EXPR **expr, const char *str, const char *lastchar, int *nvars, int *varnames)
SCIP_RETCODE SCIPexprCreatePolynomial(BMS_BLKMEM *blkmem, SCIP_EXPR **expr, int nchildren, SCIP_EXPR **children, int nmonomials, SCIP_EXPRDATA_MONOMIAL **monomials, SCIP_Real constant, SCIP_Bool copymonomials)
SCIP_RETCODE SCIPexprCheckCurvature(SCIP_EXPR *expr, SCIP_Real infinity, SCIP_INTERVAL *varbounds, SCIP_Real *param, SCIP_EXPRCURV *curv, SCIP_INTERVAL *bounds)
SCIP_RETCODE SCIPexprEvalUser(SCIP_EXPR *expr, SCIP_Real *argvals, SCIP_Real *val, SCIP_Real *gradient, SCIP_Real *hessian)
void SCIPmessagePrintInfo(SCIP_MESSAGEHDLR *messagehdlr, const char *formatstr,...)
SCIP_RETCODE SCIPexprEvalShallow(SCIP_EXPR *expr, SCIP_Real *argvals, SCIP_Real *varvals, SCIP_Real *param, SCIP_Real *val)
void SCIPexprMultiplyPolynomialByConstant(BMS_BLKMEM *blkmem, SCIP_EXPR *expr, SCIP_Real factor)
void SCIPintervalSet(SCIP_INTERVAL *resultant, SCIP_Real value)
void SCIPexprgraphTightenNodeBounds(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE *node, SCIP_INTERVAL nodebounds, SCIP_Real minstrength, SCIP_Real infinity, SCIP_Bool *cutoff)
static SCIP_RETCODE exprsimplifyUnconvertPolynomials(BMS_BLKMEM *blkmem, SCIP_EXPR *expr)
SCIP_RETCODE SCIPexprEstimateUser(SCIP_EXPR *expr, SCIP_Real infinity, SCIP_Real *argvals, SCIP_INTERVAL *argbounds, SCIP_Bool overestimate, SCIP_Real *coeffs, SCIP_Real *constant, SCIP_Bool *success)
static SCIP_RETCODE exprgraphNodeUpdateBounds(SCIP_EXPRGRAPHNODE *node, SCIP_Real infinity, SCIP_Real minstrength, SCIP_Bool parenttightenisinvalid)
#define SCIP_DECL_USEREXPRCURV(x)
void SCIPexprFreeMonomial(BMS_BLKMEM *blkmem, SCIP_EXPRDATA_MONOMIAL **monomial)
SCIP_RETCODE SCIPexprMulConstant(BMS_BLKMEM *blkmem, SCIP_EXPR **expr, SCIP_EXPR *term, SCIP_Real factor)
SCIP_EXPR * SCIPexprtreeGetRoot(SCIP_EXPRTREE *tree)
SCIP_RETCODE SCIPexprCreateUser(BMS_BLKMEM *blkmem, SCIP_EXPR **expr, int nchildren, SCIP_EXPR **children, SCIP_USEREXPRDATA *data, SCIP_EXPRINTCAPABILITY evalcapability, SCIP_DECL_USEREXPREVAL((*eval)), SCIP_DECL_USEREXPRINTEVAL((*inteval)), SCIP_DECL_USEREXPRCURV((*curv)), SCIP_DECL_USEREXPRPROP((*prop)), SCIP_DECL_USEREXPRESTIMATE((*estimate)), SCIP_DECL_USEREXPRCOPYDATA((*copydata)), SCIP_DECL_USEREXPRFREEDATA((*freedata)), SCIP_DECL_USEREXPRPRINT((*print)))
SCIP_Bool SCIPsortedvecFindInt(int *intarray, int val, int len, int *pos)
SCIP_Bool SCIPexprgraphHasNodeSibling(SCIP_EXPRGRAPHNODE *node)
SCIP_RETCODE SCIPexprgraphGetNodePolynomialMonomialCurvature(SCIP_EXPRGRAPHNODE *node, int monomialidx, SCIP_Real infinity, SCIP_EXPRCURV *curv)
#define SCIP_DECL_USEREXPRESTIMATE(x)
#define SCIP_DECL_USEREXPRPROP(x)
SCIP_Real SCIPexprgraphGetNodeOperatorReal(SCIP_EXPRGRAPHNODE *node)
#define SCIP_EXPRBOUNDSTATUS_VALID
SCIP_RETCODE SCIPexprAdd(BMS_BLKMEM *blkmem, SCIP_EXPR **expr, SCIP_Real coef1, SCIP_EXPR *term1, SCIP_Real coef2, SCIP_EXPR *term2, SCIP_Real constant)
SCIP_Real SCIPexprgraphGetNodeQuadraticConstant(SCIP_EXPRGRAPHNODE *node)
#define BMSfreeBlockMemory(mem, ptr)
SCIP_RETCODE SCIPexprMultiplyPolynomialByPolynomial(BMS_BLKMEM *blkmem, SCIP_EXPR *expr, SCIP_EXPR *factor, int *childmap)
void SCIPexprMergeMonomialFactors(SCIP_EXPRDATA_MONOMIAL *monomial, SCIP_Real eps)
void SCIPintervalCos(SCIP_Real infinity, SCIP_INTERVAL *resultant, SCIP_INTERVAL operand)
SCIP_EXPRINTCAPABILITY SCIPexprGetUserEvalCapability(SCIP_EXPR *expr)
public data structures and miscellaneous methods
static void polynomialdataMergeMonomials(BMS_BLKMEM *blkmem, SCIP_EXPRDATA_POLYNOMIAL *polynomialdata, SCIP_Real eps, SCIP_Bool mergefactors)
SCIP_EXPR ** SCIPexprGetChildren(SCIP_EXPR *expr)
SCIP_Real SCIPexprGetSignPowerExponent(SCIP_EXPR *expr)
SCIP_EXPRGRAPHNODE ** children
SCIP_Bool needvarboundprop
static SCIP_RETCODE exprgraphNodeEval(SCIP_EXPRGRAPHNODE *node, SCIP_Real *varvals)
SCIP_USEREXPRDATA * userdata
SCIP_Bool SCIPexprgraphAreAllNodeChildrenVars(SCIP_EXPRGRAPHNODE *node)
SCIPInterval sin(const SCIPInterval &x)
#define BMSallocBlockMemoryArray(mem, ptr, num)
void SCIPexprSortQuadElems(SCIP_EXPR *expr)
static SCIP_RETCODE monomialdataEnsureFactorsSize(BMS_BLKMEM *blkmem, SCIP_EXPRDATA_MONOMIAL *monomialdata, int minsize)
void SCIPexprgraphSetVarNodeLb(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE *varnode, SCIP_Real lb)
static SCIP_RETCODE exprsimplifyFlattenPolynomials(BMS_BLKMEM *blkmem, SCIP_MESSAGEHDLR *messagehdlr, SCIP_EXPR *expr, SCIP_Real eps, int maxexpansionexponent)
static SCIP_RETCODE exprgraphNodeRemoveParent(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE **node, SCIP_EXPRGRAPHNODE *parent)
SCIP_EXPRINTDATA * SCIPexprtreeGetInterpreterData(SCIP_EXPRTREE *tree)
SCIP_RETCODE SCIPexprtreeFreeInterpreterData(SCIP_EXPRTREE *tree)
void SCIPintervalSolveBivariateQuadExpressionAllScalar(SCIP_Real infinity, SCIP_INTERVAL *resultant, SCIP_Real ax, SCIP_Real ay, SCIP_Real axy, SCIP_Real bx, SCIP_Real by, SCIP_INTERVAL rhs, SCIP_INTERVAL xbnds, SCIP_INTERVAL ybnds)
#define BMSfreeBlockMemoryArray(mem, ptr, num)
void SCIPquadelemSqueeze(SCIP_QUADELEM *quadelems, int nquadelems, int *nquadelemsnew)
SCIP_Bool SCIPexprHasUserEstimator(SCIP_EXPR *expr)
SCIP_Bool SCIPstrToRealValue(const char *str, SCIP_Real *value, char **endptr)
void SCIPintervalSquareRoot(SCIP_Real infinity, SCIP_INTERVAL *resultant, SCIP_INTERVAL operand)
void SCIPintervalQuadBivar(SCIP_Real infinity, SCIP_INTERVAL *resultant, SCIP_Real ax, SCIP_Real ay, SCIP_Real axy, SCIP_Real bx, SCIP_Real by, SCIP_INTERVAL xbnds, SCIP_INTERVAL ybnds)
SCIP_INTERVAL * varbounds
int SCIPexprGetNChildren(SCIP_EXPR *expr)
void SCIPexprgraphGetSubtreeVarsUsage(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE *node, int *varsusage)
void SCIPexprgraphSetVarNodeUb(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE *varnode, SCIP_Real ub)
static SCIP_Bool exprgraphFindConstNodePos(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE *node, int *pos)
void SCIPintervalSquare(SCIP_Real infinity, SCIP_INTERVAL *resultant, SCIP_INTERVAL operand)
SCIP_RETCODE SCIPexprgraphNodeSplitOffLinear(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE **node, int linvarssize, int *nlinvars, void **linvars, SCIP_Real *lincoefs, SCIP_Real *constant)
SCIP_RETCODE SCIPexprCreate(BMS_BLKMEM *blkmem, SCIP_EXPR **expr, SCIP_EXPROP op,...)
void SCIPintervalScalprodScalars(SCIP_Real infinity, SCIP_INTERVAL *resultant, int length, SCIP_INTERVAL *operand1, SCIP_Real *operand2)
SCIP_RETCODE SCIPexprtreeFree(SCIP_EXPRTREE **tree)
SCIP_Bool SCIPexprFindMonomialFactor(SCIP_EXPRDATA_MONOMIAL *monomial, int childidx, int *pos)
static SCIP_DECL_EXPRINTEVAL(exprevalIntDefault)
void SCIPexprgraphFreeNode(BMS_BLKMEM *blkmem, SCIP_EXPRGRAPHNODE **node)
void SCIPintervalAdd(SCIP_Real infinity, SCIP_INTERVAL *resultant, SCIP_INTERVAL operand1, SCIP_INTERVAL operand2)
static void exprgraphNodePropagateBounds(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE *node, SCIP_Real infinity, SCIP_Real minstrength, SCIP_Bool *cutoff)
#define SCIP_EXPRBOUNDSTATUS_CHILDTIGHTENED
void SCIPexprgraphDisableNode(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE *node)
#define BMScopyMemoryArray(ptr, source, num)
SCIPInterval log(const SCIPInterval &x)
SCIP_USEREXPRDATA * SCIPexprGetUserData(SCIP_EXPR *expr)
SCIP_RETCODE SCIPexprtreeAddExpr(SCIP_EXPRTREE *tree, SCIP_EXPR *expr, SCIP_Bool copyexpr)
void * SCIPhashtableRetrieve(SCIP_HASHTABLE *hashtable, void *key)
#define SCIP_EXPR_DEGREEINFINITY
SCIP_EXPRGRAPHNODE ** parents
void SCIPintervalAbs(SCIP_Real infinity, SCIP_INTERVAL *resultant, SCIP_INTERVAL operand)
#define BMSclearMemory(ptr)
SCIP_Real SCIPexprGetMonomialCoef(SCIP_EXPRDATA_MONOMIAL *monomial)
static SCIP_RETCODE polynomialdataCopy(BMS_BLKMEM *blkmem, SCIP_EXPRDATA_POLYNOMIAL **polynomialdata, SCIP_EXPRDATA_POLYNOMIAL *sourcepolynomialdata)
static SCIP_DECL_SORTPTRCOMP(ptrcomp)
static SCIP_RETCODE polynomialdataExpandMonomialFactor(BMS_BLKMEM *blkmem, SCIP_MESSAGEHDLR *messagehdlr, SCIP_EXPRDATA_POLYNOMIAL *polynomialdata, int monomialpos, int factorpos, SCIP_EXPRDATA_POLYNOMIAL *factorpolynomial, int *childmap, int maxexpansionexponent, SCIP_Bool *success)
void * SCIPexprgraphGetNodeVar(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE *node)
void * SCIPexprGetOpData(SCIP_EXPR *expr)
SCIP_Real SCIPrandomGetReal(SCIP_RANDNUMGEN *randnumgen, SCIP_Real minrandval, SCIP_Real maxrandval)
SCIP_Real * SCIPexprgraphGetNodeQuadraticLinearCoefs(SCIP_EXPRGRAPHNODE *node)
void SCIPhashtableFree(SCIP_HASHTABLE **hashtable)
static SCIP_RETCODE exprConvertToPolynomial(BMS_BLKMEM *blkmem, SCIP_EXPROP *op, SCIP_EXPROPDATA *data, int nchildren)
SCIP_RETCODE SCIPexprEvalIntUser(SCIP_EXPR *expr, SCIP_Real infinity, SCIP_INTERVAL *argvals, SCIP_INTERVAL *val, SCIP_INTERVAL *gradient, SCIP_INTERVAL *hessian)
int SCIPexprgraphGetNodeIntPowerExponent(SCIP_EXPRGRAPHNODE *node)
SCIP_EXPRGRAPHNODE ** SCIPexprgraphGetNodeParents(SCIP_EXPRGRAPHNODE *node)
SCIP_QUADELEM * quadelems
static void exprgraphNodeSortParents(SCIP_EXPRGRAPHNODE *node)
#define SCIP_DECL_EXPRGRAPHVARREMOVE(x)
static SCIP_RETCODE exprgraphAddExpr(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPR *expr, void **vars, SCIP_Real *params, SCIP_EXPRGRAPHNODE **exprnode, SCIP_Bool *exprnodeisnew)
static SCIP_RETCODE polynomialdataAddMonomials(BMS_BLKMEM *blkmem, SCIP_EXPRDATA_POLYNOMIAL *polynomialdata, int nmonomials, SCIP_EXPRDATA_MONOMIAL **monomials, SCIP_Bool copymonomials)
enum SCIP_ExprCurv SCIP_EXPRCURV
int SCIPexpropGetNChildren(SCIP_EXPROP op)
static void quadraticdataSort(SCIP_EXPRDATA_QUADRATIC *quadraticdata)
#define SCIP_VARTYPE_IMPLINT_CHAR
SCIP_EXPRINTDATA * interpreterdata
SCIP_RETCODE SCIPhashmapRemove(SCIP_HASHMAP *hashmap, void *origin)
SCIP_Bool SCIPexprgraphFindVarNode(SCIP_EXPRGRAPH *exprgraph, void *var, SCIP_EXPRGRAPHNODE **varnode)
void SCIPexprReindexParams(SCIP_EXPR *expr, int *newindices)
SCIP_Real * SCIPexprgraphGetNodeLinearCoefs(SCIP_EXPRGRAPHNODE *node)
#define SCIP_EXPRINTCAPABILITY_FUNCVALUE
SCIP_Real * SCIPexprGetLinearCoefs(SCIP_EXPR *expr)
SCIP_Bool SCIPexprtreeHasParam(SCIP_EXPRTREE *tree)
void SCIPintervalSetEntire(SCIP_Real infinity, SCIP_INTERVAL *resultant)
SCIP_Real SCIPexprGetOpReal(SCIP_EXPR *expr)
int SCIPexprgraphGetNodePosition(SCIP_EXPRGRAPHNODE *node)
static SCIP_Bool isLbBetter(SCIP_Real minstrength, SCIP_Real newlb, SCIP_Real oldlb, SCIP_Real oldub)
SCIP_RETCODE SCIPexprgraphNodePolynomialAddMonomials(BMS_BLKMEM *blkmem, SCIP_EXPRGRAPHNODE *node, int nmonomials, SCIP_EXPRDATA_MONOMIAL **monomials, SCIP_Bool copymonomials)
#define SCIP_VARTYPE_CONTINUOUS_CHAR
SCIP_EXPRGRAPHNODE ** constnodes
void SCIPexprFreeShallow(BMS_BLKMEM *blkmem, SCIP_EXPR **expr)
SCIP_QUADELEM * SCIPexprGetQuadElements(SCIP_EXPR *expr)
SCIP_RETCODE SCIPexprgraphCreateNodePolynomial(BMS_BLKMEM *blkmem, SCIP_EXPRGRAPHNODE **node, int nmonomials, SCIP_EXPRDATA_MONOMIAL **monomials, SCIP_Real constant, SCIP_Bool copymonomials)
void SCIPintervalExp(SCIP_Real infinity, SCIP_INTERVAL *resultant, SCIP_INTERVAL operand)
public methods for message output
SCIP_USEREXPRDATA * SCIPexprgraphGetNodeUserData(SCIP_EXPRGRAPHNODE *node)
static SCIP_RETCODE exprsimplifySeparateLinearFromPolynomial(BMS_BLKMEM *blkmem, SCIP_EXPR *expr, SCIP_Real eps, int nvars, int *nlinvars, int *linidxs, SCIP_Real *lincoefs)
SCIP_RETCODE SCIPexprgraphCreateNode(BMS_BLKMEM *blkmem, SCIP_EXPRGRAPHNODE **node, SCIP_EXPROP op,...)
SCIP_RETCODE SCIPexprEvalIntShallow(SCIP_EXPR *expr, SCIP_Real infinity, SCIP_INTERVAL *argvals, SCIP_INTERVAL *varvals, SCIP_Real *param, SCIP_INTERVAL *val)
SCIP_RETCODE SCIPexprgraphReleaseNode(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE **node)
int SCIPexprGetNMonomials(SCIP_EXPR *expr)
#define SCIP_EXPRBOUNDSTATUS_TIGHTENEDBYPARENTFORCE
void SCIPmessageFPrintInfo(SCIP_MESSAGEHDLR *messagehdlr, FILE *file, const char *formatstr,...)
SCIP_RETCODE SCIPhashmapSetImage(SCIP_HASHMAP *hashmap, void *origin, void *image)
SCIP_RETCODE SCIPexprtreeSimplify(SCIP_EXPRTREE *tree, SCIP_MESSAGEHDLR *messagehdlr, SCIP_Real eps, int maxexpansionexponent, int *nlinvars, int *linidxs, SCIP_Real *lincoefs)
SCIP_RETCODE SCIPexprgraphGetTree(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE *rootnode, SCIP_EXPRTREE **exprtree)
#define SCIP_DECL_USEREXPRCOPYDATA(x)
void SCIPintervalIntersect(SCIP_INTERVAL *resultant, SCIP_INTERVAL operand1, SCIP_INTERVAL operand2)
static SCIP_RETCODE polynomialdataCreate(BMS_BLKMEM *blkmem, SCIP_EXPRDATA_POLYNOMIAL **polynomialdata, int nmonomials, SCIP_EXPRDATA_MONOMIAL **monomials, SCIP_Real constant, SCIP_Bool copymonomials)
void SCIPintervalMulScalar(SCIP_Real infinity, SCIP_INTERVAL *resultant, SCIP_INTERVAL operand1, SCIP_Real operand2)
SCIP_EXPRGRAPHNODE ** SCIPexprgraphGetNodeChildren(SCIP_EXPRGRAPHNODE *node)
void SCIPsortPtrReal(void **ptrarray, SCIP_Real *realarray, SCIP_DECL_SORTPTRCOMP((*ptrcomp)), int len)
SCIP_RETCODE SCIPexprAddMonomialFactors(BMS_BLKMEM *blkmem, SCIP_EXPRDATA_MONOMIAL *monomial, int nfactors, int *childidxs, SCIP_Real *exponents)
SCIP_Real * SCIPexprGetMonomialExponents(SCIP_EXPRDATA_MONOMIAL *monomial)
void SCIPexprgraphPrintNode(SCIP_EXPRGRAPHNODE *node, SCIP_MESSAGEHDLR *messagehdlr, FILE *file)
SCIP_RETCODE SCIPexprtreeSubstituteVars(SCIP_EXPRTREE *tree, SCIP_EXPR **substexprs)
static SCIP_RETCODE exprgraphNodeEvalWithChildren(SCIP_EXPRGRAPHNODE *node, SCIP_Real *varvals)
#define SCIP_VARTYPE_BINARY_CHAR
int SCIPexprtreeGetNParams(SCIP_EXPRTREE *tree)
SCIP_RETCODE SCIPexprgraphSimplify(SCIP_EXPRGRAPH *exprgraph, SCIP_MESSAGEHDLR *messagehdlr, SCIP_Real eps, int maxexpansionexponent, SCIP_Bool *havechange, SCIP_Bool *domainerror)
static SCIP_RETCODE exprsimplifyRemovePolynomialUnusedChildren(BMS_BLKMEM *blkmem, SCIP_EXPR *expr)
void SCIPintervalSub(SCIP_Real infinity, SCIP_INTERVAL *resultant, SCIP_INTERVAL operand1, SCIP_INTERVAL operand2)
static SCIP_RETCODE exprgraphMoveNode(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE *node, int newdepth)
static SCIP_RETCODE exprparseFindClosingParenthesis(const char *str, const char **endptr, int length)
SCIP_RETCODE SCIPexprAddToLinear(BMS_BLKMEM *blkmem, SCIP_EXPR *expr, int nchildren, SCIP_Real *coefs, SCIP_EXPR **children, SCIP_Real constant)
static SCIP_RETCODE exprsimplifyAddChildren(BMS_BLKMEM *blkmem, SCIP_EXPR *expr, int nexprs, SCIP_EXPR **exprs, SCIP_Bool comparechildren, SCIP_Real eps, int *childmap)
#define BMSallocBlockMemory(mem, ptr)
SCIP_RETCODE SCIPexprMultiplyPolynomialByMonomial(BMS_BLKMEM *blkmem, SCIP_EXPR *expr, SCIP_EXPRDATA_MONOMIAL *factor, int *childmap)
SCIP_Real SCIPexprgraphGetNodeRealPowerExponent(SCIP_EXPRGRAPHNODE *node)
SCIP_RETCODE SCIPexprintFreeData(SCIP_EXPRINTDATA **interpreterdata)
SCIP_RETCODE SCIPhashmapInsert(SCIP_HASHMAP *hashmap, void *origin, void *image)
#define BMSclearMemoryArray(ptr, num)
static SCIP_DECL_HASHGETKEY(exprparseVarTableGetKey)
struct BMS_BlkMem BMS_BLKMEM
int SCIPexprgraphGetNodeQuadraticNQuadElements(SCIP_EXPRGRAPHNODE *node)
static SCIP_RETCODE polynomialdataPower(BMS_BLKMEM *blkmem, SCIP_EXPRDATA_POLYNOMIAL *polynomialdata, int exponent)
#define SCIP_CALL_ABORT(x)
void ** SCIPexprgraphGetVars(SCIP_EXPRGRAPH *exprgraph)
#define SCIP_EXPRBOUNDSTATUS_TIGHTENEDBYPARENTRECENT
SCIP_RETCODE SCIPexprCreateLinear(BMS_BLKMEM *blkmem, SCIP_EXPR **expr, int nchildren, SCIP_EXPR **children, SCIP_Real *coefs, SCIP_Real constant)
void SCIPintervalAddScalar(SCIP_Real infinity, SCIP_INTERVAL *resultant, SCIP_INTERVAL operand1, SCIP_Real operand2)
SCIP_Real SCIPexprGetLinearConstant(SCIP_EXPR *expr)
void SCIPexprtreeSetInterpreterData(SCIP_EXPRTREE *tree, SCIP_EXPRINTDATA *interpreterdata)
SCIP_EXPRCURV SCIPexprcurvAdd(SCIP_EXPRCURV curv1, SCIP_EXPRCURV curv2)
struct SCIP_ExprIntData SCIP_EXPRINTDATA
static void quadelemsQuickSort(SCIP_QUADELEM *elems, int start, int end)
static SCIP_RETCODE polynomialdataEnsureMonomialsSize(BMS_BLKMEM *blkmem, SCIP_EXPRDATA_POLYNOMIAL *polynomialdata, int minsize)
SCIP_RETCODE SCIPexprtreeSetParams(SCIP_EXPRTREE *tree, int nparams, SCIP_Real *paramvals)
SCIP_ROUNDMODE SCIPintervalGetRoundingMode(void)
int SCIPexprGetNQuadElements(SCIP_EXPR *expr)
static void exprgraphPrintNodeExpression(SCIP_EXPRGRAPHNODE *node, SCIP_MESSAGEHDLR *messagehdlr, FILE *file, const char **varnames, SCIP_Bool printchildrenbounds)
#define SCIP_DECL_USEREXPRFREEDATA(x)
static SCIP_RETCODE exprgraphFindParentByOperator(SCIP_EXPRGRAPH *exprgraph, int nchildren, SCIP_EXPRGRAPHNODE **children, SCIP_EXPROP op, SCIP_EXPROPDATA opdata, SCIP_EXPR **exprchildren, SCIP_EXPRGRAPHNODE **parent)
static void exprgraphNodeGetVarsUsage(SCIP_EXPRGRAPHNODE *node, int *varsusage)
SCIP_RETCODE SCIPexprgraphPrintDot(SCIP_EXPRGRAPH *exprgraph, SCIP_MESSAGEHDLR *messagehdlr, FILE *file, const char **varnames)
#define BMSreallocBlockMemoryArray(mem, ptr, oldnum, newnum)
void SCIPintervalSetRoundingModeDownwards(void)
void SCIPintervalPowerScalarInverse(SCIP_Real infinity, SCIP_INTERVAL *resultant, SCIP_INTERVAL basedomain, SCIP_Real exponent, SCIP_INTERVAL image)
int SCIPexprgraphGetNodeDepth(SCIP_EXPRGRAPHNODE *node)
#define ensureBlockMemoryArraySize(blkmem, array1, cursize, minsize)
SCIP_EXPRCURV SCIPexprcurvNegate(SCIP_EXPRCURV curvature)
SCIP_RETCODE SCIPexprtreeEval(SCIP_EXPRTREE *tree, SCIP_Real *varvals, SCIP_Real *val)
SCIP_EXPRINTCAPABILITY evalcapability
void SCIPexprgraphSetVarBounds(SCIP_EXPRGRAPH *exprgraph, void *var, SCIP_INTERVAL varbounds)
void SCIPsortIntReal(int *intarray, SCIP_Real *realarray, int len)
static SCIP_RETCODE exprgraphRemoveVar(SCIP_EXPRGRAPH *exprgraph, int varidx)
#define SCIP_DECL_EXPRGRAPHVARCHGIDX(x)
void SCIPintervalQuad(SCIP_Real infinity, SCIP_INTERVAL *resultant, SCIP_Real sqrcoeff, SCIP_INTERVAL lincoeff, SCIP_INTERVAL xrng)
void SCIPexprgraphEnableNode(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE *node)
SCIP_QUADELEM * SCIPexprgraphGetNodeQuadraticQuadElements(SCIP_EXPRGRAPHNODE *node)