38#define _USE_MATH_DEFINES
81 1.000, 2.414, 3.078, 6.314, 12.706,
82 0.816, 1.604, 1.886, 2.920, 4.303,
83 0.765, 1.423, 1.638, 2.353, 3.182,
84 0.741, 1.344, 1.533, 2.132, 2.776,
85 0.727, 1.301, 1.476, 2.015, 2.571,
86 0.718, 1.273, 1.440, 1.943, 2.447,
87 0.711, 1.254, 1.415, 1.895, 2.365,
88 0.706, 1.240, 1.397, 1.860, 2.306,
89 0.703, 1.230, 1.383, 1.833, 2.262,
90 0.700, 1.221, 1.372, 1.812, 2.228,
91 0.697, 1.214, 1.363, 1.796, 2.201,
92 0.695, 1.209, 1.356, 1.782, 2.179,
93 0.694, 1.204, 1.350, 1.771, 2.160,
94 0.692, 1.200, 1.345, 1.761, 2.145,
95 0.691, 1.197, 1.341, 1.753, 2.131
102 0.674, 1.150, 1.282, 1.645, 1.960
139 if( countx < 1.9 || county < 1.9 )
143 pooledvariance = (countx - 1) * variancex + (county - 1) * variancey;
144 pooledvariance /= (countx + county - 2);
147 pooledvariance =
MAX(pooledvariance, 1e-9);
152 tresult = (meanx - meany) / sqrt(pooledvariance);
153 tresult *= sqrt(countx * county / (countx + county));
163#if defined(_WIN32) || defined(_WIN64)
174 sign = (
x >= 0) ? 1 : -1;
178 y = 1.0 - (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*exp(-
x*
x);
209 assert(variance >= -1e-9);
210 if( variance < 1e-9 )
213 std = sqrt(variance);
218 if( value < mean + 1e-9 )
223 assert(
std != 0.0 );
228 SCIPdebugMessage(
" Normalized value %g = ( %g - %g ) / (%g * 1.4142136)\n", normvalue, value, mean,
std);
233 if( normvalue < 1e-9 && normvalue > -1e-9 )
235 else if( normvalue > 0 )
239 erfresult =
SCIPerf(normvalue);
240 return erfresult / 2.0 + 0.5;
246 erfresult =
SCIPerf(-normvalue);
248 return 0.5 - erfresult / 2.0;
261 assert(regression !=
NULL);
271 assert(regression !=
NULL);
273 return regression->
slope;
281 assert(regression !=
NULL);
302 regression->
slope = 0.0;
336 assert(meanptr !=
NULL);
337 assert(sumvarptr !=
NULL);
338 assert(nobservations > 0 || add);
340 addfactor = add ? 1.0 : -1.0;
343 *meanptr = oldmean + addfactor * (value - oldmean)/(
SCIP_Real)nobservations;
344 *sumvarptr += addfactor * (value - oldmean) * (value - (*meanptr));
347 assert(*sumvarptr >= -1e-4);
348 *sumvarptr =
MAX(0.0, *sumvarptr);
358 assert(regression !=
NULL);
391 assert(regression !=
NULL);
410 regression->
meanx = 0;
412 regression->
sumxy = 0;
413 regression->
meany = 0;
423 assert(regression !=
NULL);
452 assert(initsize >= 0);
453 assert(growfac >= 1.0);
457 size =
MAX(initsize, num);
463 initsize =
MAX(initsize, 4);
468 while( size < num && size > oldsize )
471 size = (int)(growfac * size + initsize);
475 if( size <= oldsize )
479 assert(size >= initsize);
490#define GMLNODEWIDTH 120.0
491#define GMLNODEHEIGTH 30.0
492#define GMLFONTSIZE 13
493#define GMLNODETYPE "rectangle"
494#define GMLNODEFILLCOLOR "#ff0000"
495#define GMLEDGECOLOR "black"
496#define GMLNODEBORDERCOLOR "#000000"
504 const char* nodetype,
505 const char* fillcolor,
506 const char* bordercolor
509 assert(file !=
NULL);
510 assert(label !=
NULL);
512 fprintf(file,
" node\n");
513 fprintf(file,
" [\n");
514 fprintf(file,
" id %u\n",
id);
515 fprintf(file,
" label \"%s\"\n", label);
516 fprintf(file,
" graphics\n");
517 fprintf(file,
" [\n");
521 if( nodetype !=
NULL )
522 fprintf(file,
" type \"%s\"\n", nodetype);
526 if( fillcolor !=
NULL )
527 fprintf(file,
" fill \"%s\"\n", fillcolor);
531 if( bordercolor !=
NULL )
532 fprintf(file,
" outline \"%s\"\n", bordercolor);
536 fprintf(file,
" ]\n");
537 fprintf(file,
" LabelGraphics\n");
538 fprintf(file,
" [\n");
539 fprintf(file,
" text \"%s\"\n", label);
541 fprintf(file,
" fontName \"Dialog\"\n");
542 fprintf(file,
" anchor \"c\"\n");
543 fprintf(file,
" ]\n");
544 fprintf(file,
" ]\n");
552 const char* nodetype,
553 const char* fillcolor,
554 const char* bordercolor,
558 assert(file !=
NULL);
559 assert(label !=
NULL);
561 fprintf(file,
" node\n");
562 fprintf(file,
" [\n");
563 fprintf(file,
" id %u\n",
id);
564 fprintf(file,
" label \"%s\"\n", label);
565 fprintf(file,
" weight %g\n", weight);
566 fprintf(file,
" graphics\n");
567 fprintf(file,
" [\n");
571 if( nodetype !=
NULL )
572 fprintf(file,
" type \"%s\"\n", nodetype);
576 if( fillcolor !=
NULL )
577 fprintf(file,
" fill \"%s\"\n", fillcolor);
581 if( bordercolor !=
NULL )
582 fprintf(file,
" outline \"%s\"\n", bordercolor);
586 fprintf(file,
" ]\n");
587 fprintf(file,
" LabelGraphics\n");
588 fprintf(file,
" [\n");
589 fprintf(file,
" text \"%s\"\n", label);
591 fprintf(file,
" fontName \"Dialog\"\n");
592 fprintf(file,
" anchor \"c\"\n");
593 fprintf(file,
" ]\n");
594 fprintf(file,
" ]\n");
606 assert(file !=
NULL);
608 fprintf(file,
" edge\n");
609 fprintf(file,
" [\n");
610 fprintf(file,
" source %u\n", source);
611 fprintf(file,
" target %u\n", target);
614 fprintf(file,
" label \"%s\"\n", label);
616 fprintf(file,
" graphics\n");
617 fprintf(file,
" [\n");
620 fprintf(file,
" fill \"%s\"\n", color);
625 fprintf(file,
" ]\n");
629 fprintf(file,
" LabelGraphics\n");
630 fprintf(file,
" [\n");
631 fprintf(file,
" text \"%s\"\n", label);
633 fprintf(file,
" fontName \"Dialog\"\n");
634 fprintf(file,
" anchor \"c\"\n");
635 fprintf(file,
" ]\n");
638 fprintf(file,
" ]\n");
650 assert(file !=
NULL);
652 fprintf(file,
" edge\n");
653 fprintf(file,
" [\n");
654 fprintf(file,
" source %u\n", source);
655 fprintf(file,
" target %u\n", target);
658 fprintf(file,
" label \"%s\"\n", label);
660 fprintf(file,
" graphics\n");
661 fprintf(file,
" [\n");
664 fprintf(file,
" fill \"%s\"\n", color);
668 fprintf(file,
" targetArrow \"standard\"\n");
669 fprintf(file,
" ]\n");
673 fprintf(file,
" LabelGraphics\n");
674 fprintf(file,
" [\n");
675 fprintf(file,
" text \"%s\"\n", label);
677 fprintf(file,
" fontName \"Dialog\"\n");
678 fprintf(file,
" anchor \"c\"\n");
679 fprintf(file,
" ]\n");
682 fprintf(file,
" ]\n");
691 assert(file !=
NULL);
693 fprintf(file,
"graph\n");
694 fprintf(file,
"[\n");
695 fprintf(file,
" hierarchic 1\n");
698 fprintf(file,
" directed 1\n");
706 assert(file !=
NULL);
708 fprintf(file,
"]\n");
718 assert(file !=
NULL);
720 fprintf(file,
"digraph G {\n");
728 const char* nodetype,
729 const char* fillcolor,
730 const char* bordercolor
733 assert(file !=
NULL);
735 fprintf(file,
"\t%d [shape=\"%s\", label=\"%s\", style=\"filled\", fillcolor=\"%s\", color=\"%s\"];\n", node, nodetype, label, fillcolor, bordercolor);
746 assert(file !=
NULL);
748 fprintf(file,
"\t%d -> %d [color=\"%s\"];\n", source, target, color);
756 assert(file !=
NULL);
758 fprintf(file,
"}\n");
779 assert(sparsesol !=
NULL);
780 assert(vars !=
NULL);
789 for( v = nvars - 1; v >= 0; --v )
791 assert(vars[v] !=
NULL);
812 (*sparsesol)->nvars = nvars;
822 assert(sparsesol !=
NULL);
823 assert(*sparsesol !=
NULL);
836 assert(sparsesol !=
NULL);
838 return sparsesol->
vars;
846 assert(sparsesol !=
NULL);
848 return sparsesol->
nvars;
856 assert(sparsesol !=
NULL);
866 assert(sparsesol !=
NULL);
881 assert(sparsesol !=
NULL);
886 assert(lbvalues !=
NULL);
889 for( v = 0; v < nvars; ++v )
890 sol[v] = lbvalues[v];
909 assert(sparsesol !=
NULL);
920 assert(lbvalues !=
NULL);
921 assert(ubvalues !=
NULL);
926 for( v = 0; v < nvars; ++v )
928 lbvalue = lbvalues[v];
929 ubvalue = ubvalues[v];
931 if( lbvalue < ubvalue )
935 if( carryflag ==
FALSE )
937 if( sol[v] < ubvalue )
945 assert(sol[v] == ubvalue);
952 if( sol[v] < ubvalue )
960 assert(sol[v] == ubvalue);
967 return (!carryflag && !singular);
982 assert(queue !=
NULL);
985 if( minsize <= queue->size )
1002 assert(queue !=
NULL);
1004 initsize =
MAX(1, initsize);
1005 sizefac =
MAX(1.0, sizefac);
1008 (*queue)->firstfree = 0;
1009 (*queue)->firstused = -1;
1011 (*queue)->sizefac = sizefac;
1012 (*queue)->slots =
NULL;
1024 assert(queue !=
NULL);
1035 assert(queue !=
NULL);
1050 int oldsize = queue->
size;
1053 assert(oldsize < queue->size);
1055 sizediff = queue->
size - oldsize;
1087 assert(queue !=
NULL);
1092 assert(elem !=
NULL);
1113 assert(queue !=
NULL);
1139 assert(queue !=
NULL);
1173 assert(queue !=
NULL);
1205 assert(queue !=
NULL);
1223 assert(queue !=
NULL);
1241 assert(queue !=
NULL);
1254 assert(queue !=
NULL);
1274#define PQ_PARENT(q) (((q)+1)/2-1)
1275#define PQ_LEFTCHILD(p) (2*(p)+1)
1276#define PQ_RIGHTCHILD(p) (2*(p)+2)
1286 assert(pqueue !=
NULL);
1288 if( minsize <= pqueue->size )
1306 assert(pqueue !=
NULL);
1307 assert(ptrcomp !=
NULL);
1309 initsize =
MAX(1, initsize);
1310 sizefac =
MAX(1.0, sizefac);
1314 (*pqueue)->size = 0;
1315 (*pqueue)->sizefac = sizefac;
1316 (*pqueue)->slots =
NULL;
1317 (*pqueue)->ptrcomp = ptrcomp;
1318 (*pqueue)->elemchgpos = elemchgpos;
1329 assert(pqueue !=
NULL);
1340 assert(pqueue !=
NULL);
1354 pqueue->
slots[newpos] = elem;
1357 if( pqueue->elemchgpos !=
NULL )
1359 pqueue->elemchgpos(elem, oldpos, newpos);
1363#ifdef SCIP_MORE_DEBUG
1386 if( pqueue->ptrcomp(pqueue->
slots[i], pqueue->
slots[leftchild]) > 0 )
1405 assert(pqueue !=
NULL);
1406 assert(pqueue->
len >= 0);
1407 assert(elem !=
NULL);
1415 while( pos > 0 && (*pqueue->ptrcomp)(elem, pqueue->
slots[parentpos]) < 0 )
1417 assert((*pqueue->ptrcomp)(pqueue->
slots[parentpos], elem) >= 0);
1427#ifdef SCIP_MORE_DEBUG
1428 assert(pqueueHasHeapProperty(pqueue));
1443 assert(pqueue !=
NULL);
1453 if( pos == pqueue->
len )
1461 while( pos > 0 && (*pqueue->ptrcomp)(last, pqueue->
slots[
PQ_PARENT(pos)]) < 0 )
1473 if( brotherpos < pqueue->len && (*pqueue->ptrcomp)(pqueue->
slots[brotherpos], pqueue->
slots[childpos]) < 0 )
1474 childpos = brotherpos;
1476 if( (*pqueue->ptrcomp)(last, pqueue->
slots[childpos]) <= 0 )
1486 assert(pos <= pqueue->len - 1);
1490#ifdef SCIP_MORE_DEBUG
1491 assert(pqueueHasHeapProperty(pqueue));
1502 assert(pqueue !=
NULL);
1503 assert(pqueue->
len >= 0);
1505 if( pqueue->
len == 0 )
1508 root = pqueue->
slots[0];
1520 assert(pqueue !=
NULL);
1521 assert(pqueue->
len >= 0);
1523 if( pqueue->
len == 0 )
1526 return pqueue->
slots[0];
1534 assert(pqueue !=
NULL);
1535 assert(pqueue->
len >= 0);
1545 assert(pqueue !=
NULL);
1546 assert(pqueue->
len >= 0);
1548 return pqueue->
slots;
1561 if( pqueue->
slots[pos] == elem )
1636 return ( (uint32_t) ((UINT64_C(0x9e3779b97f4a7c15) * input)>>32) ) | 1u;
1662 assert(multihashlist !=
NULL);
1663 assert(blkmem !=
NULL);
1664 assert(element !=
NULL);
1668 newlist->
next = *multihashlist;
1669 *multihashlist = newlist;
1684 assert(multihashlist !=
NULL);
1685 assert(blkmem !=
NULL);
1687 list = *multihashlist;
1688 while( list !=
NULL )
1690 nextlist = list->
next;
1695 *multihashlist =
NULL;
1710 uint64_t currentkeyval;
1713 assert(hashkeyeq !=
NULL);
1714 assert(key !=
NULL);
1716 while( multihashlist !=
NULL )
1718 currentkey = hashgetkey(userptr, multihashlist->
element);
1719 currentkeyval = hashkeyval(userptr, currentkey);
1720 if( currentkeyval == keyval && hashkeyeq(userptr, currentkey, key) )
1721 return multihashlist;
1723 multihashlist = multihashlist->
next;
1744 h =
multihashlistFind(multihashlist, hashgetkey, hashkeyeq, hashkeyval, userptr, keyval, key);
1752 h2 =
multihashlistFind(
h->next, hashgetkey, hashkeyeq, hashkeyval, userptr, keyval, key);
1759 key1 = hashgetkey(userptr,
h->element);
1760 key2 = hashgetkey(userptr, h2->
element);
1761 assert(hashkeyval(userptr, key1) == hashkeyval(userptr, key2));
1763 if( hashkeyeq(userptr, key1, key2) )
1765 SCIPerrorMessage(
"WARNING: hashkey with same value exists multiple times (e.g. duplicate constraint/variable names), so the return value is maybe not correct\n");
1794 assert(multihashlist !=
NULL);
1797 h =
multihashlistFind(*multihashlist, hashgetkey, hashkeyeq, hashkeyval, userptr, keyval, key);
1802 *multihashlist =
h->next;
1807 *multihashlist =
NULL;
1822 assert(multihashlist !=
NULL);
1823 assert(blkmem !=
NULL);
1824 assert(element !=
NULL);
1826 while( *multihashlist !=
NULL && (*multihashlist)->element != element )
1827 multihashlist = &(*multihashlist)->
next;
1829 if( *multihashlist !=
NULL )
1831 nextlist = (*multihashlist)->
next;
1833 *multihashlist = nextlist;
1841#define SCIP_MULTIHASH_MAXSIZE 33554431
1842#define SCIP_MULTIHASH_RESIZE_PERCENTAGE 65
1843#define SCIP_MULTIHASH_GROW_FACTOR 1.31
1857 assert(multihash !=
NULL);
1859 assert(multihash->
nlists > 0);
1860 assert(multihash->hashgetkey !=
NULL);
1861 assert(multihash->hashkeyeq !=
NULL);
1862 assert(multihash->hashkeyval !=
NULL);
1866 nnewlists =
MAX(nnewlists, multihash->
nlists);
1870 if( nnewlists > multihash->
nlists )
1875 unsigned int hashval;
1880 for( l = multihash->
nlists - 1; l >= 0; --l )
1882 multihashlist = multihash->
lists[l];
1886 while( multihashlist !=
NULL )
1889 key = multihash->hashgetkey(multihash->
userptr, multihashlist->
element);
1890 keyval = multihash->hashkeyval(multihash->
userptr, key);
1891 hashval = (
unsigned int) (keyval % (
unsigned) nnewlists);
1896 if( multihashlist->
next ==
NULL && onlyone )
1899 if( newlists[hashval] ==
NULL )
1900 newlists[hashval] = multihashlist;
1907 while( next !=
NULL )
1913 lastnext->
next = multihashlist;
1925 multihashlist = multihashlist->
next;
1937 multihash->
lists = newlists;
1938 multihash->
nlists = nnewlists;
1941#ifdef SCIP_MORE_DEBUG
1945 for( l = 0; l < multihash->
nlists; ++l )
1947 multihashlist = multihash->
lists[l];
1948 while( multihashlist !=
NULL )
1951 multihashlist = multihashlist->
next;
1954 assert(sumslotsize == multihash->
nelements);
1976 assert(tablesize >= 0);
1977 assert(multihash !=
NULL);
1978 assert(hashgetkey !=
NULL);
1979 assert(hashkeyeq !=
NULL);
1980 assert(hashkeyval !=
NULL);
1984 (*multihash)->blkmem = blkmem;
1985 (*multihash)->nlists = tablesize;
1986 (*multihash)->hashgetkey = hashgetkey;
1987 (*multihash)->hashkeyeq = hashkeyeq;
1988 (*multihash)->hashkeyval = hashkeyval;
1989 (*multihash)->userptr = userptr;
1990 (*multihash)->nelements = 0;
2005 assert(multihash !=
NULL);
2006 assert(*multihash !=
NULL);
2008 table = (*multihash);
2010 lists = table->
lists;
2013 for( i = table->
nlists - 1; i >= 0; --i )
2034 unsigned int hashval;
2036 assert(multihash !=
NULL);
2038 assert(multihash->
nlists > 0);
2039 assert(multihash->hashgetkey !=
NULL);
2040 assert(multihash->hashkeyeq !=
NULL);
2041 assert(multihash->hashkeyval !=
NULL);
2042 assert(element !=
NULL);
2051 key = multihash->hashgetkey(multihash->
userptr, element);
2052 keyval = multihash->hashkeyval(multihash->
userptr, key);
2053 hashval = (
unsigned int) (keyval % (
unsigned) multihash->
nlists);
2073 assert(multihash !=
NULL);
2074 assert(multihash->hashgetkey !=
NULL);
2093 unsigned int hashval;
2095 assert(multihash !=
NULL);
2097 assert(multihash->
nlists > 0);
2098 assert(multihash->hashgetkey !=
NULL);
2099 assert(multihash->hashkeyeq !=
NULL);
2100 assert(multihash->hashkeyval !=
NULL);
2101 assert(key !=
NULL);
2104 keyval = multihash->hashkeyval(multihash->
userptr, key);
2105 hashval = (
unsigned int) (keyval % (
unsigned) multihash->
nlists);
2108 multihash->hashkeyval, multihash->
userptr, keyval, key);
2126 assert(multihash !=
NULL);
2128 assert(multihash->
nlists > 0);
2129 assert(multihash->hashgetkey !=
NULL);
2130 assert(multihash->hashkeyeq !=
NULL);
2131 assert(multihash->hashkeyval !=
NULL);
2132 assert(multihashlist !=
NULL);
2133 assert(key !=
NULL);
2135 keyval = multihash->hashkeyval(multihash->
userptr, key);
2137 if( *multihashlist ==
NULL )
2139 unsigned int hashval;
2142 hashval = (
unsigned int) (keyval % (
unsigned) multihash->
nlists);
2144 *multihashlist = multihash->
lists[hashval];
2148 multihash->hashkeyval, multihash->
userptr, keyval, key);
2159 unsigned int hashval;
2161 assert(multihash !=
NULL);
2163 assert(multihash->
nlists > 0);
2164 assert(multihash->hashgetkey !=
NULL);
2165 assert(multihash->hashkeyeq !=
NULL);
2166 assert(multihash->hashkeyval !=
NULL);
2167 assert(element !=
NULL);
2170 key = multihash->hashgetkey(multihash->
userptr, element);
2171 keyval = multihash->hashkeyval(multihash->
userptr, key);
2172 hashval = (
unsigned int) (keyval % (
unsigned) multihash->
nlists);
2175 multihash->hashkeyval, multihash->
userptr, keyval, key) !=
NULL);
2186 unsigned int hashval;
2188 assert(multihash !=
NULL);
2190 assert(multihash->
nlists > 0);
2191 assert(multihash->hashgetkey !=
NULL);
2192 assert(multihash->hashkeyeq !=
NULL);
2193 assert(multihash->hashkeyval !=
NULL);
2194 assert(element !=
NULL);
2197 key = multihash->hashgetkey(multihash->
userptr, element);
2198 keyval = multihash->hashkeyval(multihash->
userptr, key);
2199 hashval = (
unsigned int) (keyval % (
unsigned) multihash->
nlists);
2221 assert(multihash !=
NULL);
2223 blkmem = multihash->
blkmem;
2224 lists = multihash->
lists;
2227 for( i = multihash->
nlists - 1; i >= 0; --i )
2238 assert(multihash !=
NULL);
2248 assert(multihash !=
NULL);
2266 assert(multihash !=
NULL);
2271 for( i = 0; i < multihash->
nlists; ++i )
2273 multihashlist = multihash->
lists[i];
2274 if( multihashlist !=
NULL )
2278 while( multihashlist !=
NULL )
2281 multihashlist = multihashlist->
next;
2283 maxslotsize =
MAX(maxslotsize, slotsize);
2284 sumslotsize += slotsize;
2287 assert(sumslotsize == multihash->
nelements);
2309 unsigned int nslots;
2314 assert(tablesize >= 0);
2315 assert(hashtable !=
NULL);
2316 assert(hashgetkey !=
NULL);
2317 assert(hashkeyeq !=
NULL);
2318 assert(hashkeyval !=
NULL);
2319 assert(blkmem !=
NULL);
2328 (*hashtable)->shift = 32;
2329 (*hashtable)->shift -= (
unsigned int)ceil(
LOG2(
MAX(32.0, tablesize / 0.9)));
2332 nslots = 1u << (32 - (*hashtable)->shift);
2335 (*hashtable)->mask = nslots - 1;
2338 (*hashtable)->blkmem = blkmem;
2339 (*hashtable)->hashgetkey = hashgetkey;
2340 (*hashtable)->hashkeyeq = hashkeyeq;
2341 (*hashtable)->hashkeyval = hashkeyval;
2342 (*hashtable)->userptr = userptr;
2343 (*hashtable)->nelements = 0;
2356 assert(hashtable !=
NULL);
2357 assert(*hashtable !=
NULL);
2359 nslots = (*hashtable)->
mask + 1;
2362 uint32_t maxprobelen = 0;
2363 uint64_t probelensum = 0;
2366 assert(table !=
NULL);
2368 for( i = 0; i < nslots; ++i )
2370 if( table->
hashes[i] != 0 )
2372 uint32_t probelen = ((i + table->
mask + 1 - (table->
hashes[i]>>(table->
shift))) & table->
mask) + 1;
2373 probelensum += probelen;
2374 maxprobelen =
MAX(probelen, maxprobelen);
2379 (
unsigned int)table->
nelements, (
unsigned int)table->
nelements, (
unsigned int)nslots,
2409#define ELEM_DISTANCE(pos) (((pos) + hashtable->mask + 1 - (hashtable->hashes[(pos)]>>(hashtable->shift))) & hashtable->mask)
2421 uint32_t elemdistance;
2427 assert(hashtable !=
NULL);
2430 assert(hashtable->
mask > 0);
2431 assert(hashtable->hashgetkey !=
NULL);
2432 assert(hashtable->hashkeyeq !=
NULL);
2433 assert(hashtable->hashkeyval !=
NULL);
2434 assert(element !=
NULL);
2436 pos = hashval>>(hashtable->
shift);
2443 if( hashtable->
hashes[pos] == 0 )
2445 hashtable->
slots[pos] = element;
2446 hashtable->
hashes[pos] = hashval;
2451 if( hashtable->
hashes[pos] == hashval && hashtable->hashkeyeq(hashtable->
userptr,
2452 hashtable->hashgetkey(hashtable->
userptr, hashtable->
slots[pos]), key) )
2459 hashtable->
slots[pos] = element;
2460 hashtable->
hashes[pos] = hashval;
2471 if( distance < elemdistance )
2476 elemdistance = distance;
2479 hashval = hashtable->
hashes[pos];
2480 hashtable->
hashes[pos] = tmp;
2481 key = hashtable->hashgetkey(hashtable->
userptr, element);
2490 pos = (pos + 1) & hashtable->
mask;
2501 assert(hashtable !=
NULL);
2502 assert(hashtable->
shift < 32);
2505 if( ((((uint64_t)hashtable->
nelements)<<10)>>(32-hashtable->
shift) > 921) )
2514 nslots = hashtable->
mask + 1;
2515 newnslots = 2*nslots;
2516 hashtable->
mask = newnslots-1;
2528 for( i = 0; i < nslots; ++i )
2533 if( hashes[i] != 0 )
2559 assert(hashtable !=
NULL);
2562 assert(hashtable->
mask > 0);
2563 assert(hashtable->hashgetkey !=
NULL);
2564 assert(hashtable->hashkeyeq !=
NULL);
2565 assert(hashtable->hashkeyval !=
NULL);
2566 assert(element !=
NULL);
2571 key = hashtable->hashgetkey(hashtable->
userptr, element);
2572 keyval = hashtable->hashkeyval(hashtable->
userptr, key);
2591 assert(hashtable !=
NULL);
2594 assert(hashtable->
mask > 0);
2595 assert(hashtable->hashgetkey !=
NULL);
2596 assert(hashtable->hashkeyeq !=
NULL);
2597 assert(hashtable->hashkeyval !=
NULL);
2598 assert(element !=
NULL);
2603 key = hashtable->hashgetkey(hashtable->
userptr, element);
2604 keyval = hashtable->hashkeyval(hashtable->
userptr, key);
2619 uint32_t elemdistance;
2621 assert(hashtable !=
NULL);
2624 assert(hashtable->
mask > 0);
2625 assert(hashtable->hashgetkey !=
NULL);
2626 assert(hashtable->hashkeyeq !=
NULL);
2627 assert(hashtable->hashkeyval !=
NULL);
2628 assert(key !=
NULL);
2631 keyval = hashtable->hashkeyval(hashtable->
userptr, key);
2634 pos = hashval>>(hashtable->
shift);
2642 if( hashtable->
hashes[pos] == 0 )
2648 if( elemdistance > distance )
2652 if( hashtable->
hashes[pos] == hashval && hashtable->hashkeyeq(hashtable->
userptr,
2653 hashtable->hashgetkey(hashtable->
userptr, hashtable->
slots[pos]), key) )
2654 return hashtable->
slots[pos];
2656 pos = (pos + 1) & hashtable->
mask;
2667 assert(hashtable !=
NULL);
2670 assert(hashtable->
mask > 0);
2671 assert(hashtable->hashgetkey !=
NULL);
2672 assert(hashtable->hashkeyeq !=
NULL);
2673 assert(hashtable->hashkeyval !=
NULL);
2674 assert(element !=
NULL);
2688 uint32_t elemdistance;
2692 assert(hashtable !=
NULL);
2695 assert(hashtable->
mask > 0);
2696 assert(hashtable->hashgetkey !=
NULL);
2697 assert(hashtable->hashkeyeq !=
NULL);
2698 assert(hashtable->hashkeyval !=
NULL);
2699 assert(element !=
NULL);
2702 key = hashtable->hashgetkey(hashtable->
userptr, element);
2703 keyval = hashtable->hashkeyval(hashtable->
userptr, key);
2707 pos = hashval>>(hashtable->
shift);
2711 if( hashtable->
hashes[pos] == 0 )
2717 if( elemdistance > distance )
2720 if( hashtable->
hashes[pos] == hashval && hashtable->hashkeyeq(hashtable->
userptr,
2721 hashtable->hashgetkey(hashtable->
userptr, hashtable->
slots[pos]), key) )
2727 pos = (pos + 1) & hashtable->
mask;
2732 hashtable->
hashes[pos] = 0;
2736 uint32_t nextpos = (pos + 1) & hashtable->
mask;
2739 if( hashtable->
hashes[nextpos] == 0 )
2743 if( (hashtable->
hashes[nextpos]>>(hashtable->
shift)) == nextpos )
2747 hashtable->
slots[pos] = hashtable->
slots[nextpos];
2749 hashtable->
hashes[nextpos] = 0;
2762 assert(hashtable !=
NULL);
2774 assert(hashtable !=
NULL);
2784 return (
int) hashtable->
mask + 1;
2793 return hashtable->
hashes[entryidx] == 0 ?
NULL : hashtable->
slots[entryidx];
2801 assert(hashtable !=
NULL);
2812 uint32_t maxprobelen = 0;
2813 uint64_t probelensum = 0;
2817 assert(hashtable !=
NULL);
2819 nslots = hashtable->
mask + 1;
2822 for( i = 0; i < nslots; ++i )
2824 if( hashtable->
hashes[i] != 0 )
2827 probelensum += probelen;
2828 maxprobelen =
MAX(probelen, maxprobelen);
2847 const char* string1 = (
const char*)key1;
2848 const char* string2 = (
const char*)key2;
2850 return (strcmp(string1, string2) == 0);
2859 str = (
const char*)key;
2861 while( *str !=
'\0' )
2864 hash += (
unsigned int)(*str);
2882 return (key1 == key2);
2889 return (uint64_t) (uintptr_t) key;
2901#define ELEM_DISTANCE(pos) (((pos) + hashmap->mask + 1 - (hashmap->hashes[(pos)]>>(hashmap->shift))) & hashmap->mask)
2913 uint32_t elemdistance;
2916 assert(hashmap !=
NULL);
2919 assert(hashmap->
mask > 0);
2920 assert(hashval != 0);
2922 pos = hashval>>(hashmap->
shift);
2929 if( hashmap->
hashes[pos] == 0 )
2933 hashmap->
hashes[pos] = hashval;
2944 hashmap->
hashes[pos] = hashval;
2955 if( distance < elemdistance )
2961 elemdistance = distance;
2963 hashval = hashmap->
hashes[pos];
2964 hashmap->
hashes[pos] = tmphash;
2972 pos = (pos + 1) & hashmap->
mask;
2988 uint32_t elemdistance;
2990 assert(hashmap !=
NULL);
2993 assert(hashmap->
mask > 0);
2997 assert(hashval != 0);
2999 *pos = hashval>>(hashmap->
shift);
3007 if( hashmap->
hashes[*pos] == 0 )
3012 if( elemdistance > distance )
3019 *pos = (*pos + 1) & hashmap->
mask;
3030 assert(hashmap !=
NULL);
3031 assert(hashmap->
shift < 32);
3034 if( ((((uint64_t)hashmap->
nelements)<<10)>>(32-hashmap->
shift) > 921) )
3043 nslots = hashmap->
mask + 1;
3045 newnslots = 2*nslots;
3046 hashmap->
mask = newnslots-1;
3057 for( i = 0; i < nslots; ++i )
3062 if( hashes[i] != 0 )
3085 assert(hashmap !=
NULL);
3086 assert(mapsize >= 0);
3087 assert(blkmem !=
NULL);
3096 (*hashmap)->shift = 32;
3097 (*hashmap)->shift -= (
unsigned int)ceil(log(
MAX(32, mapsize / 0.9)) / log(2.0));
3098 nslots = 1u << (32 - (*hashmap)->shift);
3099 (*hashmap)->mask = nslots - 1;
3100 (*hashmap)->blkmem = blkmem;
3101 (*hashmap)->nelements = 0;
3117 assert(hashmap !=
NULL);
3118 assert(*hashmap !=
NULL);
3120 nslots = (*hashmap)->mask + 1;
3123 uint32_t maxprobelen = 0;
3124 uint64_t probelensum = 0;
3127 assert(hashmap !=
NULL);
3129 for( i = 0; i < nslots; ++i )
3131 if( (*hashmap)->hashes[i] != 0 )
3133 uint32_t probelen = ((i + (*hashmap)->mask + 1 - ((*hashmap)->hashes[i]>>((*hashmap)->shift))) & (*hashmap)->mask) + 1;
3134 probelensum += probelen;
3135 maxprobelen =
MAX(probelen, maxprobelen);
3140 (
unsigned int)(*hashmap)->nelements, (
unsigned int)(*hashmap)->nelements, (
unsigned int)nslots,
3142 if( (*hashmap)->nelements > 0 )
3143 SCIPdebugPrintf(
", avg. probe length is %.1f, max. probe length is %u",
3144 (
SCIP_Real)(probelensum)/(
SCIP_Real)(*hashmap)->nelements, (
unsigned int)maxprobelen);
3168 assert(hashmap !=
NULL);
3171 assert(hashmap->
mask > 0);
3204 assert(hashmap !=
NULL);
3207 assert(hashmap->
mask > 0);
3240 assert(hashmap !=
NULL);
3243 assert(hashmap->
mask > 0);
3271 assert(hashmap !=
NULL);
3274 assert(hashmap->
mask > 0);
3291 assert(hashmap !=
NULL);
3294 assert(hashmap->
mask > 0);
3311 assert(hashmap !=
NULL);
3314 assert(hashmap->
mask > 0);
3335 assert(hashmap !=
NULL);
3337 assert(hashmap->
mask > 0);
3369 assert(hashmap !=
NULL);
3371 assert(hashmap->
mask > 0);
3403 assert(hashmap !=
NULL);
3405 assert(hashmap->
mask > 0);
3433 assert(hashmap !=
NULL);
3436 assert(hashmap->
mask > 0);
3449 assert(hashmap !=
NULL);
3451 assert(hashmap->
mask > 0);
3453 assert(origin !=
NULL);
3458 hashmap->
hashes[pos] = 0;
3464 uint32_t nextpos = (pos + 1) & hashmap->
mask;
3467 if( hashmap->
hashes[nextpos] == 0 )
3471 if( (hashmap->
hashes[nextpos]>>(hashmap->
shift)) == nextpos )
3478 hashmap->
hashes[nextpos] = 0;
3493 uint32_t maxprobelen = 0;
3494 uint64_t probelensum = 0;
3498 assert(hashmap !=
NULL);
3500 nslots = hashmap->
mask + 1;
3503 for( i = 0; i < nslots; ++i )
3505 if( hashmap->
hashes[i] != 0 )
3508 probelensum += probelen;
3509 maxprobelen =
MAX(probelen, maxprobelen);
3530 assert(hashmap !=
NULL);
3548 return (
int) hashmap->
mask + 1;
3557 assert(hashmap !=
NULL);
3559 return hashmap->
hashes[entryidx] == 0 ?
NULL : &hashmap->
slots[entryidx];
3567 assert(entry !=
NULL);
3577 assert(entry !=
NULL);
3587 assert(entry !=
NULL);
3597 assert(entry !=
NULL);
3608 assert(entry !=
NULL);
3619 assert(entry !=
NULL);
3630 assert(entry !=
NULL);
3640 assert(hashmap !=
NULL);
3657#define ELEM_DISTANCE(pos) (((pos) + nslots - hashSetDesiredPos(hashset, hashset->slots[(pos)])) & mask)
3666 return (uint32_t)((UINT64_C(0x9e3779b97f4a7c15) * (uintptr_t)element)>>(hashset->
shift));
3675 uint32_t elemdistance;
3680 assert(hashset !=
NULL);
3682 assert(element !=
NULL);
3696 hashset->
slots[pos] = element;
3701 if( hashset->
slots[pos] == element )
3706 if( distance < elemdistance )
3709 elemdistance = distance;
3714 pos = (pos + 1) & mask;
3726 assert(hashset !=
NULL);
3727 assert(hashset->
shift < 64);
3730 if( ((((uint64_t)hashset->
nelements)<<10)>>(64-hashset->
shift) > 921) )
3739 newnslots = 2*nslots;
3749 for( i = 0; i < nslots; ++i )
3751 if( slots[i] !=
NULL )
3771 assert(hashset !=
NULL);
3773 assert(blkmem !=
NULL);
3782 (*hashset)->shift = 64;
3783 (*hashset)->shift -= (
unsigned int)ceil(log(
MAX(8.0, size / 0.9)) / log(2.0));
3785 (*hashset)->nelements = 0;
3809 assert(hashset !=
NULL);
3828 uint32_t elemdistance;
3830 assert(hashset !=
NULL);
3843 if( hashset->
slots[pos] == element )
3852 if( elemdistance > distance )
3855 pos = (pos + 1) & mask;
3869 uint32_t elemdistance;
3871 assert(hashset !=
NULL);
3873 assert(element !=
NULL);
3885 if( hashset->
slots[pos] == element )
3894 if( elemdistance > distance )
3897 pos = (pos + 1) & mask;
3901 assert(hashset->
slots[pos] == element);
3910 uint32_t nextpos = (pos + 1) & mask;
3929 hashset->
slots[pos] = hashset->
slots[nextpos];
3941 uint32_t maxprobelen = 0;
3942 uint64_t probelensum = 0;
3947 assert(hashset !=
NULL);
3953 for( i = 0; i < nslots; ++i )
3958 probelensum += probelen;
3959 maxprobelen =
MAX(probelen, maxprobelen);
3981#undef SCIPhashsetIsEmpty
3982#undef SCIPhashsetGetNElements
3983#undef SCIPhashsetGetNSlots
3984#undef SCIPhashsetGetSlots
4007 return (
int) (1u << (64 - hashset->
shift));
4015 return hashset->
slots;
4038 assert(realarray !=
NULL);
4039 assert(blkmem !=
NULL);
4042 (*realarray)->blkmem = blkmem;
4043 (*realarray)->vals =
NULL;
4044 (*realarray)->valssize = 0;
4045 (*realarray)->firstidx = -1;
4046 (*realarray)->minusedidx = INT_MAX;
4047 (*realarray)->maxusedidx = INT_MIN;
4059 assert(realarray !=
NULL);
4060 assert(sourcerealarray !=
NULL);
4063 if( sourcerealarray->
valssize > 0 )
4068 (*realarray)->valssize = sourcerealarray->
valssize;
4069 (*realarray)->firstidx = sourcerealarray->
firstidx;
4070 (*realarray)->minusedidx = sourcerealarray->
minusedidx;
4071 (*realarray)->maxusedidx = sourcerealarray->
maxusedidx;
4081 assert(realarray !=
NULL);
4082 assert(*realarray !=
NULL);
4104 assert(realarray !=
NULL);
4109 assert(0 <= minidx);
4110 assert(minidx <= maxidx);
4114 assert(0 <= minidx);
4115 assert(minidx <= maxidx);
4117 SCIPdebugMessage(
"extending realarray %p (firstidx=%d, size=%d, range=[%d,%d]) to range [%d,%d]\n",
4121 nused = maxidx - minidx + 1;
4128 newvalssize =
calcGrowSize(arraygrowinit, arraygrowfac, nused);
4130 nfree = newvalssize - nused;
4131 newfirstidx = minidx - nfree/2;
4132 newfirstidx =
MAX(newfirstidx, 0);
4133 assert(newfirstidx <= minidx);
4134 assert(maxidx < newfirstidx + newvalssize);
4139 for( i = 0; i < realarray->
minusedidx - newfirstidx; ++i )
4148 for( i = realarray->
maxusedidx - newfirstidx + 1; i < newvalssize; ++i )
4153 for( i = 0; i < newvalssize; ++i )
4159 realarray->
vals = newvals;
4163 else if( realarray->
firstidx == -1 )
4166 nfree = realarray->
valssize - nused;
4168 realarray->
firstidx = minidx - nfree/2;
4169 assert(realarray->
firstidx <= minidx);
4170 assert(maxidx < realarray->firstidx + realarray->
valssize);
4172 for( i = 0; i < realarray->
valssize; ++i )
4173 assert(realarray->
vals[i] == 0.0);
4176 else if( minidx < realarray->firstidx )
4179 nfree = realarray->
valssize - nused;
4181 newfirstidx = minidx - nfree/2;
4182 newfirstidx =
MAX(newfirstidx, 0);
4183 assert(newfirstidx <= minidx);
4184 assert(maxidx < newfirstidx + realarray->valssize);
4194 shift = realarray->
firstidx - newfirstidx;
4198 assert(0 <= i + shift && i + shift < realarray->valssize);
4199 realarray->
vals[i + shift] = realarray->
vals[i];
4202 for( i = 0; i < shift; ++i )
4210 nfree = realarray->
valssize - nused;
4212 newfirstidx = minidx - nfree/2;
4213 newfirstidx =
MAX(newfirstidx, 0);
4214 assert(newfirstidx <= minidx);
4215 assert(maxidx < newfirstidx + realarray->valssize);
4225 shift = newfirstidx - realarray->
firstidx;
4229 assert(0 <= i - shift && i - shift < realarray->valssize);
4230 realarray->
vals[i - shift] = realarray->
vals[i];
4233 for( i = 0; i < shift; ++i )
4239 assert(minidx >= realarray->
firstidx);
4240 assert(maxidx < realarray->firstidx + realarray->
valssize);
4250 assert(realarray !=
NULL);
4252 SCIPdebugMessage(
"clearing realarray %p (firstidx=%d, size=%d, range=[%d,%d])\n",
4282 assert(realarray !=
NULL);
4285 if( idx < realarray->minusedidx || idx > realarray->
maxusedidx )
4290 assert(idx - realarray->
firstidx >= 0);
4306 assert(realarray !=
NULL);
4309 SCIPdebugMessage(
"setting realarray %p (firstidx=%d, size=%d, range=[%d,%d]) index %d to %g\n",
4316 assert(idx >= realarray->
firstidx);
4317 assert(idx < realarray->firstidx + realarray->
valssize);
4326 else if( idx >= realarray->
firstidx && idx < realarray->firstidx + realarray->
valssize )
4389 assert(realarray !=
NULL);
4399 assert(realarray !=
NULL);
4410 assert(intarray !=
NULL);
4411 assert(blkmem !=
NULL);
4414 (*intarray)->blkmem = blkmem;
4415 (*intarray)->vals =
NULL;
4416 (*intarray)->valssize = 0;
4417 (*intarray)->firstidx = -1;
4418 (*intarray)->minusedidx = INT_MAX;
4419 (*intarray)->maxusedidx = INT_MIN;
4431 assert(intarray !=
NULL);
4432 assert(sourceintarray !=
NULL);
4439 (*intarray)->valssize = sourceintarray->
valssize;
4440 (*intarray)->firstidx = sourceintarray->
firstidx;
4441 (*intarray)->minusedidx = sourceintarray->
minusedidx;
4442 (*intarray)->maxusedidx = sourceintarray->
maxusedidx;
4452 assert(intarray !=
NULL);
4453 assert(*intarray !=
NULL);
4475 assert(intarray !=
NULL);
4480 assert(0 <= minidx);
4481 assert(minidx <= maxidx);
4485 assert(0 <= minidx);
4486 assert(minidx <= maxidx);
4488 SCIPdebugMessage(
"extending intarray %p (firstidx=%d, size=%d, range=[%d,%d]) to range [%d,%d]\n",
4492 nused = maxidx - minidx + 1;
4499 newvalssize =
calcGrowSize(arraygrowinit, arraygrowfac, nused);
4501 nfree = newvalssize - nused;
4502 newfirstidx = minidx - nfree/2;
4503 newfirstidx =
MAX(newfirstidx, 0);
4504 assert(newfirstidx <= minidx);
4505 assert(maxidx < newfirstidx + newvalssize);
4510 for( i = 0; i < intarray->
minusedidx - newfirstidx; ++i )
4519 for( i = intarray->
maxusedidx - newfirstidx + 1; i < newvalssize; ++i )
4524 for( i = 0; i < newvalssize; ++i )
4530 intarray->
vals = newvals;
4534 else if( intarray->
firstidx == -1 )
4537 nfree = intarray->
valssize - nused;
4539 intarray->
firstidx = minidx - nfree/2;
4540 assert(intarray->
firstidx <= minidx);
4541 assert(maxidx < intarray->firstidx + intarray->
valssize);
4543 for( i = 0; i < intarray->
valssize; ++i )
4544 assert(intarray->
vals[i] == 0);
4547 else if( minidx < intarray->firstidx )
4550 nfree = intarray->
valssize - nused;
4552 newfirstidx = minidx - nfree/2;
4553 newfirstidx =
MAX(newfirstidx, 0);
4554 assert(newfirstidx <= minidx);
4555 assert(maxidx < newfirstidx + intarray->valssize);
4565 shift = intarray->
firstidx - newfirstidx;
4569 assert(0 <= i + shift && i + shift < intarray->valssize);
4570 intarray->
vals[i + shift] = intarray->
vals[i];
4573 for( i = 0; i < shift; ++i )
4581 nfree = intarray->
valssize - nused;
4583 newfirstidx = minidx - nfree/2;
4584 newfirstidx =
MAX(newfirstidx, 0);
4585 assert(newfirstidx <= minidx);
4586 assert(maxidx < newfirstidx + intarray->valssize);
4596 shift = newfirstidx - intarray->
firstidx;
4600 assert(0 <= i - shift && i - shift < intarray->valssize);
4601 intarray->
vals[i - shift] = intarray->
vals[i];
4604 for( i = 0; i < shift; ++i )
4610 assert(minidx >= intarray->
firstidx);
4611 assert(maxidx < intarray->firstidx + intarray->
valssize);
4621 assert(intarray !=
NULL);
4623 SCIPdebugMessage(
"clearing intarray %p (firstidx=%d, size=%d, range=[%d,%d])\n",
4653 assert(intarray !=
NULL);
4656 if( idx < intarray->minusedidx || idx > intarray->
maxusedidx )
4661 assert(idx - intarray->
firstidx >= 0);
4677 assert(intarray !=
NULL);
4680 SCIPdebugMessage(
"setting intarray %p (firstidx=%d, size=%d, range=[%d,%d]) index %d to %d\n",
4688 assert(idx < intarray->firstidx + intarray->
valssize);
4697 else if( idx >= intarray->
firstidx && idx < intarray->firstidx + intarray->
valssize )
4753 assert(intarray !=
NULL);
4763 assert(intarray !=
NULL);
4775 assert(boolarray !=
NULL);
4776 assert(blkmem !=
NULL);
4779 (*boolarray)->blkmem = blkmem;
4780 (*boolarray)->vals =
NULL;
4781 (*boolarray)->valssize = 0;
4782 (*boolarray)->firstidx = -1;
4783 (*boolarray)->minusedidx = INT_MAX;
4784 (*boolarray)->maxusedidx = INT_MIN;
4796 assert(boolarray !=
NULL);
4797 assert(sourceboolarray !=
NULL);
4800 if( sourceboolarray->
valssize > 0 )
4805 (*boolarray)->valssize = sourceboolarray->
valssize;
4806 (*boolarray)->firstidx = sourceboolarray->
firstidx;
4807 (*boolarray)->minusedidx = sourceboolarray->
minusedidx;
4808 (*boolarray)->maxusedidx = sourceboolarray->
maxusedidx;
4818 assert(boolarray !=
NULL);
4819 assert(*boolarray !=
NULL);
4841 assert(boolarray !=
NULL);
4846 assert(0 <= minidx);
4847 assert(minidx <= maxidx);
4851 assert(0 <= minidx);
4852 assert(minidx <= maxidx);
4854 SCIPdebugMessage(
"extending boolarray %p (firstidx=%d, size=%d, range=[%d,%d]) to range [%d,%d]\n",
4858 nused = maxidx - minidx + 1;
4865 newvalssize =
calcGrowSize(arraygrowinit, arraygrowfac, nused);
4867 nfree = newvalssize - nused;
4868 newfirstidx = minidx - nfree/2;
4869 newfirstidx =
MAX(newfirstidx, 0);
4870 assert(newfirstidx <= minidx);
4871 assert(maxidx < newfirstidx + newvalssize);
4876 for( i = 0; i < boolarray->
minusedidx - newfirstidx; ++i )
4885 for( i = boolarray->
maxusedidx - newfirstidx + 1; i < newvalssize; ++i )
4890 for( i = 0; i < newvalssize; ++i )
4896 boolarray->
vals = newvals;
4900 else if( boolarray->
firstidx == -1 )
4903 nfree = boolarray->
valssize - nused;
4905 boolarray->
firstidx = minidx - nfree/2;
4906 assert(boolarray->
firstidx <= minidx);
4907 assert(maxidx < boolarray->firstidx + boolarray->
valssize);
4909 for( i = 0; i < boolarray->
valssize; ++i )
4913 else if( minidx < boolarray->firstidx )
4916 nfree = boolarray->
valssize - nused;
4918 newfirstidx = minidx - nfree/2;
4919 newfirstidx =
MAX(newfirstidx, 0);
4920 assert(newfirstidx <= minidx);
4921 assert(maxidx < newfirstidx + boolarray->valssize);
4931 shift = boolarray->
firstidx - newfirstidx;
4935 assert(0 <= i + shift && i + shift < boolarray->valssize);
4936 boolarray->
vals[i + shift] = boolarray->
vals[i];
4939 for( i = 0; i < shift; ++i )
4947 nfree = boolarray->
valssize - nused;
4949 newfirstidx = minidx - nfree/2;
4950 newfirstidx =
MAX(newfirstidx, 0);
4951 assert(newfirstidx <= minidx);
4952 assert(maxidx < newfirstidx + boolarray->valssize);
4962 shift = newfirstidx - boolarray->
firstidx;
4972 for( i = 0; i < shift; ++i )
4978 assert(minidx >= boolarray->
firstidx);
4979 assert(maxidx < boolarray->firstidx + boolarray->
valssize);
4989 assert(boolarray !=
NULL);
4991 SCIPdebugMessage(
"clearing boolarray %p (firstidx=%d, size=%d, range=[%d,%d])\n",
5021 assert(boolarray !=
NULL);
5024 if( idx < boolarray->minusedidx || idx > boolarray->
maxusedidx )
5029 assert(idx - boolarray->
firstidx >= 0);
5045 assert(boolarray !=
NULL);
5048 SCIPdebugMessage(
"setting boolarray %p (firstidx=%d, size=%d, range=[%d,%d]) index %d to %u\n",
5055 assert(idx >= boolarray->
firstidx);
5056 assert(idx < boolarray->firstidx + boolarray->
valssize);
5065 else if( idx >= boolarray->
firstidx && idx < boolarray->firstidx + boolarray->
valssize )
5109 assert(boolarray !=
NULL);
5119 assert(boolarray !=
NULL);
5131 assert(ptrarray !=
NULL);
5132 assert(blkmem !=
NULL);
5135 (*ptrarray)->blkmem = blkmem;
5136 (*ptrarray)->vals =
NULL;
5137 (*ptrarray)->valssize = 0;
5138 (*ptrarray)->firstidx = -1;
5139 (*ptrarray)->minusedidx = INT_MAX;
5140 (*ptrarray)->maxusedidx = INT_MIN;
5152 assert(ptrarray !=
NULL);
5153 assert(sourceptrarray !=
NULL);
5160 (*ptrarray)->valssize = sourceptrarray->
valssize;
5161 (*ptrarray)->firstidx = sourceptrarray->
firstidx;
5162 (*ptrarray)->minusedidx = sourceptrarray->
minusedidx;
5163 (*ptrarray)->maxusedidx = sourceptrarray->
maxusedidx;
5173 assert(ptrarray !=
NULL);
5174 assert(*ptrarray !=
NULL);
5196 assert(ptrarray !=
NULL);
5201 assert(0 <= minidx);
5202 assert(minidx <= maxidx);
5206 assert(0 <= minidx);
5207 assert(minidx <= maxidx);
5209 SCIPdebugMessage(
"extending ptrarray %p (firstidx=%d, size=%d, range=[%d,%d]) to range [%d,%d]\n",
5213 nused = maxidx - minidx + 1;
5220 newvalssize =
calcGrowSize(arraygrowinit, arraygrowfac, nused);
5222 nfree = newvalssize - nused;
5223 newfirstidx = minidx - nfree/2;
5224 newfirstidx =
MAX(newfirstidx, 0);
5225 assert(newfirstidx <= minidx);
5226 assert(maxidx < newfirstidx + newvalssize);
5231 for( i = 0; i < ptrarray->
minusedidx - newfirstidx; ++i )
5240 for( i = ptrarray->
maxusedidx - newfirstidx + 1; i < newvalssize; ++i )
5245 for( i = 0; i < newvalssize; ++i )
5251 ptrarray->
vals = newvals;
5255 else if( ptrarray->
firstidx == -1 )
5258 nfree = ptrarray->
valssize - nused;
5260 ptrarray->
firstidx = minidx - nfree/2;
5261 assert(ptrarray->
firstidx <= minidx);
5262 assert(maxidx < ptrarray->firstidx + ptrarray->
valssize);
5264 for( i = 0; i < ptrarray->
valssize; ++i )
5268 else if( minidx < ptrarray->firstidx )
5271 nfree = ptrarray->
valssize - nused;
5273 newfirstidx = minidx - nfree/2;
5274 newfirstidx =
MAX(newfirstidx, 0);
5275 assert(newfirstidx <= minidx);
5276 assert(maxidx < newfirstidx + ptrarray->valssize);
5286 shift = ptrarray->
firstidx - newfirstidx;
5290 assert(0 <= i + shift && i + shift < ptrarray->valssize);
5291 ptrarray->
vals[i + shift] = ptrarray->
vals[i];
5294 for( i = 0; i < shift; ++i )
5302 nfree = ptrarray->
valssize - nused;
5304 newfirstidx = minidx - nfree/2;
5305 newfirstidx =
MAX(newfirstidx, 0);
5306 assert(newfirstidx <= minidx);
5307 assert(maxidx < newfirstidx + ptrarray->valssize);
5317 shift = newfirstidx - ptrarray->
firstidx;
5321 assert(0 <= i - shift && i - shift < ptrarray->valssize);
5322 ptrarray->
vals[i - shift] = ptrarray->
vals[i];
5325 for( i = 0; i < shift; ++i )
5331 assert(minidx >= ptrarray->
firstidx);
5332 assert(maxidx < ptrarray->firstidx + ptrarray->
valssize);
5342 assert(ptrarray !=
NULL);
5344 SCIPdebugMessage(
"clearing ptrarray %p (firstidx=%d, size=%d, range=[%d,%d])\n",
5374 assert(ptrarray !=
NULL);
5377 if( idx < ptrarray->minusedidx || idx > ptrarray->
maxusedidx )
5382 assert(idx - ptrarray->
firstidx >= 0);
5398 assert(ptrarray !=
NULL);
5401 SCIPdebugMessage(
"setting ptrarray %p (firstidx=%d, size=%d, range=[%d,%d]) index %d to %p\n",
5409 assert(idx < ptrarray->firstidx + ptrarray->
valssize);
5418 else if( idx >= ptrarray->
firstidx && idx < ptrarray->firstidx + ptrarray->
valssize )