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);
131 assert(node1 !=
NULL);
132 assert(node2 !=
NULL);
133 assert(node1->
depth >= 0);
134 assert(node1->
pos >= 0);
135 assert(node2->
depth >= 0);
136 assert(node2->
pos >= 0);
142 assert((node1->
pos != node2->
pos) || (node1 == node2));
144 return node1->
pos - node2->
pos;
163 eps =
MIN(oldub - oldlb, eps);
164 return EPSGT(newlb, oldlb, minstrength *
MAX(eps, 1e-3));
183 eps =
MIN(oldub - oldlb, eps);
184 return EPSLT(newub, oldub, minstrength *
MAX(eps, 1e-3));
202 #undef SCIPexprcurvAdd 261 assert(basebounds.
inf <= basebounds.
sup);
263 if( exponent == 0.0 )
266 if( exponent == 1.0 )
274 if( !expisint && basebounds.
inf < 0.0 )
276 basebounds.
inf = 0.0;
277 if( basebounds.
sup < 0.0 )
282 if( basebounds.
inf < 0.0 && basebounds.
sup > 0.0 )
296 assert(basebounds.
inf >= 0.0 || basebounds.
sup <= 0.0);
326 sign = exponent * (exponent - 1.0);
327 assert(basebounds.
inf >= 0.0 || expisint);
328 if( basebounds.
inf < 0.0 && ((
int)exponent)%2 != 0 )
337 if( basebounds.
sup <= 0.0 && exponent < 0.0 && expisint )
339 if( basebounds.
inf >= 0.0 && exponent > 1.0 )
346 if( basebounds.
sup <= 0.0 && exponent > 1.0 && expisint )
348 if( basebounds.
inf >= 0.0 && exponent < 1.0 )
381 assert(nfactors >= 0);
382 assert(factorcurv !=
NULL || nfactors == 0);
383 assert(factorbounds !=
NULL || nfactors == 0);
390 f = factoridxs !=
NULL ? factoridxs[0] : 0;
391 e = exponents !=
NULL ? exponents[0] : 1.0;
406 for( j = 0; j < nfactors; ++j )
408 f = factoridxs !=
NULL ? factoridxs[j] : j;
411 if( factorbounds[f].inf < 0.0 && factorbounds[f].sup > 0.0 )
414 e = exponents !=
NULL ? exponents[j] : 1.0;
421 if( factorbounds[f].inf < 0.0 )
432 if( (
int)e % 2 != 0 )
437 fcurv = factorcurv[f];
460 if( nnegative == nfactors && expcurvpos )
462 else if( nnegative == nfactors-1 &&
EPSGE(sum, 1.0, 1e-9) && expcurvpos )
464 else if( npositive == nfactors &&
EPSLE(sum, 1.0, 1e-9) && expcurvneg )
500 assert(blkmem !=
NULL);
501 assert(quadraticdata !=
NULL);
502 assert(quadelems !=
NULL || nquadelems == 0);
503 assert(nchildren >= 0);
507 (*quadraticdata)->constant = constant;
508 (*quadraticdata)->lincoefs =
NULL;
509 (*quadraticdata)->nquadelems = nquadelems;
510 (*quadraticdata)->quadelems =
NULL;
511 (*quadraticdata)->sorted = (nquadelems <= 1);
513 if( lincoefs !=
NULL )
532 assert(quadraticdata !=
NULL);
534 if( quadraticdata->
sorted )
538 for( i = 1; i < quadraticdata->
nquadelems; ++i )
571 assert(elem1 !=
NULL);
572 assert(elem2 !=
NULL);
609 assert(blkmem !=
NULL);
610 assert(monomialdata !=
NULL);
621 assert(minsize <= monomialdata->factorssize);
637 assert(blkmem !=
NULL);
638 assert(polynomialdata !=
NULL);
639 assert(monomials !=
NULL || nmonomials == 0);
643 (*polynomialdata)->constant = constant;
644 (*polynomialdata)->nmonomials = nmonomials;
645 (*polynomialdata)->monomialssize = nmonomials;
646 (*polynomialdata)->monomials =
NULL;
647 (*polynomialdata)->sorted = (nmonomials <= 1);
657 for( i = 0; i < nmonomials; ++i )
659 assert(monomials[i] !=
NULL);
681 assert(blkmem !=
NULL);
682 assert(polynomialdata !=
NULL);
683 assert(sourcepolynomialdata !=
NULL);
687 (*polynomialdata)->monomialssize = sourcepolynomialdata->
nmonomials;
694 for( i = 0; i < sourcepolynomialdata->
nmonomials; ++i )
699 (*polynomialdata)->monomials[i]->sorted = sourcepolynomialdata->
monomials[i]->
sorted;
704 (*polynomialdata)->monomials =
NULL;
717 assert(blkmem !=
NULL);
718 assert(polynomialdata !=
NULL);
719 assert(*polynomialdata !=
NULL);
721 if( (*polynomialdata)->monomialssize > 0 )
725 for( i = 0; i < (*polynomialdata)->nmonomials; ++i )
727 assert((*polynomialdata)->monomials[i] !=
NULL);
729 assert((*polynomialdata)->monomials[i] ==
NULL);
734 assert((*polynomialdata)->monomials ==
NULL);
747 assert(blkmem !=
NULL);
748 assert(polynomialdata !=
NULL);
751 assert(minsize <= polynomialdata->monomialssize);
768 assert(blkmem !=
NULL);
769 assert(polynomialdata !=
NULL);
770 assert(monomials !=
NULL || nmonomials == 0);
772 if( nmonomials == 0 )
780 for( i = 0; i < nmonomials; ++i )
782 assert(monomials[i] !=
NULL);
804 assert(polynomialdata !=
NULL);
806 if( polynomialdata->
sorted )
812 for( i = 1; i < polynomialdata->
nmonomials; ++i )
816 assert(monomialdataCompare(polynomialdata->
monomials[i-1], polynomialdata->
monomials[i]) <= 0);
844 assert(polynomialdata !=
NULL);
852 while( i + offset < polynomialdata->nmonomials )
874 while( i+offset+1 < polynomialdata->
nmonomials )
886 if( monomialdataCompare((
void*)polynomialdata->
monomials[i], (
void*)polynomialdata->
monomials[i+offset+1]) != 0 )
933 assert(polynomialdata !=
NULL);
940 for( i = 0; i < polynomialdata->
nmonomials; ++i )
946 for( i = 0; i < polynomialdata->
nmonomials; ++i )
964 assert(blkmem !=
NULL);
965 assert(factor !=
NULL);
966 assert(polynomialdata !=
NULL);
975 for( i = 0; i < polynomialdata->
nmonomials; ++i )
981 if( polynomialdata->
constant != 0.0 )
1010 assert(blkmem !=
NULL);
1011 assert(polynomialdata !=
NULL);
1012 assert(factordata !=
NULL);
1013 assert(polynomialdata != factordata);
1028 if( polynomialdata->
constant != 0.0 )
1042 for( i2 = 0; i2 < factordata->
nmonomials; ++i2 )
1045 assert(polynomialdata->
nmonomials + orignmonomials <= polynomialdata->monomialssize);
1047 assert(polynomialdata->
nmonomials == (i2+2) * orignmonomials);
1050 for( i1 = (i2+1) * orignmonomials; i1 < (i2+2) * orignmonomials; ++i1 )
1066 for( i1 = 0; i1 < orignmonomials; ++i1 )
1073 for( i1 = 0; i1 < orignmonomials; ++i1 )
1097 assert(blkmem !=
NULL);
1098 assert(polynomialdata !=
NULL);
1111 for( i = 0; i < polynomialdata->
nmonomials; ++i )
1136 assert(exponent >= 2);
1144 for( i = 2; i <= exponent; ++i )
1167 assert(polynomialdata !=
NULL);
1169 for( i = 0; i < polynomialdata->
nmonomials; ++i )
1171 monomial = polynomialdata->
monomials[i];
1172 assert(monomial !=
NULL);
1174 for( j = 0; j < monomial->
nfactors; ++j )
1195 int maxexpansionexponent,
1203 assert(blkmem !=
NULL);
1204 assert(polynomialdata !=
NULL);
1205 assert(factorpolynomial !=
NULL);
1207 assert(success !=
NULL);
1208 assert(monomialpos >= 0);
1209 assert(monomialpos < polynomialdata->nmonomials);
1210 assert(factorpos >= 0);
1212 monomial = polynomialdata->
monomials[monomialpos];
1213 assert(monomial !=
NULL);
1214 assert(factorpos < monomial->nfactors);
1232 if( factorpos < monomial->nfactors-1 )
1251 factormonomial = factorpolynomial->
monomials[0];
1252 assert(factormonomial !=
NULL);
1256 if( factormonomial->
coef < 0.0 )
1278 for( i = 0; i < factormonomial->
nfactors; ++i )
1280 childidx = childmap[factormonomial->
childidxs[i]];
1291 if( factorpos < monomial->nfactors-1 )
1311 if( monomial->
exponents[factorpos] > maxexpansionexponent )
1322 if( maxexpansionexponent < INT_MAX && (monomial->
nfactors > 1 || monomial->
exponents[factorpos] != 1.0) )
1328 restdegree = -monomial->
exponents[factorpos];
1329 for( i = 0; i < monomial->
nfactors; ++i )
1334 SCIPdebugMessage(
"skip expansion because factor %d in monomial has negative exponent\n", i);
1341 for( i = 0; i < factorpolynomial->
nmonomials; ++i )
1349 SCIPdebugMessage(
"skip expansion because %d'th factor in %d'th monomial of factorpolynomial is negative\n", i, j);
1355 if( degree * monomial->
exponents[factorpos] + restdegree > maxexpansionexponent )
1358 SCIPdebugMessage(
"skip expansion because degree of %d'th monomial would yield degree %g > max = %d in expansion\n",
1359 i, degree * monomial->
exponents[factorpos] + restdegree, maxexpansionexponent);
1374 if( factorpos < monomial->nfactors-1 )
1387 if( monomialpos < polynomialdata->nmonomials-1 )
1429 assert(result !=
NULL);
1430 assert(varvals !=
NULL);
1432 *result = varvals[opdata.intval];
1441 assert(result !=
NULL);
1442 assert(varvals !=
NULL);
1444 *result = varvals[opdata.intval];
1453 assert(result !=
NULL);
1464 assert(result !=
NULL);
1466 *result = opdata.dbl;
1475 assert(result !=
NULL);
1486 assert(result !=
NULL);
1497 assert(result !=
NULL);
1498 assert(paramvals !=
NULL );
1500 *result = paramvals[opdata.intval];
1509 assert(result !=
NULL);
1510 assert(paramvals !=
NULL );
1521 assert(result !=
NULL);
1532 assert(result !=
NULL);
1533 assert(argvals !=
NULL);
1535 *result = argvals[0] + argvals[1];
1544 assert(result !=
NULL);
1545 assert(argvals !=
NULL);
1556 assert(result !=
NULL);
1557 assert(argcurv !=
NULL);
1568 assert(result !=
NULL);
1569 assert(argvals !=
NULL);
1571 *result = argvals[0] - argvals[1];
1580 assert(result !=
NULL);
1581 assert(argvals !=
NULL);
1592 assert(result !=
NULL);
1593 assert(argcurv !=
NULL);
1604 assert(result !=
NULL);
1605 assert(argvals !=
NULL);
1607 *result = argvals[0] * argvals[1];
1616 assert(result !=
NULL);
1617 assert(argvals !=
NULL);
1628 assert(result !=
NULL);
1629 assert(argcurv !=
NULL);
1630 assert(argbounds !=
NULL);
1639 if( argbounds[1].inf == argbounds[1].sup )
1641 else if( argbounds[0].inf == argbounds[0].sup )
1651 #if defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ * 10 >= 490 && !defined(__INTEL_COMPILER) 1652 __attribute__((no_sanitize_undefined))
1656 assert(result !=
NULL);
1657 assert(argvals !=
NULL);
1659 *result = argvals[0] / argvals[1];
1668 assert(result !=
NULL);
1669 assert(argvals !=
NULL);
1680 assert(result !=
NULL);
1681 assert(argcurv !=
NULL);
1682 assert(argbounds !=
NULL);
1696 if( argbounds[1].inf == argbounds[1].sup )
1701 else if( argbounds[0].inf == argbounds[0].sup )
1724 assert(result !=
NULL);
1725 assert(argvals !=
NULL);
1727 *result = argvals[0] * argvals[0];
1736 assert(result !=
NULL);
1737 assert(argvals !=
NULL);
1748 assert(result !=
NULL);
1749 assert(argcurv !=
NULL);
1750 assert(argbounds !=
NULL);
1761 assert(result !=
NULL);
1762 assert(argvals !=
NULL);
1764 *result =
sqrt(argvals[0]);
1773 assert(result !=
NULL);
1774 assert(argvals !=
NULL);
1785 assert(result !=
NULL);
1786 assert(argcurv !=
NULL);
1804 assert(result !=
NULL);
1805 assert(argvals !=
NULL);
1807 *result =
pow(argvals[0], opdata.dbl);
1816 assert(result !=
NULL);
1817 assert(argvals !=
NULL);
1828 assert(result !=
NULL);
1829 assert(argcurv !=
NULL);
1830 assert(argbounds !=
NULL);
1839 #if defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ * 10 >= 490 && !defined(__INTEL_COMPILER) 1840 __attribute__((no_sanitize_undefined))
1844 assert(result !=
NULL);
1845 assert(argvals !=
NULL);
1847 switch( opdata.intval )
1850 *result = 1.0 / argvals[0];
1858 *result = argvals[0];
1862 *result = argvals[0] * argvals[0];
1876 assert(result !=
NULL);
1877 assert(argvals !=
NULL);
1888 assert(result !=
NULL);
1889 assert(argcurv !=
NULL);
1890 assert(argbounds !=
NULL);
1901 assert(result !=
NULL);
1902 assert(argvals !=
NULL);
1904 if( argvals[0] > 0 )
1905 *result =
pow( argvals[0], opdata.dbl);
1907 *result = -
pow(-argvals[0], opdata.dbl);
1916 assert(result !=
NULL);
1917 assert(argvals !=
NULL);
1932 assert(result !=
NULL);
1933 assert(argcurv !=
NULL);
1934 assert(argbounds !=
NULL);
1942 if( argbounds[0].inf < 0 )
1952 if( argbounds[0].sup > 0 )
1971 assert(result !=
NULL);
1972 assert(argvals !=
NULL);
1974 *result =
exp(argvals[0]);
1983 assert(result !=
NULL);
1984 assert(argvals !=
NULL);
1995 assert(result !=
NULL);
1996 assert(argcurv !=
NULL);
2013 assert(result !=
NULL);
2014 assert(argvals !=
NULL);
2016 *result =
log(argvals[0]);
2025 assert(result !=
NULL);
2026 assert(argvals !=
NULL);
2037 assert(result !=
NULL);
2038 assert(argcurv !=
NULL);
2055 assert(result !=
NULL);
2056 assert(argvals !=
NULL);
2058 *result =
sin(argvals[0]);
2067 assert(result !=
NULL);
2068 assert(argvals !=
NULL);
2077 #define exprcurvSin exprcurvDefault 2083 assert(result !=
NULL);
2084 assert(argvals !=
NULL);
2086 *result =
cos(argvals[0]);
2095 assert(result !=
NULL);
2096 assert(argvals !=
NULL);
2105 #define exprcurvCos exprcurvDefault 2111 assert(result !=
NULL);
2112 assert(argvals !=
NULL);
2114 *result = tan(argvals[0]);
2120 #define exprevalIntTan exprevalIntDefault 2123 #define exprcurvTan exprcurvDefault 2126 #ifdef SCIP_DISABLED_CODE 2130 assert(result !=
NULL);
2131 assert(argvals !=
NULL);
2133 *result = erf(argvals[0]);
2139 #define exprevalIntErf exprevalIntDefault 2142 #define exprcurvErf exprcurvDefault 2147 assert(result !=
NULL);
2148 assert(argvals !=
NULL);
2157 #define exprevalIntErfi NULL 2159 #define exprcurvErfi exprcurvDefault 2166 assert(result !=
NULL);
2167 assert(argvals !=
NULL);
2169 *result =
MIN(argvals[0], argvals[1]);
2178 assert(result !=
NULL);
2179 assert(argvals !=
NULL);
2190 assert(result !=
NULL);
2191 assert(argcurv !=
NULL);
2209 assert(result !=
NULL);
2210 assert(argvals !=
NULL);
2212 *result =
MAX(argvals[0], argvals[1]);
2221 assert(result !=
NULL);
2222 assert(argvals !=
NULL);
2233 assert(result !=
NULL);
2234 assert(argcurv !=
NULL);
2251 assert(result !=
NULL);
2252 assert(argvals !=
NULL);
2254 *result = ABS(argvals[0]);
2263 assert(result !=
NULL);
2264 assert(argvals !=
NULL);
2275 assert(result !=
NULL);
2276 assert(argcurv !=
NULL);
2277 assert(argbounds !=
NULL);
2284 if( argbounds[0].sup <= 0.0 )
2286 else if( argbounds[0].inf >= 0.0 )
2287 *result = argcurv[0];
2300 assert(result !=
NULL);
2301 assert(argvals !=
NULL);
2303 *result =
SIGN(argvals[0]);
2312 assert(result !=
NULL);
2313 assert(argvals !=
NULL);
2324 assert(result !=
NULL);
2325 assert(argbounds !=
NULL);
2328 if( argbounds[0].sup <= 0.0 || argbounds[0].inf >= 0.0 )
2342 assert(result !=
NULL);
2343 assert(argvals !=
NULL);
2346 for( i = 0; i < nargs; ++i )
2347 *result += argvals[i];
2358 assert(result !=
NULL);
2359 assert(argvals !=
NULL);
2363 for( i = 0; i < nargs; ++i )
2375 assert(result !=
NULL);
2376 assert(argcurv !=
NULL);
2380 for( i = 0; i < nargs; ++i )
2392 assert(result !=
NULL);
2393 assert(argvals !=
NULL);
2396 for( i = 0; i < nargs; ++i )
2397 *result *= argvals[i];
2408 assert(result !=
NULL);
2409 assert(argvals !=
NULL);
2413 for( i = 0; i < nargs; ++i )
2427 assert(result !=
NULL);
2428 assert(argcurv !=
NULL);
2429 assert(argbounds !=
NULL);
2435 hadnonconst =
FALSE;
2438 for( i = 0; i < nargs; ++i )
2440 if( argbounds[i].inf == argbounds[i].sup )
2442 constants *= argbounds[i].inf;
2444 else if( !hadnonconst )
2447 *result = argcurv[i];
2470 assert(result !=
NULL);
2471 assert(argvals !=
NULL || nargs == 0);
2472 assert(opdata.data !=
NULL);
2474 coef = &((
SCIP_Real*)opdata.data)[nargs];
2477 for( i = nargs-1, --coef; i >= 0; --i, --coef )
2478 *result += *coef * argvals[i];
2480 assert(++coef == (
SCIP_Real*)opdata.data);
2489 assert(result !=
NULL);
2490 assert(argvals !=
NULL || nargs == 0);
2491 assert(opdata.data !=
NULL);
2506 assert(result !=
NULL);
2507 assert(argcurv !=
NULL);
2510 assert(data !=
NULL);
2514 for( i = 0; i < nargs; ++i )
2526 assert(blkmem !=
NULL);
2527 assert(nchildren >= 0);
2528 assert(opdatatarget !=
NULL);
2531 assert(opdatasource.data !=
NULL);
2533 opdatatarget->data = targetdata;
2544 assert(blkmem !=
NULL);
2545 assert(nchildren >= 0);
2548 assert(freedata !=
NULL);
2563 assert(result !=
NULL);
2564 assert(argvals !=
NULL || nargs == 0);
2567 assert(quaddata !=
NULL);
2573 assert(quadelems !=
NULL || nquadelems == 0);
2574 assert(argvals !=
NULL || nquadelems == 0);
2578 if( lincoefs !=
NULL )
2580 for( i = nargs-1; i >= 0; --i )
2581 *result += lincoefs[i] * argvals[i];
2584 for( i = 0; i < nquadelems; ++i, ++quadelems )
2585 *result += quadelems->
coef * argvals[quadelems->
idx1] * argvals[quadelems->
idx2];
2604 assert(result !=
NULL);
2605 assert(argvals !=
NULL || nargs == 0);
2608 assert(quaddata !=
NULL);
2614 assert(quadelems !=
NULL || nquadelems == 0);
2615 assert(argvals !=
NULL || nargs == 0);
2623 for( i = 0; i < nquadelems; ++i )
2625 assert(quadelems[i].idx1 == 0);
2626 assert(quadelems[i].idx2 == 0);
2627 sqrcoef += quadelems[i].
coef;
2636 if( nargs == 2 && nquadelems > 0 )
2646 for( i = 0; i < nquadelems; ++i )
2647 if( quadelems[i].idx1 == 0 && quadelems[i].idx2 == 0 )
2648 ax += quadelems[i].
coef;
2649 else if( quadelems[i].idx1 == 1 && quadelems[i].idx2 == 1 )
2650 ay += quadelems[i].
coef;
2652 axy += quadelems[i].
coef;
2655 lincoefs !=
NULL ? lincoefs[0] : 0.0, lincoefs !=
NULL ? lincoefs[1] : 0.0,
2656 argvals[0], argvals[1]);
2657 SCIPdebugMessage(
"%g x^2 + %g y^2 + %g x y + %g x + %g y = [%g,%g] for x = [%g,%g], y = [%g,%g]\n",
2658 ax, ay, axy, lincoefs !=
NULL ? lincoefs[0] : 0.0, lincoefs !=
NULL ? lincoefs[1] : 0.0,
2659 result->inf, result->sup, argvals[0].inf, argvals[0].sup, argvals[1].inf, argvals[1].sup);
2676 for( argidx = 0; argidx < nargs; ++argidx )
2678 if( i == nquadelems || quadelems[i].idx1 > argidx )
2681 if( lincoefs !=
NULL )
2692 assert(i < nquadelems && quadelems[i].idx1 == argidx);
2695 if( quadelems[i].idx2 == argidx )
2697 sqrcoef += quadelems[i].
coef;
2706 while( i < nquadelems && quadelems[i].idx1 == argidx );
2707 assert(i == nquadelems || quadelems[i].idx1 > argidx);
2712 assert(i == nquadelems);
2727 assert(result !=
NULL);
2728 assert(argcurv !=
NULL);
2729 assert(argbounds !=
NULL);
2732 assert(data !=
NULL);
2740 if( lincoefs !=
NULL )
2741 for( i = 0; i < nargs; ++i )
2749 if( quadelems[i].coef == 0.0 )
2752 if( argbounds[quadelems[i].idx1].inf == argbounds[quadelems[i].idx1].sup &&
2753 +argbounds[quadelems[i].idx2].inf == argbounds[quadelems[i].idx2].sup
2760 if( argbounds[quadelems[i].idx1].inf == argbounds[quadelems[i].idx1].sup )
2765 else if( argbounds[quadelems[i].idx2].inf == argbounds[quadelems[i].idx2].sup )
2770 else if( quadelems[i].idx1 == quadelems[i].idx2 )
2791 assert(blkmem !=
NULL);
2792 assert(opdatatarget !=
NULL);
2795 assert(sourcedata !=
NULL);
2809 assert(blkmem !=
NULL);
2810 assert(nchildren >= 0);
2813 assert(quadraticdata !=
NULL);
2841 assert(result !=
NULL);
2842 assert(argvals !=
NULL || nargs == 0);
2843 assert(opdata.data !=
NULL);
2846 assert(polynomialdata !=
NULL);
2848 *result = polynomialdata->
constant;
2850 for( i = 0; i < polynomialdata->
nmonomials; ++i )
2852 monomialdata = polynomialdata->
monomials[i];
2853 assert(monomialdata !=
NULL);
2855 monomialval = monomialdata->
coef;
2856 for( j = 0; j < monomialdata->
nfactors; ++j )
2858 assert(monomialdata->
childidxs[j] >= 0);
2859 assert(monomialdata->
childidxs[j] < nargs);
2861 childval = argvals[monomialdata->
childidxs[j]];
2862 if( childval == 1.0 )
2867 if( childval == 0.0 )
2869 if( exponent > 0.0 )
2875 else if( exponent < 0.0 )
2882 *result =
pow(0.0, -1.0);
2891 if( exponent == 0.0 )
2893 if( exponent == 1.0 )
2895 monomialval *= childval;
2898 if( exponent == 2.0 )
2900 monomialval *= childval * childval;
2903 if( exponent == 0.5 )
2905 monomialval *=
sqrt(childval);
2908 if( exponent == -1.0 )
2910 monomialval /= childval;
2913 if( exponent == -2.0 )
2915 monomialval /= childval * childval;
2918 monomialval *=
pow(childval, exponent);
2921 *result += monomialval;
2939 assert(result !=
NULL);
2940 assert(argvals !=
NULL || nargs == 0);
2941 assert(opdata.data !=
NULL);
2944 assert(polynomialdata !=
NULL);
2948 for( i = 0; i < polynomialdata->
nmonomials; ++i )
2950 monomialdata = polynomialdata->
monomials[i];
2951 assert(monomialdata !=
NULL);
2956 assert(monomialdata->
childidxs[j] >= 0);
2957 assert(monomialdata->
childidxs[j] < nargs);
2959 childval = argvals[monomialdata->
childidxs[j]];
2964 if( exponent == 0.0 )
2967 if( exponent == 1.0 )
2973 if( exponent == 2.0 )
2980 if( exponent == 0.5 )
2991 else if( exponent == -1.0 )
2995 else if( exponent == -2.0 )
3031 assert(result !=
NULL);
3032 assert(argcurv !=
NULL);
3033 assert(argbounds !=
NULL);
3036 assert(data !=
NULL);
3048 monomial = monomials[i];
3062 assert(blkmem !=
NULL);
3063 assert(opdatatarget !=
NULL);
3066 assert(sourcepolynomialdata !=
NULL);
3070 opdatatarget->data = (
void*)targetpolynomialdata;
3081 assert(blkmem !=
NULL);
3084 assert(polynomialdata !=
NULL);
3110 if( exprdata->inteval !=
NULL )
3131 if( exprdata->curv !=
NULL )
3151 assert(blkmem !=
NULL);
3152 assert(opdatatarget !=
NULL);
3155 assert(exprdatasource !=
NULL);
3161 if( exprdatasource->copydata !=
NULL )
3171 opdatatarget->data = (
void*)exprdatatarget;
3182 assert(blkmem !=
NULL);
3187 if( exprdata->freedata !=
NULL )
3189 exprdata->freedata(blkmem, nchildren, exprdata->
userdata);
3201 struct exprOpTableElement
3212 #define EXPROPEMPTY {NULL, -1, NULL, NULL, NULL, NULL, NULL} 3219 {
"variable", 0, exprevalVar, exprevalIntVar, exprcurvVar,
NULL, NULL },
3220 {
"constant", 0, exprevalConst, exprevalIntConst, exprcurvConst,
NULL, NULL },
3221 {
"parameter", 0, exprevalParam, exprevalIntParam, exprcurvParam,
NULL, NULL },
3223 {
"plus", 2, exprevalPlus, exprevalIntPlus, exprcurvPlus,
NULL, NULL },
3224 {
"minus", 2, exprevalMinus, exprevalIntMinus, exprcurvMinus,
NULL, NULL },
3225 {
"mul", 2, exprevalMult, exprevalIntMult, exprcurvMult,
NULL, NULL },
3226 {
"div", 2, exprevalDiv, exprevalIntDiv, exprcurvDiv,
NULL, NULL },
3227 {
"sqr", 1, exprevalSquare, exprevalIntSquare, exprcurvSquare,
NULL, NULL },
3228 {
"sqrt", 1, exprevalSquareRoot, exprevalIntSquareRoot, exprcurvSquareRoot,
NULL, NULL },
3229 {
"realpower", 1, exprevalRealPower, exprevalIntRealPower, exprcurvRealPower,
NULL, NULL },
3230 {
"intpower", 1, exprevalIntPower, exprevalIntIntPower, exprcurvIntPower,
NULL, NULL },
3231 {
"signpower", 1, exprevalSignPower, exprevalIntSignPower, exprcurvSignPower,
NULL, NULL },
3232 {
"exp", 1, exprevalExp, exprevalIntExp, exprcurvExp,
NULL, NULL },
3233 {
"log", 1, exprevalLog, exprevalIntLog, exprcurvLog,
NULL, NULL },
3240 {
"min", 2, exprevalMin, exprevalIntMin, exprcurvMin,
NULL, NULL },
3241 {
"max", 2, exprevalMax, exprevalIntMax, exprcurvMax,
NULL, NULL },
3242 {
"abs", 1, exprevalAbs, exprevalIntAbs, exprcurvAbs,
NULL, NULL },
3243 {
"sign", 1, exprevalSign, exprevalIntSign, exprcurvSign,
NULL, NULL },
3245 EXPROPEMPTY,
EXPROPEMPTY,
EXPROPEMPTY,
EXPROPEMPTY,
EXPROPEMPTY,
EXPROPEMPTY,
EXPROPEMPTY,
EXPROPEMPTY,
EXPROPEMPTY,
EXPROPEMPTY,
3246 EXPROPEMPTY,
EXPROPEMPTY,
EXPROPEMPTY,
EXPROPEMPTY,
EXPROPEMPTY,
EXPROPEMPTY,
EXPROPEMPTY,
EXPROPEMPTY,
EXPROPEMPTY,
EXPROPEMPTY,
3247 EXPROPEMPTY,
EXPROPEMPTY,
EXPROPEMPTY,
EXPROPEMPTY,
EXPROPEMPTY,
EXPROPEMPTY,
EXPROPEMPTY,
EXPROPEMPTY,
EXPROPEMPTY,
EXPROPEMPTY,
3249 {
"sum", -2, exprevalSum, exprevalIntSum, exprcurvSum,
NULL, NULL },
3250 {
"prod", -2, exprevalProduct, exprevalIntProduct, exprcurvProduct,
NULL, NULL },
3251 {
"linear", -2, exprevalLinear, exprevalIntLinear, exprcurvLinear, exprCopyDataLinear, exprFreeDataLinear },
3252 {
"quadratic", -2, exprevalQuadratic, exprevalIntQuadratic, exprcurvQuadratic, exprCopyDataQuadratic, exprFreeDataQuadratic },
3253 {
"polynomial", -2, exprevalPolynomial, exprevalIntPolynomial, exprcurvPolynomial, exprCopyDataPolynomial, exprFreeDataPolynomial },
3254 {
"user", -2, exprevalUser, exprevalIntUser, exprcurvUser, exprCopyDataUser, exprFreeDataUser }
3269 return exprOpTable[op].name;
3279 return exprOpTable[op].nargs;
3301 assert(blkmem !=
NULL);
3302 assert(expr !=
NULL);
3303 assert(children !=
NULL || nchildren == 0);
3304 assert(children ==
NULL || nchildren > 0);
3309 (*expr)->nchildren = nchildren;
3310 (*expr)->children = children;
3311 (*expr)->
data = opdata;
3330 assert(blkmem !=
NULL);
3332 assert(data !=
NULL);
3348 assert(nchildren == 2);
3364 data->data = (
void*)polynomialdata;
3376 assert(nchildren == 2);
3392 data->data = (
void*)polynomialdata;
3404 assert(nchildren == 2);
3417 data->data = (
void*)polynomialdata;
3429 assert(nchildren == 2);
3442 data->data = (
void*)polynomialdata;
3454 assert(nchildren == 1);
3465 data->data = (
void*)polynomialdata;
3477 assert(nchildren == 1);
3488 data->data = (
void*)polynomialdata;
3499 assert(nchildren == 1);
3511 data->data = (
void*)polynomialdata;
3520 assert(nchildren == 1);
3523 exponent = data->dbl;
3524 if(
EPSISINT(exponent, 0.0) && (
int)exponent % 2 != 0 )
3539 data->data = (
void*)polynomialdata;
3552 assert(nchildren == 1);
3556 exponent = data->intval;
3563 data->data = (
void*)polynomialdata;
3599 for( i = 0; i < nchildren; ++i )
3607 data->data = (
void*)polynomialdata;
3624 for( i = 0; i < nchildren; ++i )
3634 data->data = (
void*)polynomialdata;
3650 assert(lineardata !=
NULL);
3662 for( i = 0; i < nchildren; ++i )
3664 monomial->
coef = lineardata[i];
3671 exprFreeDataLinear(blkmem, nchildren, *data);
3674 data->data = (
void*)polynomialdata;
3692 assert(quaddata !=
NULL);
3713 for( i = 0; i < nchildren; ++i )
3743 exprFreeDataQuadratic(blkmem, nchildren, *data);
3746 data->data = (
void*)polynomialdata;
3776 assert(blkmem !=
NULL);
3779 assert(data !=
NULL);
3780 assert(children !=
NULL || nchildren == 0);
3783 assert(polynomialdata !=
NULL);
3796 for( i = 0; i < polynomialdata->
nmonomials; ++i )
3800 monomial = polynomialdata->
monomials[i];
3801 assert(monomial !=
NULL);
3804 for(j = 0; j < monomial->
nfactors; ++j )
3821 if( monomialdegree == 1 )
3824 if( monomialdegree > maxdegree )
3825 maxdegree = monomialdegree;
3827 assert(maxdegree > 0 );
3829 if( maxdegree == 1 )
3834 assert(polynomialdata->
nmonomials == nchildren);
3835 assert(polynomialdata->
nmonomials == nlinmonomials);
3886 children[1] = children[0];
3895 if( polynomialdata->
constant == 0.0 )
3898 for( i = 0; i < polynomialdata->
nmonomials; ++i )
3927 for( i = 0; i < polynomialdata->
nmonomials; ++i )
3933 lindata[i] = polynomialdata->
constant;
3937 data->data = (
void*)lindata;
3955 if( nlinmonomials > 0 )
3964 for( i = 0; i < polynomialdata->
nmonomials; ++i )
3979 assert(quadelemidx < quaddata->nquadelems);
3991 assert(quadelemidx < quaddata->nquadelems);
4003 data->data = (
void*)quaddata;
4011 monomial = polynomialdata->
monomials[0];
4012 assert(monomial->
nfactors == nchildren);
4042 data->intval = exponent;
4068 data->dbl = exponent;
4074 if( maxdegree == 2 && monomial->
nfactors == 2 )
4088 if( maxdegree == monomial->
nfactors )
4127 children[1] = children[0];
4158 assert(blkmem !=
NULL);
4159 assert(expr !=
NULL);
4161 assert(exprs !=
NULL || nexprs == 0);
4172 for( i = 0; i < nexprs; ++i )
4175 if( childmap !=
NULL )
4194 for( i = 0; i < nexprs; ++i )
4196 existsalready =
FALSE;
4197 if( comparechildren )
4198 for( j = 0; j < orignchildren; ++j )
4202 existsalready =
TRUE;
4206 if( !existsalready )
4210 if( childmap !=
NULL )
4216 if( childmap !=
NULL )
4227 assert(comparechildren || expr->
nchildren == orignchildren + nexprs);
4237 data[expr->
nchildren] = data[orignchildren];
4238 for( i = orignchildren; i < expr->
nchildren; ++i )
4240 expr->
data.data = (
void*)data;
4256 SCIPerrorMessage(
"exprsimplifyAddChildren cannot be called for operand %d\n", expr->
op);
4272 assert(expr !=
NULL);
4300 assert(blkmem !=
NULL);
4301 assert(expr !=
NULL);
4309 foundduplicates =
FALSE;
4316 for( j = i+1; j < expr->
nchildren; ++j )
4326 foundduplicates =
TRUE;
4332 if( foundduplicates )
4352 assert(blkmem !=
NULL);
4353 assert(expr !=
NULL);
4363 while( lastnonnull >= 0 && expr->
children[lastnonnull] ==
NULL )
4365 for( i = 0; i <= lastnonnull; ++i )
4377 childmap[lastnonnull] = i;
4381 while( lastnonnull >= 0 && expr->
children[lastnonnull] ==
NULL )
4384 assert(i > lastnonnull);
4387 if( lastnonnull < expr->nchildren-1 )
4393 if( lastnonnull >= 0 )
4420 assert(blkmem !=
NULL);
4421 assert(expr !=
NULL);
4427 assert(polynomialdata !=
NULL);
4432 for( i = 0; i < polynomialdata->
nmonomials; ++i )
4434 monomial = polynomialdata->
monomials[i];
4435 assert(monomial !=
NULL);
4437 for( j = 0; j < monomial->
nfactors; ++j )
4465 int maxexpansionexponent
4470 assert(expr !=
NULL);
4520 expr->
data.data = (
void*)polynomialdata;
4552 expr->
data.data = (
void*)polynomialdata;
4585 assert(polynomialdata !=
NULL);
4608 if( childmapsize < expr->children[i]->nchildren )
4614 childmapsize = newsize;
4618 for( j = 0; j < polynomialdata->
nmonomials; ++j )
4623 monomial = polynomialdata->
monomials[j];
4629 assert(factorpos >= 0);
4630 assert(factorpos < monomial->nfactors);
4632 assert(factorpos == 0 || monomial->
childidxs[factorpos-1] != i);
4633 assert(factorpos == monomial->
nfactors-1 || monomial->
childidxs[factorpos+1] != i);
4651 if( factorpos < monomial->nfactors-1 )
4664 removechild =
FALSE;
4687 if( childmapsize < expr->children[i]->nchildren )
4693 childmapsize = newsize;
4701 while( j < polynomialdata->nmonomials )
4706 monomial = polynomialdata->
monomials[j];
4712 assert(factorpos >= 0);
4713 assert(factorpos < monomial->nfactors);
4715 assert(factorpos == 0 || monomial->
childidxs[factorpos-1] != i);
4716 assert(factorpos == monomial->
nfactors-1 || monomial->
childidxs[factorpos+1] != i);
4727 removechild =
FALSE;
4767 expr->
data.dbl = val;
4807 assert(blkmem !=
NULL);
4808 assert(expr !=
NULL);
4809 assert(nlinvars !=
NULL);
4810 assert(linidxs !=
NULL);
4811 assert(lincoefs !=
NULL);
4822 assert(polynomialdata !=
NULL);
4832 for( i = 0; i < polynomialdata->
nmonomials; ++i )
4834 monomial = polynomialdata->
monomials[i];
4835 assert(monomial !=
NULL);
4836 for( j = 0; j < monomial->
nfactors; ++j )
4845 for( i = 0; i < polynomialdata->
nmonomials; ++i )
4847 monomial = polynomialdata->
monomials[i];
4848 assert(monomial !=
NULL);
4866 lincoefs[*nlinvars] = monomial->
coef;
4870 monomial->
coef = 0.0;
4897 assert(blkmem !=
NULL);
4898 assert(expr !=
NULL);
4916 return (
void*)((
char*)elem +
sizeof(
int));
4932 const char* varnameendptr
4942 assert(blkmem !=
NULL);
4943 assert(str !=
NULL);
4944 assert(expr !=
NULL);
4945 assert(nvars !=
NULL);
4946 assert(varnames !=
NULL);
4947 assert(vartable !=
NULL);
4949 if( varnameendptr ==
NULL )
4952 varnameendptr = *str;
4953 while( varnameendptr[0] !=
'>' )
4957 namelength = varnameendptr - *str;
4960 SCIPerrorMessage(
"Variable name %.*s is too long for buffer in exprparseReadVariable.\n", namelength, str);
4964 memcpy(varname, *str, namelength *
sizeof(
char));
4965 varname[namelength] =
'\0';
4968 if( element !=
NULL )
4971 assert(strcmp((
char*)element +
sizeof(
int), varname) == 0);
4973 varidx = *(
int*)element;
4981 **varnames = varidx;
4982 strcpy((
char*)(*varnames + 1), varname);
4988 *varnames += 1 + (strlen(varname) + 1) /
sizeof(
int) + 1;
4993 if( coefficient != 1.0 )
4999 *str = varnameendptr + 1;
5002 if( (*str)[0] ==
'[' && (*str)[2] ==
']' &&
5019 const char** endptr,
5025 assert(str[0] ==
'(');
5031 while( (*endptr - str ) < length && !(nopenbrackets == 1 && *endptr[0] ==
')') )
5033 if( *endptr[0] ==
'(')
5035 if( *endptr[0] ==
')')
5040 if( *endptr[0] !=
')' )
5042 SCIPerrorMessage(
"unable to find closing parenthesis in unbalanced expression %.*s\n", length, str);
5058 const char** endptr,
5068 while( (*endptr - str ) < length && !(nopenbrackets == 0 && *endptr[0] ==
',') )
5070 if( *endptr[0] ==
'(')
5072 if( *endptr[0] ==
')')
5077 if( *endptr[0] !=
',' )
5079 SCIPerrorMessage(
"unable to find separating comma in unbalanced expression %.*s\n", length, str);
5094 const char* lastchar,
5103 const char* subexpptr;
5104 const char* subexpendptr;
5105 const char* strstart;
5107 char* nonconstendptr;
5112 assert(blkmem !=
NULL);
5113 assert(expr !=
NULL);
5114 assert(str !=
NULL);
5115 assert(lastchar >= str);
5116 assert(nvars !=
NULL);
5117 assert(varnames !=
NULL);
5118 assert(vartable !=
NULL);
5120 assert(recursiondepth < 100);
5124 SCIPdebugMessage(
"exprParse (%i): parsing %.*s\n", recursiondepth, (
int) (lastchar-str + 1), str);
5127 while( isspace((
unsigned char)*str) )
5137 while( subexpptr != lastchar && !(nopenbrackets == 0 && (subexpptr[0] ==
'+' || subexpptr[0] ==
'-') && subexpptr != str) )
5139 if( subexpptr[0] ==
'(')
5141 if( subexpptr[0] ==
')')
5146 if( subexpptr != lastchar )
5148 SCIP_CALL(
exprParse(blkmem, messagehdlr, &arg1, str, (
int) ((subexpptr - 1) - str + 1), subexpptr - 1, nvars, varnames, vartable, recursiondepth + 1) );
5150 if( subexpptr[0] ==
'+' )
5152 SCIP_CALL(
exprParse(blkmem, messagehdlr, &arg2, subexpptr , (
int) (lastchar - (subexpptr ) + 1), lastchar, nvars, varnames, vartable, recursiondepth + 1) );
5174 subexpptr = str + 1;
5177 while( subexplength < length && !(nopenbrackets == 1 && str[0] ==
')') )
5186 subexpendptr = str - 1;
5188 SCIP_CALL(
exprParse(blkmem, messagehdlr, expr, subexpptr, subexplength, subexpendptr, nvars, varnames, vartable, recursiondepth + 1) );
5191 else if( isdigit((
unsigned char)str[0]) || ((str[0] ==
'-' || str[0] ==
'+')
5192 && (isdigit((
unsigned char)str[1]) || str[1] ==
' ')) )
5195 if( str[0] ==
'-' && str[1] ==
' ' )
5198 nonconstendptr = (
char*) str + 1;
5206 str = nonconstendptr;
5209 while( isspace((
unsigned char)*str) && str != lastchar )
5212 if( str[0] !=
'*' && str[0] !=
'/' && str[0] !=
'+' && str[0] !=
'-' && str[0] !=
'^' )
5214 if( str < lastchar )
5216 SCIP_CALL(
exprParse(blkmem, messagehdlr, expr, str, (
int)(lastchar - str) + 1, lastchar, nvars, varnames, vartable, recursiondepth + 1) );
5230 else if( str[0] ==
'<' )
5236 else if( strncmp(str,
"sqrt", 4) == 0 )
5240 SCIP_CALL(
exprParse(blkmem, messagehdlr, &arg1, str + 1, endptr - str - 1, endptr -1, nvars, varnames, vartable, recursiondepth + 1) );
5247 strncmp(str,
"abs", 3) == 0 ||
5248 strncmp(str,
"cos", 3) == 0 ||
5249 strncmp(str,
"exp", 3) == 0 ||
5250 strncmp(str,
"log", 3) == 0 ||
5251 strncmp(str,
"sin", 3) == 0 ||
5252 strncmp(str,
"sqr", 3) == 0 ||
5253 strncmp(str,
"tan", 3) == 0 )
5255 const char* opname = str;
5259 SCIP_CALL(
exprParse(blkmem, messagehdlr, &arg1, str + 1, endptr - str - 1, endptr -1, nvars, varnames, vartable, recursiondepth + 1) );
5262 if( strncmp(opname,
"abs", 3) == 0 )
5266 else if( strncmp(opname,
"cos", 3) == 0 )
5270 else if( strncmp(opname,
"exp", 3) == 0 )
5274 else if( strncmp(opname,
"log", 3) == 0 )
5278 else if( strncmp(opname,
"sin", 3) == 0 )
5282 else if( strncmp(opname,
"sqr", 3) == 0 )
5288 assert(strncmp(opname,
"tan", 3) == 0);
5294 strncmp(str,
"max", 3) == 0 ||
5295 strncmp(str,
"min", 3) == 0 )
5311 SCIP_CALL(
exprParse(blkmem, messagehdlr, &arg1, str + 1, comma - str - 1, comma - 1, nvars, varnames, vartable, recursiondepth + 1) );
5315 while( comma < endptr && *comma ==
' ' )
5318 SCIP_CALL(
exprParse(blkmem, messagehdlr, &arg2, comma, endptr - comma, endptr - 1, nvars, varnames, vartable, recursiondepth + 1) );
5324 else if( strncmp(str,
"power", 5) == 0 )
5338 SCIP_CALL(
exprParse(blkmem, messagehdlr, &arg1, str + 1, comma - str - 1, comma - 1, nvars, varnames, vartable, recursiondepth + 1) );
5342 while( comma < endptr && *comma ==
' ' )
5344 if( !isdigit((
unsigned char)comma[0]) && !((comma[0] ==
'-' || comma[0] ==
'+') && isdigit((
unsigned char)comma[1])) )
5358 else if( strncmp(str,
"realpower", 9) == 0 || strncmp(str,
"signpower", 9) == 0 )
5363 const char* opname = str;
5372 SCIP_CALL(
exprParse(blkmem, messagehdlr, &arg1, str + 1, comma - str - 1, comma - 1, nvars, varnames, vartable, recursiondepth + 1) );
5376 while( comma < endptr && *comma ==
' ' )
5378 if( !isdigit((
unsigned char)comma[0]) && !((comma[0] ==
'-' || comma[0] ==
'+') && isdigit((
unsigned char)comma[1])) )
5388 if( strncmp(opname,
"realpower", 9) == 0 )
5394 assert(strncmp(opname,
"signpower", 9) == 0);
5400 else if( isalpha(*str) || *str ==
'_' || *str ==
'#' )
5406 const char* varnamestartptr = str;
5409 while( isalnum(str[0]) || str[0] ==
'_' || str[0] ==
'#' )
5416 SCIPerrorMessage(
"parsing of invalid expression %.*s.\n", (
int) (lastchar - str + 1), str);
5421 if( str == lastchar + 1)
5431 if( str > lastchar + 1)
5433 SCIPerrorMessage(
"error finding first expression in \"%.*s\" took us outside of given subexpression length\n", length, strstart);
5438 while( isspace((
unsigned char)*str) && str != lastchar + 1 )
5442 if( str >= lastchar + 1)
5458 while( isspace((
unsigned char)*str) && str != lastchar + 1 )
5461 if( isdigit((
unsigned char)str[0]) || ((str[0] ==
'-' || str[0] ==
'+') && isdigit((
unsigned char)str[1])) )
5471 str = nonconstendptr;
5486 else if( str[0] ==
'(' )
5491 SCIP_CALL(
exprParse(blkmem, messagehdlr, &arg2, str + 1, endptr - str - 1, endptr -1, nvars, varnames, vartable, recursiondepth + 1) );
5523 while( isspace((
unsigned char)*str) && str != lastchar + 1 )
5528 if( str <= lastchar && (str[0] ==
'+' || str[0] ==
'-' || str[0] ==
'/') )
5538 SCIP_CALL(
exprParse(blkmem, messagehdlr, &arg2, str, (
int) (lastchar - str + 1), lastchar, nvars, varnames, vartable, recursiondepth + 1) );
5550 else if( op ==
'*' )
5582 while( isspace((
unsigned char)*str) )
5586 if( str >= lastchar + 1 )
5603 else if( str[0] !=
'(' )
5605 SCIPdebugMessage(
"No operator found, assuming a multiplication before %.*s\n", (
int) (lastchar - str + 1), str);
5608 SCIP_CALL(
exprParse(blkmem, messagehdlr, &arg2, str, (
int) (lastchar - str + 1), lastchar, nvars, varnames, vartable, recursiondepth + 1) );
5643 #undef SCIPexprGetOperator 5644 #undef SCIPexprGetNChildren 5645 #undef SCIPexprGetChildren 5646 #undef SCIPexprGetOpIndex 5647 #undef SCIPexprGetOpReal 5648 #undef SCIPexprGetOpData 5649 #undef SCIPexprGetRealPowerExponent 5650 #undef SCIPexprGetIntPowerExponent 5651 #undef SCIPexprGetSignPowerExponent 5652 #undef SCIPexprGetLinearCoefs 5653 #undef SCIPexprGetLinearConstant 5654 #undef SCIPexprGetQuadElements 5655 #undef SCIPexprGetQuadConstant 5656 #undef SCIPexprGetQuadLinearCoefs 5657 #undef SCIPexprGetNQuadElements 5658 #undef SCIPexprGetMonomials 5659 #undef SCIPexprGetNMonomials 5660 #undef SCIPexprGetPolynomialConstant 5661 #undef SCIPexprGetMonomialCoef 5662 #undef SCIPexprGetMonomialNFactors 5663 #undef SCIPexprGetMonomialChildIndices 5664 #undef SCIPexprGetMonomialExponents 5665 #undef SCIPexprGetUserData 5666 #undef SCIPexprHasUserEstimator 5667 #undef SCIPexprGetUserEvalCapability 5674 assert(expr !=
NULL);
5684 assert(expr !=
NULL);
5694 assert(expr !=
NULL);
5704 assert(expr !=
NULL);
5707 return expr->
data.intval;
5715 assert(expr !=
NULL);
5718 return expr->
data.dbl;
5726 assert(expr !=
NULL);
5729 return expr->
data.data;
5737 assert(expr !=
NULL);
5740 return expr->
data.dbl;
5748 assert(expr !=
NULL);
5751 return expr->
data.intval;
5759 assert(expr !=
NULL);
5762 return expr->
data.dbl;
5770 assert(expr !=
NULL);
5783 assert(expr !=
NULL);
5796 assert(expr !=
NULL);
5808 assert(expr !=
NULL);
5821 assert(expr !=
NULL);
5833 assert(expr !=
NULL);
5845 assert(expr !=
NULL);
5857 assert(expr !=
NULL);
5869 assert(expr !=
NULL);
5881 assert(monomial !=
NULL);
5883 return monomial->
coef;
5891 assert(monomial !=
NULL);
5901 assert(monomial !=
NULL);
5911 assert(monomial !=
NULL);
5921 assert(expr !=
NULL);
5932 assert(expr !=
NULL);
5943 assert(expr !=
NULL);
5961 assert(blkmem !=
NULL);
5962 assert(expr !=
NULL);
5970 opdata.intval = va_arg( ap,
int );
5973 assert( opdata.intval >= 0 );
6002 assert(children[0] !=
NULL);
6003 assert(children[1] !=
NULL);
6028 assert(children[0] !=
NULL);
6043 assert(children[0] !=
NULL);
6057 assert(children[0] !=
NULL);
6058 opdata.intval = va_arg( ap,
int);
6076 nchildren = va_arg( ap,
int );
6077 assert(nchildren >= 0);
6080 if( nchildren == 0 )
6088 childrenarg = va_arg( ap,
SCIP_EXPR** );
6089 assert(childrenarg !=
NULL);
6103 SCIPerrorMessage(
"cannot create complex expression linear, quadratic, polynomial, or user with SCIPexprCreate\n");
6122 assert(blkmem !=
NULL);
6123 assert(targetexpr !=
NULL);
6124 assert(sourceexpr !=
NULL);
6136 for( i = 0; i < sourceexpr->
nchildren; ++i )
6143 assert((*targetexpr)->children ==
NULL);
6149 if( exprOpTable[sourceexpr->
op].copydata !=
NULL )
6151 SCIP_CALL( exprOpTable[sourceexpr->
op].copydata(blkmem, sourceexpr->
nchildren, sourceexpr->
data, &(*targetexpr)->data) );
6163 assert(blkmem !=
NULL);
6164 assert(expr !=
NULL);
6165 assert(*expr !=
NULL);
6168 if( exprOpTable[(*expr)->op].freedata !=
NULL )
6170 exprOpTable[(*expr)->op].freedata(blkmem, (*expr)->nchildren, (*expr)->data);
6173 if( (*expr)->nchildren )
6177 assert( (*expr)->children !=
NULL );
6179 for( i = 0; i < (*expr)->nchildren; ++i )
6182 assert((*expr)->children[i] ==
NULL);
6189 assert( (*expr)->children ==
NULL );
6201 assert(blkmem !=
NULL);
6202 assert(expr !=
NULL);
6203 assert(*expr !=
NULL);
6206 if( exprOpTable[(*expr)->op].freedata !=
NULL )
6208 exprOpTable[(*expr)->op].freedata(blkmem, (*expr)->nchildren, (*expr)->data);
6231 assert(blkmem !=
NULL);
6232 assert(expr !=
NULL);
6248 if( term1 ==
NULL && term2 ==
NULL )
6261 assert(data !=
NULL);
6264 for( i = 0; i <= term1->
nchildren; ++i )
6277 assert(data !=
NULL);
6280 for( i = 0; i <= term2->
nchildren; ++i )
6286 if( term1 ==
NULL || term2 ==
NULL )
6293 if( constant != 0.0 || coef1 != 1.0 )
6297 assert(coef1 == 1.0);
6311 assert(constant == 0.0);
6312 assert(coef1 == 1.0);
6322 assert(coef1 == 1.0);
6323 assert(coef2 == 1.0);
6339 assert(coef2 == 1.0);
6350 assert(coef1 == 1.0);
6365 children[0] = term1;
6366 children[1] = term2;
6386 assert(blkmem !=
NULL);
6387 assert(expr !=
NULL);
6388 assert(term !=
NULL);
6419 assert(data !=
NULL);
6442 for( i = 0; i < data->nquadelems; ++i )
6458 for( i = 0; i < data->nmonomials; ++i )
6490 assert(nchildren >= 0);
6491 assert(children !=
NULL || nchildren == 0);
6492 assert(coefs !=
NULL || nchildren == 0);
6499 childrencopy =
NULL;
6504 data[nchildren] = constant;
6506 opdata.data = (
void*)data;
6525 assert(blkmem !=
NULL);
6526 assert(expr !=
NULL);
6528 assert(nchildren >= 0);
6529 assert(coefs !=
NULL || nchildren == 0);
6530 assert(children !=
NULL || nchildren == 0);
6533 assert(data !=
NULL);
6536 if( nchildren == 0 )
6551 expr->
data.data = (
void*)data;
6574 assert(nchildren >= 0);
6575 assert(children !=
NULL || nchildren == 0);
6576 assert(quadelems !=
NULL || nquadelems == 0);
6583 childrencopy =
NULL;
6587 opdata.data = (
void*)data;
6599 assert(expr !=
NULL);
6622 assert(nchildren >= 0);
6623 assert(children !=
NULL || nchildren == 0);
6624 assert(monomials !=
NULL || nmonomials == 0);
6631 childrencopy =
NULL;
6634 opdata.data = (
void*)data;
6650 assert(blkmem !=
NULL);
6651 assert(expr !=
NULL);
6653 assert(monomials !=
NULL || nmonomials == 0);
6655 if( nmonomials == 0 )
6669 assert(expr !=
NULL);
6683 assert(expr !=
NULL);
6698 assert(blkmem !=
NULL);
6699 assert(factor !=
NULL);
6700 assert(expr !=
NULL);
6721 assert(blkmem !=
NULL);
6722 assert(expr !=
NULL);
6725 assert(factor !=
NULL);
6728 assert(expr != factor);
6731 if( childmap ==
NULL )
6735 for( i = 0; i < factor->
nchildren; ++i )
6741 for( i = 0; i < factor->
nchildren; ++i )
6743 assert(childmap[i] >= 0);
6766 assert(blkmem !=
NULL);
6767 assert(expr !=
NULL);
6787 assert(expr !=
NULL);
6803 assert(monomial1 !=
NULL);
6804 assert(monomial2 !=
NULL);
6815 for( i = 0; i < monomial1->
nfactors; ++i )
6831 assert(monomial !=
NULL);
6833 monomial->
coef = newcoef;
6845 assert(monomial !=
NULL);
6846 assert(nfactors >= 0);
6847 assert(childidxs !=
NULL || nfactors == 0);
6848 assert(exponents !=
NULL || nfactors == 0);
6854 assert(monomial->
nfactors + nfactors <= monomial->factorssize);
6873 assert(monomial !=
NULL);
6874 assert(factor !=
NULL);
6876 if( factor->
coef == 0.0 )
6879 monomial->
coef = 0.0;
6885 if( childmap !=
NULL )
6888 for( i = monomial->
nfactors - factor->
nfactors; i < monomial->nfactors; ++i )
6908 assert(monomial !=
NULL);
6916 if( monomial->
coef != 0.0 )
6917 monomial->
coef = 1.0;
6923 for( i = 0; i < monomial->
nfactors; ++i )
6939 assert(monomial !=
NULL);
6948 while( i + offset < monomial->nfactors )
6953 assert(monomial->
childidxs[i+offset] >= 0);
6985 for( ; i < monomial->
nfactors; ++i )
6992 monomial->
coef = 1.0;
6993 else if(
EPSEQ(monomial->
coef, -1.0, eps) )
6994 monomial->
coef = -1.0;
7002 assert(expr !=
NULL);
7019 assert(blkmem !=
NULL);
7020 assert(monomial !=
NULL);
7024 (*monomial)->coef = coef;
7025 (*monomial)->nfactors = nfactors;
7026 (*monomial)->factorssize = nfactors;
7027 (*monomial)->sorted = (nfactors <= 1);
7031 if( childidxs !=
NULL )
7040 for( i = 0; i < nfactors; ++i )
7041 (*monomial)->childidxs[i] = i;
7044 if( exponents !=
NULL )
7053 for( i = 0; i < nfactors; ++i )
7054 (*monomial)->exponents[i] = 1.0;
7059 (*monomial)->childidxs =
NULL;
7060 (*monomial)->exponents =
NULL;
7072 assert(blkmem !=
NULL);
7073 assert( monomial !=
NULL);
7074 assert(*monomial !=
NULL);
7076 if( (*monomial)->factorssize > 0 )
7078 assert((*monomial)->childidxs !=
NULL);
7079 assert((*monomial)->exponents !=
NULL);
7084 assert((*monomial)->childidxs ==
NULL);
7085 assert((*monomial)->exponents ==
NULL);
7095 assert(monomial !=
NULL);
7117 assert(monomial !=
NULL);
7149 assert(blkmem !=
NULL);
7150 assert(expr !=
NULL);
7154 assert(curv !=
NULL);
7155 assert(copydata !=
NULL || data ==
NULL);
7156 assert(freedata !=
NULL || data ==
NULL);
7162 userexprdata->eval =
eval;
7163 userexprdata->inteval = inteval;
7164 userexprdata->curv = curv;
7165 userexprdata->prop = prop;
7166 userexprdata->estimate = estimate;
7167 userexprdata->copydata = copydata;
7168 userexprdata->freedata = freedata;
7169 userexprdata->print = print;
7171 opdata.data = (
void*) userexprdata;
7173 if( nchildren == 0 )
7178 assert(children !=
NULL);
7194 assert(expr !=
NULL);
7215 assert(expr !=
NULL);
7216 assert(maxdegree !=
NULL);
7238 *maxdegree =
MAX(child1, child2);
7250 *maxdegree = child1 + child2;
7273 *maxdegree = 2 * child1;
7311 if( expr->
data.dbl == 0.0 )
7313 else if( expr->
data.dbl > 0.0 && (
int)expr->
data.dbl == expr->
data.dbl )
7314 *maxdegree = child1 * (int)expr->
data.dbl;
7328 if( child1 == 0 || expr->
data.intval == 0 )
7342 *maxdegree = child1 * expr->
data.intval;
7401 if( child1 > *maxdegree )
7402 *maxdegree = child1;
7421 *maxdegree += child1;
7440 for( childidx = 0; childidx < expr->
nchildren; ++childidx )
7454 while( quadidx < quadraticdata->nquadelems && quadraticdata->
quadelems[quadidx].
idx1 == childidx )
7459 if( 2*child1 > *maxdegree )
7460 *maxdegree = 2*child1;
7471 if( child1 + child2 > *maxdegree )
7472 *maxdegree = child1 + child2;
7496 monomialdata = polynomialdata->
monomials[i];
7497 assert(monomialdata !=
NULL);
7501 for( j = 0; j < monomialdata->
nfactors; ++j )
7513 monomialdegree += child1 * (int)monomialdata->
exponents[j];
7516 if( monomialdegree > *maxdegree )
7517 *maxdegree = monomialdegree;
7539 assert(expr !=
NULL);
7540 assert(varsusage !=
NULL);
7544 ++varsusage[expr->
data.intval];
7561 assert(expr1 !=
NULL);
7562 assert(expr2 !=
NULL);
7564 if( expr1 == expr2 )
7567 if( expr1->
op != expr2->
op )
7574 return expr1->
data.intval == expr2->
data.intval;
7644 for( i = 0; i < expr1->
nchildren + 1; ++i )
7645 if( !
EPSEQ(data1[i], data2[i], eps) )
7775 int maxexpansionexponent,
7782 assert(blkmem !=
NULL);
7783 assert(expr !=
NULL);
7802 if( nlinvars !=
NULL )
7830 assert(expr !=
NULL);
7834 assert( exprOpTable[expr->
op].eval !=
NULL );
7869 assert( exprOpTable[expr->
op].eval !=
NULL );
7873 if( staticbuf != buf )
7891 assert(expr !=
NULL);
7895 assert( exprOpTable[expr->
op].inteval !=
NULL );
7931 assert( exprOpTable[expr->
op].inteval !=
NULL );
7935 if( staticbuf != buf )
7954 assert(expr !=
NULL);
7959 assert(exprdata->eval !=
NULL);
7978 assert(expr !=
NULL);
7984 if( exprdata->inteval ==
NULL )
8015 assert(expr !=
NULL);
8016 assert(curv !=
NULL);
8017 assert(bounds !=
NULL);
8027 childbounds = childboundsbuf;
8028 childcurv = childcurvbuf;
8036 if( childbounds[i].inf == childbounds[i].sup )
8041 assert(exprOpTable[expr->
op].curv !=
NULL);
8042 assert(exprOpTable[expr->
op].inteval !=
NULL);
8045 SCIP_CALL( exprOpTable[expr->
op].inteval(infinity, expr->
data, expr->
nchildren, childbounds, varbounds, param, bounds) );
8048 if( childboundsbuf != childbounds )
8071 assert(expr !=
NULL);
8078 if( exprdata->estimate !=
NULL )
8080 SCIP_CALL( exprdata->estimate(infinity, exprdata->
userdata, expr->
nchildren, argvals, argbounds, overestimate, coeffs, constant, success ) );
8104 assert(blkmem !=
NULL);
8105 assert(expr !=
NULL);
8106 assert(substexprs !=
NULL);
8115 assert(varidx >= 0);
8116 if( substexprs[varidx] !=
NULL )
8141 assert(expr !=
NULL);
8142 assert(newindices !=
NULL);
8146 expr->
data.intval = newindices[expr->
data.intval];
8147 assert(expr->
data.intval >= 0);
8162 assert(expr !=
NULL);
8163 assert(newindices !=
NULL);
8167 expr->
data.intval = newindices[expr->
data.intval];
8168 assert(expr->
data.intval >= 0);
8180 const char** varnames,
8181 const char** paramnames,
8185 assert( expr !=
NULL );
8194 if( varnames !=
NULL )
8196 assert(varnames[expr->
data.intval] !=
NULL);
8206 if( paramnames !=
NULL )
8208 assert(paramnames[expr->
data.intval] !=
NULL);
8215 if( paramvals !=
NULL )
8222 if (expr->
data.dbl < 0.0 )
8350 if( constant != 0.0 )
8371 assert(quadraticdata !=
NULL);
8375 if( quadraticdata->
constant != 0.0 )
8381 if( quadraticdata->
lincoefs[i] == 0.0 )
8387 for( i = 0; i < quadraticdata->
nquadelems; ++i )
8416 assert(polynomialdata !=
NULL);
8423 for( i = 0; i < polynomialdata->
nmonomials; ++i )
8425 monomialdata = polynomialdata->
monomials[i];
8428 for( j = 0; j < monomialdata->
nfactors; ++j )
8437 else if( monomialdata->
exponents[j] != 1.0 )
8454 assert(exprdata !=
NULL);
8456 if( exprdata->print !=
NULL )
8458 exprdata->print(exprdata->
userdata, messagehdlr, file);
8493 const char* lastchar,
8501 assert(blkmem !=
NULL);
8502 assert(expr !=
NULL);
8503 assert(str !=
NULL);
8504 assert(lastchar !=
NULL);
8505 assert(nvars !=
NULL);
8506 assert(varnames !=
NULL);
8515 retcode =
exprParse(blkmem, messagehdlr, expr, str, (
int) (lastchar - str + 1), lastchar, nvars, &varnames, vartable, 0);
8534 #undef SCIPexprtreeGetRoot 8535 #undef SCIPexprtreeGetNVars 8536 #undef SCIPexprtreeGetNParams 8537 #undef SCIPexprtreeGetParamVals 8538 #undef SCIPexprtreeSetParamVal 8539 #undef SCIPexprtreeGetInterpreterData 8540 #undef SCIPexprtreeSetInterpreterData 8541 #undef SCIPexprtreeFreeInterpreterData 8542 #undef SCIPexprtreeHasParam 8543 #undef SCIPexprtreeGetMaxDegree 8544 #undef SCIPexprtreeEval 8545 #undef SCIPexprtreeEvalInt 8546 #undef SCIPexprtreePrint 8553 assert(tree !=
NULL);
8563 assert(tree !=
NULL);
8573 assert(tree !=
NULL);
8583 assert(tree !=
NULL);
8595 assert(tree !=
NULL);
8596 assert(paramidx >= 0);
8597 assert(paramidx < tree->nparams);
8600 tree->
params[paramidx] = paramval;
8608 assert(tree !=
NULL);
8619 assert(tree !=
NULL);
8620 assert(interpreterdata !=
NULL);
8645 assert(tree !=
NULL);
8662 assert(tree !=
NULL);
8676 assert(tree !=
NULL);
8677 assert(varvals !=
NULL || tree->
nvars == 0);
8678 assert(val !=
NULL);
8693 assert(tree !=
NULL);
8694 assert(varvals !=
NULL || tree->
nvars == 0);
8695 assert(val !=
NULL);
8707 const char** varnames,
8708 const char** paramnames
8711 assert(tree !=
NULL);
8727 assert(blkmem !=
NULL);
8728 assert(tree !=
NULL);
8732 (*tree)->blkmem = blkmem;
8733 (*tree)->root = root;
8734 (*tree)->nvars = nvars;
8735 (*tree)->vars =
NULL;
8736 (*tree)->nparams = nparams;
8737 (*tree)->interpreterdata =
NULL;
8739 if( params !=
NULL )
8741 assert(nparams > 0);
8744 else if( nparams > 0 )
8751 assert(nparams == 0);
8752 (*tree)->params =
NULL;
8765 assert(blkmem !=
NULL);
8766 assert(targettree !=
NULL);
8767 assert(sourcetree !=
NULL);
8773 (*targettree)->blkmem = blkmem;
8774 (*targettree)->interpreterdata =
NULL;
8779 assert(sourcetree->
nvars > 0);
8787 assert(sourcetree->
nparams > 0);
8803 assert( tree !=
NULL);
8804 assert(*tree !=
NULL);
8808 if( (*tree)->root !=
NULL )
8811 assert((*tree)->root ==
NULL);
8829 assert(tree !=
NULL);
8830 assert(paramvals !=
NULL || nparams == 0);
8859 assert(tree !=
NULL);
8860 assert(varsusage !=
NULL);
8862 if( tree->
nvars == 0 )
8877 int maxexpansionexponent,
8891 assert(tree !=
NULL);
8909 if( nlinvars !=
NULL && testval_before == testval_before )
8910 for( i = 0; i < *nlinvars; ++i )
8911 testval_after += lincoefs[i] * testx[linidxs[i]];
8912 assert(testval_before != testval_before || testval_before == testval_after ||
EPSZ(
SCIPrelDiff(testval_before, testval_after), eps));
8917 if( nlinvars !=
NULL && *nlinvars > 0 )
8933 assert(tree !=
NULL);
8960 assert(tree !=
NULL);
8965 if( bounds !=
NULL )
8966 *bounds = exprbounds;
8981 assert(tree !=
NULL);
8989 assert(varidx >= 0);
8990 if( substexprs[varidx] !=
NULL )
9018 #define QUADELEMS_ISBETTER(a, b) ( ((a).idx1 < (b).idx1) || ((a).idx1 == (b).idx1 && (a).idx2 < (b).idx2) ) 9021 #define QUADELEMS_SWAP(x,y) \ 9023 SCIP_QUADELEM temp = x; \ 9036 assert(start <= end);
9039 while( end - start >= 25 )
9047 mid = (start+end)/2;
9048 pivotkey = elems[mid];
9068 assert(hi == lo-1 || hi == start);
9085 if( hi - start <= end - lo )
9106 if( end - start >= 1 )
9108 static const int incs[3] = {1, 5, 19};
9111 for( k = 2; k >= 0; --k )
9116 for( h = incs[k], i = h + start; i <= end; ++i )
9124 elems[j] = elems[j-h];
9145 if( nquadelems == 0 )
9151 for( i = 0; i < nquadelems; ++i )
9152 assert(quadelems[i].idx1 <= quadelems[i].idx2);
9176 assert(quadelems !=
NULL || nquadelems == 0);
9177 assert(idx1 <= idx2);
9179 if( nquadelems == 0 )
9187 right = nquadelems - 1;
9188 while( left <= right )
9192 middle = (left+right)/2;
9193 assert(0 <= middle && middle < nquadelems);
9195 if( idx1 < quadelems[middle].idx1 || (idx1 == quadelems[middle].idx1 && idx2 < quadelems[middle].idx2) )
9197 else if( quadelems[middle].idx1 < idx1 || (quadelems[middle].idx1 == idx1 && quadelems[middle].idx2 < idx2) )
9206 assert(left == right+1);
9226 assert(quadelems !=
NULL);
9227 assert(nquadelemsnew !=
NULL);
9228 assert(nquadelems >= 0);
9232 while( next < nquadelems )
9236 (quadelems[i].idx1 == quadelems[next].idx1 && quadelems[i].idx2 == quadelems[next].idx2));
9239 if( quadelems[next].coef == 0.0 )
9247 quadelems[i-1].idx1 == quadelems[next].idx1 &&
9248 quadelems[i-1].idx2 == quadelems[next].idx2 )
9250 quadelems[i-1].
coef += quadelems[next].
coef;
9256 quadelems[i] = quadelems[next];
9260 assert(next == nquadelems);
9279 assert(blkmem !=
NULL);
9280 assert(node !=
NULL);
9281 assert(node->
depth >= 0);
9282 assert(node->
pos >= 0);
9283 assert(parent !=
NULL);
9284 assert(parent->
depth >= 0);
9285 assert(parent->
pos >= 0);
9306 assert(node !=
NULL);
9312 for( i = 1; i < node->
nparents; ++i )
9313 assert(exprgraphnodecomp((
void*)node->
parents[i-1], (
void*)node->
parents[i]) <= 0);
9337 assert(exprgraph !=
NULL);
9338 assert(node !=
NULL);
9339 assert(*node !=
NULL);
9340 assert((*node)->depth >= 0);
9341 assert((*node)->pos >= 0);
9342 assert((*node)->nparents > 0);
9343 assert(parent !=
NULL);
9344 assert(parent->
depth >= 0);
9345 assert(parent->
pos >= 0);
9346 assert(parent->
depth > (*node)->depth);
9352 assert(pos < (*node)->nparents);
9353 assert((*node)->parents[pos] == parent);
9357 if( pos < (*node)->nparents-1 )
9359 (*node)->parents[pos] = (*node)->parents[(*node)->nparents-1];
9360 (*node)->parentssorted = ((*node)->nparents <= 2);
9362 --(*node)->nparents;
9365 node_ = (*node)->
nuses > 0 ? *node :
NULL;
9386 assert(node !=
NULL);
9387 assert(parent !=
NULL);
9423 assert(blkmem !=
NULL);
9424 assert(node !=
NULL);
9425 assert(node->
depth > 0);
9426 assert(node->
pos >= 0);
9428 assert(exprs !=
NULL || nexprs == 0);
9436 for( i = 0; i < nexprs; ++i )
9438 assert(exprs[i]->depth >= 0);
9439 assert(exprs[i]->pos >= 0);
9440 assert(exprs[i]->depth < node->depth);
9443 existsalready =
FALSE;
9445 for( j = 0; j < orignchildren; ++j )
9449 existsalready =
TRUE;
9453 if( !existsalready )
9458 if( childmap !=
NULL )
9464 if( childmap !=
NULL )
9484 data[node->
nchildren] = data[orignchildren];
9485 for( i = orignchildren; i < node->
nchildren; ++i )
9487 node->
data.data = (
void*)data;
9520 assert(exprgraph !=
NULL);
9521 assert(node !=
NULL);
9522 assert(oldchild !=
NULL);
9523 assert(*oldchild !=
NULL);
9524 assert(newchild !=
NULL);
9526 if( *oldchild == newchild )
9529 SCIPdebugMessage(
"replace child %p in node %p by %p\n", (
void*)*oldchild, (
void*)node, (
void*)newchild);
9532 for( i = 0; i < node->nchildren; ++i )
9534 if( node->children[i] == *oldchild )
9543 node->children[i] = newchild;
9549 assert(i < node->nchildren);
9551 node->simplified =
FALSE;
9563 assert(elem1 !=
NULL);
9564 assert(elem2 !=
NULL);
9584 assert(exprgraph !=
NULL);
9606 assert(exprgraph !=
NULL);
9607 assert(node !=
NULL);
9609 assert(node->
depth == 0);
9610 assert(node->
pos >= 0);
9611 assert(pos !=
NULL);
9620 while( left <= right )
9622 middle = (left+right)/2;
9623 assert(0 <= middle && middle < exprgraph->nconsts);
9635 assert(left == right+1 || *pos >= 0);
9636 if( left == right+1 )
9643 while( exprgraph->
constnodes[*pos] != node && *pos < exprgraph->nconsts-1 && exprgraph->
constnodes[*pos+1]->
data.dbl == node->
data.dbl )
9658 assert(blkmem !=
NULL);
9659 assert(node !=
NULL);
9665 (*node)->data = opdata;
9668 (*node)->depth = -1;
9672 (*node)->parentssorted =
TRUE;
9688 (*node)->enabled =
TRUE;
9699 const char** varnames,
9705 assert(node !=
NULL);
9710 if( varnames !=
NULL )
9727 if( printchildrenbounds )
9730 if( printchildrenbounds )
9735 if( printchildrenbounds )
9738 if( printchildrenbounds )
9743 if( printchildrenbounds )
9746 if( printchildrenbounds )
9751 if( printchildrenbounds )
9754 if( printchildrenbounds )
9759 if( printchildrenbounds )
9765 if( printchildrenbounds )
9771 if( printchildrenbounds )
9780 if( printchildrenbounds )
9798 if( printchildrenbounds )
9808 if( printchildrenbounds )
9820 if( printchildrenbounds )
9837 if( constant != 0.0 || node->
nchildren == 0 )
9849 if( printchildrenbounds )
9861 assert(quadraticdata !=
NULL);
9863 if( quadraticdata->
constant != 0.0 )
9869 if( quadraticdata->
lincoefs[i] == 0.0 )
9872 if( printchildrenbounds )
9876 for( i = 0; i < quadraticdata->
nquadelems; ++i )
9885 if( printchildrenbounds )
9892 if( printchildrenbounds )
9907 assert(polynomialdata !=
NULL);
9914 for( i = 0; i < polynomialdata->
nmonomials; ++i )
9916 monomialdata = polynomialdata->
monomials[i];
9917 if( monomialdata->
coef == 1.0 )
9919 else if( monomialdata->
coef == -1.0 )
9924 for( j = 0; j < monomialdata->
nfactors; ++j )
9927 if( printchildrenbounds )
9931 else if( monomialdata->
exponents[j] != 1.0 )
9956 const char** varnames
9962 assert(exprgraph !=
NULL);
9963 assert(node !=
NULL);
9964 assert(file !=
NULL);
9967 SCIPmessageFPrintInfo(messagehdlr, file,
"n%d_%d [fillcolor=\"%g,%g,%g\", label=\"", node->
depth, node->
pos, color, color, color);
10002 assert(node !=
NULL);
10022 assert(exprOpTable[node->
op].eval !=
NULL);
10027 if( staticbuf != buf )
10044 assert(node !=
NULL);
10070 assert(node !=
NULL);
10071 assert(node->
depth >= 1);
10072 assert(node->
pos >= 0);
10088 childbounds = childboundsstatic;
10102 assert( exprOpTable[node->
op].inteval !=
NULL );
10107 if( childbounds != childboundsstatic )
10124 for( i = 0; i < node->
nparents; ++i )
10127 node->
bounds = newbounds;
10132 for( i = 0; i < node->
nparents; ++i )
10135 node->
bounds = newbounds;
10163 assert(exprgraph !=
NULL);
10164 assert(node !=
NULL);
10165 assert(node->
depth >= 0);
10166 assert(node->
pos >= 0);
10167 assert(minstrength >= 0.0);
10168 assert(cutoff !=
NULL);
10182 minstrength = -1.0;
10320 if( node->
data.dbl != 0.0 )
10484 int minlinactivityinf;
10485 int maxlinactivityinf;
10493 minlinactivity = 0.0;
10494 maxlinactivity = 0.0;
10495 minlinactivityinf = 0;
10496 maxlinactivityinf = 0;
10510 ++minlinactivityinf;
10526 ++maxlinactivityinf;
10535 maxlinactivity = -maxlinactivity;
10538 if( (minlinactivityinf >= 2 || node->
bounds.
sup >= infinity) &&
10539 ( maxlinactivityinf >= 2 || node->
bounds.
inf <= -infinity)
10546 for( i = 0; i < node->
nchildren && !*cutoff; ++i )
10558 assert(minlinactivityinf == 1);
10561 else if( minlinactivityinf == 0 )
10575 assert(maxlinactivityinf == 1);
10578 else if( maxlinactivityinf == 0 )
10605 for( i = 0; i < node->
nchildren && !*cutoff; ++i )
10616 if( childbounds.
inf <= 0.0 && childbounds.
sup >= 0.0 )
10639 int minlinactivityinf;
10640 int maxlinactivityinf;
10650 minlinactivity = coefs[node->
nchildren];
10651 maxlinactivity = -coefs[node->
nchildren];
10652 minlinactivityinf = 0;
10653 maxlinactivityinf = 0;
10665 if( coefs[i] >= 0.0 )
10669 ++minlinactivityinf;
10681 ++minlinactivityinf;
10696 if( coefs[i] >= 0.0 )
10700 ++maxlinactivityinf;
10712 ++maxlinactivityinf;
10727 if( (minlinactivityinf >= 2 || node->
bounds.
sup >= infinity) &&
10728 (maxlinactivityinf >= 2 || node->
bounds.
inf <= -infinity)
10735 for( i = 0; i < node->
nchildren && !*cutoff; ++i )
10739 if( coefs[i] == 0.0 )
10744 if( coefs[i] >= 0.0 )
10760 if( coefs[i] > 0.0 )
10771 assert(minlinactivityinf == 1);
10774 else if( minlinactivityinf == 0 )
10788 assert(maxlinactivityinf == 1);
10789 childbounds.
inf = (node->
bounds.
inf - maxlinactivity)/coefs[i];
10791 else if( maxlinactivityinf == 0 )
10793 childbounds.
inf = (node->
bounds.
inf - maxlinactivity + ac.
sup)/coefs[i];
10810 assert(minlinactivityinf == 1);
10813 else if( minlinactivityinf == 0 )
10828 assert(maxlinactivityinf == 1);
10831 else if( maxlinactivityinf == 0 )
10868 if( nquadelems > 10 )
10874 if( node->
nchildren == 2 && nquadelems > 0 )
10884 for( i = 0; i < nquadelems; ++i )
10885 if( quadelems[i].idx1 == 0 && quadelems[i].idx2 == 0 )
10886 ax += quadelems[i].
coef;
10887 else if( quadelems[i].idx1 == 1 && quadelems[i].idx2 == 1 )
10888 ay += quadelems[i].
coef;
10890 axy += quadelems[i].
coef;
10897 infinity, &childbounds, ax, ay, axy,
10898 lincoefs !=
NULL ? lincoefs[0] : 0.0, lincoefs !=
NULL ? lincoefs[1] : 0.0,
10903 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",
10904 ax, ay, axy, lincoefs !=
NULL ? lincoefs[0] : 0.0, lincoefs !=
NULL ? lincoefs[1] : 0.0,
10919 infinity, &childbounds, ay, ax, axy,
10920 lincoefs !=
NULL ? lincoefs[1] : 0.0, lincoefs !=
NULL ? lincoefs[0] : 0.0,
10926 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",
10927 ax, ay, axy, lincoefs !=
NULL ? lincoefs[0] : 0.0, lincoefs !=
NULL ? lincoefs[1] : 0.0,
10943 for( i = 0; i < node->
nchildren && !*cutoff; ++i )
10953 if( lincoefs !=
NULL )
10955 if( i != k && lincoefs[k] != 0.0 )
10961 for( k = 0; k < nquadelems; ++k )
10963 if( quadelems[k].idx1 == i && quadelems[k].idx2 == i )
10967 else if( quadelems[k].idx1 == i )
10972 else if( quadelems[k].idx2 == i )
10977 else if( quadelems[k].idx1 == quadelems[k].idx2 )
11037 for( i = 0; i < node->
nchildren && !*cutoff; ++i )
11042 for( j = 0; j < nmonomials; ++j )
11044 monomial = monomials[j];
11045 for( k = 0; k < monomial->
nfactors; ++k )
11051 else if( n == 2*monomial->
exponents[k] )
11053 else if( 2*n == monomial->
exponents[k] )
11066 if( nexpishalfn > nexpisdoublen )
11073 for( j = 0; j < nmonomials; ++j )
11075 monomial = monomials[j];
11078 for( k = 0; k < monomial->
nfactors; ++k )
11082 assert(abc_flag ==
'c');
11091 else if( monomial->
exponents[k] == 2*n )
11120 else if( monomial->
exponents[k] == 2*n )
11148 if( abc_flag ==
'a' )
11152 if( a.
inf >= infinity || a.
sup <= -infinity )
11155 else if( abc_flag ==
'b' )
11159 if( b.
inf >= infinity || b.
sup <= -infinity )
11166 if( c.
inf >= infinity || c.
sup <= -infinity )
11172 if( j < nmonomials )
11178 SCIPdebugMessage(
"solve [%10g,%10g]c%d^%g + [%10g,%10g]c%d^%g = [%10g,%10g]",
11217 if( exprdata->prop ==
NULL )
11238 for( c = 0; !*cutoff && c < node->
nchildren; ++c )
11269 assert(exprgraph !=
NULL);
11270 assert(node !=
NULL);
11278 foundduplicates =
FALSE;
11285 for( j = i+1; j < node->
nchildren; ++j )
11300 foundduplicates =
TRUE;
11306 if( foundduplicates )
11326 assert(blkmem !=
NULL);
11327 assert(node !=
NULL);
11337 while( lastnonnull >= 0 && node->
children[lastnonnull] ==
NULL )
11339 for( i = 0; i <= lastnonnull; ++i )
11351 childmap[lastnonnull] = i;
11355 while( lastnonnull >= 0 && node->
children[lastnonnull] ==
NULL )
11358 assert(i > lastnonnull);
11361 if( lastnonnull < node->nchildren-1 )
11367 if( lastnonnull >= 0 )
11391 int maxexpansionexponent,
11406 assert(exprgraph !=
NULL);
11407 assert(node !=
NULL);
11408 assert(node->
depth > 0);
11409 assert(havechange !=
NULL);
11411 blkmem = exprgraph->
blkmem;
11412 assert(blkmem !=
NULL);
11414 SCIPdebugMessage(
"attempt simplification of node %p (%d,%d)\n", (
void*)node, node->
depth, node->pos);
11417 for( i = 0; i < node->nchildren; ++i )
11420 if( node->nchildren > 0 && i == node->nchildren )
11426 SCIPdebugMessage(
"turn node %p (%d,%d) into constant %g\n", (
void*)node, node->depth, node->pos, node->value);
11431 if( exprOpTable[node->op].freedata !=
NULL )
11432 exprOpTable[node->op].freedata(blkmem, node->nchildren, node->data);
11435 for( i = 0; i < node->nchildren; ++i )
11440 node->nchildren = 0;
11444 node->data.dbl = node->value;
11446 *havechange =
TRUE;
11447 node->simplified =
TRUE;
11463 node->simplified =
TRUE;
11468 assert(polynomialdata !=
NULL);
11470 orignchildren = node->nchildren;
11487 for( i = 0; i < node->nchildren; ++i )
11489 if( node->children[i] ==
NULL )
11505 removechild =
TRUE;
11510 for( j = 0; j < polynomialdata->
nmonomials; ++j )
11514 monomial = polynomialdata->
monomials[j];
11520 assert(factorpos >= 0);
11521 assert(factorpos < monomial->nfactors);
11523 assert(factorpos == 0 || monomial->
childidxs[factorpos-1] != i);
11524 assert(factorpos == monomial->
nfactors-1 || monomial->
childidxs[factorpos+1] != i);
11526 SCIPdebugMessage(
"attempt expanding child %d at monomial %d factor %d\n", i, j, factorpos);
11528 if( !
EPSISINT(monomial->
exponents[factorpos], 0.0) && node->children[i]->data.dbl < 0.0 )
11531 SCIPmessagePrintWarning(messagehdlr,
"got negative constant %g to the power of a noninteger exponent %g\n", node->children[i]->data.dbl, monomial->
exponents[factorpos]);
11532 removechild =
FALSE;
11536 monomial->
coef *=
pow(node->children[i]->data.dbl, monomial->
exponents[factorpos]);
11539 if( factorpos < monomial->nfactors-1 )
11548 *havechange =
TRUE;
11558 node->children[i] =
NULL;
11566 for( i = 0; i < node->nchildren; ++i )
11568 if( node->children[i] ==
NULL )
11586 removechild =
TRUE;
11595 while( j < polynomialdata->nmonomials )
11600 monomial = polynomialdata->
monomials[j];
11610 assert(factorpos >= 0);
11611 assert(factorpos < monomial->nfactors);
11613 assert(factorpos == 0 || monomial->
childidxs[factorpos-1] != i);
11614 assert(factorpos == monomial->
nfactors-1 || monomial->
childidxs[factorpos+1] != i);
11616 SCIPdebugMessage(
"attempt expanding child %d at monomial %d factor %d\n", i, j, factorpos);
11623 removechild =
FALSE;
11627 *havechange =
TRUE;
11639 node->children[i] =
NULL;
11651 for( i = 0; i < polynomialdata->
nmonomials; ++i )
11653 monomial = polynomialdata->
monomials[i];
11654 assert(monomial !=
NULL);
11656 for( j = 0; j < monomial->
nfactors; ++j )
11659 assert(monomial->
childidxs[j] < node->nchildren);
11665 for( i = 0; i < node->nchildren; ++i )
11666 if( node->children[i] !=
NULL && !childinuse[i] )
11669 node->children[i] =
NULL;
11678 if( node->nchildren == 0 )
11689 node->data.dbl = val;
11696 *havechange |= (node->nchildren < orignchildren);
11698 node->simplified =
TRUE;
11723 assert(exprgraph !=
NULL);
11724 assert(node !=
NULL);
11725 assert(expr !=
NULL);
11726 assert(nexprvars !=
NULL);
11727 assert(*nexprvars >= 0);
11728 assert(varidx !=
NULL);
11747 assert(node->
data.intval >= 0);
11748 assert(node->
data.intval < exprgraph->
nvars);
11749 assert(varidx[node->
data.intval] >= -1);
11750 assert(varidx[node->
data.intval] < *nexprvars);
11751 if( varidx[node->
data.intval] == -1 )
11753 varidx[node->
data.intval] = *nexprvars;
11771 assert(childexprs !=
NULL);
11779 assert(childexprs !=
NULL);
11792 assert(childexprs !=
NULL);
11810 assert(childexprs !=
NULL);
11835 assert(quaddata !=
NULL);
11847 assert(polynomialdata !=
NULL);
11861 assert(exprdata !=
NULL);
11863 if( exprdata->copydata !=
NULL )
11871 userdata, exprdata->
evalcapability, exprdata->eval, exprdata->inteval, exprdata->curv, exprdata->prop, exprdata->estimate, exprdata->copydata, exprdata->freedata, exprdata->print) );
11901 assert(node !=
NULL);
11902 assert(varsusage !=
NULL);
11906 ++varsusage[node->
data.intval];
11931 assert(node !=
NULL);
11932 assert(compnr !=
NULL);
11933 assert(*compnr >= 0);
11934 assert(childcomps !=
NULL);
11935 assert(varcomps !=
NULL);
11944 varidx = node->
data.intval;
11945 assert(varidx >= 0);
11946 assert(varidx < nvars);
11948 if( varcomps[varidx] == -1 )
11951 varcomps[varidx] = *compnr;
11955 if( varcomps[varidx] == *compnr )
11963 for( i = 0; i < nvars; ++i )
11964 if( varcomps[i] == *compnr )
11965 varcomps[i] = varcomps[varidx];
11966 for( i = 0; i < nchildcomps; ++i )
11967 if( childcomps[i] == *compnr )
11968 childcomps[i] = varcomps[varidx];
11969 *compnr = varcomps[varidx];
11986 assert(exprgraph !=
NULL);
11989 if( mindepth <= exprgraph->depth )
11992 olddepth = exprgraph->
depth;
11994 assert(exprgraph->
depth >= mindepth);
12014 assert(exprgraph !=
NULL);
12015 assert(varidx >= 0);
12016 assert(varidx < exprgraph->nvars);
12018 varnode = exprgraph->
varnodes[varidx];
12019 assert(varnode->
data.intval == varidx);
12021 var = exprgraph->
vars[varidx];
12024 if( exprgraph->exprgraphvarremove !=
NULL )
12026 SCIP_CALL( exprgraph->exprgraphvarremove(exprgraph, exprgraph->
userdata, var, varnode) );
12033 if( varidx < exprgraph->nvars-1 )
12036 if( exprgraph->exprgraphvarchgidx !=
NULL )
12041 exprgraph->
vars[varidx] = exprgraph->
vars[exprgraph->
nvars-1];
12047 --exprgraph->
nvars;
12069 assert(exprgraph !=
NULL);
12070 assert(node !=
NULL);
12071 assert(node->
depth >= 0);
12072 assert(newdepth >= 0);
12075 if( node->
depth == newdepth )
12078 SCIPdebugMessage(
"move node %p (%d,%d) to depth %d\n", (
void*)node, node->
depth, node->pos, newdepth);
12082 for( i = 0; i < node->nchildren; ++i )
12083 assert(node->children[i]->depth < newdepth);
12087 for( i = 0; i < node->nparents; ++i )
12089 if( node->parents[i]->depth <= newdepth )
12093 assert(node->parents[i]->depth > newdepth);
12099 assert(exprgraph->
depth > newdepth);
12101 olddepth = node->depth;
12102 oldpos = node->pos;
12106 node->depth = newdepth;
12107 node->pos = exprgraph->
nnodes[newdepth];
12108 exprgraph->
nodes[newdepth][node->pos] = node;
12109 ++exprgraph->
nnodes[newdepth];
12112 for( i = 0; i < node->nchildren; ++i )
12113 node->children[i]->parentssorted =
FALSE;
12116 if( oldpos < exprgraph->
nnodes[olddepth]-1 )
12118 exprgraph->
nodes[olddepth][oldpos] = exprgraph->
nodes[olddepth][exprgraph->
nnodes[olddepth]-1];
12119 exprgraph->
nodes[olddepth][oldpos]->
pos = oldpos;
12122 for( i = 0; i < exprgraph->
nodes[olddepth][oldpos]->
nchildren; ++i )
12125 --exprgraph->
nnodes[olddepth];
12127 if( node->depth == 0 )
12167 int parentcandssize;
12171 assert(exprgraph !=
NULL);
12172 assert(nchildren > 0);
12173 assert(children !=
NULL);
12174 assert(parent !=
NULL);
12186 parentcandssize = children[0]->
nparents;
12189 for( p = 0; p < children[0]->
nparents; ++p )
12190 if( children[0]->parents[p]->op == op &&
12191 children[0]->parents[p]->nchildren == nchildren &&
12202 parentcands[nparentcands++] = children[0]->
parents[p];
12206 for( i = 1; i < nchildren && nparentcands > 0; ++i )
12209 while( p < nparentcands )
12216 parentcands[p] = parentcands[nparentcands-1];
12224 SCIPdebugMessage(
"check %d parent candidates for expr with operator %d and %d children\n", nparentcands, op, nchildren);
12226 if( nparentcands == 0 )
12257 if( nchildren > 2 )
12258 SCIPsortPtr((
void**)children, exprgraphnodecomp, nchildren);
12259 for( p = 0; p < nparentcands; ++p )
12261 assert(parentcands[p]->op == op);
12262 assert(parentcands[p]->nchildren == nchildren);
12264 if( nchildren == 1 )
12266 assert(parentcands[p]->children[0] == children[0]);
12268 *parent = parentcands[p];
12271 else if( nchildren == 2 )
12277 if( (parentcands[p]->children[0] == children[0] && parentcands[p]->children[1] == children[1]) ||
12278 ( parentcands[p]->children[0] == children[1] && parentcands[p]->children[1] == children[0]) )
12280 *parent = parentcands[p];
12289 SCIPsortPtr((
void**)parentcands[p]->children, exprgraphnodecomp, nchildren);
12292 for( i = 0; i < nchildren; ++i )
12293 if( children[i] != parentcands[p]->children[i] )
12295 if( i == nchildren )
12298 *parent = parentcands[p];
12311 for( p = 0; p < nparentcands; ++p )
12313 assert(parentcands[p]->op == op);
12314 assert(parentcands[p]->nchildren == 2);
12316 if( parentcands[p]->children[0] == children[0] && parentcands[p]->children[1] == children[1] )
12319 *parent = parentcands[p];
12330 assert(parentcands[0]->op == op);
12331 assert(parentcands[0]->nchildren == 1);
12332 assert(parentcands[0]->children[0] == children[0]);
12333 assert(parentcands[0]->data.intval == opdata.intval);
12336 *parent = parentcands[0];
12344 assert(parentcands[0]->op == op);
12345 assert(parentcands[0]->nchildren == 1);
12346 assert(parentcands[0]->children[0] == children[0]);
12347 assert(parentcands[0]->data.dbl == opdata.dbl);
12350 *parent = parentcands[0];
12363 if( exprchildren !=
NULL )
12364 SCIPsortPtrPtrReal((
void**)children, (
void**)exprchildren, exprcoef, exprgraphnodecomp, nchildren);
12366 SCIPsortPtrReal((
void**)children, exprcoef, exprgraphnodecomp, nchildren);
12367 for( p = 0; p < nparentcands; ++p )
12369 assert(parentcands[p]->op == op);
12370 assert(parentcands[p]->nchildren == nchildren);
12373 assert(exprcoef[nchildren] == candcoef[nchildren]);
12376 SCIPsortPtrReal((
void**)parentcands[p]->children, candcoef, exprgraphnodecomp, nchildren);
12379 for( i = 0; i < nchildren; ++i )
12381 if( children[i] != parentcands[p]->children[i] )
12383 if( exprcoef[i] != candcoef[i] )
12386 if( i < nchildren )
12390 *parent = parentcands[p];
12414 for( i = 0; i < nchildren; ++i )
12417 if( exprlincoef !=
NULL )
12418 if( exprchildren !=
NULL )
12419 SCIPsortPtrPtrRealInt((
void**)children, (
void**)exprchildren, exprlincoef, invperm, exprgraphnodecomp, nchildren);
12421 SCIPsortPtrRealInt((
void**)children, exprlincoef, invperm, exprgraphnodecomp, nchildren);
12423 if( exprchildren !=
NULL )
12424 SCIPsortPtrPtrInt((
void**)children, (
void**)exprchildren, invperm, exprgraphnodecomp, nchildren);
12426 SCIPsortPtrInt((
void**)children, invperm, exprgraphnodecomp, nchildren);
12429 for( i = 0; i < nchildren; ++i )
12430 perm[invperm[i]] = i;
12448 for( p = 0; p < nparentcands; ++p )
12450 assert(parentcands[p]->op == op);
12451 assert(parentcands[p]->nchildren == nchildren);
12459 for( i = 0; i < nchildren; ++i )
12462 if( candlincoef !=
NULL )
12463 SCIPsortPtrRealInt((
void**)parentcands[p]->children, candlincoef, invperm, exprgraphnodecomp, parentcands[p]->nchildren);
12465 SCIPsortPtrInt((
void**)parentcands[p]->children, invperm, exprgraphnodecomp, nchildren);
12468 for( i = 0; i < nchildren; ++i )
12469 perm[invperm[i]] = i;
12488 for( i = 0; i < nchildren; ++i )
12490 if( children[i] != parentcands[p]->children[i] )
12492 if( (exprlincoef ==
NULL ? 0.0 : exprlincoef[i]) != (candlincoef ==
NULL ? 0.0 : candlincoef[i]) )
12495 if( i < nchildren )
12509 *parent = parentcands[p];
12535 for( i = 0; i < nchildren; ++i )
12538 if( exprchildren !=
NULL )
12539 SCIPsortPtrPtrInt((
void**)children, (
void**)exprchildren, invperm, exprgraphnodecomp, nchildren);
12541 SCIPsortPtrInt((
void**)children, invperm, exprgraphnodecomp, nchildren);
12544 for( i = 0; i < nchildren; ++i )
12545 perm[invperm[i]] = i;
12551 for( p = 0; p < nparentcands; ++p )
12553 assert(parentcands[p]->op == op);
12554 assert(parentcands[p]->nchildren == nchildren);
12561 for( i = 0; i < nchildren; ++i )
12564 SCIPsortPtrInt((
void**)parentcands[p]->children, invperm, exprgraphnodecomp, nchildren);
12567 for( i = 0; i < nchildren; ++i )
12568 perm[invperm[i]] = i;
12575 for( i = 0; i < nchildren; ++i )
12576 if( children[i] != parentcands[p]->children[i] )
12578 if( i < nchildren )
12588 *parent = parentcands[p];
12638 assert(exprgraph !=
NULL);
12639 assert(expr !=
NULL);
12640 assert(exprnode !=
NULL);
12641 assert(exprnodeisnew !=
NULL);
12649 assert(*exprnode !=
NULL);
12651 assert((*exprnode)->data.intval >= 0);
12652 assert((*exprnode)->data.intval < exprgraph->
nvars);
12653 assert(exprgraph->
vars[(*exprnode)->data.intval] == vars[expr->
data.intval]);
12655 *exprnodeisnew = (*exprnode)->nuses == 0 && (*exprnode)->nparents == 0;
12666 assert(*exprnode !=
NULL);
12668 assert((*exprnode)->data.dbl == expr->
data.dbl);
12670 *exprnodeisnew = (*exprnode)->nuses == 0 && (*exprnode)->nparents == 0;
12679 assert(params !=
NULL);
12682 assert(*exprnode !=
NULL);
12684 assert((*exprnode)->data.dbl == params[expr->
data.intval]);
12686 *exprnodeisnew = (*exprnode)->nuses == 0 && (*exprnode)->nparents == 0;
12698 nochildisnew =
TRUE;
12702 assert(childnodes[i] !=
NULL);
12703 nochildisnew &= !childisnew;
12711 if( *exprnode !=
NULL )
12714 (*exprnode)->enabled =
TRUE;
12715 *exprnodeisnew =
FALSE;
12730 if( exprOpTable[expr->
op].copydata !=
NULL )
12736 opdata = expr->
data;
12741 *exprnodeisnew =
TRUE;
12765 assert(exprgraph !=
NULL);
12766 assert(clearreverseprop !=
NULL);
12767 assert(boundchanged !=
NULL);
12769 *boundchanged =
FALSE;
12770 for( i = 0; i < exprgraph->
nvars; ++i )
12794 for( p = 0; p < node->
nparents; ++p )
12800 *boundchanged =
TRUE;
12803 *clearreverseprop =
TRUE;
12808 for( p = 0; p < node->
nparents; ++p )
12814 *boundchanged =
TRUE;
12837 #undef SCIPexprgraphCaptureNode 12838 #undef SCIPexprgraphIsNodeEnabled 12839 #undef SCIPexprgraphGetNodeNChildren 12840 #undef SCIPexprgraphGetNodeChildren 12841 #undef SCIPexprgraphGetNodeNParents 12842 #undef SCIPexprgraphGetNodeParents 12843 #undef SCIPexprgraphGetNodeDepth 12844 #undef SCIPexprgraphGetNodePosition 12845 #undef SCIPexprgraphGetNodeOperator 12846 #undef SCIPexprgraphGetNodeOperatorIndex 12847 #undef SCIPexprgraphGetNodeOperatorReal 12848 #undef SCIPexprgraphGetNodeVar 12849 #undef SCIPexprgraphGetNodeRealPowerExponent 12850 #undef SCIPexprgraphGetNodeIntPowerExponent 12851 #undef SCIPexprgraphGetNodeSignPowerExponent 12852 #undef SCIPexprgraphGetNodeLinearCoefs 12853 #undef SCIPexprgraphGetNodeLinearConstant 12854 #undef SCIPexprgraphGetNodeQuadraticConstant 12855 #undef SCIPexprgraphGetNodeQuadraticLinearCoefs 12856 #undef SCIPexprgraphGetNodeQuadraticQuadElements 12857 #undef SCIPexprgraphGetNodeQuadraticNQuadElements 12858 #undef SCIPexprgraphGetNodePolynomialMonomials 12859 #undef SCIPexprgraphGetNodePolynomialNMonomials 12860 #undef SCIPexprgraphGetNodePolynomialConstant 12861 #undef SCIPexprgraphGetNodeUserData 12862 #undef SCIPexprgraphHasNodeUserEstimator 12863 #undef SCIPexprgraphGetNodeBounds 12864 #undef SCIPexprgraphGetNodeVal 12865 #undef SCIPexprgraphGetNodeCurvature 12872 assert(node->
nuses >= 0);
12884 assert(node !=
NULL);
12894 assert(node !=
NULL);
12904 assert(node !=
NULL);
12914 assert(node !=
NULL);
12924 assert(node !=
NULL);
12934 assert(node !=
NULL);
12936 return node->
depth;
12944 assert(node !=
NULL);
12954 assert(node !=
NULL);
12964 assert(node !=
NULL);
12967 return node->
data.intval;
12975 assert(node !=
NULL);
12978 return node->
data.dbl;
12987 assert(exprgraph !=
NULL);
12988 assert(node !=
NULL);
12990 assert(node->
data.intval >= 0);
12991 assert(node->
data.intval < exprgraph->
nvars);
12993 return exprgraph->
vars[node->
data.intval];
13001 assert(node !=
NULL);
13004 return node->
data.dbl;
13012 assert(node !=
NULL);
13015 return node->
data.intval;
13023 assert(node !=
NULL);
13026 return node->
data.dbl;
13034 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);
13117 assert(node !=
NULL);
13129 assert(node !=
NULL);
13155 assert(node !=
NULL);
13156 assert(node->
depth >= 0);
13157 assert(node->
pos >= 0);
13162 assert(monomialidx >= 0);
13164 assert(curv !=
NULL);
13173 assert(monomial !=
NULL);
13183 childbounds = childboundsstatic;
13184 childcurv = childcurvstatic;
13188 for( i = 0; i < monomial->
nfactors; ++i )
13191 assert(child !=
NULL);
13199 childbounds[i] = child->
bounds;
13200 childcurv[i] = child->
curv;
13208 if( childbounds != childboundsstatic )
13222 assert(node !=
NULL);
13234 assert(node !=
NULL);
13246 assert(node !=
NULL);
13256 assert(node !=
NULL);
13258 return node->
value;
13266 assert(node !=
NULL);
13282 assert(blkmem !=
NULL);
13283 assert(node !=
NULL);
13297 SCIPerrorMessage(
"cannot create node with operand %d via SCIPexprgraphCreateNode\n");
13322 opdata.data =
NULL;
13338 opdata.intval = va_arg( ap,
int);
13366 assert(blkmem !=
NULL);
13367 assert(node !=
NULL);
13372 data[ncoefs] = constant;
13374 opdata.data = data;
13394 assert(blkmem !=
NULL);
13395 assert(node !=
NULL);
13396 assert(quadelems !=
NULL || nquadelems == 0);
13400 opdata.data = data;
13419 assert(blkmem !=
NULL);
13420 assert(node !=
NULL);
13421 assert(monomials !=
NULL || nmonomials == 0);
13425 opdata.data = data;
13440 assert(blkmem !=
NULL);
13441 assert(node !=
NULL);
13443 assert(monomials !=
NULL || nmonomials == 0);
13469 assert(blkmem !=
NULL);
13470 assert(node !=
NULL);
13474 assert(copydata !=
NULL || data ==
NULL);
13475 assert(freedata !=
NULL || data ==
NULL);
13481 exprdata->eval =
eval;
13482 exprdata->estimate = estimate;
13483 exprdata->inteval = inteval;
13484 exprdata->curv = curv;
13485 exprdata->prop = prop;
13486 exprdata->copydata = copydata;
13487 exprdata->freedata = freedata;
13488 exprdata->print = print;
13490 opdata.data = (
void*) exprdata;
13521 assert(exprgraph !=
NULL);
13522 assert(node !=
NULL);
13523 assert(*node !=
NULL);
13524 assert((*node)->nuses > 0);
13525 assert(nlinvars !=
NULL);
13526 assert(linvars !=
NULL || linvarssize == 0);
13527 assert(lincoefs !=
NULL || linvarssize == 0);
13528 assert(constant !=
NULL);
13536 switch( (*node)->op )
13540 if( linvarssize >= 1 )
13543 linvars[0] = exprgraph->
vars[(*node)->data.intval];
13553 *constant = (*node)->data.dbl;
13562 if( (*node)->data.dbl == 1.0 && (*node)->children[0]->op ==
SCIP_EXPR_VARIDX && linvarssize >= 1 )
13565 linvars[0] = exprgraph->
vars[(*node)->children[0]->data.intval];
13575 if( (*node)->data.intval == 1 && (*node)->children[0]->op ==
SCIP_EXPR_VARIDX && linvarssize >= 1 )
13578 linvars[0] = exprgraph->
vars[(*node)->children[0]->data.intval];
13590 *constant = (*node)->children[0]->data.dbl;
13592 linvars[0] = exprgraph->
vars[(*node)->children[1]->data.intval];
13601 *constant = (*node)->children[1]->data.dbl;
13603 linvars[0] = exprgraph->
vars[(*node)->children[0]->data.intval];
13613 linvars[0] = exprgraph->
vars[(*node)->children[0]->data.intval];
13615 linvars[1] = exprgraph->
vars[(*node)->children[1]->data.intval];
13634 *constant = (*node)->children[0]->data.dbl;
13636 linvars[0] = exprgraph->
vars[(*node)->children[1]->data.intval];
13637 lincoefs[0] = -1.0;
13645 *constant = -(*node)->children[1]->data.dbl;
13647 linvars[0] = exprgraph->
vars[(*node)->children[0]->data.intval];
13657 linvars[0] = exprgraph->
vars[(*node)->children[0]->data.intval];
13659 linvars[1] = exprgraph->
vars[(*node)->children[1]->data.intval];
13660 lincoefs[1] = -1.0;
13679 linvars[0] = exprgraph->
vars[(*node)->children[1]->data.intval];
13680 lincoefs[0] = (*node)->children[0]->data.dbl;
13687 linvars[0] = exprgraph->
vars[(*node)->children[0]->data.intval];
13688 lincoefs[0] = (*node)->children[1]->data.dbl;
13703 linvars[0] = exprgraph->
vars[(*node)->children[0]->data.intval];
13704 lincoefs[0] = 1.0/(*node)->children[1]->data.dbl;
13737 for( i = 0; i < (*node)->nchildren; ++i )
13743 if( i == (*node)->nchildren )
13751 assert(exprgraph->
nvars > 0);
13752 orignvars = exprgraph->
nvars;
13760 if( (*node)->nparents > 0 || (*node)->nuses > 1 )
13766 if( exprOpTable[orignode->
op].copydata !=
NULL )
13771 data = orignode->
data;
13778 havechange =
FALSE;
13780 switch( (*node)->op )
13792 assert(linvarssize >= 1);
13796 varidx = varchild->
data.intval;
13798 if( varsusage[varidx] > 1 )
13803 linvars[0] = exprgraph->
vars[varidx];
13805 lincoefs[0] = -1.0;
13809 if( (*node)->op ==
SCIP_EXPR_PLUS || (*node)->children[0] == otherchild )
13814 *node = otherchild;
13824 (*node)->children[0] = otherchild;
13832 (*node)->data.data = (
void*)lindata;
13848 nchildren = (*node)->nchildren;
13849 while( i < nchildren )
13854 *constant += (*node)->children[i]->data.dbl;
13857 if( i < nchildren-1 )
13859 (*node)->children[i] = (*node)->children[nchildren-1];
13860 (*node)->children[nchildren-1] =
NULL;
13875 if( varsusage[(*node)->children[i]->data.intval] > 1 )
13882 if( *nlinvars < linvarssize )
13884 linvars[*nlinvars] = exprgraph->
vars[(*node)->children[i]->data.intval];
13885 lincoefs[*nlinvars] = 1.0;
13889 if( i < nchildren-1 )
13891 (*node)->children[i] = (*node)->children[nchildren-1];
13892 (*node)->children[nchildren-1] =
NULL;
13899 assert(i == nchildren);
13901 if( nchildren == 0 )
13906 (*node)->nchildren = 0;
13911 if( nchildren < (*node)->nchildren )
13916 (*node)->nchildren = nchildren;
13919 if( havechange && (*node)->nchildren == 1 )
13940 coefs = (
SCIP_Real*)(*node)->data.data;
13941 assert(coefs !=
NULL);
13944 if( coefs[(*node)->nchildren] != 0.0 )
13946 *constant = coefs[(*node)->nchildren];
13947 coefs[(*node)->nchildren] = 0.0;
13952 nchildren = (*node)->nchildren;
13953 while( i < nchildren )
13958 *constant += coefs[i] * (*node)->children[i]->data.dbl;
13961 if( i < nchildren-1 )
13963 (*node)->children[i] = (*node)->children[nchildren-1];
13964 (*node)->children[nchildren-1] =
NULL;
13965 coefs[i] = coefs[nchildren-1];
13966 coefs[nchildren-1] = 0.0;
13981 if( varsusage[(*node)->children[i]->data.intval] > 1 )
13988 if( *nlinvars < linvarssize )
13990 linvars[*nlinvars] = exprgraph->
vars[(*node)->children[i]->data.intval];
13991 lincoefs[*nlinvars] = coefs[i];
13995 if( i < nchildren-1 )
13997 (*node)->children[i] = (*node)->children[nchildren-1];
13998 (*node)->children[nchildren-1] =
NULL;
13999 coefs[i] = coefs[nchildren-1];
14000 coefs[nchildren-1] = 0.0;
14007 assert(i == nchildren);
14009 if( nchildren == 0 )
14015 (*node)->data.data =
NULL;
14016 (*node)->nchildren = 0;
14022 if( nchildren < (*node)->nchildren )
14028 coefs[nchildren] = 0.0;
14029 (*node)->data.data = (
void*)coefs;
14030 (*node)->nchildren = nchildren;
14033 if( havechange && (*node)->nchildren == 1 && coefs[0] == 1.0 )
14057 assert(quaddata !=
NULL);
14084 nchildren = (*node)->nchildren;
14085 for( i = 0; i < nchildren; ++i )
14088 if( *nlinvars >= linvarssize )
14095 if( varsusage[(*node)->children[i]->data.intval] > 1 )
14099 linvars[*nlinvars] = exprgraph->
vars[(*node)->children[i]->data.intval];
14100 lincoefs[*nlinvars] = quaddata->
lincoefs[i];
14107 if( i < nchildren-1 )
14109 (*node)->children[i] = (*node)->children[nchildren-1];
14111 childused[i] = childused[nchildren-1];
14112 childmap[nchildren-1] = i;
14123 if( nchildren < (*node)->nchildren )
14142 if( nchildren == 0 )
14147 exprFreeDataQuadratic(exprgraph->
blkmem, (*node)->nchildren, (*node)->data);
14148 (*node)->data.data =
NULL;
14149 (*node)->nchildren = 0;
14155 if( nchildren < (*node)->nchildren )
14160 (*node)->nchildren = nchildren;
14175 assert(polynomialdata !=
NULL);
14181 if( polynomialdata->
constant != 0.0 )
14183 *constant = polynomialdata->
constant;
14189 if( linvarssize == 0 )
14195 for( i = 0; i < polynomialdata->
nmonomials; ++i )
14197 monomial = polynomialdata->
monomials[i];
14198 assert(monomial !=
NULL);
14201 for( j = 0; j < monomial->
nfactors; ++j )
14204 assert(monomial->
childidxs[j] < (*node)->nchildren);
14210 for( i = 0; i < polynomialdata->
nmonomials && *nlinvars < linvarssize; ++i )
14212 monomial = polynomialdata->
monomials[i];
14213 assert(monomial !=
NULL);
14218 if( monomial->
coef != 0.0 )
14220 *constant += monomial->
coef;
14231 assert((*node)->children[childidx] !=
NULL);
14234 if( childused[childidx] || varsusage[(*node)->children[childidx]->data.intval] > 1 )
14240 linvars[*nlinvars] = exprgraph->
vars[(*node)->children[childidx]->data.intval];
14241 lincoefs[*nlinvars] = monomial->
coef;
14244 monomial->
coef = 0.0;
14249 (*node)->children[childidx] =
NULL;
14256 if( *nlinvars > 0 )
14263 if( (*node)->nchildren == 0 )
14266 assert(polynomialdata->
constant == 0.0);
14280 if( orignode !=
NULL )
14286 assert(*constant == 0.0);
14287 assert(*nlinvars == 0);
14288 assert(*node !=
NULL);
14298 else if( havechange && *node !=
NULL )
14302 (*node)->simplified =
FALSE;
14323 assert(exprgraph !=
NULL);
14324 assert(srcnode !=
NULL);
14325 assert(*srcnode !=
NULL);
14326 assert(targetnode !=
NULL);
14328 while( *srcnode !=
NULL && (*srcnode)->nparents > 0 )
14330 if( (*srcnode)->parents[0]->depth <= targetnode->
depth )
14336 assert(*srcnode ==
NULL || (*srcnode)->nuses > 0);
14356 assert(exprgraph !=
NULL);
14357 assert(node !=
NULL);
14358 assert(*node !=
NULL);
14359 assert((*node)->depth >= 0);
14360 assert((*node)->pos >= 0);
14361 assert((*node)->depth < exprgraph->
depth);
14362 assert((*node)->pos < exprgraph->
nnodes[(*node)->depth]);
14363 assert((*node)->nuses >= 1);
14364 assert(exprgraph->
nodes[(*node)->depth][(*node)->pos] == *node);
14371 if( (*node)->nparents > 0 || (*node)->nuses > 0 )
14373 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);
14382 for( i = 0; i < (*node)->nchildren; ++i )
14385 (*node)->children[i] =
NULL;
14390 assert((*node)->depth == 0);
14398 assert(constidx >= 0);
14399 assert(constidx < exprgraph->nconsts);
14400 assert(exprgraph->
constnodes[constidx] == *node);
14403 if( constidx < exprgraph->nconsts-1 )
14413 assert((*node)->depth > 0);
14417 if( (*node)->pos < exprgraph->
nnodes[(*node)->depth]-1 )
14420 exprgraph->
nodes[(*node)->depth][(*node)->pos] = exprgraph->
nodes[(*node)->depth][exprgraph->
nnodes[(*node)->depth]-1];
14421 exprgraph->
nodes[(*node)->depth][(*node)->pos]->
pos = (*node)->pos;
14424 for( i = 0; i < exprgraph->
nodes[(*node)->depth][(*node)->pos]->
nchildren; ++i )
14427 --exprgraph->
nnodes[(*node)->depth];
14430 (*node)->depth = -1;
14448 assert(blkmem !=
NULL);
14449 assert( node !=
NULL);
14450 assert(*node !=
NULL);
14451 assert((*node)->depth == -1);
14452 assert((*node)->pos == -1);
14453 assert((*node)->nuses == 0);
14456 if( exprOpTable[(*node)->op].freedata !=
NULL )
14457 exprOpTable[(*node)->op].freedata(blkmem, (*node)->nchildren, (*node)->data);
14475 assert(exprgraph !=
NULL);
14476 assert(node !=
NULL);
14477 assert(node->
depth >= 0);
14478 assert(node->
pos >= 0);
14485 node->enabled =
TRUE;
14486 for( i = 0; i < node->nchildren; ++i )
14502 assert(exprgraph !=
NULL);
14503 assert(node !=
NULL);
14504 assert(node->
depth >= 0);
14505 assert(node->
pos >= 0);
14514 if( node->
nuses > 1 )
14519 for( i = 0; i < node->
nparents; ++i )
14526 SCIPdebugMessage(
"disabled node %p (%d,%d), nuses = %d\n", (
void*)node, node->
depth, node->pos, node->nuses);
14528 for( i = 0; i < node->nchildren; ++i )
14539 assert(node !=
NULL);
14541 for( p = 0; p < node->
nparents; ++p )
14558 assert(node !=
NULL);
14574 for( p = 0; p < node->
nparents; ++p )
14611 assert(node !=
NULL);
14630 assert(exprgraph !=
NULL);
14631 assert(node !=
NULL);
14632 assert(node->
depth >= 0);
14633 assert(node->
pos >= 0);
14635 assert(cutoff !=
NULL);
14642 SCIPdebugMessage(
"ignore bound tightening for node %p (%d,%d)\n", (
void*)node, node->
depth, node->pos);
14646 SCIPdebugMessage(
"tighten bounds of node %p (%d,%d) from [%10g, %10g] by [%10g, %10g]",
14647 (
void*)node, node->
depth, node->pos,
14648 node->bounds.inf, node->bounds.sup, nodebounds.
inf, nodebounds.
sup);
14653 if( nodebounds.
inf > node->bounds.sup || nodebounds.
sup < node->bounds.inf )
14666 if( minstrength < 0.0 )
14669 isLbBetter(minstrength, nodebounds.
inf, node->bounds.inf, node->bounds.sup) ||
14670 isUbBetter(minstrength, nodebounds.
sup, node->bounds.inf, node->bounds.sup) )
14672 else if( nodebounds.
inf > node->bounds.inf || nodebounds.
sup < node->bounds.sup )
14676 SCIPdebugPrintf(
" -> [%10g, %10g] status %d\n", node->bounds.inf, node->bounds.sup, node->boundstatus);
14696 assert(node !=
NULL);
14697 assert(node->
depth >= 0);
14698 assert(node->
pos >= 0);
14701 if( node->
depth == 0 )
14719 childbounds = childboundsstatic;
14720 childcurv = childcurvstatic;
14743 assert( exprOpTable[node->
op].inteval !=
NULL );
14756 for( i = 0; i < node->
nparents; ++i )
14759 node->
bounds = newbounds;
14764 for( i = 0; i < node->
nparents; ++i )
14767 node->
bounds = newbounds;
14785 SCIPdebugMessage(
"node %p(%d,%d) has empty domain in SCIPexprgraphUpdateNodeBoundsCurvature\n", (
void*)node, node->
depth, node->pos);
14798 if( childbounds != childboundsstatic )
14818 #undef SCIPexprgraphGetDepth 14819 #undef SCIPexprgraphGetNNodes 14820 #undef SCIPexprgraphGetNodes 14821 #undef SCIPexprgraphGetNVars 14822 #undef SCIPexprgraphGetVars 14823 #undef SCIPexprgraphGetVarNodes 14824 #undef SCIPexprgraphSetVarNodeValue 14825 #undef SCIPexprgraphSetVarsBounds 14826 #undef SCIPexprgraphSetVarBounds 14827 #undef SCIPexprgraphSetVarNodeBounds 14828 #undef SCIPexprgraphSetVarNodeLb 14829 #undef SCIPexprgraphSetVarNodeUb 14830 #undef SCIPexprgraphGetVarsBounds 14837 assert(exprgraph !=
NULL);
14839 return exprgraph->
depth;
14847 assert(exprgraph !=
NULL);
14849 return exprgraph->
nnodes;
14857 assert(exprgraph !=
NULL);
14859 return exprgraph->
nodes;
14867 assert(exprgraph !=
NULL);
14869 return exprgraph->
nvars;
14877 assert(exprgraph !=
NULL);
14879 return exprgraph->
vars;
14887 assert(exprgraph !=
NULL);
14898 assert(varnode !=
NULL);
14901 varnode->
value = value;
14910 assert(exprgraph !=
NULL);
14911 assert(varbounds !=
NULL || exprgraph->
nvars == 0);
14925 assert(exprgraph !=
NULL);
14926 assert(var !=
NULL);
14930 assert(pos < exprgraph->nvars);
14931 assert(exprgraph->
vars[pos] == var);
14945 assert(exprgraph !=
NULL);
14946 assert(varnode !=
NULL);
14948 pos = varnode->
data.intval;
14950 assert(pos < exprgraph->nvars);
14951 assert(exprgraph->
varnodes[pos] == varnode);
14965 assert(exprgraph !=
NULL);
14966 assert(varnode !=
NULL);
14968 pos = varnode->
data.intval;
14970 assert(pos < exprgraph->nvars);
14971 assert(exprgraph->
varnodes[pos] == varnode);
14985 assert(exprgraph !=
NULL);
14986 assert(varnode !=
NULL);
14988 pos = varnode->
data.intval;
14990 assert(pos < exprgraph->nvars);
14991 assert(exprgraph->
varnodes[pos] == varnode);
15016 assert(blkmem !=
NULL);
15017 assert(exprgraph !=
NULL);
15021 (*exprgraph)->blkmem = blkmem;
15025 assert((*exprgraph)->depth >= 1);
15028 ensureBlockMemoryArraySize3((*exprgraph)->blkmem, &(*exprgraph)->varnodes, &(*exprgraph)->vars, &(*exprgraph)->varbounds, &(*exprgraph)->varssize, varssizeinit);
15032 (*exprgraph)->constssorted =
TRUE;
15035 (*exprgraph)->exprgraphvaradded = exprgraphvaradded;
15036 (*exprgraph)->exprgraphvarremove = exprgraphvarremove;
15037 (*exprgraph)->exprgraphvarchgidx = exprgraphvarchgidx;
15038 (*exprgraph)->userdata = userdata;
15051 assert( exprgraph !=
NULL);
15052 assert(*exprgraph !=
NULL);
15053 assert((*exprgraph)->nvars == 0);
15054 assert((*exprgraph)->nconsts == 0);
15056 blkmem = (*exprgraph)->blkmem;
15057 assert(blkmem !=
NULL);
15060 for( d = 0; d < (*exprgraph)->depth; ++d )
15062 assert((*exprgraph)->nnodes[d] == 0);
15065 assert((*exprgraph)->nodes !=
NULL);
15066 assert((*exprgraph)->nnodes !=
NULL);
15067 assert((*exprgraph)->nodessize !=
NULL);
15105 assert(exprgraph !=
NULL);
15106 assert(node !=
NULL);
15107 assert(node->
pos < 0);
15108 assert(node->
depth < 0);
15112 assert(children !=
NULL || nchildren == 0);
15115 depth =
MAX(0, mindepth);
15116 for( i = 0; i < nchildren; ++i )
15118 if( children[i]->depth >= depth )
15119 depth = children[i]->
depth + 1;
15124 assert(exprgraph->
depth > depth);
15130 node->
depth = depth;
15132 exprgraph->
nodes[depth][node->
pos] = node;
15133 ++exprgraph->
nnodes[depth];
15137 childvalsvalid =
TRUE;
15138 for( i = 0; i < nchildren; ++i )
15144 if( nchildren > 0 )
15188 assert(exprgraph !=
NULL);
15189 assert(exprgraph->
depth >= 1);
15190 assert(vars !=
NULL || nvars == 0);
15193 if( exprgraph->
nvars == 0 )
15199 for( i = 0; i < nvars; ++i )
15205 assert(node !=
NULL);
15210 if( varnodes !=
NULL )
15211 varnodes[i] = node;
15217 opdata.intval = exprgraph->
nvars;
15225 exprgraph->
vars[exprgraph->
nvars] = vars[i];
15229 ++exprgraph->
nvars;
15231 if( varnodes !=
NULL )
15232 varnodes[i] = node;
15234 SCIPdebugMessage(
"added node %p (%d, %d) for new variable %d\n", (
void*)node, node->
depth, node->pos, node->data.intval);
15237 if( exprgraph->exprgraphvaradded !=
NULL )
15239 SCIP_CALL( exprgraph->exprgraphvaradded(exprgraph, exprgraph->
userdata, vars[i], node) );
15258 assert(exprgraph !=
NULL);
15259 assert(constnode !=
NULL);
15264 assert(*constnode !=
NULL);
15266 assert((*constnode)->data.dbl == constant);
15267 (*constnode)->enabled =
TRUE;
15272 opdata.dbl = constant;
15277 assert((*constnode)->depth == 0);
15278 assert((*constnode)->pos == exprgraph->
nnodes[0]-1);
15286 SCIPdebugMessage(
"added node %p (%d, %d) for new constant %g\n", (
void*)constnode, (*constnode)->
depth, (*constnode)->pos, (*constnode)->data.dbl);
15308 assert(exprgraph !=
NULL);
15309 assert(nexprtrees > 0);
15310 assert(exprtrees !=
NULL);
15311 assert(rootnode !=
NULL);
15312 assert(rootnodeisnew !=
NULL);
15316 if( nexprtrees == 1 && (coefs ==
NULL || coefs[0] == 1.0) )
15318 assert(exprtrees[0] !=
NULL);
15319 assert(exprtrees[0]->vars !=
NULL || exprtrees[0]->nvars == 0);
15321 SCIP_CALL(
exprgraphAddExpr(exprgraph, exprtrees[0]->root, exprtrees[0]->vars, exprtrees[0]->params, rootnode, rootnodeisnew) );
15330 *rootnodeisnew =
TRUE;
15334 for( i = 0; i < nexprtrees; ++i )
15336 assert(exprtrees[i] !=
NULL);
15337 assert(exprtrees[i]->vars !=
NULL || exprtrees[i]->nvars == 0);
15339 SCIP_CALL(
exprgraphAddExpr(exprgraph, exprtrees[i]->root, exprtrees[i]->vars, exprtrees[i]->params, &rootnodes[i], &rootnodeisnew_) );
15340 assert(rootnodes[i] !=
NULL);
15341 *rootnodeisnew &= rootnodeisnew_;
15343 allone &= (coefs ==
NULL || coefs[i] == 1.0);
15347 if( coefs ==
NULL || allone )
15349 else if( nexprtrees == 2 && coefs[0] == 1.0 && coefs[1] == -1.0 )
15351 else if( nexprtrees == 2 && coefs[1] == 1.0 && coefs[0] == -1.0 )
15355 tmp = rootnodes[0];
15356 rootnodes[0] = rootnodes[1];
15357 rootnodes[1] = tmp;
15368 if( !*rootnodeisnew )
15374 if( *rootnode ==
NULL )
15379 *rootnodeisnew =
TRUE;
15384 *rootnodeisnew =
FALSE;
15397 lindata[nexprtrees] = 0.0;
15398 data.data = lindata;
15400 if( !*rootnodeisnew )
15406 if( *rootnode ==
NULL )
15411 *rootnodeisnew =
TRUE;
15416 *rootnodeisnew =
FALSE;
15423 assert(*rootnode !=
NULL);
15428 rootnodeisnew ?
"new" :
"old", (
void*)*rootnode, (*rootnode)->
depth, (*rootnode)->pos, nexprtrees);
15451 assert(exprgraph !=
NULL);
15452 assert(var !=
NULL);
15454 assert(coefs !=
NULL || ncoefs == 0);
15455 assert(vars !=
NULL || ncoefs == 0);
15458 assert(varidx < exprgraph->nvars);
15459 assert(exprgraph->
vars[varidx] == var);
15460 varnode = exprgraph->
varnodes[varidx];
15461 assert(varnode !=
NULL);
15462 assert(varnode->
data.intval == varidx);
15464 if( ncoefs == 0 || (ncoefs == 1 && constant == 0.0 && coefs[0] == 1.0) )
15474 assert(node ==
NULL || node->
data.dbl == constant);
15479 assert(node ==
NULL || exprgraph->
vars[node->
data.intval] == vars[0]);
15484 SCIPdebugMessage(
"try to replace varnode %p (%d uses, %d parents) by %p\n", (
void*)varnode, varnode->
nuses, varnode->nparents, (
void*)node);
15490 if( varnode !=
NULL )
15492 assert(varnode->nuses > 0);
15493 assert(varnode->nparents == 0);
15503 varnode->data.data =
NULL;
15505 varnode->children[0] = node;
15506 varnode->nchildren = 1;
15509 varnode->value = node->value;
15510 varnode->bounds = node->bounds;
15514 else if( ncoefs == 0 )
15523 varnode->
data.dbl = constant;
15525 varnode->
value = constant;
15542 varnode->
data.intval = exprgraph->
nvars;
15546 exprgraph->
vars[exprgraph->
nvars] = vars[0];
15550 ++exprgraph->
nvars;
15553 if( exprgraph->exprgraphvaradded !=
NULL )
15555 SCIP_CALL( exprgraph->exprgraphvaradded(exprgraph, exprgraph->
userdata, vars[0], varnode) );
15560 if( varnode !=
NULL )
15563 for( i = 0; i < varnode->
nparents; ++i )
15581 lindata[ncoefs] = constant;
15582 varnode->
data.data = (
void*)lindata;
15591 for( i = 0; i < ncoefs; ++i )
15602 for( i = 0; i < varnode->
nparents; ++i )
15617 assert(exprgraph !=
NULL);
15618 assert(var !=
NULL);
15619 assert(varnode !=
NULL);
15628 assert(pos < exprgraph->nvars);
15630 *varnode = exprgraph->
varnodes[pos];
15631 assert(*varnode !=
NULL);
15648 assert(exprgraph !=
NULL);
15649 assert(constnode !=
NULL);
15650 assert(constant == constant);
15657 right = exprgraph->
nconsts-1;
15660 while( left <= right )
15662 middle = (left+right)/2;
15663 assert(0 <= middle && middle < exprgraph->nconsts);
15665 if( constant < exprgraph->constnodes[middle]->data.dbl )
15666 right = middle - 1;
15675 if( left == right+1 )
15678 assert(*constnode !=
NULL);
15680 assert((*constnode)->data.dbl == constant);
15690 const char** varnames
15696 assert(exprgraph !=
NULL);
15704 for( d = 0; d < exprgraph->
depth; ++d )
15706 if( exprgraph->
nnodes[d] == 0 )
15709 for( i = 0; i < exprgraph->
nnodes[d]; ++i )
15717 for( i = 0; i < exprgraph->
nnodes[0]; ++i )
15723 for( d = 0; d < exprgraph->
depth; ++d )
15724 for( i = 0; i < exprgraph->
nnodes[d]; ++i )
15743 assert(exprgraph !=
NULL);
15744 assert(varvals !=
NULL || exprgraph->
nvars == 0);
15746 for( d = 0; d < exprgraph->
depth; ++d )
15747 for( i = 0; i < exprgraph->
nnodes[d]; ++i )
15768 assert(exprgraph !=
NULL);
15769 assert(domainerror !=
NULL);
15771 *domainerror =
FALSE;
15779 SCIPdebugMessage(
"no bounds changed and clearreverseprop is FALSE -> skip propagation of variable bounds\n");
15784 for( d = 1; d < exprgraph->
depth; ++d )
15786 for( i = 0; i < exprgraph->
nnodes[d]; ++i )
15788 node = exprgraph->
nodes[d][i];
15792 SCIPdebugMessage(
"bounds of node %p(%d,%d) empty, stop bounds propagation\n", (
void*)node, node->
depth, node->pos);
15794 *domainerror =
TRUE;
15821 assert(exprgraph !=
NULL);
15822 assert(cutoff !=
NULL);
15826 for( d = exprgraph->
depth-1; d >= 0 && !*cutoff; --d )
15828 for( i = 0; i < exprgraph->
nnodes[d] && !*cutoff; ++i )
15830 node = exprgraph->
nodes[d][i];
15853 assert(exprgraph !=
NULL);
15859 for( i = 0; i < exprgraph->
nnodes[0]; ++i )
15863 for( d = 1; d < exprgraph->
depth; ++d )
15864 for( i = 0; i < exprgraph->
nnodes[d]; ++i )
15866 node = exprgraph->
nodes[d][i];
15867 assert(node !=
NULL);
15873 SCIPerrorMessage(
"SCIPexprgraphCheckCurvature gets domain error while propagating variables bounds, ignoring...\n");
15889 int maxexpansionexponent,
15910 assert(exprgraph !=
NULL);
15911 assert(eps >= 0.0);
15912 assert(havechange !=
NULL);
15913 assert(domainerror !=
NULL);
15923 for( i = 0; i < exprgraph->
nvars; ++i )
15926 for( d = 1; d < exprgraph->
depth; ++d )
15927 for( i = 0; i < exprgraph->
nnodes[d]; ++i )
15929 node = exprgraph->
nodes[d][i];
15930 assert(node !=
NULL);
15933 if( node->
nuses > 0 )
15948 file = fopen(
"exprgraph_beforesimplify.dot",
"w");
15957 *havechange =
FALSE;
15958 *domainerror =
FALSE;
15959 allsimplified =
TRUE;
15964 for( d = 1; d < exprgraph->
depth && !*domainerror; ++d )
15966 for( i = 0; i < exprgraph->
nnodes[d]; ++i )
15968 node = exprgraph->
nodes[d][i];
15969 assert(node !=
NULL);
15971 havechangenode =
FALSE;
15979 allsimplified =
FALSE;
15984 *havechange |= havechangenode;
15994 SCIPdebugMessage(
"Expression graph simplify turned node into NaN or inf.\n");
15995 *domainerror =
TRUE;
16003 assert(constnode->
data.dbl == node->
value);
16010 assert(node ==
NULL || node->
nuses > 0);
16011 havechangenode =
TRUE;
16020 assert(node !=
NULL);
16021 assert(node->
nuses > 0);
16023 if( constnode->
nuses == 0 )
16030 assert(constnode ==
NULL);
16031 havechangenode =
TRUE;
16049 if( havechangenode )
16050 for( j = 0; j < node->
nparents; ++j )
16056 if( allsimplified || *domainerror )
16057 goto EXPRGRAPHSIMPLIFY_CLEANUP;
16062 for( d = 1; d < exprgraph->
depth; ++d )
16064 for( i = 0; i < exprgraph->
nnodes[d]; ++i )
16066 node = exprgraph->
nodes[d][i];
16067 assert(node !=
NULL);
16085 assert(node ==
NULL || node->
nuses > 0);
16097 file = fopen(
"exprgraph_aftersimplify.dot",
"w");
16107 for( d = 1; d < exprgraph->
depth; ++d )
16108 for( i = 0; i < exprgraph->
nnodes[d]; ++i )
16114 node = exprgraph->
nodes[d][i];
16115 assert(node !=
NULL);
16120 if( node->
nuses > 0 )
16125 assert(idx < ntestvals);
16127 testval_before = testvals[idx];
16135 EXPRGRAPHSIMPLIFY_CLEANUP:
16157 assert(exprgraph !=
NULL);
16158 assert(rootnode !=
NULL);
16159 assert(rootnode->
depth >= 0);
16160 assert(rootnode->
pos >= 0);
16161 assert(exprtree !=
NULL);
16167 for( i = 0; i < exprgraph->
nvars; ++i )
16178 if( nexprvars > 0 )
16181 for( i = 0; i < exprgraph->
nvars; ++i )
16183 assert(varidx[i] >= -1);
16184 assert(varidx[i] < nexprvars);
16185 if( varidx[i] >= 0 )
16186 (*exprtree)->vars[varidx[i]] = exprgraph->
vars[i];
16224 assert(exprgraph !=
NULL);
16225 assert(node !=
NULL);
16226 assert(node->
depth >= 0);
16227 assert(node->
pos >= 0);
16228 assert(exprtreessize > 0);
16229 assert(nexprtrees !=
NULL);
16230 assert(exprtrees !=
NULL);
16231 assert(exprtreecoefs !=
NULL);
16235 if( exprtreessize == 1 || node->
nchildren <= 1 || exprgraph->
nvars <= 1 ||
16244 exprtreecoefs[0] = 1.0;
16253 for( i = 0; i < exprgraph->
nvars; ++i )
16256 haveoverlap =
FALSE;
16261 assert(compnr >= 0);
16262 assert(compnr < node->nchildren);
16263 childcomp[i] = compnr;
16267 haveoverlap =
TRUE;
16278 assert(data !=
NULL);
16286 if( childcomp[j] == compnr )
16289 haveoverlap =
TRUE;
16298 assert(data !=
NULL);
16307 if( childcomp[k] == compnr )
16310 haveoverlap =
TRUE;
16326 if( compmap[childcomp[i]] == -1 )
16327 compmap[childcomp[i]] = ncomponents++;
16328 childcomp[i] = compmap[childcomp[i]];
16338 if( ncomponents == 1 )
16344 exprtreecoefs[0] = 1.0;
16350 if( ncomponents > exprtreessize )
16354 if( childcomp[i] >= exprtreessize )
16355 childcomp[i] = exprtreessize-1;
16356 ncomponents = exprtreessize;
16359 assert(ncomponents >= 2);
16366 for( i = 0; i < ncomponents; ++i )
16369 for( j = 0; j < exprgraph->
nvars; ++j )
16377 assert(childcomp[j] >= 0);
16378 assert(childcomp[j] < ncomponents);
16379 if( childcomp[j] != i )
16384 childmap[j] = nexprs;
16385 childmapinv[nexprs] = j;
16394 assert(ncomponents == 2);
16395 assert(nexprs == 1);
16398 exprtreecoefs[i] = 1.0;
16405 assert(ncomponents == 2);
16406 assert(nexprs == 1);
16410 assert(childmapinv[0] == 0 || childmapinv[0] == 1);
16411 exprtreecoefs[i] = (childmapinv[0] == 0 ? 1.0 : -1.0);
16431 exprtreecoefs[i] = 1.0;
16444 if( nexprs == 1 && (i > 0 || nodecoefs[node->
nchildren] == 0.0) )
16448 exprtreecoefs[i] = nodecoefs[childmapinv[0]];
16450 else if( nexprs == 1 )
16454 assert(nodecoefs[node->
nchildren] != 0.0);
16455 assert(nodecoefs[childmapinv[0]] != 0.0);
16459 exprtreecoefs[i] = nodecoefs[childmapinv[0]];
16465 if( nexprs == 2 && nodecoefs[childmapinv[0]] == nodecoefs[childmapinv[1]] && (i > 0 || nodecoefs[node->
nchildren] == 0.0) )
16469 exprtreecoefs[i] = nodecoefs[childmapinv[0]];
16471 else if( nexprs == 2 && nodecoefs[childmapinv[0]] == -nodecoefs[childmapinv[1]] && (i > 0 || nodecoefs[node->
nchildren] == 0.0) )
16475 exprtreecoefs[i] = nodecoefs[childmapinv[0]];
16484 allcoefsequal =
TRUE;
16485 coefs[0] = nodecoefs[childmapinv[0]];
16486 for( j = 0; j < nexprs; ++j )
16488 coefs[j] = nodecoefs[childmapinv[j]];
16489 allcoefsequal &= (coefs[j] == coefs[0]);
16493 if( allcoefsequal && (i > 0 || nodecoefs[node->
nchildren] == 0.0) )
16496 exprtreecoefs[i] = coefs[0];
16501 exprtreecoefs[i] = 1.0;
16523 exprtreecoefs[i] = 1.0;
16529 for( j = 0; j < nexprs; ++j )
16530 lincoefs[j] = nodedata->
lincoefs[childmapinv[j]];
16569 exprtreecoefs[i] = 1.0;
16586 for( k = 0; k < monomials[nmonomials]->
nfactors; ++k )
16589 monomials[nmonomials]->
childidxs[k] = childmap[monomials[nmonomials]->
childidxs[k]];
16608 if( nexprvars > 0 )
16611 for( j = 0; j < exprgraph->
nvars; ++j )
16613 assert(varidx[j] >= -1);
16614 assert(varidx[j] < nexprvars);
16615 if( varidx[j] >= 0 )
16616 exprtrees[i]->
vars[varidx[j]] = exprgraph->
vars[j];
16627 *nexprtrees = ncomponents;
16639 assert(exprgraph !=
NULL);
16640 assert(node !=
NULL);
16641 assert(varsusage !=
NULL);
16698 assert(exprgraph !=
NULL);
16699 assert(node !=
NULL);
16700 assert(node->
depth >= 0);
16701 assert(node->
pos >= 0);
16702 assert(exprtreessize > 0);
16703 assert(nexprtrees !=
NULL);
16704 assert(exprtrees !=
NULL);
16705 assert(exprtreecoefs !=
NULL);
16716 exprtreecoefs[0] = 1.0;
16726 assert(exprtreessize >= 2);
16731 exprtreecoefs[0] = 1.0;
16732 exprtreecoefs[1] = 1.0;
16740 assert(exprtreessize >= 2);
16745 exprtreecoefs[0] = 1.0;
16746 exprtreecoefs[1] = -1.0;
16754 assert(exprtreessize >= node->
nchildren);
16759 exprtreecoefs[i] = 1.0;
16770 assert(exprtreessize >= node->
nchildren);
16774 assert(nodecoefs !=
NULL);
16779 exprtreecoefs[i] = nodecoefs[i];
16783 if( nodecoefs[node->
nchildren] != 0.0 )
16809 assert(exprtreessize >= (lincoefs !=
NULL ? node->
nchildren : 0) + nquadelems);
16813 if( lincoefs !=
NULL )
16817 if( lincoefs[i] == 0.0 )
16820 exprtreecoefs[*nexprtrees] = lincoefs[i];
16828 for( i = 0; i < nquadelems; ++i )
16831 for( j = 0; j < exprgraph->
nvars; ++j )
16838 if( quadelems[i].idx1 == quadelems[i].idx2 )
16857 if( nexprvars > 0 )
16860 for( j = 0; j < exprgraph->
nvars; ++j )
16862 assert(varidx[j] >= -1);
16863 assert(varidx[j] < nexprvars);
16864 if( varidx[j] >= 0 )
16865 exprtrees[*nexprtrees]->
vars[varidx[j]] = exprgraph->
vars[j];
16869 exprtreecoefs[*nexprtrees] = quadelems[i].
coef;
16879 assert(*nexprtrees > 0);
16904 assert(exprtreessize >= nmonomials);
16912 for( i = 0; i < nmonomials; ++i )
16915 for( j = 0; j < exprgraph->
nvars; ++j )
16919 if( monomials[i]->nfactors == 1 )
16925 if( monomials[i]->exponents[0] == 1.0 )
16927 else if( monomials[i]->exponents[0] == 2.0 )
16931 else if(
EPSISINT(monomials[i]->exponents[0], 0.0) )
16940 else if( monomials[i]->nfactors == 2 && monomials[i]->exponents[0] == 1.0 && monomials[i]->exponents[1] == 1.0 )
16961 for( f = 0; f < monomials[i]->
nfactors; ++f )
16982 if( nexprvars > 0 )
16985 for( j = 0; j < exprgraph->
nvars; ++j )
16987 assert(varidx[j] >= -1);
16988 assert(varidx[j] < nexprvars);
16989 if( varidx[j] >= 0 )
16990 exprtrees[*nexprtrees]->
vars[varidx[j]] = exprgraph->
vars[j];
16994 exprtreecoefs[*nexprtrees] = monomials[i]->
coef;
17000 if( constant != 0.0 )
17004 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)
static SCIP_DECL_SORTPTRCOMP(exprgraphnodecomp)
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_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)