40 #define SCIP_EXPRESSION_MAXCHILDEST 16 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 )
696 assert(sourcepolynomialdata->
monomials[i] != NULL);
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 )
856 assert(polynomialdata->
monomials[i] == NULL);
857 assert(polynomialdata->
monomials[i+offset] != NULL);
860 polynomialdata->
monomials[i+offset] = NULL;
874 while( i+offset+1 < polynomialdata->
nmonomials )
876 assert(polynomialdata->
monomials[i+offset+1] != NULL);
886 if( monomialdataCompare((
void*)polynomialdata->
monomials[i], (
void*)polynomialdata->
monomials[i+offset+1]) != 0 )
914 assert(polynomialdata->
monomials[i] == NULL);
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);
1206 assert(childmap != NULL || factorpolynomial->
nmonomials == 0);
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);
2815 if( quadraticdata->
lincoefs != NULL )
2822 assert(quadraticdata->
quadelems != 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);
3097 SCIP_CALL( exprdata->eval(exprdata->
userdata, nargs, argvals, result, NULL, 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 )
3168 assert(exprdatatarget->
userdata == NULL);
3171 opdatatarget->data = (
void*)exprdatatarget;
3182 assert(blkmem != NULL);
3187 if( exprdata->freedata != NULL )
3189 exprdata->freedata(blkmem, nchildren, exprdata->
userdata);
3193 assert(exprdata->
userdata == NULL);
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 },
3234 {
"sin", 1, exprevalSin, exprevalIntSin,
exprcurvSin, NULL, NULL },
3235 {
"cos", 1, exprevalCos, exprevalIntCos,
exprcurvCos, 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 )
3972 assert(quaddata->
lincoefs != NULL);
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 )
4372 assert(expr->
children[lastnonnull] != NULL);
4376 expr->
children[lastnonnull] = NULL;
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 )
4447 if( expr->
children[i] != NULL && !childinuse[i] )
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));
4930 int* varnameslength,
4933 const char* varnameendptr
4943 assert(blkmem != NULL);
4944 assert(str != NULL);
4945 assert(expr != NULL);
4946 assert(nvars != NULL);
4947 assert(varnames != NULL);
4948 assert(vartable != NULL);
4950 if( varnameendptr == NULL )
4953 varnameendptr = *str;
4954 while( varnameendptr[0] !=
'>' )
4958 namelength = varnameendptr - *str;
4961 SCIPerrorMessage(
"Variable name %.*s is too long for buffer in exprparseReadVariable.\n", namelength, str);
4965 memcpy(varname, *str, namelength *
sizeof(
char));
4966 varname[namelength] =
'\0';
4969 if( element != NULL )
4972 assert(strcmp((
char*)element +
sizeof(
int), varname) == 0);
4974 varidx = *(
int*)element;
4981 (*varnameslength) -= (int)(1 + (strlen(varname) + 1) /
sizeof(
int) + 1);
4982 if( *varnameslength < 0 )
4984 SCIPerrorMessage(
"Buffer in exprparseReadVariable is too short for varaible name %.*s.\n", namelength, str);
4989 **varnames = varidx;
4990 strcpy((
char*)(*varnames + 1), varname);
4996 *varnames += 1 + (strlen(varname) + 1) /
sizeof(
int) + 1;
5001 if( coefficient != 1.0 )
5007 *str = varnameendptr + 1;
5010 if( (*str)[0] ==
'[' && (*str)[2] ==
']' &&
5027 const char** endptr,
5033 assert(str[0] ==
'(');
5039 while( (*endptr - str ) < length && !(nopenbrackets == 1 && *endptr[0] ==
')') )
5041 if( *endptr[0] ==
'(')
5043 if( *endptr[0] ==
')')
5048 if( *endptr[0] !=
')' )
5050 SCIPerrorMessage(
"unable to find closing parenthesis in unbalanced expression %.*s\n", length, str);
5066 const char** endptr,
5076 while( (*endptr - str ) < length && !(nopenbrackets == 0 && *endptr[0] ==
',') )
5078 if( *endptr[0] ==
'(')
5080 if( *endptr[0] ==
')')
5085 if( *endptr[0] !=
',' )
5087 SCIPerrorMessage(
"unable to find separating comma in unbalanced expression %.*s\n", length, str);
5102 const char* lastchar,
5105 int* varnameslength,
5112 const char* subexpptr;
5113 const char* subexpendptr;
5114 const char* strstart;
5116 char* nonconstendptr;
5121 assert(blkmem != NULL);
5122 assert(expr != NULL);
5123 assert(str != NULL);
5124 assert(lastchar >= str);
5125 assert(nvars != NULL);
5126 assert(varnames != NULL);
5127 assert(vartable != NULL);
5129 assert(recursiondepth < 100);
5133 SCIPdebugMessage(
"exprParse (%i): parsing %.*s\n", recursiondepth, (
int) (lastchar-str + 1), str);
5136 while( isspace((
unsigned char)*str) )
5146 while( subexpptr != lastchar && !(nopenbrackets == 0 && (subexpptr[0] ==
'+' || subexpptr[0] ==
'-') && subexpptr != str) )
5148 if( subexpptr[0] ==
'(')
5150 if( subexpptr[0] ==
')')
5155 if( subexpptr != lastchar )
5157 SCIP_CALL(
exprParse(blkmem, messagehdlr, &arg1, str, (
int) ((subexpptr - 1) - str + 1), subexpptr - 1, nvars,
5158 varnames, varnameslength, vartable, recursiondepth + 1) );
5160 if( subexpptr[0] ==
'+' )
5162 SCIP_CALL(
exprParse(blkmem, messagehdlr, &arg2, subexpptr , (
int) (lastchar - (subexpptr ) + 1), lastchar, nvars,
5163 varnames, varnameslength, vartable, recursiondepth + 1) );
5185 subexpptr = str + 1;
5188 while( subexplength < length && !(nopenbrackets == 1 && str[0] ==
')') )
5197 subexpendptr = str - 1;
5199 SCIP_CALL(
exprParse(blkmem, messagehdlr, expr, subexpptr, subexplength, subexpendptr, nvars, varnames,
5200 varnameslength, vartable, recursiondepth + 1) );
5203 else if( isdigit((
unsigned char)str[0]) || ((str[0] ==
'-' || str[0] ==
'+')
5204 && (isdigit((
unsigned char)str[1]) || str[1] ==
' ')) )
5207 if( str[0] ==
'-' && str[1] ==
' ' )
5210 nonconstendptr = (
char*) str + 1;
5218 str = nonconstendptr;
5221 while( isspace((
unsigned char)*str) && str != lastchar )
5224 if( str[0] !=
'*' && str[0] !=
'/' && str[0] !=
'+' && str[0] !=
'-' && str[0] !=
'^' )
5226 if( str < lastchar )
5228 SCIP_CALL(
exprParse(blkmem, messagehdlr, expr, str, (
int)(lastchar - str) + 1, lastchar, nvars, varnames,
5229 varnameslength, vartable, recursiondepth + 1) );
5243 else if( str[0] ==
'<' )
5249 else if( strncmp(str,
"sqrt", 4) == 0 )
5253 SCIP_CALL(
exprParse(blkmem, messagehdlr, &arg1, str + 1, endptr - str - 1, endptr -1, nvars, varnames,
5254 varnameslength, vartable, recursiondepth + 1) );
5261 strncmp(str,
"abs", 3) == 0 ||
5262 strncmp(str,
"cos", 3) == 0 ||
5263 strncmp(str,
"exp", 3) == 0 ||
5264 strncmp(str,
"log", 3) == 0 ||
5265 strncmp(str,
"sin", 3) == 0 ||
5266 strncmp(str,
"sqr", 3) == 0 ||
5267 strncmp(str,
"tan", 3) == 0 )
5269 const char* opname = str;
5273 SCIP_CALL(
exprParse(blkmem, messagehdlr, &arg1, str + 1, endptr - str - 1, endptr -1, nvars, varnames,
5274 varnameslength, vartable, recursiondepth + 1) );
5277 if( strncmp(opname,
"abs", 3) == 0 )
5281 else if( strncmp(opname,
"cos", 3) == 0 )
5285 else if( strncmp(opname,
"exp", 3) == 0 )
5289 else if( strncmp(opname,
"log", 3) == 0 )
5293 else if( strncmp(opname,
"sin", 3) == 0 )
5297 else if( strncmp(opname,
"sqr", 3) == 0 )
5303 assert(strncmp(opname,
"tan", 3) == 0);
5309 strncmp(str,
"max", 3) == 0 ||
5310 strncmp(str,
"min", 3) == 0 )
5326 SCIP_CALL(
exprParse(blkmem, messagehdlr, &arg1, str + 1, comma - str - 1, comma - 1, nvars, varnames,
5327 varnameslength, vartable, recursiondepth + 1) );
5331 while( comma < endptr && *comma ==
' ' )
5334 SCIP_CALL(
exprParse(blkmem, messagehdlr, &arg2, comma, endptr - comma, endptr - 1, nvars, varnames,
5335 varnameslength, vartable, recursiondepth + 1) );
5341 else if( strncmp(str,
"power", 5) == 0 )
5355 SCIP_CALL(
exprParse(blkmem, messagehdlr, &arg1, str + 1, comma - str - 1, comma - 1, nvars, varnames,
5356 varnameslength, vartable, recursiondepth + 1) );
5360 while( comma < endptr && *comma ==
' ' )
5362 if( !isdigit((
unsigned char)comma[0]) && !((comma[0] ==
'-' || comma[0] ==
'+') && isdigit((
unsigned char)comma[1])) )
5376 else if( strncmp(str,
"realpower", 9) == 0 || strncmp(str,
"signpower", 9) == 0 )
5381 const char* opname = str;
5390 SCIP_CALL(
exprParse(blkmem, messagehdlr, &arg1, str + 1, comma - str - 1, comma - 1, nvars, varnames,
5391 varnameslength, vartable, recursiondepth + 1) );
5395 while( comma < endptr && *comma ==
' ' )
5397 if( !isdigit((
unsigned char)comma[0]) && !((comma[0] ==
'-' || comma[0] ==
'+') && isdigit((
unsigned char)comma[1])) )
5407 if( strncmp(opname,
"realpower", 9) == 0 )
5413 assert(strncmp(opname,
"signpower", 9) == 0);
5419 else if( isalpha(*str) || *str ==
'_' || *str ==
'#' )
5425 const char* varnamestartptr = str;
5428 while( isalnum(str[0]) || str[0] ==
'_' || str[0] ==
'#' )
5432 vartable, 1.0, str) );
5436 SCIPerrorMessage(
"parsing of invalid expression %.*s.\n", (
int) (lastchar - str + 1), str);
5441 if( str == lastchar + 1)
5451 if( str > lastchar + 1)
5453 SCIPerrorMessage(
"error finding first expression in \"%.*s\" took us outside of given subexpression length\n", length, strstart);
5458 while( isspace((
unsigned char)*str) && str != lastchar + 1 )
5462 if( str >= lastchar + 1)
5478 while( isspace((
unsigned char)*str) && str != lastchar + 1 )
5481 if( isdigit((
unsigned char)str[0]) || ((str[0] ==
'-' || str[0] ==
'+') && isdigit((
unsigned char)str[1])) )
5491 str = nonconstendptr;
5506 else if( str[0] ==
'(' )
5511 SCIP_CALL(
exprParse(blkmem, messagehdlr, &arg2, str + 1, endptr - str - 1, endptr -1, nvars, varnames,
5512 varnameslength, vartable, recursiondepth + 1) );
5544 while( isspace((
unsigned char)*str) && str != lastchar + 1 )
5549 if( str <= lastchar && (str[0] ==
'+' || str[0] ==
'-' || str[0] ==
'/') )
5559 SCIP_CALL(
exprParse(blkmem, messagehdlr, &arg2, str, (
int) (lastchar - str + 1), lastchar, nvars, varnames,
5560 varnameslength, vartable, recursiondepth + 1) );
5572 else if( op ==
'*' )
5604 while( isspace((
unsigned char)*str) )
5608 if( str >= lastchar + 1 )
5625 else if( str[0] !=
'(' )
5627 SCIPdebugMessage(
"No operator found, assuming a multiplication before %.*s\n", (
int) (lastchar - str + 1), str);
5630 SCIP_CALL(
exprParse(blkmem, messagehdlr, &arg2, str, (
int) (lastchar - str + 1), lastchar, nvars, varnames,
5631 varnameslength, vartable, recursiondepth + 1) );
5666 #undef SCIPexprGetOperator 5667 #undef SCIPexprGetNChildren 5668 #undef SCIPexprGetChildren 5669 #undef SCIPexprGetOpIndex 5670 #undef SCIPexprGetOpReal 5671 #undef SCIPexprGetOpData 5672 #undef SCIPexprGetRealPowerExponent 5673 #undef SCIPexprGetIntPowerExponent 5674 #undef SCIPexprGetSignPowerExponent 5675 #undef SCIPexprGetLinearCoefs 5676 #undef SCIPexprGetLinearConstant 5677 #undef SCIPexprGetQuadElements 5678 #undef SCIPexprGetQuadConstant 5679 #undef SCIPexprGetQuadLinearCoefs 5680 #undef SCIPexprGetNQuadElements 5681 #undef SCIPexprGetMonomials 5682 #undef SCIPexprGetNMonomials 5683 #undef SCIPexprGetPolynomialConstant 5684 #undef SCIPexprGetMonomialCoef 5685 #undef SCIPexprGetMonomialNFactors 5686 #undef SCIPexprGetMonomialChildIndices 5687 #undef SCIPexprGetMonomialExponents 5688 #undef SCIPexprGetUserData 5689 #undef SCIPexprHasUserEstimator 5690 #undef SCIPexprGetUserEvalCapability 5697 assert(expr != NULL);
5707 assert(expr != NULL);
5717 assert(expr != NULL);
5727 assert(expr != NULL);
5730 return expr->
data.intval;
5738 assert(expr != NULL);
5741 return expr->
data.dbl;
5749 assert(expr != NULL);
5752 return expr->
data.data;
5760 assert(expr != NULL);
5763 return expr->
data.dbl;
5771 assert(expr != NULL);
5774 return expr->
data.intval;
5782 assert(expr != NULL);
5785 return expr->
data.dbl;
5793 assert(expr != NULL);
5795 assert(expr->
data.data != NULL);
5806 assert(expr != NULL);
5808 assert(expr->
data.data != NULL);
5819 assert(expr != NULL);
5821 assert(expr->
data.data != NULL);
5831 assert(expr != NULL);
5833 assert(expr->
data.data != NULL);
5844 assert(expr != NULL);
5846 assert(expr->
data.data != NULL);
5856 assert(expr != NULL);
5858 assert(expr->
data.data != NULL);
5868 assert(expr != NULL);
5870 assert(expr->
data.data != NULL);
5880 assert(expr != NULL);
5882 assert(expr->
data.data != NULL);
5892 assert(expr != NULL);
5894 assert(expr->
data.data != NULL);
5904 assert(monomial != NULL);
5906 return monomial->
coef;
5914 assert(monomial != NULL);
5924 assert(monomial != NULL);
5934 assert(monomial != NULL);
5944 assert(expr != NULL);
5945 assert(expr->
data.data != NULL);
5955 assert(expr != NULL);
5956 assert(expr->
data.data != NULL);
5966 assert(expr != NULL);
5967 assert(expr->
data.data != NULL);
5984 assert(blkmem != NULL);
5985 assert(expr != NULL);
5993 opdata.intval = va_arg( ap,
int );
5996 assert( opdata.intval >= 0 );
6025 assert(children[0] != NULL);
6026 assert(children[1] != NULL);
6051 assert(children[0] != NULL);
6066 assert(children[0] != NULL);
6080 assert(children[0] != NULL);
6081 opdata.intval = va_arg( ap,
int);
6099 nchildren = va_arg( ap,
int );
6100 assert(nchildren >= 0);
6103 if( nchildren == 0 )
6106 retcode =
exprCreate( blkmem, expr, op, 0, NULL, opdata);
6113 childrenarg = va_arg( ap,
SCIP_EXPR** );
6114 assert(childrenarg != NULL);
6128 SCIPerrorMessage(
"cannot create complex expression linear, quadratic, polynomial, or user with SCIPexprCreate\n");
6147 assert(blkmem != NULL);
6148 assert(targetexpr != NULL);
6149 assert(sourceexpr != NULL);
6161 for( i = 0; i < sourceexpr->
nchildren; ++i )
6168 assert((*targetexpr)->children == NULL);
6174 if( exprOpTable[sourceexpr->
op].copydata != NULL )
6176 SCIP_CALL( exprOpTable[sourceexpr->
op].copydata(blkmem, sourceexpr->
nchildren, sourceexpr->
data, &(*targetexpr)->data) );
6188 assert(blkmem != NULL);
6189 assert(expr != NULL);
6190 assert(*expr != NULL);
6193 if( exprOpTable[(*expr)->op].freedata != NULL )
6195 exprOpTable[(*expr)->op].freedata(blkmem, (*expr)->nchildren, (*expr)->data);
6198 if( (*expr)->nchildren )
6202 assert( (*expr)->children != NULL );
6204 for( i = 0; i < (*expr)->nchildren; ++i )
6207 assert((*expr)->children[i] == NULL);
6214 assert( (*expr)->children == NULL );
6226 assert(blkmem != NULL);
6227 assert(expr != NULL);
6228 assert(*expr != NULL);
6231 if( exprOpTable[(*expr)->op].freedata != NULL )
6233 exprOpTable[(*expr)->op].freedata(blkmem, (*expr)->nchildren, (*expr)->data);
6256 assert(blkmem != NULL);
6257 assert(expr != NULL);
6273 if( term1 == NULL && term2 == NULL )
6286 assert(data != NULL);
6289 for( i = 0; i <= term1->
nchildren; ++i )
6302 assert(data != NULL);
6305 for( i = 0; i <= term2->
nchildren; ++i )
6311 if( term1 == NULL || term2 == NULL )
6318 if( constant != 0.0 || coef1 != 1.0 )
6322 assert(coef1 == 1.0);
6336 assert(constant == 0.0);
6337 assert(coef1 == 1.0);
6347 assert(coef1 == 1.0);
6348 assert(coef2 == 1.0);
6364 assert(coef2 == 1.0);
6375 assert(coef1 == 1.0);
6390 children[0] = term1;
6391 children[1] = term2;
6411 assert(blkmem != NULL);
6412 assert(expr != NULL);
6413 assert(term != NULL);
6444 assert(data != NULL);
6467 for( i = 0; i < data->nquadelems; ++i )
6483 for( i = 0; i < data->nmonomials; ++i )
6515 assert(nchildren >= 0);
6516 assert(children != NULL || nchildren == 0);
6517 assert(coefs != NULL || nchildren == 0);
6524 childrencopy = NULL;
6529 data[nchildren] = constant;
6531 opdata.data = (
void*)data;
6550 assert(blkmem != NULL);
6551 assert(expr != NULL);
6553 assert(nchildren >= 0);
6554 assert(coefs != NULL || nchildren == 0);
6555 assert(children != NULL || nchildren == 0);
6558 assert(data != NULL);
6561 if( nchildren == 0 )
6576 expr->
data.data = (
void*)data;
6599 assert(nchildren >= 0);
6600 assert(children != NULL || nchildren == 0);
6601 assert(quadelems != NULL || nquadelems == 0);
6608 childrencopy = NULL;
6612 opdata.data = (
void*)data;
6624 assert(expr != NULL);
6626 assert(expr->
data.data != NULL);
6647 assert(nchildren >= 0);
6648 assert(children != NULL || nchildren == 0);
6649 assert(monomials != NULL || nmonomials == 0);
6656 childrencopy = NULL;
6659 opdata.data = (
void*)data;
6675 assert(blkmem != NULL);
6676 assert(expr != NULL);
6678 assert(monomials != NULL || nmonomials == 0);
6680 if( nmonomials == 0 )
6694 assert(expr != NULL);
6696 assert(expr->
data.data != NULL);
6708 assert(expr != NULL);
6710 assert(expr->
data.data != NULL);
6723 assert(blkmem != NULL);
6724 assert(factor != NULL);
6725 assert(expr != NULL);
6727 assert(expr->
data.data != NULL);
6746 assert(blkmem != NULL);
6747 assert(expr != NULL);
6749 assert(expr->
data.data != NULL);
6750 assert(factor != NULL);
6752 assert(factor->
data.data != NULL);
6753 assert(expr != factor);
6756 if( childmap == NULL )
6760 for( i = 0; i < factor->
nchildren; ++i )
6766 for( i = 0; i < factor->
nchildren; ++i )
6768 assert(childmap[i] >= 0);
6791 assert(blkmem != NULL);
6792 assert(expr != NULL);
6794 assert(expr->
data.data != NULL);
6812 assert(expr != NULL);
6814 assert(expr->
data.data != NULL);
6828 assert(monomial1 != NULL);
6829 assert(monomial2 != NULL);
6840 for( i = 0; i < monomial1->
nfactors; ++i )
6856 assert(monomial != NULL);
6858 monomial->
coef = newcoef;
6870 assert(monomial != NULL);
6871 assert(nfactors >= 0);
6872 assert(childidxs != NULL || nfactors == 0);
6873 assert(exponents != NULL || nfactors == 0);
6879 assert(monomial->
nfactors + nfactors <= monomial->factorssize);
6898 assert(monomial != NULL);
6899 assert(factor != NULL);
6901 if( factor->
coef == 0.0 )
6904 monomial->
coef = 0.0;
6910 if( childmap != NULL )
6913 for( i = monomial->
nfactors - factor->
nfactors; i < monomial->nfactors; ++i )
6933 assert(monomial != NULL);
6941 if( monomial->
coef != 0.0 )
6942 monomial->
coef = 1.0;
6948 for( i = 0; i < monomial->
nfactors; ++i )
6964 assert(monomial != NULL);
6973 while( i + offset < monomial->nfactors )
6978 assert(monomial->
childidxs[i+offset] >= 0);
7010 for( ; i < monomial->
nfactors; ++i )
7017 monomial->
coef = 1.0;
7018 else if(
EPSEQ(monomial->
coef, -1.0, eps) )
7019 monomial->
coef = -1.0;
7027 assert(expr != NULL);
7029 assert(expr->
data.data != NULL);
7044 assert(blkmem != NULL);
7045 assert(monomial != NULL);
7049 (*monomial)->coef = coef;
7050 (*monomial)->nfactors = nfactors;
7051 (*monomial)->factorssize = nfactors;
7052 (*monomial)->sorted = (nfactors <= 1);
7056 if( childidxs != NULL )
7065 for( i = 0; i < nfactors; ++i )
7066 (*monomial)->childidxs[i] = i;
7069 if( exponents != NULL )
7078 for( i = 0; i < nfactors; ++i )
7079 (*monomial)->exponents[i] = 1.0;
7084 (*monomial)->childidxs = NULL;
7085 (*monomial)->exponents = NULL;
7097 assert(blkmem != NULL);
7098 assert( monomial != NULL);
7099 assert(*monomial != NULL);
7101 if( (*monomial)->factorssize > 0 )
7103 assert((*monomial)->childidxs != NULL);
7104 assert((*monomial)->exponents != NULL);
7109 assert((*monomial)->childidxs == NULL);
7110 assert((*monomial)->exponents == NULL);
7120 assert(monomial != NULL);
7142 assert(monomial != NULL);
7174 assert(blkmem != NULL);
7175 assert(expr != NULL);
7176 assert(
eval != NULL);
7179 assert(curv != NULL);
7180 assert(copydata != NULL || data == NULL);
7181 assert(freedata != NULL || data == NULL);
7187 userexprdata->eval =
eval;
7188 userexprdata->inteval = inteval;
7189 userexprdata->curv = curv;
7190 userexprdata->prop = prop;
7191 userexprdata->estimate = estimate;
7192 userexprdata->copydata = copydata;
7193 userexprdata->freedata = freedata;
7194 userexprdata->print = print;
7196 opdata.data = (
void*) userexprdata;
7198 if( nchildren == 0 )
7203 assert(children != NULL);
7219 assert(expr != NULL);
7240 assert(expr != NULL);
7241 assert(maxdegree != NULL);
7263 *maxdegree =
MAX(child1, child2);
7275 *maxdegree = child1 + child2;
7298 *maxdegree = 2 * child1;
7336 if( expr->
data.dbl == 0.0 )
7338 else if( expr->
data.dbl > 0.0 && (
int)expr->
data.dbl == expr->
data.dbl )
7339 *maxdegree = child1 * (int)expr->
data.dbl;
7353 if( child1 == 0 || expr->
data.intval == 0 )
7367 *maxdegree = child1 * expr->
data.intval;
7426 if( child1 > *maxdegree )
7427 *maxdegree = child1;
7446 *maxdegree += child1;
7465 for( childidx = 0; childidx < expr->
nchildren; ++childidx )
7468 if( (quadraticdata->
lincoefs == NULL || quadraticdata->
lincoefs[childidx] == 0.0) &&
7479 while( quadidx < quadraticdata->nquadelems && quadraticdata->
quadelems[quadidx].
idx1 == childidx )
7484 if( 2*child1 > *maxdegree )
7485 *maxdegree = 2*child1;
7496 if( child1 + child2 > *maxdegree )
7497 *maxdegree = child1 + child2;
7521 monomialdata = polynomialdata->
monomials[i];
7522 assert(monomialdata != NULL);
7526 for( j = 0; j < monomialdata->
nfactors; ++j )
7538 monomialdegree += child1 * (int)monomialdata->
exponents[j];
7541 if( monomialdegree > *maxdegree )
7542 *maxdegree = monomialdegree;
7564 assert(expr != NULL);
7565 assert(varsusage != NULL);
7569 ++varsusage[expr->
data.intval];
7586 assert(expr1 != NULL);
7587 assert(expr2 != NULL);
7589 if( expr1 == expr2 )
7592 if( expr1->
op != expr2->
op )
7599 return expr1->
data.intval == expr2->
data.intval;
7669 for( i = 0; i < expr1->
nchildren + 1; ++i )
7670 if( !
EPSEQ(data1[i], data2[i], eps) )
7800 int maxexpansionexponent,
7807 assert(blkmem != NULL);
7808 assert(expr != NULL);
7827 if( nlinvars != NULL )
7855 assert(expr != NULL);
7856 assert(argvals != NULL || expr->
nchildren == 0);
7859 assert( exprOpTable[expr->
op].eval != NULL );
7894 assert( exprOpTable[expr->
op].eval != NULL );
7898 if( staticbuf != buf )
7916 assert(expr != NULL);
7917 assert(argvals != NULL || expr->
nchildren == 0);
7920 assert( exprOpTable[expr->
op].inteval != NULL );
7956 assert( exprOpTable[expr->
op].inteval != NULL );
7960 if( staticbuf != buf )
7979 assert(expr != NULL);
7981 assert(argvals != NULL || expr->
nchildren == 0);
7984 assert(exprdata->eval != NULL);
8003 assert(expr != NULL);
8005 assert(argvals != NULL || expr->
nchildren == 0);
8009 if( exprdata->inteval == NULL )
8039 assert(childbounds != NULL);
8040 assert(childcurv != NULL);
8047 if( childbounds[i].inf == childbounds[i].sup )
8052 assert(exprOpTable[expr->
op].curv != NULL);
8053 assert(exprOpTable[expr->
op].inteval != NULL);
8056 SCIP_CALL( exprOpTable[expr->
op].inteval(infinity, expr->
data, expr->
nchildren, childbounds, varbounds, param, bounds) );
8077 assert(expr != NULL);
8078 assert(curv != NULL);
8079 assert(bounds != NULL);
8089 childbounds = childboundsbuf;
8090 childcurv = childcurvbuf;
8093 retcode =
doCheckCurvature(expr, infinity, varbounds, childbounds, param, curv, childcurv, bounds);
8097 if( childboundsbuf != childbounds )
8120 assert(expr != NULL);
8122 assert(argvals != NULL || expr->
nchildren == 0);
8123 assert(argbounds != NULL || expr->
nchildren == 0);
8127 if( exprdata->estimate != NULL )
8129 SCIP_CALL( exprdata->estimate(infinity, exprdata->
userdata, expr->
nchildren, argvals, argbounds, overestimate, coeffs, constant, success ) );
8153 assert(blkmem != NULL);
8154 assert(expr != NULL);
8155 assert(substexprs != NULL);
8164 assert(varidx >= 0);
8165 if( substexprs[varidx] != NULL )
8190 assert(expr != NULL);
8191 assert(newindices != NULL);
8195 expr->
data.intval = newindices[expr->
data.intval];
8196 assert(expr->
data.intval >= 0);
8211 assert(expr != NULL);
8212 assert(newindices != NULL);
8216 expr->
data.intval = newindices[expr->
data.intval];
8217 assert(expr->
data.intval >= 0);
8229 const char** varnames,
8230 const char** paramnames,
8234 assert( expr != NULL );
8243 if( varnames != NULL )
8245 assert(varnames[expr->
data.intval] != NULL);
8255 if( paramnames != NULL )
8257 assert(paramnames[expr->
data.intval] != NULL);
8264 if( paramvals != NULL )
8271 if (expr->
data.dbl < 0.0 )
8400 if( constant != 0.0 )
8421 assert(quadraticdata != NULL);
8425 if( quadraticdata->
constant != 0.0 )
8428 if( quadraticdata->
lincoefs != NULL )
8431 if( quadraticdata->
lincoefs[i] == 0.0 )
8437 for( i = 0; i < quadraticdata->
nquadelems; ++i )
8466 assert(polynomialdata != NULL);
8473 for( i = 0; i < polynomialdata->
nmonomials; ++i )
8475 monomialdata = polynomialdata->
monomials[i];
8478 for( j = 0; j < monomialdata->
nfactors; ++j )
8487 else if( monomialdata->
exponents[j] != 1.0 )
8504 assert(exprdata != NULL);
8506 if( exprdata->print != NULL )
8508 exprdata->print(exprdata->
userdata, messagehdlr, file);
8543 const char* lastchar,
8552 assert(blkmem != NULL);
8553 assert(expr != NULL);
8554 assert(str != NULL);
8555 assert(lastchar != NULL);
8556 assert(nvars != NULL);
8557 assert(varnames != NULL);
8565 SCIPhashKeyValString, NULL) );
8567 retcode =
exprParse(blkmem, messagehdlr, expr, str, (
int) (lastchar - str + 1), lastchar, nvars, &varnames,
8568 &varnameslength, vartable, 0);
8587 #undef SCIPexprtreeGetRoot 8588 #undef SCIPexprtreeGetNVars 8589 #undef SCIPexprtreeGetNParams 8590 #undef SCIPexprtreeGetParamVals 8591 #undef SCIPexprtreeSetParamVal 8592 #undef SCIPexprtreeGetInterpreterData 8593 #undef SCIPexprtreeSetInterpreterData 8594 #undef SCIPexprtreeFreeInterpreterData 8595 #undef SCIPexprtreeHasParam 8596 #undef SCIPexprtreeGetMaxDegree 8597 #undef SCIPexprtreeEval 8598 #undef SCIPexprtreeEvalInt 8599 #undef SCIPexprtreePrint 8606 assert(tree != NULL);
8616 assert(tree != NULL);
8626 assert(tree != NULL);
8636 assert(tree != NULL);
8648 assert(tree != NULL);
8649 assert(paramidx >= 0);
8650 assert(paramidx < tree->nparams);
8651 assert(tree->
params != NULL);
8653 tree->
params[paramidx] = paramval;
8661 assert(tree != NULL);
8672 assert(tree != NULL);
8673 assert(interpreterdata != NULL);
8698 assert(tree != NULL);
8715 assert(tree != NULL);
8729 assert(tree != NULL);
8730 assert(varvals != NULL || tree->
nvars == 0);
8731 assert(val != NULL);
8746 assert(tree != NULL);
8747 assert(varvals != NULL || tree->
nvars == 0);
8748 assert(val != NULL);
8760 const char** varnames,
8761 const char** paramnames
8764 assert(tree != NULL);
8780 assert(blkmem != NULL);
8781 assert(tree != NULL);
8785 (*tree)->blkmem = blkmem;
8786 (*tree)->root = root;
8787 (*tree)->nvars = nvars;
8788 (*tree)->vars = NULL;
8789 (*tree)->nparams = nparams;
8790 (*tree)->interpreterdata = NULL;
8792 if( params != NULL )
8794 assert(nparams > 0);
8797 else if( nparams > 0 )
8804 assert(nparams == 0);
8805 (*tree)->params = NULL;
8818 assert(blkmem != NULL);
8819 assert(targettree != NULL);
8820 assert(sourcetree != NULL);
8826 (*targettree)->blkmem = blkmem;
8827 (*targettree)->interpreterdata = NULL;
8830 if( sourcetree->
vars != NULL )
8832 assert(sourcetree->
nvars > 0);
8838 if( sourcetree->
params != NULL )
8840 assert(sourcetree->
nparams > 0);
8856 assert( tree != NULL);
8857 assert(*tree != NULL);
8861 if( (*tree)->root != NULL )
8864 assert((*tree)->root == NULL);
8882 assert(tree != NULL);
8883 assert(paramvals != NULL || nparams == 0);
8889 else if( tree->
params != NULL )
8912 assert(tree != NULL);
8913 assert(varsusage != NULL);
8915 if( tree->
nvars == 0 )
8930 int maxexpansionexponent,
8944 assert(tree != NULL);
8962 if( nlinvars != NULL && testval_before == testval_before )
8963 for( i = 0; i < *nlinvars; ++i )
8964 testval_after += lincoefs[i] * testx[linidxs[i]];
8965 assert(testval_before != testval_before || testval_before == testval_after ||
EPSZ(
SCIPrelDiff(testval_before, testval_after), eps));
8970 if( nlinvars != NULL && *nlinvars > 0 )
8986 assert(tree != NULL);
8987 assert(tree->
root != NULL);
9013 assert(tree != NULL);
9014 assert(tree->
root != NULL);
9018 if( bounds != NULL )
9019 *bounds = exprbounds;
9034 assert(tree != NULL);
9035 assert(tree->
root != NULL);
9042 assert(varidx >= 0);
9043 if( substexprs[varidx] != NULL )
9071 #define QUADELEMS_ISBETTER(a, b) ( ((a).idx1 < (b).idx1) || ((a).idx1 == (b).idx1 && (a).idx2 < (b).idx2) ) 9074 #define QUADELEMS_SWAP(x,y) \ 9076 SCIP_QUADELEM temp = x; \ 9089 assert(start <= end);
9092 while( end - start >= 25 )
9100 mid = (start+end)/2;
9101 pivotkey = elems[mid];
9121 assert(hi == lo-1 || hi == start);
9138 if( hi - start <= end - lo )
9159 if( end - start >= 1 )
9161 static const int incs[3] = {1, 5, 19};
9164 for( k = 2; k >= 0; --k )
9169 for( h = incs[k], i = h + start; i <= end; ++i )
9177 elems[j] = elems[j-h];
9198 if( nquadelems == 0 )
9204 for( i = 0; i < nquadelems; ++i )
9205 assert(quadelems[i].idx1 <= quadelems[i].idx2);
9229 assert(quadelems != NULL || nquadelems == 0);
9230 assert(idx1 <= idx2);
9232 if( nquadelems == 0 )
9240 right = nquadelems - 1;
9241 while( left <= right )
9245 middle = (left+right)/2;
9246 assert(0 <= middle && middle < nquadelems);
9248 if( idx1 < quadelems[middle].idx1 || (idx1 == quadelems[middle].idx1 && idx2 < quadelems[middle].idx2) )
9250 else if( quadelems[middle].idx1 < idx1 || (quadelems[middle].idx1 == idx1 && quadelems[middle].idx2 < idx2) )
9259 assert(left == right+1);
9279 assert(quadelems != NULL);
9280 assert(nquadelemsnew != NULL);
9281 assert(nquadelems >= 0);
9285 while( next < nquadelems )
9289 (quadelems[i].idx1 == quadelems[next].idx1 && quadelems[i].idx2 == quadelems[next].idx2));
9292 if( quadelems[next].coef == 0.0 )
9300 quadelems[i-1].idx1 == quadelems[next].idx1 &&
9301 quadelems[i-1].idx2 == quadelems[next].idx2 )
9303 quadelems[i-1].
coef += quadelems[next].
coef;
9309 quadelems[i] = quadelems[next];
9313 assert(next == nquadelems);
9332 assert(blkmem != NULL);
9333 assert(node != NULL);
9334 assert(node->
depth >= 0);
9335 assert(node->
pos >= 0);
9336 assert(parent != NULL);
9337 assert(parent->
depth >= 0);
9338 assert(parent->
pos >= 0);
9359 assert(node != NULL);
9365 for( i = 1; i < node->
nparents; ++i )
9366 assert(exprgraphnodecomp((
void*)node->
parents[i-1], (
void*)node->
parents[i]) <= 0);
9390 assert(exprgraph != NULL);
9391 assert(node != NULL);
9392 assert(*node != NULL);
9393 assert((*node)->depth >= 0);
9394 assert((*node)->pos >= 0);
9395 assert((*node)->nparents > 0);
9396 assert(parent != NULL);
9397 assert(parent->
depth >= 0);
9398 assert(parent->
pos >= 0);
9399 assert(parent->
depth > (*node)->depth);
9405 assert(pos < (*node)->nparents);
9406 assert((*node)->parents[pos] == parent);
9410 if( pos < (*node)->nparents-1 )
9412 (*node)->parents[pos] = (*node)->parents[(*node)->nparents-1];
9413 (*node)->parentssorted = ((*node)->nparents <= 2);
9415 --(*node)->nparents;
9418 node_ = (*node)->
nuses > 0 ? *node : NULL;
9439 assert(node != NULL);
9440 assert(parent != NULL);
9445 assert(node->
parents != NULL);
9476 assert(blkmem != NULL);
9477 assert(node != NULL);
9478 assert(node->
depth > 0);
9479 assert(node->
pos >= 0);
9481 assert(exprs != NULL || nexprs == 0);
9489 for( i = 0; i < nexprs; ++i )
9491 assert(exprs[i]->depth >= 0);
9492 assert(exprs[i]->pos >= 0);
9493 assert(exprs[i]->depth < node->depth);
9496 existsalready =
FALSE;
9498 for( j = 0; j < orignchildren; ++j )
9502 existsalready =
TRUE;
9506 if( !existsalready )
9511 if( childmap != NULL )
9517 if( childmap != NULL )
9537 data[node->
nchildren] = data[orignchildren];
9538 for( i = orignchildren; i < node->
nchildren; ++i )
9540 node->
data.data = (
void*)data;
9573 assert(exprgraph != NULL);
9574 assert(node != NULL);
9575 assert(oldchild != NULL);
9576 assert(*oldchild != NULL);
9577 assert(newchild != NULL);
9579 if( *oldchild == newchild )
9582 SCIPdebugMessage(
"replace child %p in node %p by %p\n", (
void*)*oldchild, (
void*)node, (
void*)newchild);
9585 for( i = 0; i < node->nchildren; ++i )
9587 if( node->children[i] == *oldchild )
9596 node->children[i] = newchild;
9602 assert(i < node->nchildren);
9604 node->simplified =
FALSE;
9616 assert(elem1 != NULL);
9617 assert(elem2 != NULL);
9637 assert(exprgraph != NULL);
9659 assert(exprgraph != NULL);
9660 assert(node != NULL);
9662 assert(node->
depth == 0);
9663 assert(node->
pos >= 0);
9664 assert(pos != NULL);
9673 while( left <= right )
9675 middle = (left+right)/2;
9676 assert(0 <= middle && middle < exprgraph->nconsts);
9688 assert(left == right+1 || *pos >= 0);
9689 if( left == right+1 )
9696 while( exprgraph->
constnodes[*pos] != node && *pos < exprgraph->nconsts-1 && exprgraph->
constnodes[*pos+1]->
data.dbl == node->
data.dbl )
9711 assert(blkmem != NULL);
9712 assert(node != NULL);
9718 (*node)->data = opdata;
9721 (*node)->depth = -1;
9725 (*node)->parentssorted =
TRUE;
9741 (*node)->enabled =
TRUE;
9752 const char** varnames,
9758 assert(node != NULL);
9763 if( varnames != NULL )
9780 if( printchildrenbounds )
9783 if( printchildrenbounds )
9788 if( printchildrenbounds )
9791 if( printchildrenbounds )
9796 if( printchildrenbounds )
9799 if( printchildrenbounds )
9804 if( printchildrenbounds )
9807 if( printchildrenbounds )
9812 if( printchildrenbounds )
9818 if( printchildrenbounds )
9824 if( printchildrenbounds )
9833 if( printchildrenbounds )
9851 if( printchildrenbounds )
9861 if( printchildrenbounds )
9873 if( printchildrenbounds )
9890 if( constant != 0.0 || node->
nchildren == 0 )
9902 if( printchildrenbounds )
9914 assert(quadraticdata != NULL);
9916 if( quadraticdata->
constant != 0.0 )
9919 if( quadraticdata->
lincoefs != NULL )
9922 if( quadraticdata->
lincoefs[i] == 0.0 )
9925 if( printchildrenbounds )
9929 for( i = 0; i < quadraticdata->
nquadelems; ++i )
9938 if( printchildrenbounds )
9945 if( printchildrenbounds )
9960 assert(polynomialdata != NULL);
9967 for( i = 0; i < polynomialdata->
nmonomials; ++i )
9969 monomialdata = polynomialdata->
monomials[i];
9970 if( monomialdata->
coef == 1.0 )
9972 else if( monomialdata->
coef == -1.0 )
9977 for( j = 0; j < monomialdata->
nfactors; ++j )
9980 if( printchildrenbounds )
9984 else if( monomialdata->
exponents[j] != 1.0 )
10009 const char** varnames
10015 assert(exprgraph != NULL);
10016 assert(node != NULL);
10017 assert(file != NULL);
10020 SCIPmessageFPrintInfo(messagehdlr, file,
"n%d_%d [fillcolor=\"%g,%g,%g\", label=\"", node->
depth, node->
pos, color, color, color);
10055 assert(node != NULL);
10075 assert(exprOpTable[node->
op].eval != NULL);
10080 if( staticbuf != buf )
10097 assert(node != NULL);
10123 assert(node != NULL);
10124 assert(node->
depth >= 1);
10125 assert(node->
pos >= 0);
10141 childbounds = childboundsstatic;
10155 assert( exprOpTable[node->
op].inteval != NULL );
10157 SCIP_CALL( exprOpTable[node->
op].inteval(infinity, node->
data, node->
nchildren, childbounds, NULL, NULL, &newbounds) );
10160 if( childbounds != childboundsstatic )
10177 for( i = 0; i < node->
nparents; ++i )
10180 node->
bounds = newbounds;
10185 for( i = 0; i < node->
nparents; ++i )
10188 node->
bounds = newbounds;
10216 assert(exprgraph != NULL);
10217 assert(node != NULL);
10218 assert(node->
depth >= 0);
10219 assert(node->
pos >= 0);
10220 assert(minstrength >= 0.0);
10221 assert(cutoff != NULL);
10235 minstrength = -1.0;
10373 if( node->
data.dbl != 0.0 )
10537 int minlinactivityinf;
10538 int maxlinactivityinf;
10546 minlinactivity = 0.0;
10547 maxlinactivity = 0.0;
10548 minlinactivityinf = 0;
10549 maxlinactivityinf = 0;
10563 ++minlinactivityinf;
10579 ++maxlinactivityinf;
10588 maxlinactivity = -maxlinactivity;
10591 if( (minlinactivityinf >= 2 || node->
bounds.
sup >= infinity) &&
10592 ( maxlinactivityinf >= 2 || node->
bounds.
inf <= -infinity)
10599 for( i = 0; i < node->
nchildren && !*cutoff; ++i )
10611 assert(minlinactivityinf == 1);
10614 else if( minlinactivityinf == 0 )
10628 assert(maxlinactivityinf == 1);
10631 else if( maxlinactivityinf == 0 )
10658 for( i = 0; i < node->
nchildren && !*cutoff; ++i )
10669 if( childbounds.
inf <= 0.0 && childbounds.
sup >= 0.0 )
10692 int minlinactivityinf;
10693 int maxlinactivityinf;
10703 minlinactivity = coefs[node->
nchildren];
10704 maxlinactivity = -coefs[node->
nchildren];
10705 minlinactivityinf = 0;
10706 maxlinactivityinf = 0;
10718 if( coefs[i] >= 0.0 )
10722 ++minlinactivityinf;
10734 ++minlinactivityinf;
10749 if( coefs[i] >= 0.0 )
10753 ++maxlinactivityinf;
10765 ++maxlinactivityinf;
10780 if( (minlinactivityinf >= 2 || node->
bounds.
sup >= infinity) &&
10781 (maxlinactivityinf >= 2 || node->
bounds.
inf <= -infinity)
10788 for( i = 0; i < node->
nchildren && !*cutoff; ++i )
10792 if( coefs[i] == 0.0 )
10797 if( coefs[i] >= 0.0 )
10813 if( coefs[i] > 0.0 )
10824 assert(minlinactivityinf == 1);
10827 else if( minlinactivityinf == 0 )
10841 assert(maxlinactivityinf == 1);
10842 childbounds.
inf = (node->
bounds.
inf - maxlinactivity)/coefs[i];
10844 else if( maxlinactivityinf == 0 )
10846 childbounds.
inf = (node->
bounds.
inf - maxlinactivity + ac.
sup)/coefs[i];
10863 assert(minlinactivityinf == 1);
10866 else if( minlinactivityinf == 0 )
10881 assert(maxlinactivityinf == 1);
10884 else if( maxlinactivityinf == 0 )
10921 if( nquadelems > 10 )
10927 if( node->
nchildren == 2 && nquadelems > 0 )
10937 for( i = 0; i < nquadelems; ++i )
10938 if( quadelems[i].idx1 == 0 && quadelems[i].idx2 == 0 )
10939 ax += quadelems[i].
coef;
10940 else if( quadelems[i].idx1 == 1 && quadelems[i].idx2 == 1 )
10941 ay += quadelems[i].
coef;
10943 axy += quadelems[i].
coef;
10950 infinity, &childbounds, ax, ay, axy,
10951 lincoefs != NULL ? lincoefs[0] : 0.0, lincoefs != NULL ? lincoefs[1] : 0.0,
10956 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",
10957 ax, ay, axy, lincoefs != NULL ? lincoefs[0] : 0.0, lincoefs != NULL ? lincoefs[1] : 0.0,
10972 infinity, &childbounds, ay, ax, axy,
10973 lincoefs != NULL ? lincoefs[1] : 0.0, lincoefs != NULL ? lincoefs[0] : 0.0,
10979 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",
10980 ax, ay, axy, lincoefs != NULL ? lincoefs[0] : 0.0, lincoefs != NULL ? lincoefs[1] : 0.0,
10996 for( i = 0; i < node->
nchildren && !*cutoff; ++i )
11006 if( lincoefs != NULL )
11008 if( i != k && lincoefs[k] != 0.0 )
11014 for( k = 0; k < nquadelems; ++k )
11016 if( quadelems[k].idx1 == i && quadelems[k].idx2 == i )
11020 else if( quadelems[k].idx1 == i )
11025 else if( quadelems[k].idx2 == i )
11030 else if( quadelems[k].idx1 == quadelems[k].idx2 )
11090 for( i = 0; i < node->
nchildren && !*cutoff; ++i )
11095 for( j = 0; j < nmonomials; ++j )
11097 monomial = monomials[j];
11098 for( k = 0; k < monomial->
nfactors; ++k )
11104 else if( n == 2*monomial->
exponents[k] )
11106 else if( 2*n == monomial->
exponents[k] )
11119 if( nexpishalfn > nexpisdoublen )
11126 for( j = 0; j < nmonomials; ++j )
11128 monomial = monomials[j];
11131 for( k = 0; k < monomial->
nfactors; ++k )
11135 assert(abc_flag ==
'c');
11144 else if( monomial->
exponents[k] == 2*n )
11173 else if( monomial->
exponents[k] == 2*n )
11201 if( abc_flag ==
'a' )
11205 if( a.
inf >= infinity || a.
sup <= -infinity )
11208 else if( abc_flag ==
'b' )
11212 if( b.
inf >= infinity || b.
sup <= -infinity )
11219 if( c.
inf >= infinity || c.
sup <= -infinity )
11225 if( j < nmonomials )
11231 SCIPdebugMessage(
"solve [%10g,%10g]c%d^%g + [%10g,%10g]c%d^%g = [%10g,%10g]",
11270 if( exprdata->prop == NULL )
11291 for( c = 0; !*cutoff && c < node->
nchildren; ++c )
11322 assert(exprgraph != NULL);
11323 assert(node != NULL);
11331 foundduplicates =
FALSE;
11338 for( j = i+1; j < node->
nchildren; ++j )
11353 foundduplicates =
TRUE;
11359 if( foundduplicates )
11379 assert(blkmem != NULL);
11380 assert(node != NULL);
11390 while( lastnonnull >= 0 && node->
children[lastnonnull] == NULL )
11392 for( i = 0; i <= lastnonnull; ++i )
11399 assert(node->
children[lastnonnull] != NULL);
11403 node->
children[lastnonnull] = NULL;
11404 childmap[lastnonnull] = i;
11408 while( lastnonnull >= 0 && node->
children[lastnonnull] == NULL )
11411 assert(i > lastnonnull);
11414 if( lastnonnull < node->nchildren-1 )
11420 if( lastnonnull >= 0 )
11444 int maxexpansionexponent,
11459 assert(exprgraph != NULL);
11460 assert(node != NULL);
11461 assert(node->
depth > 0);
11462 assert(havechange != NULL);
11464 blkmem = exprgraph->
blkmem;
11465 assert(blkmem != NULL);
11467 SCIPdebugMessage(
"attempt simplification of node %p (%d,%d)\n", (
void*)node, node->
depth, node->pos);
11470 for( i = 0; i < node->nchildren; ++i )
11473 if( node->nchildren > 0 && i == node->nchildren )
11479 SCIPdebugMessage(
"turn node %p (%d,%d) into constant %g\n", (
void*)node, node->depth, node->pos, node->value);
11484 if( exprOpTable[node->op].freedata != NULL )
11485 exprOpTable[node->op].freedata(blkmem, node->nchildren, node->data);
11488 for( i = 0; i < node->nchildren; ++i )
11493 node->nchildren = 0;
11497 node->data.dbl = node->value;
11499 *havechange =
TRUE;
11500 node->simplified =
TRUE;
11516 node->simplified =
TRUE;
11521 assert(polynomialdata != NULL);
11523 orignchildren = node->nchildren;
11540 for( i = 0; i < node->nchildren; ++i )
11542 if( node->children[i] == NULL )
11558 removechild =
TRUE;
11563 for( j = 0; j < polynomialdata->
nmonomials; ++j )
11567 monomial = polynomialdata->
monomials[j];
11573 assert(factorpos >= 0);
11574 assert(factorpos < monomial->nfactors);
11576 assert(factorpos == 0 || monomial->
childidxs[factorpos-1] != i);
11577 assert(factorpos == monomial->
nfactors-1 || monomial->
childidxs[factorpos+1] != i);
11579 SCIPdebugMessage(
"attempt expanding child %d at monomial %d factor %d\n", i, j, factorpos);
11581 if( !
EPSISINT(monomial->
exponents[factorpos], 0.0) && node->children[i]->data.dbl < 0.0 )
11584 SCIPmessagePrintWarning(messagehdlr,
"got negative constant %g to the power of a noninteger exponent %g\n", node->children[i]->data.dbl, monomial->
exponents[factorpos]);
11585 removechild =
FALSE;
11589 monomial->
coef *=
pow(node->children[i]->data.dbl, monomial->
exponents[factorpos]);
11592 if( factorpos < monomial->nfactors-1 )
11601 *havechange =
TRUE;
11611 node->children[i] = NULL;
11619 for( i = 0; i < node->nchildren; ++i )
11621 if( node->children[i] == NULL )
11633 SCIPdebugMessage(
"expand child %d in expression node %p = ", i, (
void*)node);
11639 removechild =
TRUE;
11648 while( j < polynomialdata->nmonomials )
11653 monomial = polynomialdata->
monomials[j];
11667 assert(factorpos >= 0);
11668 assert(factorpos < monomial->nfactors);
11670 assert(factorpos == 0 || monomial->
childidxs[factorpos-1] != i);
11671 assert(factorpos == monomial->
nfactors-1 || monomial->
childidxs[factorpos+1] != i);
11673 SCIPdebugMessage(
"attempt expanding child %d at monomial %d factor %d\n", i, j, factorpos);
11680 removechild =
FALSE;
11684 *havechange =
TRUE;
11696 node->children[i] = NULL;
11708 for( i = 0; i < polynomialdata->
nmonomials; ++i )
11710 monomial = polynomialdata->
monomials[i];
11711 assert(monomial != NULL);
11713 for( j = 0; j < monomial->
nfactors; ++j )
11716 assert(monomial->
childidxs[j] < node->nchildren);
11722 for( i = 0; i < node->nchildren; ++i )
11723 if( node->children[i] != NULL && !childinuse[i] )
11726 node->children[i] = NULL;
11735 if( node->nchildren == 0 )
11746 node->data.dbl = val;
11753 *havechange |= (node->nchildren < orignchildren);
11755 node->simplified =
TRUE;
11780 assert(exprgraph != NULL);
11781 assert(node != NULL);
11782 assert(expr != NULL);
11783 assert(nexprvars != NULL);
11784 assert(*nexprvars >= 0);
11785 assert(varidx != NULL);
11804 assert(node->
data.intval >= 0);
11805 assert(node->
data.intval < exprgraph->
nvars);
11806 assert(varidx[node->
data.intval] >= -1);
11807 assert(varidx[node->
data.intval] < *nexprvars);
11808 if( varidx[node->
data.intval] == -1 )
11810 varidx[node->
data.intval] = *nexprvars;
11828 assert(childexprs != NULL);
11836 assert(childexprs != NULL);
11849 assert(childexprs != NULL);
11867 assert(childexprs != NULL);
11881 assert(node->
data.data != NULL);
11892 assert(quaddata != NULL);
11904 assert(polynomialdata != NULL);
11918 assert(exprdata != NULL);
11920 if( exprdata->copydata != NULL )
11928 userdata, exprdata->
evalcapability, exprdata->eval, exprdata->inteval, exprdata->curv, exprdata->prop, exprdata->estimate, exprdata->copydata, exprdata->freedata, exprdata->print) );
11958 assert(node != NULL);
11959 assert(varsusage != NULL);
11963 ++varsusage[node->
data.intval];
11988 assert(node != NULL);
11989 assert(compnr != NULL);
11990 assert(*compnr >= 0);
11991 assert(childcomps != NULL);
11992 assert(varcomps != NULL);
12001 varidx = node->
data.intval;
12002 assert(varidx >= 0);
12003 assert(varidx < nvars);
12005 if( varcomps[varidx] == -1 )
12008 varcomps[varidx] = *compnr;
12012 if( varcomps[varidx] == *compnr )
12020 for( i = 0; i < nvars; ++i )
12021 if( varcomps[i] == *compnr )
12022 varcomps[i] = varcomps[varidx];
12023 for( i = 0; i < nchildcomps; ++i )
12024 if( childcomps[i] == *compnr )
12025 childcomps[i] = varcomps[varidx];
12026 *compnr = varcomps[varidx];
12043 assert(exprgraph != NULL);
12044 assert(exprgraph->
blkmem != NULL);
12046 if( mindepth <= exprgraph->depth )
12049 olddepth = exprgraph->
depth;
12051 assert(exprgraph->
depth >= mindepth);
12071 assert(exprgraph != NULL);
12072 assert(varidx >= 0);
12073 assert(varidx < exprgraph->nvars);
12075 varnode = exprgraph->
varnodes[varidx];
12076 assert(varnode->
data.intval == varidx);
12078 var = exprgraph->
vars[varidx];
12081 if( exprgraph->exprgraphvarremove != NULL )
12083 SCIP_CALL( exprgraph->exprgraphvarremove(exprgraph, exprgraph->
userdata, var, varnode) );
12090 if( varidx < exprgraph->nvars-1 )
12093 if( exprgraph->exprgraphvarchgidx != NULL )
12098 exprgraph->
vars[varidx] = exprgraph->
vars[exprgraph->
nvars-1];
12104 --exprgraph->
nvars;
12126 assert(exprgraph != NULL);
12127 assert(node != NULL);
12128 assert(node->
depth >= 0);
12129 assert(newdepth >= 0);
12132 if( node->
depth == newdepth )
12135 SCIPdebugMessage(
"move node %p (%d,%d) to depth %d\n", (
void*)node, node->
depth, node->pos, newdepth);
12139 for( i = 0; i < node->nchildren; ++i )
12140 assert(node->children[i]->depth < newdepth);
12144 for( i = 0; i < node->nparents; ++i )
12146 if( node->parents[i]->depth <= newdepth )
12150 assert(node->parents[i]->depth > newdepth);
12156 assert(exprgraph->
depth > newdepth);
12158 olddepth = node->depth;
12159 oldpos = node->pos;
12163 node->depth = newdepth;
12164 node->pos = exprgraph->
nnodes[newdepth];
12165 exprgraph->
nodes[newdepth][node->pos] = node;
12166 ++exprgraph->
nnodes[newdepth];
12169 for( i = 0; i < node->nchildren; ++i )
12170 node->children[i]->parentssorted =
FALSE;
12173 if( oldpos < exprgraph->
nnodes[olddepth]-1 )
12175 exprgraph->
nodes[olddepth][oldpos] = exprgraph->
nodes[olddepth][exprgraph->
nnodes[olddepth]-1];
12176 exprgraph->
nodes[olddepth][oldpos]->
pos = oldpos;
12179 for( i = 0; i < exprgraph->
nodes[olddepth][oldpos]->
nchildren; ++i )
12182 --exprgraph->
nnodes[olddepth];
12184 if( node->depth == 0 )
12224 int parentcandssize;
12228 assert(exprgraph != NULL);
12229 assert(nchildren > 0);
12230 assert(children != NULL);
12231 assert(parent != NULL);
12243 parentcandssize = children[0]->
nparents;
12246 for( p = 0; p < children[0]->
nparents; ++p )
12247 if( children[0]->parents[p]->op == op &&
12248 children[0]->parents[p]->nchildren == nchildren &&
12259 parentcands[nparentcands++] = children[0]->
parents[p];
12263 for( i = 1; i < nchildren && nparentcands > 0; ++i )
12266 while( p < nparentcands )
12273 parentcands[p] = parentcands[nparentcands-1];
12281 SCIPdebugMessage(
"check %d parent candidates for expr with operator %d and %d children\n", nparentcands, op, nchildren);
12283 if( nparentcands == 0 )
12314 if( nchildren > 2 )
12315 SCIPsortPtr((
void**)children, exprgraphnodecomp, nchildren);
12316 for( p = 0; p < nparentcands; ++p )
12318 assert(parentcands[p]->op == op);
12319 assert(parentcands[p]->nchildren == nchildren);
12321 if( nchildren == 1 )
12323 assert(parentcands[p]->children[0] == children[0]);
12325 *parent = parentcands[p];
12328 else if( nchildren == 2 )
12334 if( (parentcands[p]->children[0] == children[0] && parentcands[p]->children[1] == children[1]) ||
12335 ( parentcands[p]->children[0] == children[1] && parentcands[p]->children[1] == children[0]) )
12337 *parent = parentcands[p];
12346 SCIPsortPtr((
void**)parentcands[p]->children, exprgraphnodecomp, nchildren);
12349 for( i = 0; i < nchildren; ++i )
12350 if( children[i] != parentcands[p]->children[i] )
12352 if( i == nchildren )
12355 *parent = parentcands[p];
12368 for( p = 0; p < nparentcands; ++p )
12370 assert(parentcands[p]->op == op);
12371 assert(parentcands[p]->nchildren == 2);
12373 if( parentcands[p]->children[0] == children[0] && parentcands[p]->children[1] == children[1] )
12376 *parent = parentcands[p];
12387 assert(parentcands[0]->op == op);
12388 assert(parentcands[0]->nchildren == 1);
12389 assert(parentcands[0]->children[0] == children[0]);
12390 assert(parentcands[0]->data.intval == opdata.intval);
12393 *parent = parentcands[0];
12401 assert(parentcands[0]->op == op);
12402 assert(parentcands[0]->nchildren == 1);
12403 assert(parentcands[0]->children[0] == children[0]);
12404 assert(parentcands[0]->data.dbl == opdata.dbl);
12407 *parent = parentcands[0];
12420 if( exprchildren != NULL )
12421 SCIPsortPtrPtrReal((
void**)children, (
void**)exprchildren, exprcoef, exprgraphnodecomp, nchildren);
12423 SCIPsortPtrReal((
void**)children, exprcoef, exprgraphnodecomp, nchildren);
12424 for( p = 0; p < nparentcands; ++p )
12426 assert(parentcands[p]->op == op);
12427 assert(parentcands[p]->nchildren == nchildren);
12430 assert(exprcoef[nchildren] == candcoef[nchildren]);
12433 SCIPsortPtrReal((
void**)parentcands[p]->children, candcoef, exprgraphnodecomp, nchildren);
12436 for( i = 0; i < nchildren; ++i )
12438 if( children[i] != parentcands[p]->children[i] )
12440 if( exprcoef[i] != candcoef[i] )
12443 if( i < nchildren )
12447 *parent = parentcands[p];
12471 for( i = 0; i < nchildren; ++i )
12474 if( exprlincoef != NULL )
12475 if( exprchildren != NULL )
12476 SCIPsortPtrPtrRealInt((
void**)children, (
void**)exprchildren, exprlincoef, invperm, exprgraphnodecomp, nchildren);
12478 SCIPsortPtrRealInt((
void**)children, exprlincoef, invperm, exprgraphnodecomp, nchildren);
12480 if( exprchildren != NULL )
12481 SCIPsortPtrPtrInt((
void**)children, (
void**)exprchildren, invperm, exprgraphnodecomp, nchildren);
12483 SCIPsortPtrInt((
void**)children, invperm, exprgraphnodecomp, nchildren);
12486 for( i = 0; i < nchildren; ++i )
12487 perm[invperm[i]] = i;
12505 for( p = 0; p < nparentcands; ++p )
12507 assert(parentcands[p]->op == op);
12508 assert(parentcands[p]->nchildren == nchildren);
12516 for( i = 0; i < nchildren; ++i )
12519 if( candlincoef != NULL )
12520 SCIPsortPtrRealInt((
void**)parentcands[p]->children, candlincoef, invperm, exprgraphnodecomp, parentcands[p]->nchildren);
12522 SCIPsortPtrInt((
void**)parentcands[p]->children, invperm, exprgraphnodecomp, nchildren);
12525 for( i = 0; i < nchildren; ++i )
12526 perm[invperm[i]] = i;
12545 for( i = 0; i < nchildren; ++i )
12547 if( children[i] != parentcands[p]->children[i] )
12549 if( (exprlincoef == NULL ? 0.0 : exprlincoef[i]) != (candlincoef == NULL ? 0.0 : candlincoef[i]) )
12552 if( i < nchildren )
12566 *parent = parentcands[p];
12592 for( i = 0; i < nchildren; ++i )
12595 if( exprchildren != NULL )
12596 SCIPsortPtrPtrInt((
void**)children, (
void**)exprchildren, invperm, exprgraphnodecomp, nchildren);
12598 SCIPsortPtrInt((
void**)children, invperm, exprgraphnodecomp, nchildren);
12601 for( i = 0; i < nchildren; ++i )
12602 perm[invperm[i]] = i;
12608 for( p = 0; p < nparentcands; ++p )
12610 assert(parentcands[p]->op == op);
12611 assert(parentcands[p]->nchildren == nchildren);
12618 for( i = 0; i < nchildren; ++i )
12621 SCIPsortPtrInt((
void**)parentcands[p]->children, invperm, exprgraphnodecomp, nchildren);
12624 for( i = 0; i < nchildren; ++i )
12625 perm[invperm[i]] = i;
12632 for( i = 0; i < nchildren; ++i )
12633 if( children[i] != parentcands[p]->children[i] )
12635 if( i < nchildren )
12645 *parent = parentcands[p];
12695 assert(exprgraph != NULL);
12696 assert(expr != NULL);
12697 assert(exprnode != NULL);
12698 assert(exprnodeisnew != NULL);
12706 assert(*exprnode != NULL);
12708 assert((*exprnode)->data.intval >= 0);
12709 assert((*exprnode)->data.intval < exprgraph->
nvars);
12710 assert(exprgraph->
vars[(*exprnode)->data.intval] == vars[expr->
data.intval]);
12712 *exprnodeisnew = (*exprnode)->nuses == 0 && (*exprnode)->nparents == 0;
12723 assert(*exprnode != NULL);
12725 assert((*exprnode)->data.dbl == expr->
data.dbl);
12727 *exprnodeisnew = (*exprnode)->nuses == 0 && (*exprnode)->nparents == 0;
12736 assert(params != NULL);
12739 assert(*exprnode != NULL);
12741 assert((*exprnode)->data.dbl == params[expr->
data.intval]);
12743 *exprnodeisnew = (*exprnode)->nuses == 0 && (*exprnode)->nparents == 0;
12755 nochildisnew =
TRUE;
12759 assert(childnodes[i] != NULL);
12760 nochildisnew &= !childisnew;
12768 if( *exprnode != NULL )
12771 (*exprnode)->enabled =
TRUE;
12772 *exprnodeisnew =
FALSE;
12787 if( exprOpTable[expr->
op].copydata != NULL )
12793 opdata = expr->
data;
12798 *exprnodeisnew =
TRUE;
12822 assert(exprgraph != NULL);
12823 assert(clearreverseprop != NULL);
12824 assert(boundchanged != NULL);
12826 *boundchanged =
FALSE;
12827 for( i = 0; i < exprgraph->
nvars; ++i )
12851 for( p = 0; p < node->
nparents; ++p )
12857 *boundchanged =
TRUE;
12860 *clearreverseprop =
TRUE;
12865 for( p = 0; p < node->
nparents; ++p )
12871 *boundchanged =
TRUE;
12894 #undef SCIPexprgraphCaptureNode 12895 #undef SCIPexprgraphIsNodeEnabled 12896 #undef SCIPexprgraphGetNodeNChildren 12897 #undef SCIPexprgraphGetNodeChildren 12898 #undef SCIPexprgraphGetNodeNParents 12899 #undef SCIPexprgraphGetNodeParents 12900 #undef SCIPexprgraphGetNodeDepth 12901 #undef SCIPexprgraphGetNodePosition 12902 #undef SCIPexprgraphGetNodeOperator 12903 #undef SCIPexprgraphGetNodeOperatorIndex 12904 #undef SCIPexprgraphGetNodeOperatorReal 12905 #undef SCIPexprgraphGetNodeVar 12906 #undef SCIPexprgraphGetNodeRealPowerExponent 12907 #undef SCIPexprgraphGetNodeIntPowerExponent 12908 #undef SCIPexprgraphGetNodeSignPowerExponent 12909 #undef SCIPexprgraphGetNodeLinearCoefs 12910 #undef SCIPexprgraphGetNodeLinearConstant 12911 #undef SCIPexprgraphGetNodeQuadraticConstant 12912 #undef SCIPexprgraphGetNodeQuadraticLinearCoefs 12913 #undef SCIPexprgraphGetNodeQuadraticQuadElements 12914 #undef SCIPexprgraphGetNodeQuadraticNQuadElements 12915 #undef SCIPexprgraphGetNodePolynomialMonomials 12916 #undef SCIPexprgraphGetNodePolynomialNMonomials 12917 #undef SCIPexprgraphGetNodePolynomialConstant 12918 #undef SCIPexprgraphGetNodeUserData 12919 #undef SCIPexprgraphHasNodeUserEstimator 12920 #undef SCIPexprgraphGetNodeBounds 12921 #undef SCIPexprgraphGetNodeVal 12922 #undef SCIPexprgraphGetNodeCurvature 12929 assert(node->
nuses >= 0);
12941 assert(node != NULL);
12951 assert(node != NULL);
12961 assert(node != NULL);
12971 assert(node != NULL);
12981 assert(node != NULL);
12991 assert(node != NULL);
12993 return node->
depth;
13001 assert(node != NULL);
13011 assert(node != NULL);
13021 assert(node != NULL);
13024 return node->
data.intval;
13032 assert(node != NULL);
13035 return node->
data.dbl;
13044 assert(exprgraph != NULL);
13045 assert(node != NULL);
13047 assert(node->
data.intval >= 0);
13048 assert(node->
data.intval < exprgraph->
nvars);
13050 return exprgraph->
vars[node->
data.intval];
13058 assert(node != NULL);
13061 return node->
data.dbl;
13069 assert(node != NULL);
13072 return node->
data.intval;
13080 assert(node != NULL);
13083 return node->
data.dbl;
13091 assert(node != NULL);
13102 assert(node != NULL);
13104 assert(node->
data.data != NULL);
13114 assert(node != NULL);
13116 assert(node->
data.data != NULL);
13126 assert(node != NULL);
13128 assert(node->
data.data != NULL);
13138 assert(node != NULL);
13140 assert(node->
data.data != NULL);
13150 assert(node != NULL);
13152 assert(node->
data.data != NULL);
13162 assert(node != NULL);
13164 assert(node->
data.data != NULL);
13174 assert(node != NULL);
13176 assert(node->
data.data != NULL);
13186 assert(node != NULL);
13188 assert(node->
data.data != NULL);
13213 assert(node != NULL);
13214 assert(node->
depth >= 0);
13215 assert(node->
pos >= 0);
13219 assert(node->
data.data != NULL);
13220 assert(monomialidx >= 0);
13222 assert(curv != NULL);
13231 assert(monomial != NULL);
13241 childbounds = childboundsstatic;
13242 childcurv = childcurvstatic;
13246 for( i = 0; i < monomial->
nfactors; ++i )
13249 assert(child != NULL);
13257 childbounds[i] = child->
bounds;
13258 childcurv[i] = child->
curv;
13267 if( childbounds != childboundsstatic )
13281 assert(node != NULL);
13283 assert(node->
data.data != NULL);
13293 assert(node != NULL);
13295 assert(node->
data.data != NULL);
13305 assert(node != NULL);
13315 assert(node != NULL);
13317 return node->
value;
13325 assert(node != NULL);
13341 assert(blkmem != NULL);
13342 assert(node != NULL);
13356 SCIPerrorMessage(
"cannot create node with operand %d via SCIPexprgraphCreateNode\n");
13381 opdata.data = NULL;
13397 opdata.intval = va_arg( ap,
int);
13425 assert(blkmem != NULL);
13426 assert(node != NULL);
13431 data[ncoefs] = constant;
13433 opdata.data = data;
13453 assert(blkmem != NULL);
13454 assert(node != NULL);
13455 assert(quadelems != NULL || nquadelems == 0);
13459 opdata.data = data;
13478 assert(blkmem != NULL);
13479 assert(node != NULL);
13480 assert(monomials != NULL || nmonomials == 0);
13484 opdata.data = data;
13499 assert(blkmem != NULL);
13500 assert(node != NULL);
13502 assert(monomials != NULL || nmonomials == 0);
13528 assert(blkmem != NULL);
13529 assert(node != NULL);
13530 assert(
eval != NULL);
13533 assert(copydata != NULL || data == NULL);
13534 assert(freedata != NULL || data == NULL);
13540 exprdata->eval =
eval;
13541 exprdata->estimate = estimate;
13542 exprdata->inteval = inteval;
13543 exprdata->curv = curv;
13544 exprdata->prop = prop;
13545 exprdata->copydata = copydata;
13546 exprdata->freedata = freedata;
13547 exprdata->print = print;
13549 opdata.data = (
void*) exprdata;
13580 assert(exprgraph != NULL);
13581 assert(node != NULL);
13582 assert(*node != NULL);
13583 assert((*node)->nuses > 0);
13584 assert(nlinvars != NULL);
13585 assert(linvars != NULL || linvarssize == 0);
13586 assert(lincoefs != NULL || linvarssize == 0);
13587 assert(constant != NULL);
13595 switch( (*node)->op )
13599 if( linvarssize >= 1 )
13602 linvars[0] = exprgraph->
vars[(*node)->data.intval];
13612 *constant = (*node)->data.dbl;
13621 if( (*node)->data.dbl == 1.0 && (*node)->children[0]->op ==
SCIP_EXPR_VARIDX && linvarssize >= 1 )
13624 linvars[0] = exprgraph->
vars[(*node)->children[0]->data.intval];
13634 if( (*node)->data.intval == 1 && (*node)->children[0]->op ==
SCIP_EXPR_VARIDX && linvarssize >= 1 )
13637 linvars[0] = exprgraph->
vars[(*node)->children[0]->data.intval];
13649 *constant = (*node)->children[0]->data.dbl;
13651 linvars[0] = exprgraph->
vars[(*node)->children[1]->data.intval];
13660 *constant = (*node)->children[1]->data.dbl;
13662 linvars[0] = exprgraph->
vars[(*node)->children[0]->data.intval];
13672 linvars[0] = exprgraph->
vars[(*node)->children[0]->data.intval];
13674 linvars[1] = exprgraph->
vars[(*node)->children[1]->data.intval];
13693 *constant = (*node)->children[0]->data.dbl;
13695 linvars[0] = exprgraph->
vars[(*node)->children[1]->data.intval];
13696 lincoefs[0] = -1.0;
13704 *constant = -(*node)->children[1]->data.dbl;
13706 linvars[0] = exprgraph->
vars[(*node)->children[0]->data.intval];
13716 linvars[0] = exprgraph->
vars[(*node)->children[0]->data.intval];
13718 linvars[1] = exprgraph->
vars[(*node)->children[1]->data.intval];
13719 lincoefs[1] = -1.0;
13738 linvars[0] = exprgraph->
vars[(*node)->children[1]->data.intval];
13739 lincoefs[0] = (*node)->children[0]->data.dbl;
13746 linvars[0] = exprgraph->
vars[(*node)->children[0]->data.intval];
13747 lincoefs[0] = (*node)->children[1]->data.dbl;
13762 linvars[0] = exprgraph->
vars[(*node)->children[0]->data.intval];
13763 lincoefs[0] = 1.0/(*node)->children[1]->data.dbl;
13796 for( i = 0; i < (*node)->nchildren; ++i )
13802 if( i == (*node)->nchildren )
13810 assert(exprgraph->
nvars > 0);
13811 orignvars = exprgraph->
nvars;
13819 if( (*node)->nparents > 0 || (*node)->nuses > 1 )
13825 if( exprOpTable[orignode->
op].copydata != NULL )
13830 data = orignode->
data;
13837 havechange =
FALSE;
13839 switch( (*node)->op )
13851 assert(linvarssize >= 1);
13855 varidx = varchild->
data.intval;
13857 if( varsusage[varidx] > 1 )
13862 linvars[0] = exprgraph->
vars[varidx];
13864 lincoefs[0] = -1.0;
13868 if( (*node)->op ==
SCIP_EXPR_PLUS || (*node)->children[0] == otherchild )
13873 *node = otherchild;
13883 (*node)->children[0] = otherchild;
13891 (*node)->data.data = (
void*)lindata;
13907 nchildren = (*node)->nchildren;
13908 while( i < nchildren )
13913 *constant += (*node)->children[i]->data.dbl;
13916 if( i < nchildren-1 )
13918 (*node)->children[i] = (*node)->children[nchildren-1];
13919 (*node)->children[nchildren-1] = NULL;
13934 if( varsusage[(*node)->children[i]->data.intval] > 1 )
13941 if( *nlinvars < linvarssize )
13943 linvars[*nlinvars] = exprgraph->
vars[(*node)->children[i]->data.intval];
13944 lincoefs[*nlinvars] = 1.0;
13948 if( i < nchildren-1 )
13950 (*node)->children[i] = (*node)->children[nchildren-1];
13951 (*node)->children[nchildren-1] = NULL;
13958 assert(i == nchildren);
13960 if( nchildren == 0 )
13965 (*node)->nchildren = 0;
13970 if( nchildren < (*node)->nchildren )
13975 (*node)->nchildren = nchildren;
13978 if( havechange && (*node)->nchildren == 1 )
13999 coefs = (
SCIP_Real*)(*node)->data.data;
14000 assert(coefs != NULL);
14003 if( coefs[(*node)->nchildren] != 0.0 )
14005 *constant = coefs[(*node)->nchildren];
14006 coefs[(*node)->nchildren] = 0.0;
14011 nchildren = (*node)->nchildren;
14012 while( i < nchildren )
14017 *constant += coefs[i] * (*node)->children[i]->data.dbl;
14020 if( i < nchildren-1 )
14022 (*node)->children[i] = (*node)->children[nchildren-1];
14023 (*node)->children[nchildren-1] = NULL;
14024 coefs[i] = coefs[nchildren-1];
14025 coefs[nchildren-1] = 0.0;
14040 if( varsusage[(*node)->children[i]->data.intval] > 1 )
14047 if( *nlinvars < linvarssize )
14049 linvars[*nlinvars] = exprgraph->
vars[(*node)->children[i]->data.intval];
14050 lincoefs[*nlinvars] = coefs[i];
14054 if( i < nchildren-1 )
14056 (*node)->children[i] = (*node)->children[nchildren-1];
14057 (*node)->children[nchildren-1] = NULL;
14058 coefs[i] = coefs[nchildren-1];
14059 coefs[nchildren-1] = 0.0;
14066 assert(i == nchildren);
14068 if( nchildren == 0 )
14074 (*node)->data.data = NULL;
14075 (*node)->nchildren = 0;
14081 if( nchildren < (*node)->nchildren )
14087 coefs[nchildren] = 0.0;
14088 (*node)->data.data = (
void*)coefs;
14089 (*node)->nchildren = nchildren;
14092 if( havechange && (*node)->nchildren == 1 && coefs[0] == 1.0 )
14116 assert(quaddata != NULL);
14127 if( quaddata->
lincoefs != NULL || linvarssize == 0 )
14143 nchildren = (*node)->nchildren;
14144 for( i = 0; i < nchildren; ++i )
14147 if( *nlinvars >= linvarssize )
14154 if( varsusage[(*node)->children[i]->data.intval] > 1 )
14158 linvars[*nlinvars] = exprgraph->
vars[(*node)->children[i]->data.intval];
14159 lincoefs[*nlinvars] = quaddata->
lincoefs[i];
14166 if( i < nchildren-1 )
14168 (*node)->children[i] = (*node)->children[nchildren-1];
14170 childused[i] = childused[nchildren-1];
14171 childmap[nchildren-1] = i;
14182 if( nchildren < (*node)->nchildren )
14201 if( nchildren == 0 )
14206 exprFreeDataQuadratic(exprgraph->
blkmem, (*node)->nchildren, (*node)->data);
14207 (*node)->data.data = NULL;
14208 (*node)->nchildren = 0;
14214 if( nchildren < (*node)->nchildren )
14219 (*node)->nchildren = nchildren;
14234 assert(polynomialdata != NULL);
14240 if( polynomialdata->
constant != 0.0 )
14242 *constant = polynomialdata->
constant;
14248 if( linvarssize == 0 )
14254 for( i = 0; i < polynomialdata->
nmonomials; ++i )
14256 monomial = polynomialdata->
monomials[i];
14257 assert(monomial != NULL);
14260 for( j = 0; j < monomial->
nfactors; ++j )
14263 assert(monomial->
childidxs[j] < (*node)->nchildren);
14269 for( i = 0; i < polynomialdata->
nmonomials && *nlinvars < linvarssize; ++i )
14271 monomial = polynomialdata->
monomials[i];
14272 assert(monomial != NULL);
14277 if( monomial->
coef != 0.0 )
14279 *constant += monomial->
coef;
14290 assert((*node)->children[childidx] != NULL);
14293 if( childused[childidx] || varsusage[(*node)->children[childidx]->data.intval] > 1 )
14299 linvars[*nlinvars] = exprgraph->
vars[(*node)->children[childidx]->data.intval];
14300 lincoefs[*nlinvars] = monomial->
coef;
14303 monomial->
coef = 0.0;
14308 (*node)->children[childidx] = NULL;
14315 if( *nlinvars > 0 )
14322 if( (*node)->nchildren == 0 )
14325 assert(polynomialdata->
constant == 0.0);
14339 if( orignode != NULL )
14345 assert(*constant == 0.0);
14346 assert(*nlinvars == 0);
14347 assert(*node != NULL);
14357 else if( havechange && *node != NULL )
14361 (*node)->simplified =
FALSE;
14382 assert(exprgraph != NULL);
14383 assert(srcnode != NULL);
14384 assert(*srcnode != NULL);
14385 assert(targetnode != NULL);
14387 while( *srcnode != NULL && (*srcnode)->
nparents > 0 )
14389 if( (*srcnode)->parents[0]->depth <= targetnode->
depth )
14395 assert(*srcnode == NULL || (*srcnode)->
nuses > 0);
14415 assert(exprgraph != NULL);
14416 assert(node != NULL);
14417 assert(*node != NULL);
14418 assert((*node)->depth >= 0);
14419 assert((*node)->pos >= 0);
14420 assert((*node)->depth < exprgraph->
depth);
14421 assert((*node)->pos < exprgraph->
nnodes[(*node)->depth]);
14422 assert((*node)->nuses >= 1);
14423 assert(exprgraph->
nodes[(*node)->depth][(*node)->pos] == *node);
14430 if( (*node)->nparents > 0 || (*node)->nuses > 0 )
14432 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);
14441 for( i = 0; i < (*node)->nchildren; ++i )
14444 (*node)->children[i] = NULL;
14449 assert((*node)->depth == 0);
14457 assert(constidx >= 0);
14458 assert(constidx < exprgraph->nconsts);
14459 assert(exprgraph->
constnodes[constidx] == *node);
14462 if( constidx < exprgraph->nconsts-1 )
14472 assert((*node)->depth > 0);
14476 if( (*node)->pos < exprgraph->
nnodes[(*node)->depth]-1 )
14479 exprgraph->
nodes[(*node)->depth][(*node)->pos] = exprgraph->
nodes[(*node)->depth][exprgraph->
nnodes[(*node)->depth]-1];
14480 exprgraph->
nodes[(*node)->depth][(*node)->pos]->
pos = (*node)->pos;
14483 for( i = 0; i < exprgraph->
nodes[(*node)->depth][(*node)->pos]->
nchildren; ++i )
14486 --exprgraph->
nnodes[(*node)->depth];
14489 (*node)->depth = -1;
14507 assert(blkmem != NULL);
14508 assert( node != NULL);
14509 assert(*node != NULL);
14510 assert((*node)->depth == -1);
14511 assert((*node)->pos == -1);
14512 assert((*node)->nuses == 0);
14515 if( exprOpTable[(*node)->op].freedata != NULL )
14516 exprOpTable[(*node)->op].freedata(blkmem, (*node)->nchildren, (*node)->data);
14534 assert(exprgraph != NULL);
14535 assert(node != NULL);
14536 assert(node->
depth >= 0);
14537 assert(node->
pos >= 0);
14544 node->enabled =
TRUE;
14545 for( i = 0; i < node->nchildren; ++i )
14561 assert(exprgraph != NULL);
14562 assert(node != NULL);
14563 assert(node->
depth >= 0);
14564 assert(node->
pos >= 0);
14573 if( node->
nuses > 1 )
14578 for( i = 0; i < node->
nparents; ++i )
14585 SCIPdebugMessage(
"disabled node %p (%d,%d), nuses = %d\n", (
void*)node, node->
depth, node->pos, node->nuses);
14587 for( i = 0; i < node->nchildren; ++i )
14598 assert(node != NULL);
14600 for( p = 0; p < node->
nparents; ++p )
14617 assert(node != NULL);
14633 for( p = 0; p < node->
nparents; ++p )
14670 assert(node != NULL);
14689 assert(exprgraph != NULL);
14690 assert(node != NULL);
14691 assert(node->
depth >= 0);
14692 assert(node->
pos >= 0);
14694 assert(cutoff != NULL);
14701 SCIPdebugMessage(
"ignore bound tightening for node %p (%d,%d)\n", (
void*)node, node->
depth, node->pos);
14705 SCIPdebugMessage(
"tighten bounds of node %p (%d,%d) from [%10g, %10g] by [%10g, %10g]",
14706 (
void*)node, node->
depth, node->pos,
14707 node->bounds.inf, node->bounds.sup, nodebounds.
inf, nodebounds.
sup);
14712 if( nodebounds.
inf > node->bounds.sup || nodebounds.
sup < node->bounds.inf )
14725 if( minstrength < 0.0 )
14728 isLbBetter(minstrength, nodebounds.
inf, node->bounds.inf, node->bounds.sup) ||
14729 isUbBetter(minstrength, nodebounds.
sup, node->bounds.inf, node->bounds.sup) )
14731 else if( nodebounds.
inf > node->bounds.inf || nodebounds.
sup < node->bounds.sup )
14735 SCIPdebugPrintf(
" -> [%10g, %10g] status %d\n", node->bounds.inf, node->bounds.sup, node->boundstatus);
14756 assert(node != NULL);
14757 assert(node->
depth >= 0);
14758 assert(node->
pos >= 0);
14761 if( node->
depth == 0 )
14779 childbounds = childboundsstatic;
14780 childcurv = childcurvstatic;
14803 assert( exprOpTable[node->
op].inteval != NULL );
14816 for( i = 0; i < node->
nparents; ++i )
14819 node->
bounds = newbounds;
14824 for( i = 0; i < node->
nparents; ++i )
14827 node->
bounds = newbounds;
14845 SCIPdebugMessage(
"node %p(%d,%d) has empty domain in SCIPexprgraphUpdateNodeBoundsCurvature\n", (
void*)node, node->
depth, node->pos);
14858 if( childbounds != childboundsstatic )
14878 #undef SCIPexprgraphGetDepth 14879 #undef SCIPexprgraphGetNNodes 14880 #undef SCIPexprgraphGetNodes 14881 #undef SCIPexprgraphGetNVars 14882 #undef SCIPexprgraphGetVars 14883 #undef SCIPexprgraphGetVarNodes 14884 #undef SCIPexprgraphSetVarNodeValue 14885 #undef SCIPexprgraphSetVarsBounds 14886 #undef SCIPexprgraphSetVarBounds 14887 #undef SCIPexprgraphSetVarNodeBounds 14888 #undef SCIPexprgraphSetVarNodeLb 14889 #undef SCIPexprgraphSetVarNodeUb 14890 #undef SCIPexprgraphGetVarsBounds 14897 assert(exprgraph != NULL);
14899 return exprgraph->
depth;
14907 assert(exprgraph != NULL);
14909 return exprgraph->
nnodes;
14917 assert(exprgraph != NULL);
14919 return exprgraph->
nodes;
14927 assert(exprgraph != NULL);
14929 return exprgraph->
nvars;
14937 assert(exprgraph != NULL);
14939 return exprgraph->
vars;
14947 assert(exprgraph != NULL);
14958 assert(varnode != NULL);
14961 varnode->
value = value;
14970 assert(exprgraph != NULL);
14971 assert(varbounds != NULL || exprgraph->
nvars == 0);
14985 assert(exprgraph != NULL);
14986 assert(var != NULL);
14990 assert(pos < exprgraph->nvars);
14991 assert(exprgraph->
vars[pos] == var);
15005 assert(exprgraph != NULL);
15006 assert(varnode != NULL);
15008 pos = varnode->
data.intval;
15010 assert(pos < exprgraph->nvars);
15011 assert(exprgraph->
varnodes[pos] == varnode);
15025 assert(exprgraph != NULL);
15026 assert(varnode != NULL);
15028 pos = varnode->
data.intval;
15030 assert(pos < exprgraph->nvars);
15031 assert(exprgraph->
varnodes[pos] == varnode);
15045 assert(exprgraph != NULL);
15046 assert(varnode != NULL);
15048 pos = varnode->
data.intval;
15050 assert(pos < exprgraph->nvars);
15051 assert(exprgraph->
varnodes[pos] == varnode);
15076 assert(blkmem != NULL);
15077 assert(exprgraph != NULL);
15081 (*exprgraph)->blkmem = blkmem;
15085 assert((*exprgraph)->depth >= 1);
15088 ensureBlockMemoryArraySize3((*exprgraph)->blkmem, &(*exprgraph)->varnodes, &(*exprgraph)->vars, &(*exprgraph)->varbounds, &(*exprgraph)->varssize, varssizeinit);
15092 (*exprgraph)->constssorted =
TRUE;
15095 (*exprgraph)->exprgraphvaradded = exprgraphvaradded;
15096 (*exprgraph)->exprgraphvarremove = exprgraphvarremove;
15097 (*exprgraph)->exprgraphvarchgidx = exprgraphvarchgidx;
15098 (*exprgraph)->userdata = userdata;
15111 assert( exprgraph != NULL);
15112 assert(*exprgraph != NULL);
15113 assert((*exprgraph)->nvars == 0);
15114 assert((*exprgraph)->nconsts == 0);
15116 blkmem = (*exprgraph)->blkmem;
15117 assert(blkmem != NULL);
15120 for( d = 0; d < (*exprgraph)->depth; ++d )
15122 assert((*exprgraph)->nnodes[d] == 0);
15125 assert((*exprgraph)->nodes != NULL);
15126 assert((*exprgraph)->nnodes != NULL);
15127 assert((*exprgraph)->nodessize != NULL);
15165 assert(exprgraph != NULL);
15166 assert(node != NULL);
15167 assert(node->
pos < 0);
15168 assert(node->
depth < 0);
15172 assert(children != NULL || nchildren == 0);
15175 depth =
MAX(0, mindepth);
15176 for( i = 0; i < nchildren; ++i )
15178 if( children[i]->depth >= depth )
15179 depth = children[i]->
depth + 1;
15184 assert(exprgraph->
depth > depth);
15190 node->
depth = depth;
15192 exprgraph->
nodes[depth][node->
pos] = node;
15193 ++exprgraph->
nnodes[depth];
15197 childvalsvalid =
TRUE;
15198 for( i = 0; i < nchildren; ++i )
15204 if( nchildren > 0 )
15248 assert(exprgraph != NULL);
15249 assert(exprgraph->
depth >= 1);
15250 assert(vars != NULL || nvars == 0);
15253 if( exprgraph->
nvars == 0 )
15259 for( i = 0; i < nvars; ++i )
15265 assert(node != NULL);
15270 if( varnodes != NULL )
15271 varnodes[i] = node;
15277 opdata.intval = exprgraph->
nvars;
15285 exprgraph->
vars[exprgraph->
nvars] = vars[i];
15289 ++exprgraph->
nvars;
15291 if( varnodes != NULL )
15292 varnodes[i] = node;
15294 SCIPdebugMessage(
"added node %p (%d, %d) for new variable %d\n", (
void*)node, node->
depth, node->pos, node->data.intval);
15297 if( exprgraph->exprgraphvaradded != NULL )
15299 SCIP_CALL( exprgraph->exprgraphvaradded(exprgraph, exprgraph->
userdata, vars[i], node) );
15318 assert(exprgraph != NULL);
15319 assert(constnode != NULL);
15324 assert(*constnode != NULL);
15326 assert((*constnode)->data.dbl == constant);
15327 (*constnode)->enabled =
TRUE;
15332 opdata.dbl = constant;
15337 assert((*constnode)->depth == 0);
15338 assert((*constnode)->pos == exprgraph->
nnodes[0]-1);
15346 SCIPdebugMessage(
"added node %p (%d, %d) for new constant %g\n", (
void*)constnode, (*constnode)->
depth, (*constnode)->pos, (*constnode)->data.dbl);
15368 assert(exprgraph != NULL);
15369 assert(nexprtrees > 0);
15370 assert(exprtrees != NULL);
15371 assert(rootnode != NULL);
15372 assert(rootnodeisnew != NULL);
15376 if( nexprtrees == 1 && (coefs == NULL || coefs[0] == 1.0) )
15378 assert(exprtrees[0] != NULL);
15379 assert(exprtrees[0]->vars != NULL || exprtrees[0]->nvars == 0);
15381 SCIP_CALL(
exprgraphAddExpr(exprgraph, exprtrees[0]->root, exprtrees[0]->vars, exprtrees[0]->params, rootnode, rootnodeisnew) );
15390 *rootnodeisnew =
TRUE;
15394 for( i = 0; i < nexprtrees; ++i )
15396 assert(exprtrees[i] != NULL);
15397 assert(exprtrees[i]->vars != NULL || exprtrees[i]->nvars == 0);
15399 SCIP_CALL(
exprgraphAddExpr(exprgraph, exprtrees[i]->root, exprtrees[i]->vars, exprtrees[i]->params, &rootnodes[i], &rootnodeisnew_) );
15400 assert(rootnodes[i] != NULL);
15401 *rootnodeisnew &= rootnodeisnew_;
15403 allone &= (coefs == NULL || coefs[i] == 1.0);
15407 if( coefs == NULL || allone )
15409 else if( nexprtrees == 2 && coefs[0] == 1.0 && coefs[1] == -1.0 )
15411 else if( nexprtrees == 2 && coefs[1] == 1.0 && coefs[0] == -1.0 )
15415 tmp = rootnodes[0];
15416 rootnodes[0] = rootnodes[1];
15417 rootnodes[1] = tmp;
15428 if( !*rootnodeisnew )
15434 if( *rootnode == NULL )
15439 *rootnodeisnew =
TRUE;
15444 *rootnodeisnew =
FALSE;
15457 lindata[nexprtrees] = 0.0;
15458 data.data = lindata;
15460 if( !*rootnodeisnew )
15466 if( *rootnode == NULL )
15471 *rootnodeisnew =
TRUE;
15476 *rootnodeisnew =
FALSE;
15483 assert(*rootnode != NULL);
15488 rootnodeisnew ?
"new" :
"old", (
void*)*rootnode, (*rootnode)->
depth, (*rootnode)->pos, nexprtrees);
15511 assert(exprgraph != NULL);
15512 assert(var != NULL);
15514 assert(coefs != NULL || ncoefs == 0);
15515 assert(vars != NULL || ncoefs == 0);
15518 assert(varidx < exprgraph->nvars);
15519 assert(exprgraph->
vars[varidx] == var);
15520 varnode = exprgraph->
varnodes[varidx];
15521 assert(varnode != NULL);
15522 assert(varnode->
data.intval == varidx);
15524 if( ncoefs == 0 || (ncoefs == 1 && constant == 0.0 && coefs[0] == 1.0) )
15534 assert(node == NULL || node->
data.dbl == constant);
15539 assert(node == NULL || exprgraph->
vars[node->
data.intval] == vars[0]);
15544 SCIPdebugMessage(
"try to replace varnode %p (%d uses, %d parents) by %p\n", (
void*)varnode, varnode->
nuses, varnode->nparents, (
void*)node);
15550 if( varnode != NULL )
15552 assert(varnode->nuses > 0);
15553 assert(varnode->nparents == 0);
15563 varnode->data.data = NULL;
15565 varnode->children[0] = node;
15566 varnode->nchildren = 1;
15569 varnode->value = node->value;
15570 varnode->bounds = node->bounds;
15574 else if( ncoefs == 0 )
15583 varnode->
data.dbl = constant;
15585 varnode->
value = constant;
15602 varnode->
data.intval = exprgraph->
nvars;
15606 exprgraph->
vars[exprgraph->
nvars] = vars[0];
15610 ++exprgraph->
nvars;
15613 if( exprgraph->exprgraphvaradded != NULL )
15615 SCIP_CALL( exprgraph->exprgraphvaradded(exprgraph, exprgraph->
userdata, vars[0], varnode) );
15620 if( varnode != NULL )
15623 for( i = 0; i < varnode->
nparents; ++i )
15641 lindata[ncoefs] = constant;
15642 varnode->
data.data = (
void*)lindata;
15651 for( i = 0; i < ncoefs; ++i )
15662 for( i = 0; i < varnode->
nparents; ++i )
15677 assert(exprgraph != NULL);
15678 assert(var != NULL);
15679 assert(varnode != NULL);
15688 assert(pos < exprgraph->nvars);
15690 *varnode = exprgraph->
varnodes[pos];
15691 assert(*varnode != NULL);
15708 assert(exprgraph != NULL);
15709 assert(constnode != NULL);
15710 assert(constant == constant);
15717 right = exprgraph->
nconsts-1;
15720 while( left <= right )
15722 middle = (left+right)/2;
15723 assert(0 <= middle && middle < exprgraph->nconsts);
15725 if( constant < exprgraph->constnodes[middle]->data.dbl )
15726 right = middle - 1;
15735 if( left == right+1 )
15738 assert(*constnode != NULL);
15740 assert((*constnode)->data.dbl == constant);
15750 const char** varnames
15756 assert(exprgraph != NULL);
15764 for( d = 0; d < exprgraph->
depth; ++d )
15766 if( exprgraph->
nnodes[d] == 0 )
15769 for( i = 0; i < exprgraph->
nnodes[d]; ++i )
15777 for( i = 0; i < exprgraph->
nnodes[0]; ++i )
15783 for( d = 0; d < exprgraph->
depth; ++d )
15784 for( i = 0; i < exprgraph->
nnodes[d]; ++i )
15803 assert(exprgraph != NULL);
15804 assert(varvals != NULL || exprgraph->
nvars == 0);
15806 for( d = 0; d < exprgraph->
depth; ++d )
15807 for( i = 0; i < exprgraph->
nnodes[d]; ++i )
15828 assert(exprgraph != NULL);
15829 assert(domainerror != NULL);
15831 *domainerror =
FALSE;
15839 SCIPdebugMessage(
"no bounds changed and clearreverseprop is FALSE -> skip propagation of variable bounds\n");
15844 for( d = 1; d < exprgraph->
depth; ++d )
15846 for( i = 0; i < exprgraph->
nnodes[d]; ++i )
15848 node = exprgraph->
nodes[d][i];
15852 SCIPdebugMessage(
"bounds of node %p(%d,%d) empty, stop bounds propagation\n", (
void*)node, node->
depth, node->pos);
15854 *domainerror =
TRUE;
15881 assert(exprgraph != NULL);
15882 assert(cutoff != NULL);
15886 for( d = exprgraph->
depth-1; d >= 0 && !*cutoff; --d )
15888 for( i = 0; i < exprgraph->
nnodes[d] && !*cutoff; ++i )
15890 node = exprgraph->
nodes[d][i];
15913 assert(exprgraph != NULL);
15919 for( i = 0; i < exprgraph->
nnodes[0]; ++i )
15923 for( d = 1; d < exprgraph->
depth; ++d )
15924 for( i = 0; i < exprgraph->
nnodes[d]; ++i )
15926 node = exprgraph->
nodes[d][i];
15927 assert(node != NULL);
15933 SCIPerrorMessage(
"SCIPexprgraphCheckCurvature gets domain error while propagating variables bounds, ignoring...\n");
15949 int maxexpansionexponent,
15970 assert(exprgraph != NULL);
15971 assert(eps >= 0.0);
15972 assert(havechange != NULL);
15973 assert(domainerror != NULL);
15983 for( i = 0; i < exprgraph->
nvars; ++i )
15986 for( d = 1; d < exprgraph->
depth; ++d )
15987 for( i = 0; i < exprgraph->
nnodes[d]; ++i )
15989 node = exprgraph->
nodes[d][i];
15990 assert(node != NULL);
15993 if( node->
nuses > 0 )
16008 file = fopen(
"exprgraph_beforesimplify.dot",
"w");
16017 *havechange =
FALSE;
16018 *domainerror =
FALSE;
16019 allsimplified =
TRUE;
16024 for( d = 1; d < exprgraph->
depth && !*domainerror; ++d )
16026 for( i = 0; i < exprgraph->
nnodes[d]; ++i )
16028 node = exprgraph->
nodes[d][i];
16029 assert(node != NULL);
16031 havechangenode =
FALSE;
16039 allsimplified =
FALSE;
16044 *havechange |= havechangenode;
16054 SCIPdebugMessage(
"Expression graph simplify turned node into NaN or inf.\n");
16055 *domainerror =
TRUE;
16063 assert(constnode->
data.dbl == node->
value);
16070 assert(node == NULL || node->
nuses > 0);
16071 havechangenode =
TRUE;
16080 assert(node != NULL);
16081 assert(node->
nuses > 0);
16083 if( constnode->
nuses == 0 )
16090 assert(constnode == NULL);
16091 havechangenode =
TRUE;
16109 if( havechangenode )
16110 for( j = 0; j < node->
nparents; ++j )
16116 if( allsimplified || *domainerror )
16117 goto EXPRGRAPHSIMPLIFY_CLEANUP;
16122 for( d = 1; d < exprgraph->
depth; ++d )
16124 for( i = 0; i < exprgraph->
nnodes[d]; ++i )
16126 node = exprgraph->
nodes[d][i];
16127 assert(node != NULL);
16140 for( j = 0; node != NULL && j < node->
nparents; ++j )
16145 assert(node == NULL || node->
nuses > 0);
16157 file = fopen(
"exprgraph_aftersimplify.dot",
"w");
16167 for( d = 1; d < exprgraph->
depth; ++d )
16168 for( i = 0; i < exprgraph->
nnodes[d]; ++i )
16174 node = exprgraph->
nodes[d][i];
16175 assert(node != NULL);
16180 if( node->
nuses > 0 )
16185 assert(idx < ntestvals);
16187 testval_before = testvals[idx];
16195 EXPRGRAPHSIMPLIFY_CLEANUP:
16217 assert(exprgraph != NULL);
16218 assert(rootnode != NULL);
16219 assert(rootnode->
depth >= 0);
16220 assert(rootnode->
pos >= 0);
16221 assert(exprtree != NULL);
16227 for( i = 0; i < exprgraph->
nvars; ++i )
16238 if( nexprvars > 0 )
16241 for( i = 0; i < exprgraph->
nvars; ++i )
16243 assert(varidx[i] >= -1);
16244 assert(varidx[i] < nexprvars);
16245 if( varidx[i] >= 0 )
16246 (*exprtree)->vars[varidx[i]] = exprgraph->
vars[i];
16284 assert(exprgraph != NULL);
16285 assert(node != NULL);
16286 assert(node->
depth >= 0);
16287 assert(node->
pos >= 0);
16288 assert(exprtreessize > 0);
16289 assert(nexprtrees != NULL);
16290 assert(exprtrees != NULL);
16291 assert(exprtreecoefs != NULL);
16295 if( exprtreessize == 1 || node->
nchildren <= 1 || exprgraph->
nvars <= 1 ||
16304 exprtreecoefs[0] = 1.0;
16313 for( i = 0; i < exprgraph->
nvars; ++i )
16316 haveoverlap =
FALSE;
16321 assert(compnr >= 0);
16322 assert(compnr < node->nchildren);
16323 childcomp[i] = compnr;
16327 haveoverlap =
TRUE;
16338 assert(data != NULL);
16346 if( childcomp[j] == compnr )
16349 haveoverlap =
TRUE;
16358 assert(data != NULL);
16367 if( childcomp[k] == compnr )
16370 haveoverlap =
TRUE;
16386 if( compmap[childcomp[i]] == -1 )
16387 compmap[childcomp[i]] = ncomponents++;
16388 childcomp[i] = compmap[childcomp[i]];
16398 if( ncomponents == 1 )
16404 exprtreecoefs[0] = 1.0;
16410 if( ncomponents > exprtreessize )
16414 if( childcomp[i] >= exprtreessize )
16415 childcomp[i] = exprtreessize-1;
16416 ncomponents = exprtreessize;
16419 assert(ncomponents >= 2);
16426 for( i = 0; i < ncomponents; ++i )
16429 for( j = 0; j < exprgraph->
nvars; ++j )
16437 assert(childcomp[j] >= 0);
16438 assert(childcomp[j] < ncomponents);
16439 if( childcomp[j] != i )
16444 childmap[j] = nexprs;
16445 childmapinv[nexprs] = j;
16454 assert(ncomponents == 2);
16455 assert(nexprs == 1);
16458 exprtreecoefs[i] = 1.0;
16465 assert(ncomponents == 2);
16466 assert(nexprs == 1);
16470 assert(childmapinv[0] == 0 || childmapinv[0] == 1);
16471 exprtreecoefs[i] = (childmapinv[0] == 0 ? 1.0 : -1.0);
16491 exprtreecoefs[i] = 1.0;
16504 if( nexprs == 1 && (i > 0 || nodecoefs[node->
nchildren] == 0.0) )
16508 exprtreecoefs[i] = nodecoefs[childmapinv[0]];
16510 else if( nexprs == 1 )
16514 assert(nodecoefs[node->
nchildren] != 0.0);
16515 assert(nodecoefs[childmapinv[0]] != 0.0);
16519 exprtreecoefs[i] = nodecoefs[childmapinv[0]];
16525 if( nexprs == 2 && nodecoefs[childmapinv[0]] == nodecoefs[childmapinv[1]] && (i > 0 || nodecoefs[node->
nchildren] == 0.0) )
16529 exprtreecoefs[i] = nodecoefs[childmapinv[0]];
16531 else if( nexprs == 2 && nodecoefs[childmapinv[0]] == -nodecoefs[childmapinv[1]] && (i > 0 || nodecoefs[node->
nchildren] == 0.0) )
16535 exprtreecoefs[i] = nodecoefs[childmapinv[0]];
16544 allcoefsequal =
TRUE;
16545 coefs[0] = nodecoefs[childmapinv[0]];
16546 for( j = 0; j < nexprs; ++j )
16548 coefs[j] = nodecoefs[childmapinv[j]];
16549 allcoefsequal &= (coefs[j] == coefs[0]);
16553 if( allcoefsequal && (i > 0 || nodecoefs[node->
nchildren] == 0.0) )
16556 exprtreecoefs[i] = coefs[0];
16561 exprtreecoefs[i] = 1.0;
16583 exprtreecoefs[i] = 1.0;
16589 for( j = 0; j < nexprs; ++j )
16590 lincoefs[j] = nodedata->
lincoefs[childmapinv[j]];
16629 exprtreecoefs[i] = 1.0;
16646 for( k = 0; k < monomials[nmonomials]->
nfactors; ++k )
16649 monomials[nmonomials]->
childidxs[k] = childmap[monomials[nmonomials]->
childidxs[k]];
16668 if( nexprvars > 0 )
16671 for( j = 0; j < exprgraph->
nvars; ++j )
16673 assert(varidx[j] >= -1);
16674 assert(varidx[j] < nexprvars);
16675 if( varidx[j] >= 0 )
16676 exprtrees[i]->
vars[varidx[j]] = exprgraph->
vars[j];
16687 *nexprtrees = ncomponents;
16699 assert(exprgraph != NULL);
16700 assert(node != NULL);
16701 assert(varsusage != NULL);
16758 assert(exprgraph != NULL);
16759 assert(node != NULL);
16760 assert(node->
depth >= 0);
16761 assert(node->
pos >= 0);
16762 assert(exprtreessize > 0);
16763 assert(nexprtrees != NULL);
16764 assert(exprtrees != NULL);
16765 assert(exprtreecoefs != NULL);
16776 exprtreecoefs[0] = 1.0;
16786 assert(exprtreessize >= 2);
16791 exprtreecoefs[0] = 1.0;
16792 exprtreecoefs[1] = 1.0;
16800 assert(exprtreessize >= 2);
16805 exprtreecoefs[0] = 1.0;
16806 exprtreecoefs[1] = -1.0;
16814 assert(exprtreessize >= node->
nchildren);
16819 exprtreecoefs[i] = 1.0;
16830 assert(exprtreessize >= node->
nchildren);
16834 assert(nodecoefs != NULL);
16839 exprtreecoefs[i] = nodecoefs[i];
16843 if( nodecoefs[node->
nchildren] != 0.0 )
16869 assert(exprtreessize >= (lincoefs != NULL ? node->
nchildren : 0) + nquadelems);
16873 if( lincoefs != NULL )
16877 if( lincoefs[i] == 0.0 )
16880 exprtreecoefs[*nexprtrees] = lincoefs[i];
16888 for( i = 0; i < nquadelems; ++i )
16891 for( j = 0; j < exprgraph->
nvars; ++j )
16898 if( quadelems[i].idx1 == quadelems[i].idx2 )
16917 if( nexprvars > 0 )
16920 for( j = 0; j < exprgraph->
nvars; ++j )
16922 assert(varidx[j] >= -1);
16923 assert(varidx[j] < nexprvars);
16924 if( varidx[j] >= 0 )
16925 exprtrees[*nexprtrees]->
vars[varidx[j]] = exprgraph->
vars[j];
16929 exprtreecoefs[*nexprtrees] = quadelems[i].
coef;
16939 assert(*nexprtrees > 0);
16964 assert(exprtreessize >= nmonomials);
16972 for( i = 0; i < nmonomials; ++i )
16975 for( j = 0; j < exprgraph->
nvars; ++j )
16979 if( monomials[i]->nfactors == 1 )
16985 if( monomials[i]->exponents[0] == 1.0 )
16987 else if( monomials[i]->exponents[0] == 2.0 )
16991 else if(
EPSISINT(monomials[i]->exponents[0], 0.0) )
17000 else if( monomials[i]->nfactors == 2 && monomials[i]->exponents[0] == 1.0 && monomials[i]->exponents[1] == 1.0 )
17021 for( f = 0; f < monomials[i]->
nfactors; ++f )
17042 if( nexprvars > 0 )
17045 for( j = 0; j < exprgraph->
nvars; ++j )
17047 assert(varidx[j] >= -1);
17048 assert(varidx[j] < nexprvars);
17049 if( varidx[j] >= 0 )
17050 exprtrees[*nexprtrees]->
vars[varidx[j]] = exprgraph->
vars[j];
17054 exprtreecoefs[*nexprtrees] = monomials[i]->
coef;
17060 if( constant != 0.0 )
17064 assert(*nexprtrees > 0);
void SCIPintervalSignPowerScalar(SCIP_Real infinity, SCIP_INTERVAL *resultant, SCIP_INTERVAL operand1, SCIP_Real operand2)
#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)
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)
#define BMSfreeMemoryArrayNull(ptr)
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 doCheckCurvature(SCIP_EXPR *expr, SCIP_Real infinity, SCIP_INTERVAL *varbounds, SCIP_INTERVAL *childbounds, SCIP_Real *param, SCIP_EXPRCURV *curv, SCIP_EXPRCURV *childcurv, SCIP_INTERVAL *bounds)
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)
int SCIPsnprintf(char *t, int len, const char *s,...)
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)
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)
static SCIP_RETCODE exprparseReadVariable(BMS_BLKMEM *blkmem, const char **str, SCIP_EXPR **expr, int *nvars, int **varnames, int *varnameslength, SCIP_HASHTABLE *vartable, SCIP_Real coefficient, const char *varnameendptr)
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 exprParse(BMS_BLKMEM *blkmem, SCIP_MESSAGEHDLR *messagehdlr, SCIP_EXPR **expr, const char *str, int length, const char *lastchar, int *nvars, int **varnames, int *varnameslength, SCIP_HASHTABLE *vartable, int recursiondepth)
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
internal miscellaneous methods
void SCIPrandomFree(SCIP_RANDNUMGEN **randnumgen, BMS_BLKMEM *blkmem)
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 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)
#define SCIP_CALL_TERMINATE(retcode, x, TERM)
SCIP_RETCODE SCIPrandomCreate(SCIP_RANDNUMGEN **randnumgen, BMS_BLKMEM *blkmem, unsigned int initialseed)
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)
SCIP_RETCODE SCIPexprParse(BMS_BLKMEM *blkmem, SCIP_MESSAGEHDLR *messagehdlr, SCIP_EXPR **expr, const char *str, const char *lastchar, int *nvars, int *varnames, int varnameslength)
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)
#define SCIP_ALLOC_TERMINATE(retcode, x, TERM)
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)