85 assert( permvars !=
NULL );
86 assert( perms !=
NULL );
88 assert( npermvars > 0 );
89 assert( orbits !=
NULL );
90 assert( orbitbegins !=
NULL );
91 assert( norbits !=
NULL );
101 for (i = 0; i < permlen; ++i)
106 for (i = 0; i < permlen; ++i)
116 beginorbitidx = orbitidx;
117 orbits[orbitidx++] = i;
122 while ( j < orbitidx )
130 for (p = 0; p < nperms; ++p)
132 image = perms[p][curelem];
135 if ( ! varadded[image] )
137 orbits[orbitidx++] = image;
138 assert( orbitidx <= permlen );
139 varadded[image] =
TRUE;
146 if ( orbitidx <= beginorbitidx + 1 )
147 orbitidx = beginorbitidx;
149 orbitbegins[(*norbits)++] = beginorbitidx;
153 assert( *norbits < permlen );
154 orbitbegins[*norbits] = orbitidx;
157 printf(
"Orbits (total number: %d):\n", *norbits);
158 for (i = 0; i < *norbits; ++i)
163 for (j = orbitbegins[i]; j < orbitbegins[i+1]; ++j)
164 printf(
"%d ", orbits[j]);
198 int* componentbegins,
202 unsigned* componentblocked,
215 assert( permstrans !=
NULL );
216 assert( nperms > 0 );
217 assert( npermvars > 0 );
218 assert( inactiveperms !=
NULL );
219 assert( orbits !=
NULL );
220 assert( orbitbegins !=
NULL );
221 assert( norbits !=
NULL );
222 assert( components !=
NULL );
223 assert( componentbegins !=
NULL );
224 assert( vartocomponent !=
NULL );
225 assert( ncomponents > 0 );
226 assert( nmovedpermvars > 0 );
232 for (i = 0; i < npermvars; ++i)
237 for (i = 0; i < npermvars; ++i)
244 componentidx = vartocomponent[i];
245 if ( componentidx < 0 || componentblocked[componentidx] )
253 beginorbitidx = orbitidx;
254 orbits[orbitidx++] = i;
260 while ( j < orbitidx )
269 pt = permstrans[curelem];
270 for (p = componentbegins[componentidx]; p < componentbegins[componentidx + 1]; ++p)
274 perm = components[p];
276 if ( ! inactiveperms[perm] )
279 assert( vartocomponent[image] == componentidx );
282 if ( ! varadded[image] )
284 orbits[orbitidx++] = image;
285 assert( orbitidx <= npermvars );
286 varadded[image] =
TRUE;
295 if ( orbitidx <= beginorbitidx + 1 )
296 orbitidx = beginorbitidx;
298 orbitbegins[(*norbits)++] = beginorbitidx;
301 if ( nvaradded >= nmovedpermvars )
306 assert( *norbits < npermvars );
307 orbitbegins[*norbits] = orbitidx;
310 printf(
"Orbits (total number: %d):\n", *norbits);
311 for (i = 0; i < *norbits; ++i)
316 for (j = orbitbegins[i]; j < orbitbegins[i+1]; ++j)
317 printf(
"%d ", orbits[j]);
341 int* componentbegins,
357 assert( perms !=
NULL || permstrans !=
NULL );
358 assert( components !=
NULL );
359 assert( componentbegins !=
NULL );
360 assert( ignoredvars !=
NULL );
361 assert( orbit !=
NULL );
362 assert( orbitsize !=
NULL );
363 assert( 0 <= varidx && varidx < npermvars );
364 assert( component >= 0 );
365 assert( npermvars > 0 );
373 varstotest[0] = varidx;
376 varadded[varidx] =
TRUE;
378 if ( varfound !=
NULL )
379 varfound[varidx] =
TRUE;
383 while ( j < nvarstotest )
387 currvar = varstotest[j++];
389 for (p = componentbegins[component]; p < componentbegins[component+1]; ++p)
394 comp = components[p];
397 image = perms[comp][currvar];
399 image = permstrans[currvar][comp];
402 if ( ! varadded[image] )
404 varstotest[nvarstotest++] = image;
405 varadded[image] =
TRUE;
407 if ( ! ignoredvars[image] )
409 orbit[(*orbitsize)++] = image;
411 if ( varfound !=
NULL )
412 varfound[image] =
TRUE;
441 int* componentbegins,
456 assert( permstrans !=
NULL );
457 assert( nperms > 0 );
458 assert( npermvars > 0 );
459 assert( components !=
NULL );
460 assert( componentbegins !=
NULL );
461 assert( vartocomponent !=
NULL );
462 assert( ncomponents > 0 );
463 assert( orbits !=
NULL );
464 assert( orbitbegins !=
NULL );
465 assert( norbits !=
NULL );
466 assert( varorbitmap !=
NULL );
472 for (i = 0; i < npermvars; ++i)
480 for (i = 0; i < npermvars; ++i)
487 componentidx = vartocomponent[i];
488 if ( componentidx < 0 )
496 beginorbitidx = orbitidx;
497 orbits[orbitidx++] = i;
499 varorbitmap[i] = *norbits;
503 while ( j < orbitidx )
512 pt = permstrans[curelem];
513 for (p = componentbegins[componentidx]; p < componentbegins[componentidx + 1]; ++p)
517 perm = components[p];
519 assert( vartocomponent[image] == componentidx );
522 if ( ! varadded[image] )
524 orbits[orbitidx++] = image;
525 assert( orbitidx <= npermvars );
526 varadded[image] =
TRUE;
527 varorbitmap[image] = *norbits;
534 if ( orbitidx <= beginorbitidx + 1 )
536 orbitidx = beginorbitidx;
540 orbitbegins[(*norbits)++] = beginorbitidx;
544 assert( *norbits < npermvars );
545 orbitbegins[*norbits] = orbitidx;
569 assert( perm !=
NULL );
570 assert( vars !=
NULL );
571 assert( ntwocyclesperm !=
NULL );
572 assert( nbincyclesperm !=
NULL );
576 for (i = 0; i < nvars; ++i)
578 assert( 0 <= perm[i] && perm[i] < nvars );
584 if ( perm[perm[i]] == i )
588 else if ( earlytermination )
601 *ntwocyclesperm = ntwocycles;
622 assert( perms !=
NULL );
623 assert( nperms > 0 );
624 assert( permvars !=
NULL );
625 assert( npermvars > 0 );
626 assert( nvarsaffected !=
NULL );
633 for (p = 0; p < nperms; ++p)
635 for (i = 0; i < npermvars; ++i)
640 if ( perms[p][i] != i )
674 int nintersections = 0;
679 assert( suborbitope !=
NULL );
681 assert( nfilledcols > 0 );
682 assert( coltoextend >= 0 );
683 assert( perm !=
NULL );
684 assert( nusedelems !=
NULL );
685 assert( permvars !=
NULL );
686 assert( success !=
NULL );
687 assert( infeasible !=
NULL );
694 if ( nfilledcols == 2 )
697 for (row = 0; row < nrows; ++row)
699 idx1 = suborbitope[row][0];
700 idx2 = suborbitope[row][1];
703 if ( idx1 != perm[idx1] )
706 if ( ! leftextension )
708 suborbitope[row][0] = idx2;
709 suborbitope[row][1] = idx1;
711 assert( rowisbinary ==
NULL || rowisbinary[row] ==
SCIPvarIsBinary(permvars[perm[idx1]]) );
713 suborbitope[row][2] = perm[idx1];
716 ++(*nusedelems)[idx1];
717 ++(*nusedelems)[perm[idx1]];
720 if ( (*nusedelems)[idx1] + (*nusedelems)[perm[idx1]] > 3 )
726 else if ( idx2 != perm[idx2] )
731 suborbitope[row][0] = idx2;
732 suborbitope[row][1] = idx1;
734 assert( rowisbinary ==
NULL || rowisbinary[row] ==
SCIPvarIsBinary(permvars[perm[idx1]]) );
736 suborbitope[row][2] = perm[idx2];
739 ++(*nusedelems)[idx2];
740 ++(*nusedelems)[perm[idx2]];
743 if ( (*nusedelems)[idx2] + (*nusedelems)[perm[idx2]] > 3 )
754 for (row = 0; row < nrows; ++row)
756 idx1 = suborbitope[row][coltoextend];
759 if ( idx1 != perm[idx1] )
761 assert( rowisbinary ==
NULL || rowisbinary[row] ==
SCIPvarIsBinary(permvars[perm[idx1]]) );
763 suborbitope[row][nfilledcols] = perm[idx1];
766 ++(*nusedelems)[idx1];
767 ++(*nusedelems)[perm[idx1]];
770 if ( (*nusedelems)[idx1] + (*nusedelems)[perm[idx1]] > 3 )
780 if ( nintersections > 0 && nintersections < nrows )
782 else if ( nintersections == nrows )
800 int** componentbegins,
802 int** vartocomponent,
804 unsigned** componentblocked,
811 int* permtocomponent;
817 assert( permvars !=
NULL );
818 assert( npermvars > 0 );
819 assert( perms !=
NULL );
820 assert( components !=
NULL );
821 assert( componentbegins !=
NULL );
822 assert( vartocomponent !=
NULL );
823 assert( componentblocked !=
NULL );
824 assert( ncomponents !=
NULL );
830 *ncomponents = npermvars;
834 for (p = 0; p < nperms; ++p)
835 permtovarcomp[p] = -1;
839 for (i = 0; i < npermvars; ++i)
841 (*vartocomponent)[i] = -1;
843 for (p = 0; p < nperms; ++p)
847 img = transposed ? perms[i][p] : perms[p][i];
856 if ( img >= npermvars )
860 assert( 0 <= img && img < npermvars );
865 (*vartocomponent)[i] = p;
866 (*vartocomponent)[img] = p;
869 if ( component2 < component1 )
874 component1 = component2;
879 if ( permtovarcomp[p] == -1 )
881 permtovarcomp[p] = component1;
882 representative = component1;
887 representative = permtovarcomp[p];
891 if ( component1 != component2 )
899 if ( representative != component1 && representative != component2 )
901 if ( representative > component1 )
904 permtovarcomp[p] = component1;
910 else if ( representative > component1 )
912 assert( representative == component2 );
913 permtovarcomp[p] = component1;
919 if ( (*vartocomponent)[i] == -1 )
922 assert( *ncomponents > 0 );
925 for (p = 0; p < nperms; ++p)
930 for (p = 0; p < nperms; ++p)
931 (*components)[p] = p;
940 (*componentbegins)[0] = 0;
941 permtocomponent[(*components)[0]] = 0;
944 for (p = 1; p < nperms; ++p)
946 if ( permtovarcomp[p] > permtovarcomp[p - 1] )
947 (*componentbegins)[++idx] = p;
949 assert( (*components)[p] >= 0 );
950 assert( (*components)[p] < nperms );
951 permtocomponent[(*components)[p]] = idx;
953 assert( *ncomponents == idx + 1 );
954 (*componentbegins)[++idx] = nperms;
957 for (i = 0; i < npermvars; ++i)
960 permidx = (*vartocomponent)[i];
961 assert( -1 <= permidx && permidx < nperms );
965 assert( 0 <= permtocomponent[permidx] );
966 assert( permtocomponent[permidx] < *ncomponents );
968 (*vartocomponent)[i] = permtocomponent[permidx];
974 for (i = 0; i < *ncomponents; ++i)
975 (*componentblocked)[i] = 0;
982 printf(
"number of components: %d\n", *ncomponents);
983 for (i = 0; i < *ncomponents; ++i)
985 printf(
"Component %d contains the following permutations:\n\t", i);
986 for (p = (*componentbegins)[i]; p < (*componentbegins)[i + 1]; ++p)
988 printf(
"%d, ", (*components)[p]);
1009 int** orbitopevaridx,
1020 int nfilledcols = 0;
1024 int nvarsorderold = 0;
1026 assert( vars !=
NULL );
1027 assert( nrows > 0 );
1028 assert( ncols > 0 );
1029 assert( permvars !=
NULL );
1030 assert( npermvars > 0 );
1031 assert( orbitopevaridx !=
NULL );
1032 assert( columnorder !=
NULL );
1033 assert( nusedelems !=
NULL );
1034 assert( infeasible !=
NULL );
1035 assert( ! storelexorder || lexorder !=
NULL );
1036 assert( ! storelexorder || nvarsorder !=
NULL );
1037 assert( ! storelexorder || maxnvarsorder !=
NULL );
1043 if ( storelexorder )
1045 assert( *nvarsorder == *maxnvarsorder );
1046 assert( lexorder !=
NULL );
1048 *maxnvarsorder += nrows * ncols;
1049 nvarsorderold = *nvarsorder;
1051 if ( *lexorder ==
NULL )
1061 curcolumn = ncols - 1;
1064 while ( curcolumn >= 0 && columnorder[curcolumn] >= 0 && ! *infeasible )
1067 for (i = 0; i < nrows; ++i)
1070 if ( rowisbinary !=
NULL && ! rowisbinary[i] )
1073 assert( 0 <= orbitopevaridx[i][curcolumn] && orbitopevaridx[i][curcolumn] < npermvars );
1077 if ( nfilledcols == 0 && nusedelems[orbitopevaridx[i][curcolumn]] > 1 )
1080 assert( ! storelexorder );
1084 if ( storelexorder )
1086 (*lexorder)[nvarsorderold + nrows * nfilledcols + cnt] = orbitopevaridx[i][curcolumn];
1089 (*vars)[cnt++][nfilledcols] = permvars[orbitopevaridx[i][curcolumn]];
1101 assert( curcolumn > 1 || (curcolumn < 0 && nfilledcols == ncols) );
1103 if ( curcolumn > 1 && ! *infeasible )
1107 for (i = 0; i < nrows; ++i)
1110 if ( rowisbinary !=
NULL && ! rowisbinary[i] )
1113 assert( orbitopevaridx[i][1] < npermvars );
1116 if ( storelexorder )
1118 (*lexorder)[nvarsorderold + nrows * nfilledcols + cnt] = orbitopevaridx[i][1];
1121 (*vars)[cnt++][nfilledcols] = permvars[orbitopevaridx[i][1]];
1127 for (i = 0; i < nrows; ++i)
1130 if ( rowisbinary !=
NULL && ! rowisbinary[i] )
1133 assert( orbitopevaridx[i][0] < npermvars );
1136 if ( storelexorder )
1138 (*lexorder)[nvarsorderold + nrows * nfilledcols + cnt] = orbitopevaridx[i][0];
1141 (*vars)[cnt++][nfilledcols] = permvars[orbitopevaridx[i][0]];
1146 if ( nfilledcols < ncols )
1148 assert( ncols > 2 );
1151 while ( nfilledcols < ncols && ! *infeasible )
1153 assert( columnorder[curcolumn] < 0 );
1156 for (i = 0; i < nrows; ++i)
1159 if ( rowisbinary !=
NULL && ! rowisbinary[i] )
1162 assert( orbitopevaridx[i][curcolumn] < npermvars );
1166 if ( nfilledcols == ncols - 1 && nusedelems[orbitopevaridx[i][curcolumn]] > 1 )
1169 assert( ! storelexorder );
1173 if ( storelexorder )
1175 (*lexorder)[nvarsorderold + nrows * nfilledcols + cnt] = orbitopevaridx[i][curcolumn];
1178 (*vars)[cnt++][nfilledcols] = permvars[orbitopevaridx[i][curcolumn]];
1211 int* rowcoveragesetppc;
1220 assert( vars !=
NULL );
1221 assert( vars !=
NULL );
1222 assert( nrows > 0 );
1223 assert( ncols > 0 );
1224 assert( type !=
NULL );
1227 if ( npprows !=
NULL )
1231 if ( setppcconshdlr ==
NULL )
1241 if ( nsetppcconss == 0 || (nsetppcconss < nrows && npprows ==
NULL ))
1243 assert( setppcconss !=
NULL );
1255 for (i = 0; i < nprobvars; ++i)
1258 for (i = 0; i < nrows; ++i)
1260 for (j = 0; j < ncols; ++j)
1279 for (c = 0; c < nsetppcconss && ncoveredpart < ncols; ++c)
1283 int nrowintersect = 0;
1284 int nvarsinorbitope;
1294 if ( nsetppcvars < ncols )
1298 assert( setppcvars !=
NULL );
1301 nvarsinorbitope = nsetppcvars;
1307 for (i = 0; i < nsetppcvars && nvarsinorbitope >= ncols; ++i)
1313 var = setppcvars[i];
1316 assert( 0 <= idx && idx < nprobvars );
1318 rowidx = rowidxvar[idx];
1328 if ( covered[rowidx] == 2 || (covered[rowidx] == 1 && (nsetppcvars > ncols || nrowintersect > 1)) )
1335 if ( rowcoveragesetppc[rowidx] == 0 )
1336 rowsinsetppc[nrowintersect++] = rowidx;
1337 ++(rowcoveragesetppc[rowidx]);
1342 if ( nsetppcvars - nrowintersect < ncols - 1 )
1350 && nrowintersect == 1 && rowcoveragesetppc[rowsinsetppc[0]] == ncols && nsetppcvars == ncols )
1352 if ( covered[rowsinsetppc[0]] == 1 )
1354 covered[rowsinsetppc[0]] = 2;
1360 for (i = 0; i < nrowintersect; ++i)
1362 if ( covered[rowsinsetppc[i]] == 0 && rowcoveragesetppc[rowsinsetppc[i]] >= ncols )
1364 covered[rowsinsetppc[i]] = 1;
1371 for (i = 0; i < nrowintersect; ++i)
1372 rowcoveragesetppc[rowsinsetppc[i]] = 0;
1376 if ( ncovered == nrows )
1378 if ( ncoveredpart == nrows )
1384 if ( npprows !=
NULL )
1385 *npprows = ncovered;
1387 if ( pprows !=
NULL )
1390 for (i = 0; i < nrows; ++i)
1391 (*pprows)[i] = covered[i] > 0 ? 1 : 0;
1413 assert( perm !=
NULL );
1414 assert( permlen > 0 );
1415 assert( isinvolution !=
NULL );
1416 assert( ntwocycles !=
NULL );
1419 *isinvolution =
TRUE;
1420 for (v = 0; v < permlen && *isinvolution; ++v)
1427 if ( perm[perm[v]] == v )
1430 *isinvolution =
FALSE;
1454 int* permstoconsider;
1462 int npermstoconsider;
1463 int colorrepresentative1 = -1;
1464 int colorrepresentative2 = -1;
1481 assert( perms !=
NULL );
1482 assert( selectedperms !=
NULL );
1483 assert( nselectedperms >= 0 );
1484 assert( permlen > 0 );
1485 assert( nrows > 0 || nselectedperms == 0 );
1486 assert( success !=
NULL );
1487 assert( matrices !=
NULL );
1488 assert( ncols !=
NULL );
1489 assert( nmatrices !=
NULL );
1498 if ( nselectedperms == 0 )
1515 for (v = 0; v < permlen; ++v)
1516 complastperm[v] = -1;
1519 for (p = 0; p < nselectedperms; ++p)
1521 perm = perms[selectedperms[p]];
1526 for (v = 0; v < permlen; ++v)
1537 if ( curcomp1 == curcomp2 )
1541 if ( complastperm[curcomp1] == p || complastperm[curcomp2] == p )
1549 if ( curcolor1 == curcolor2 )
1552 if ( curdeg1 == -1 )
1554 assert( curdeg2 == -1 );
1556 curdeg1 = degrees[v];
1557 curdeg2 = degrees[
w];
1558 colorrepresentative1 = curcolor1;
1559 colorrepresentative2 = curcolor2;
1562 if ( curdeg1 == 2 || curdeg2 == 2 )
1568 if ( ! ((curdeg1 == degrees[v] && curdeg2 == degrees[
w])
1569 || (curdeg1 == degrees[
w] && curdeg2 == degrees[v])) )
1571 assert( colorrepresentative1 >= 0 );
1572 assert( colorrepresentative2 >= 0 || curdeg2 == -1 );
1575 if ( curdeg1 > 0 && curcolor1 != colorrepresentative1 && curcolor2 != colorrepresentative1 )
1577 if ( curdeg2 > 0 && curcolor1 != colorrepresentative2 && curcolor2 != colorrepresentative2 )
1582 complastperm[curcomp1] = p;
1583 complastperm[curcomp2] = p;
1592 assert( curdeg1 >= 0 && curdeg2 >= 0 );
1595 for (v = 0; v < permlen; ++v)
1605 assert( curcomp1 != curcomp2 );
1617 if ( curcolor1 != curcolor2 )
1627 for (v = 0; v < permlen; ++v)
1629 if ( degrees[v] > 0 )
1637 for (v = 0,
w = 0; v < permlen; ++v)
1639 if ( degrees[v] > 0 )
1644 if (
w > 0 && compidx[
w] == compidx[
w-1] )
1645 assert( colidx[
w] == colidx[
w-1]);
1650 assert(
w == nposdegree );
1659 for (v = 1; v < nposdegree; ++v)
1661 if ( colidx[v] != colidx[
w] )
1664 colorbegins[++ncolors] = v;
1669 colorbegins[++ncolors] = nposdegree;
1676 *nmatrices = ncolors;
1678 for (c = 0; c < ncolors; ++c)
1681 for (v = colorbegins[c]; compidx[v] == compidx[colorbegins[c]]; ++v)
1683 assert( v < nposdegree );
1685 if ( degrees[varidx[v]] == 1 )
1688 assert( compidx[v] == compidx[colorbegins[c]] );
1689 elemtomove = varidx[v];
1692 npermstoconsider = 0;
1693 for (p = 0; p < nselectedperms; ++p)
1695 perm = perms[selectedperms[p]];
1696 for (v = colorbegins[c]; v < nposdegree && compidx[v] == compidx[colorbegins[c]]; ++v)
1698 if ( perm[varidx[v]] != varidx[v] )
1700 permstoconsider[npermstoconsider++] = selectedperms[p];
1708 (*ncols)[c] = npermstoconsider + 1;
1709 for (p = 0; p < nrows; ++p)
1715 assert( degrees[elemtomove] == 1 );
1718 for (p = 0; p < npermstoconsider; ++p)
1720 perm = perms[permstoconsider[p]];
1721 if ( perm[elemtomove] != elemtomove )
1724 assert( p < npermstoconsider );
1727 for (v = 0, cnt = 0; v < permlen; ++v)
1731 if ( degrees[v] == 1 )
1733 (*matrices)[c][cnt][0] = v;
1734 (*matrices)[c][cnt++][1] = perm[v];
1738 (*matrices)[c][cnt][0] = perm[v];
1739 (*matrices)[c][cnt++][1] = v;
1748 for (p = nrows - 1; p >= 0; --p)
1757 goto FREEMOREMEMORY;
1759 assert( cnt == nrows );
1762 permstoconsider[p] = permstoconsider[--npermstoconsider];
1765 while ( npermstoconsider > 0 )
1767 elemtomove = (*matrices)[c][0][ncurcols];
1770 for (p = 0; p < npermstoconsider; ++p)
1772 perm = perms[permstoconsider[p]];
1773 if ( perm[elemtomove] != elemtomove )
1776 assert( p < npermstoconsider );
1779 for (v = 0; v < nrows; ++v)
1781 assert( perm[(*matrices)[c][v][ncurcols]] != (*matrices)[c][v][ncurcols] );
1782 (*matrices)[c][v][ncurcols + 1] = perm[(*matrices)[c][v][ncurcols]];
1785 permstoconsider[p] = permstoconsider[--npermstoconsider];
1822 int*** doublelexmatrix,
1849 assert( nsymvars >= 0 );
1850 assert( matrices1 !=
NULL );
1851 assert( nrows1 > 0 );
1852 assert( ncols1 !=
NULL );
1853 assert( nmatrices1 > 0 );
1854 assert( matrices2 !=
NULL );
1855 assert( nrows2 > 0 || nmatrices2 == 0 );
1856 assert( ncols2 !=
NULL );
1857 assert( nmatrices2 >= 0 );
1858 assert( doublelexmatrix !=
NULL );
1859 assert( nrows !=
NULL );
1860 assert( ncols !=
NULL );
1861 assert( rowsbegin !=
NULL );
1862 assert( colsbegin !=
NULL );
1863 assert( success !=
NULL );
1871 for (j = 0, cnt = 0; j < nmatrices1; ++j)
1873 if ( cnt != *ncols )
1879 for (i = 0, cnt = 0; i < nmatrices2; ++i)
1881 if ( cnt != *nrows )
1896 for (i = 0; i < nsymvars; ++i)
1897 idxtomatrix1[i] = -1;
1898 for (i = 0; i < nsymvars; ++i)
1899 idxtomatrix2[i] = -1;
1900 for (i = 0; i < nsymvars; ++i)
1902 for (i = 0; i < nsymvars; ++i)
1904 for (i = 0; i < nsymvars; ++i)
1906 for (i = 0; i < nsymvars; ++i)
1909 for (c = 0; c < nmatrices1; ++c)
1911 for (i = 0; i < nrows1; ++i)
1913 for (j = 0; j < ncols1[c]; ++j)
1915 idxtomatrix1[matrices1[c][i][j]] = c;
1916 idxtorow1[matrices1[c][i][j]] = i;
1917 idxtocol1[matrices1[c][i][j]] = j;
1921 for (c = 0; c < nmatrices2; ++c)
1923 for (i = 0; i < nrows2; ++i)
1925 for (j = 0; j < ncols2[c]; ++j)
1927 idxtomatrix2[matrices2[c][i][j]] = c;
1928 idxtorow2[matrices2[c][i][j]] = i;
1929 idxtocol2[matrices2[c][i][j]] = j;
1935 for (i = 0; i < nsymvars; ++i)
1937 if ( (idxtomatrix1[i] == -1) != (idxtomatrix2[i] == -1) )
1940 goto FREEINITMEMORY;
1958 for (i = 0; i < *nrows; ++i)
1961 (*doublelexmatrix)[i][0] = matrices1[0][i][0];
1962 sortvals[i] = idxtomatrix2[matrices1[0][i][0]];
1968 for (i = 0; i < nmatrices2; ++i)
1972 end = cnt + ncols2[i] - 1;
1973 for (j = cnt; j < end; ++j)
1975 assert( idxtomatrix2[(*doublelexmatrix)[j][0]] == idxtomatrix2[(*doublelexmatrix)[j + 1][0]] );
1976 if( idxtorow2[(*doublelexmatrix)[j][0]] != idxtorow2[(*doublelexmatrix)[j + 1][0]] )
1985 mat = idxtomatrix2[(*doublelexmatrix)[0][0]];
1986 col = idxtocol2[(*doublelexmatrix)[0][0]];
1988 for (j = 0; j < *ncols; ++j)
1991 if ( matrices2[mat][j][col] == (*doublelexmatrix)[0][0] )
1994 sortvals[cnt++] = idxtomatrix1[matrices2[mat][j][col]];
1995 (*doublelexmatrix)[0][cnt] = matrices2[mat][j][col];
1997 assert( cnt == nrows2 - 1);
2001 for (i = 1; i < *nrows; ++i)
2003 for (j = 1; j < *ncols; ++j)
2006 mat = idxtomatrix1[(*doublelexmatrix)[0][j]];
2007 mat2 = idxtomatrix2[(*doublelexmatrix)[i][0]];
2008 col = idxtocol1[(*doublelexmatrix)[0][j]];
2009 col2 = idxtocol2[(*doublelexmatrix)[i][0]];
2015 for (c = 0; c < *nrows; ++c)
2017 for (d = 0; d < *ncols; ++d)
2019 if ( matrices1[mat][c][col] == matrices2[mat2][d][col2] )
2022 elem = matrices1[mat][c][col];
2034 (*doublelexmatrix)[i][j] = elem;
2041 assert( nmatrices2 > 0 );
2044 (*rowsbegin)[0] = 0;
2045 (*colsbegin)[0] = 0;
2046 for (j = 0; j < nmatrices2; ++j)
2047 (*rowsbegin)[j + 1] = (*rowsbegin)[j] + ncols2[j];
2048 for (j = 0; j < nmatrices1; ++j)
2049 (*colsbegin)[j + 1] = (*colsbegin)[j] + ncols1[j];
2053 for (i = 0; i < *nrows; ++i)
2055 for (c = 0; c < nmatrices1; ++c)
2057 for (j = (*colsbegin)[c]; j < (*colsbegin)[c + 1] - 1; ++j)
2059 assert( idxtomatrix1[(*doublelexmatrix)[i][j]] == idxtomatrix1[(*doublelexmatrix)[i][j + 1]] );
2060 if( idxtorow1[(*doublelexmatrix)[i][j]] != idxtorow1[(*doublelexmatrix)[i][j + 1]] )
2070 for (i = 0; i < *ncols; ++i)
2072 for (c = 0; c < nmatrices2; ++c)
2074 for (j = (*rowsbegin)[c]; j < (*rowsbegin)[c + 1] - 1; ++j)
2076 assert( idxtomatrix2[(*doublelexmatrix)[j][i]] == idxtomatrix2[(*doublelexmatrix)[j + 1][i]] );
2077 if( idxtorow2[(*doublelexmatrix)[j][i]] != idxtorow2[(*doublelexmatrix)[j + 1][i]] )
2091 for (i = *nrows - 1; i >= 0; --i)
2096 *doublelexmatrix =
NULL;
2135 int*** matricestype1 =
NULL;
2136 int*** matricestype2 =
NULL;
2137 int* ncolstype1 =
NULL;
2138 int* ncolstype2 =
NULL;
2139 int nmatricestype1 = 0;
2140 int nmatricestype2 = 0;
2143 int npermstype1 = 0;
2144 int npermstype2 = 0;
2153 assert( perms !=
NULL );
2154 assert( nperms > 0 );
2155 assert( permlen > 0 );
2156 assert( success !=
NULL );
2157 assert( lexmatrix !=
NULL );
2158 assert( nrows !=
NULL );
2159 assert( ncols !=
NULL );
2160 assert( lexrowsbegin !=
NULL );
2161 assert( lexcolsbegin !=
NULL );
2162 assert( nrowmatrices !=
NULL );
2163 assert( ncolmatrices !=
NULL );
2166 *isorbitope =
FALSE;
2175 for (p = 0; p < nperms; ++p)
2180 if ( ! isinvolution )
2187 if ( ncycs1 == -1 || ncycs1 == tmpncycs )
2190 permstype1[npermstype1++] = p;
2192 else if ( ncycs2 == -1 || ncycs2 == tmpncycs )
2195 permstype2[npermstype2++] = p;
2206 &matricestype1, &ncolstype1, &nmatricestype1) );
2211 &matricestype2, &ncolstype2, &nmatricestype2) );
2217 if ( !detectsinglelex && ncycs2 != -1 )
2219 assert( ncycs1 > 0 );
2222 matricestype2, ncycs2, ncolstype2, nmatricestype2,
2223 lexmatrix, nrows, ncols, lexrowsbegin, lexcolsbegin, success) );
2227 *nrowmatrices = nmatricestype2;
2228 *ncolmatrices = nmatricestype1;
2233 if ( !(*success) && ncycs2 == -1 && nmatricestype1 == 1 )
2236 for (i = 0; i < ncycs1; ++i)
2239 for (p = 0; p < ncolstype1[0]; ++p)
2240 (*lexmatrix)[i][p] = matricestype1[0][i][p];
2243 *ncols = ncolstype1[0];
2249 for (p = nmatricestype2 - 1; p >= 0; --p)
2251 for (i = ncycs2 - 1; i >= 0; --i)
2259 for (p = nmatricestype1 - 1; p >= 0; --p)
2261 for (i = ncycs1 - 1; i >= 0; --i)
2300 if ( minf1 && minf2 )
2302 if ( minf1 != minf2 )
2327 if ( !inf1 && inf2 )
2329 if ( inf1 && !inf2 )
2336 if ( minf1 && minf2 )
2338 if ( !minf1 && minf2 )
2340 if ( minf1 && !minf2 )
2365 if ( !inf1 && inf2 )
2367 if ( inf1 && !inf2 )
2374 if ( minf1 && minf2 )
2376 if ( !minf1 && minf2 )
2378 if ( minf1 && !minf2 )
2403 if ( !inf1 && inf2 )
2405 if ( inf1 && !inf2 )
2412 if ( minf1 && minf2 )
2414 if ( !minf1 && minf2 )
2416 if ( minf1 && !minf2 )
2441 if ( !inf1 && inf2 )
2443 if ( inf1 && !inf2 )
2450 if ( minf1 && minf2 )
2452 if ( !minf1 && minf2 )
2454 if ( minf1 && !minf2 )
interface for constraint handlers of type partitioning, packing, and full
Constraint handler for the set partitioning / packing / covering constraints .
int SCIPgetNVarsSetppc(SCIP *scip, SCIP_CONS *cons)
SCIP_VAR ** SCIPgetVarsSetppc(SCIP *scip, SCIP_CONS *cons)
SCIP_SETPPCTYPE SCIPgetTypeSetppc(SCIP *scip, SCIP_CONS *cons)
@ SCIP_SETPPCTYPE_PARTITIONING
@ SCIP_SETPPCTYPE_COVERING
void SCIPfreeDisjointset(SCIP *scip, SCIP_DISJOINTSET **djset)
int SCIPdisjointsetFind(SCIP_DISJOINTSET *djset, int element)
void SCIPdisjointsetUnion(SCIP_DISJOINTSET *djset, int p, int q, SCIP_Bool forcerepofp)
SCIP_RETCODE SCIPcreateDisjointset(SCIP *scip, SCIP_DISJOINTSET **djset, int ncomponents)
int SCIPgetNTotalVars(SCIP *scip)
int SCIPconshdlrGetNConss(SCIP_CONSHDLR *conshdlr)
SCIP_CONSHDLR * SCIPfindConshdlr(SCIP *scip, const char *name)
SCIP_CONS ** SCIPconshdlrGetConss(SCIP_CONSHDLR *conshdlr)
#define SCIPfreeCleanBufferArray(scip, ptr)
#define SCIPallocCleanBufferArray(scip, ptr, num)
#define SCIPfreeBlockMemoryArray(scip, ptr, num)
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
#define SCIPallocClearBufferArray(scip, ptr, num)
#define SCIPallocBufferArray(scip, ptr, num)
#define SCIPfreeBufferArray(scip, ptr)
#define SCIPallocBlockMemoryArray(scip, ptr, num)
#define SCIPreallocBlockMemoryArray(scip, ptr, oldnum, newnum)
#define SCIPfreeBlockMemoryArrayNull(scip, ptr, num)
SCIP_RETCODE SCIPdetermineNVarsAffectedSym(SCIP *scip, int **perms, int nperms, SCIP_VAR **permvars, int npermvars, int *nvarsaffected)
SCIP_RETCODE SCIPcomputeComponentsSym(SCIP *scip, SYM_SYMTYPE symtype, int **perms, int nperms, SCIP_VAR **permvars, int npermvars, SCIP_Bool transposed, int **components, int **componentbegins, int **vartocomponent, unsigned **componentblocked, int *ncomponents)
SCIP_RETCODE SCIPcomputeOrbitVar(SCIP *scip, int npermvars, int **perms, int **permstrans, int *components, int *componentbegins, SCIP_Shortbool *ignoredvars, SCIP_Shortbool *varfound, int varidx, int component, int *orbit, int *orbitsize)
SCIP_RETCODE SCIPisInvolutionPerm(int *perm, SCIP_VAR **vars, int nvars, int *ntwocyclesperm, int *nbincyclesperm, SCIP_Bool earlytermination)
SCIP_Bool SCIPsymGE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_RETCODE SCIPcomputeOrbitsComponentsSym(SCIP *scip, int npermvars, int **permstrans, int nperms, int *components, int *componentbegins, int *vartocomponent, int ncomponents, int *orbits, int *orbitbegins, int *norbits, int *varorbitmap)
SCIP_Bool SCIPsymEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_RETCODE SCIPcomputeOrbitsSym(SCIP *scip, SCIP_Bool issigned, SCIP_VAR **permvars, int npermvars, int **perms, int nperms, int *orbits, int *orbitbegins, int *norbits)
SCIP_Bool SCIPsymLT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_VARTYPE SCIPgetSymInferredVarType(SCIP_VAR *var)
SCIP_Bool SCIPsymGT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPsymLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_RETCODE SCIPdetectSingleOrDoubleLexMatrices(SCIP *scip, SCIP_Bool detectsinglelex, int **perms, int nperms, int permlen, SCIP_Bool *success, SCIP_Bool *isorbitope, int ***lexmatrix, int *nrows, int *ncols, int **lexrowsbegin, int **lexcolsbegin, int *nrowmatrices, int *ncolmatrices)
SCIP_RETCODE SCIPgenerateOrbitopeVarsMatrix(SCIP *scip, SCIP_VAR ****vars, int nrows, int ncols, SCIP_VAR **permvars, int npermvars, int **orbitopevaridx, int *columnorder, int *nusedelems, SCIP_Shortbool *rowisbinary, SCIP_Bool *infeasible, SCIP_Bool storelexorder, int **lexorder, int *nvarsorder, int *maxnvarsorder)
SCIP_RETCODE SCIPisPackingPartitioningOrbitope(SCIP *scip, SCIP_VAR ***vars, int nrows, int ncols, SCIP_Bool **pprows, int *npprows, SCIP_ORBITOPETYPE *type)
SCIP_RETCODE SCIPcomputeOrbitsFilterSym(SCIP *scip, int npermvars, int **permstrans, int nperms, SCIP_Shortbool *inactiveperms, int *orbits, int *orbitbegins, int *norbits, int *components, int *componentbegins, int *vartocomponent, unsigned *componentblocked, int ncomponents, int nmovedpermvars)
SCIP_RETCODE SCIPextendSubOrbitope(int **suborbitope, int nrows, int nfilledcols, int coltoextend, int *perm, SCIP_Bool leftextension, int **nusedelems, SCIP_VAR **permvars, SCIP_Shortbool *rowisbinary, SCIP_Bool *success, SCIP_Bool *infeasible)
SCIP_Bool SCIPisGE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisGT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisLT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPvarIsBinary(SCIP_VAR *var)
int SCIPvarGetIndex(SCIP_VAR *var)
SCIP_Bool SCIPvarIsIntegral(SCIP_VAR *var)
void SCIPsortIntInt(int *intarray1, int *intarray2, int len)
void SCIPsortIntIntInt(int *intarray1, int *intarray2, int *intarray3, int len)
void SCIPsortIntPtr(int *intarray, void **ptrarray, int len)
void SCIPdisjointsetFree(SCIP_DISJOINTSET **djset, BMS_BLKMEM *blkmem)
SCIP_RETCODE SCIPdisjointsetCreate(SCIP_DISJOINTSET **djset, BMS_BLKMEM *blkmem, int ncomponents)
internal miscellaneous methods
structs for symmetry computations
static SCIP_RETCODE detectOrbitopalSymmetries(SCIP *scip, int **perms, int *selectedperms, int nselectedperms, int permlen, int nrows, SCIP_Bool *success, int ****matrices, int **ncols, int *nmatrices)
static SCIP_RETCODE isPermInvolution(int *perm, int permlen, SCIP_Bool *isinvolution, int *ntwocycles)
static SCIP_RETCODE isDoublelLexSym(SCIP *scip, int nsymvars, int ***matrices1, int nrows1, int *ncols1, int nmatrices1, int ***matrices2, int nrows2, int *ncols2, int nmatrices2, int ***doublelexmatrix, int *nrows, int *ncols, int **rowsbegin, int **colsbegin, SCIP_Bool *success)
methods for handling symmetries
enum SCIP_Retcode SCIP_RETCODE
type definitions for symmetry computations
@ SCIP_ORBITOPETYPE_PACKING
@ SCIP_ORBITOPETYPE_PARTITIONING
enum SYM_Symtype SYM_SYMTYPE
enum SCIP_OrbitopeType SCIP_ORBITOPETYPE
@ SCIP_VARTYPE_CONTINUOUS
enum SCIP_Vartype SCIP_VARTYPE