11 #ifndef CoinFactorization_H
12 #define CoinFactorization_H
87 int rowIsBasic[],
int columnIsBasic[] ,
104 const int indicesRow[],
105 const int indicesColumn[],
const double elements[] ,
116 int * indicesColumn[],
133 inline int status ( )
const {
268 #ifndef COIN_FAST_CODE
372 bool checkBeforeModifying=
false,
373 double acceptablePivot=1.0e-8);
380 int internalPivotRow);
398 bool noPermute=
false)
const;
407 bool noPermuteRegion3=
false) ;
439 int indicesColumn[],
double elements[] );
444 int indicesRow[],
double elements[] );
449 int indicesColumn[],
double elements[] );
459 int replaceRow (
int whichRow,
int numberElements,
460 const int indicesColumn[],
const double elements[] );
462 void emptyRows(
int numberToEmpty,
const int which[]);
495 int possibleDuplicates = -1 );
557 inline void addLink (
int index,
int count ) {
561 int next = firstCount[count];
562 lastCount[index] = -2 - count;
565 firstCount[count] = index;
566 nextCount[index] = -1;
568 firstCount[count] = index;
569 nextCount[index] = next;
570 lastCount[next] = index;
577 int next = nextCount[index];
578 int last = lastCount[index];
580 nextCount[last] = next;
582 int count = -last - 2;
584 firstCount[count] = next;
587 lastCount[next] = last;
589 nextCount[index] = -2;
590 lastCount[index] = -2;
618 int * indexIn)
const;
621 int * indexIn)
const;
627 int & numberNonZero1,
630 int & numberNonZero2,
644 int smallestIndex)
const;
648 int smallestIndex)
const;
652 int smallestIndex)
const;
659 int smallestIndex)
const;
684 int pivotRow,
double alpha);
688 int checkPivot(
double saveFromU,
double oldPivot)
const;
691 #define COINFACTORIZATION_BITS_PER_INT 64
692 #define COINFACTORIZATION_SHIFT_PER_INT 6
693 #define COINFACTORIZATION_MASK_PER_INT 0x3f
695 #define COINFACTORIZATION_BITS_PER_INT 32
696 #define COINFACTORIZATION_SHIFT_PER_INT 5
697 #define COINFACTORIZATION_MASK_PER_INT 0x1f
699 template <
class T>
inline bool
705 unsigned int workArea2[],
724 int numberInPivotRow = numberInRow[pivotRow] - 1;
726 int numberInPivotColumn = numberInColumn[
pivotColumn] - 1;
727 CoinBigIndex endColumn = startColumn + numberInPivotColumn + 1;
732 if ( pivotColumnPosition < 0 ) {
733 for ( pivotColumnPosition = startRow; pivotColumnPosition < endRow; pivotColumnPosition++ ) {
734 int iColumn = indexColumnU[pivotColumnPosition];
735 if ( iColumn != pivotColumn ) {
736 saveColumn[put++] = iColumn;
742 for (
CoinBigIndex i = startRow ; i < pivotColumnPosition ; i++ ) {
743 saveColumn[put++] = indexColumnU[i];
746 assert (pivotColumnPosition<endRow);
747 assert (indexColumnU[pivotColumnPosition]==pivotColumn);
748 pivotColumnPosition++;
749 for ( ; pivotColumnPosition < endRow; pivotColumnPosition++ ) {
750 saveColumn[put++] = indexColumnU[pivotColumnPosition];
753 int next = nextRow[pivotRow];
754 int last = lastRow[pivotRow];
756 nextRow[last] = next;
757 lastRow[next] = last;
759 lastRow[pivotRow] = -2;
760 numberInRow[pivotRow] = 0;
767 printf(
"more memory needed in middle of invert\n");
778 if ( pivotRowPosition < 0 ) {
779 for ( pivotRowPosition = startColumn; pivotRowPosition < endColumn; pivotRowPosition++ ) {
780 int iRow = indexRowU[pivotRowPosition];
781 if ( iRow != pivotRow ) {
783 elementL[l] = elementU[pivotRowPosition];
784 markRow[iRow] =
static_cast<T
>(l - lSave);
791 while ( indexColumnU[where] != pivotColumn ) {
795 if ( where >= end ) {
799 indexColumnU[where] = indexColumnU[end - 1];
808 for ( i = startColumn; i < pivotRowPosition; i++ ) {
809 int iRow = indexRowU[i];
811 markRow[iRow] =
static_cast<T
>(l - lSave);
813 elementL[l] = elementU[i];
820 while ( indexColumnU[where] != pivotColumn ) {
824 if ( where >= end ) {
828 indexColumnU[where] = indexColumnU[end - 1];
830 assert (numberInRow[iRow]>=0);
833 assert (pivotRowPosition<endColumn);
834 assert (indexRowU[pivotRowPosition]==pivotRow);
840 for ( ; pivotRowPosition < endColumn; pivotRowPosition++ ) {
841 int iRow = indexRowU[pivotRowPosition];
843 markRow[iRow] =
static_cast<T
>(l - lSave);
845 elementL[l] = elementU[pivotRowPosition];
852 while ( indexColumnU[where] != pivotColumn ) {
856 if ( where >= end ) {
860 indexColumnU[where] = indexColumnU[end - 1];
862 assert (numberInRow[iRow]>=0);
864 markRow[pivotRow] =
static_cast<T
>(largeInteger);
868 int *indexL = &indexRowL[lSave];
874 for ( j = 0; j < numberInPivotColumn; j++ ) {
875 multipliersL[j] *= pivotMultiplier;
879 for ( iErase = 0; iErase < increment2 * numberInPivotRow;
881 workArea2[iErase] = 0;
883 CoinBigIndex added = numberInPivotRow * numberInPivotColumn;
884 unsigned int *temp2 = workArea2;
889 for ( jColumn = 0; jColumn < numberInPivotRow; jColumn++ ) {
890 int iColumn = saveColumn[jColumn];
892 CoinBigIndex endColumn = startColumn + numberInColumn[iColumn];
893 int iRow = indexRowU[startColumn];
902 int mark = markRow[iRow];
904 if ( mark == largeInteger+1 ) {
905 largest = fabs ( value );
906 positionLargest = put;
908 checkLargest =
false;
913 if ( mark != largeInteger ) {
919 temp2[word] = temp2[word] | ( 1 << bit );
922 thisPivotValue = value;
926 for ( i = startColumn + 1; i < endColumn; i++ ) {
929 int mark = markRow[iRow];
931 if ( mark == largeInteger+1 ) {
933 indexRowU[put] = iRow;
934 elementU[put] = value;
935 if ( checkLargest ) {
936 double absValue = fabs ( value );
938 if ( absValue > largest ) {
940 positionLargest = put;
944 }
else if ( mark != largeInteger ) {
950 temp2[word] = temp2[word] | ( 1 << bit );
953 thisPivotValue = value;
957 elementU[put] = elementU[startColumn];
958 indexRowU[put] = indexRowU[startColumn];
959 if ( positionLargest == startColumn ) {
960 positionLargest = put;
963 elementU[startColumn] = thisPivotValue;
964 indexRowU[startColumn] = pivotRow;
967 numberInColumn[iColumn] = put - startColumn;
969 numberInColumnPlus[iColumn]++;
970 startColumnU[iColumn]++;
972 int next = nextColumn[iColumn];
975 space = startColumnU[next] - put - numberInColumnPlus[next];
977 if ( numberInPivotColumn > space ) {
983 positionLargest = positionLargest + startColumnU[iColumn] - startColumn;
984 startColumn = startColumnU[iColumn];
985 put = startColumn + numberInColumn[iColumn];
990 for ( j = 0; j < numberInPivotColumn; j++ ) {
991 value = work[j] - thisPivotValue * multipliersL[j];
992 double absValue = fabs ( value );
994 if ( absValue > tolerance ) {
997 elementU[put] = value;
998 indexRowU[put] = indexL[j];
999 if ( absValue > largest ) {
1001 positionLargest = put;
1010 if ( temp2[word] & ( 1 << bit ) ) {
1017 while ( indexColumnU[where] != iColumn ) {
1021 if ( where >= end ) {
1025 indexColumnU[where] = indexColumnU[end - 1];
1026 numberInRow[iRow]--;
1032 temp2[word] = temp2[word] | ( 1 << bit );
1036 numberInColumn[iColumn] = put - startColumn;
1038 if ( positionLargest >= 0 ) {
1039 value = elementU[positionLargest];
1040 iRow = indexRowU[positionLargest];
1041 elementU[positionLargest] = elementU[startColumn];
1042 indexRowU[positionLargest] = indexRowU[startColumn];
1043 elementU[startColumn] = value;
1044 indexRowU[startColumn] = iRow;
1052 temp2 += increment2;
1055 unsigned int *putBase = workArea2;
1060 while ( bigLoops ) {
1064 unsigned int *putThis = putBase;
1065 int iRow = indexL[i];
1071 for ( jColumn = 0; jColumn < numberInPivotRow; jColumn++ ) {
1072 unsigned int test = *putThis;
1074 putThis += increment2;
1075 test = 1 - ( ( test >> bit ) & 1 );
1078 int next = nextRow[iRow];
1081 space = startRowU[next] - startRowU[iRow];
1082 number += numberInRow[iRow];
1083 if ( space < number ) {
1090 next = nextRow[iRow];
1091 number = numberInRow[iRow];
1093 int saveIndex = indexColumnU[startRowU[next]];
1096 for ( jColumn = 0; jColumn < numberInPivotRow; jColumn++ ) {
1097 unsigned int test = *putThis;
1099 putThis += increment2;
1100 test = 1 - ( ( test >> bit ) & 1 );
1101 indexColumnU[end] = saveColumn[jColumn];
1105 indexColumnU[startRowU[next]] = saveIndex;
1106 markRow[iRow] =
static_cast<T
>(largeInteger+1);
1107 number = end - startRowU[iRow];
1108 numberInRow[iRow] = number;
1116 for ( bit = 0; i < numberInPivotColumn; i++, bit++ ) {
1117 unsigned int *putThis = putBase;
1118 int iRow = indexL[i];
1124 for ( jColumn = 0; jColumn < numberInPivotRow; jColumn++ ) {
1125 unsigned int test = *putThis;
1127 putThis += increment2;
1128 test = 1 - ( ( test >> bit ) & 1 );
1131 int next = nextRow[iRow];
1134 space = startRowU[next] - startRowU[iRow];
1135 number += numberInRow[iRow];
1136 if ( space < number ) {
1143 next = nextRow[iRow];
1144 number = numberInRow[iRow];
1148 saveIndex = indexColumnU[startRowU[next]];
1151 for ( jColumn = 0; jColumn < numberInPivotRow; jColumn++ ) {
1152 unsigned int test = *putThis;
1154 putThis += increment2;
1155 test = 1 - ( ( test >> bit ) & 1 );
1157 indexColumnU[end] = saveColumn[jColumn];
1160 indexColumnU[startRowU[next]] = saveIndex;
1161 markRow[iRow] =
static_cast<T
>(largeInteger+1);
1162 number = end - startRowU[iRow];
1163 numberInRow[iRow] = number;
1167 markRow[pivotRow] =
static_cast<T
>(largeInteger+1);
1186 #ifndef COIN_FAST_CODE
1191 #define slackValue_ -1.0
1445 #ifdef COIN_HAS_LAPACK
1446 #define DENSE_CODE 1
1451 typedef const int cipfint;
1456 #ifdef UGLY_COIN_FACTOR_CODING
1457 #define FAC_UNSET (FAC_SET+1)
1461 CoinBigIndex startColumnThis = startColumn[iPivotColumn];
1462 CoinBigIndex endColumn = startColumnThis + numberDoColumn + 1;
1466 if ( pivotColumnPosition < 0 ) {
1467 for ( pivotColumnPosition = startRowThis; pivotColumnPosition < endRow; pivotColumnPosition++ ) {
1468 int iColumn = indexColumn[pivotColumnPosition];
1469 if ( iColumn != iPivotColumn ) {
1470 saveColumn[put++] = iColumn;
1476 for (
CoinBigIndex i = startRowThis ; i < pivotColumnPosition ; i++ ) {
1477 saveColumn[put++] = indexColumn[i];
1480 assert (pivotColumnPosition<endRow);
1481 assert (indexColumn[pivotColumnPosition]==iPivotColumn);
1482 pivotColumnPosition++;
1483 for ( ; pivotColumnPosition < endRow; pivotColumnPosition++ ) {
1484 saveColumn[put++] = indexColumn[pivotColumnPosition];
1487 int next = nextRow[iPivotRow];
1488 int last = lastRow[iPivotRow];
1490 nextRow[last] = next;
1491 lastRow[next] = last;
1492 nextRow[iPivotRow] = numberGoodU_;
1493 lastRow[iPivotRow] = -2;
1494 numberInRow[iPivotRow] = 0;
1499 if ( l + numberDoColumn > lengthAreaL_ ) {
1501 if ((messageLevel_&4)!=0)
1502 printf(
"more memory needed in middle of invert\n");
1509 startColumnL[numberGoodL_] = l;
1511 startColumnL[numberGoodL_] = l + numberDoColumn;
1512 lengthL_ += numberDoColumn;
1513 if ( pivotRowPosition < 0 ) {
1514 for ( pivotRowPosition = startColumnThis; pivotRowPosition < endColumn; pivotRowPosition++ ) {
1515 int iRow = indexRow[pivotRowPosition];
1516 if ( iRow != iPivotRow ) {
1517 indexRowL[l] = iRow;
1518 elementL[l] = element[pivotRowPosition];
1519 markRow[iRow] = l - lSave;
1526 while ( indexColumn[where] != iPivotColumn ) {
1530 if ( where >= end ) {
1534 indexColumn[where] = indexColumn[end - 1];
1535 numberInRow[iRow]--;
1543 for ( i = startColumnThis; i < pivotRowPosition; i++ ) {
1544 int iRow = indexRow[i];
1546 markRow[iRow] = l - lSave;
1547 indexRowL[l] = iRow;
1548 elementL[l] = element[i];
1555 while ( indexColumn[where] != iPivotColumn ) {
1559 if ( where >= end ) {
1563 indexColumn[where] = indexColumn[end - 1];
1564 numberInRow[iRow]--;
1565 assert (numberInRow[iRow]>=0);
1568 assert (pivotRowPosition<endColumn);
1569 assert (indexRow[pivotRowPosition]==iPivotRow);
1573 pivotRegion_.array()[numberGoodU_] = pivotMultiplier;
1575 for ( ; pivotRowPosition < endColumn; pivotRowPosition++ ) {
1576 int iRow = indexRow[pivotRowPosition];
1578 markRow[iRow] = l - lSave;
1579 indexRowL[l] = iRow;
1580 elementL[l] = element[pivotRowPosition];
1587 while ( indexColumn[where] != iPivotColumn ) {
1591 if ( where >= end ) {
1595 indexColumn[where] = indexColumn[end - 1];
1596 numberInRow[iRow]--;
1597 assert (numberInRow[iRow]>=0);
1599 markRow[iPivotRow] = FAC_SET;
1601 numberInColumn[iPivotColumn] = 0;
1603 int *indexL = &indexRowL[lSave];
1609 for ( j = 0; j < numberDoColumn; j++ ) {
1610 multipliersL[j] *= pivotMultiplier;
1614 for ( iErase = 0; iErase < increment2 * numberDoRow;
1616 workArea2[iErase] = 0;
1619 unsigned int *temp2 = workArea2;
1620 int * nextColumn = nextColumn_.array();
1624 for ( jColumn = 0; jColumn < numberDoRow; jColumn++ ) {
1625 int iColumn = saveColumn[jColumn];
1627 CoinBigIndex endColumn = startColumnThis + numberInColumn[iColumn];
1628 int iRow = indexRow[startColumnThis];
1637 int mark = markRow[iRow];
1639 if ( mark == FAC_UNSET ) {
1640 largest = fabs ( value );
1641 positionLargest = put;
1643 checkLargest =
false;
1647 checkLargest =
true;
1648 if ( mark != FAC_SET ) {
1650 workArea[mark] = value;
1654 temp2[word] = temp2[word] | ( 1 << bit );
1657 thisPivotValue = value;
1661 for ( i = startColumnThis + 1; i < endColumn; i++ ) {
1664 int mark = markRow[iRow];
1666 if ( mark == FAC_UNSET ) {
1668 indexRow[put] = iRow;
1669 element[put] = value;
1670 if ( checkLargest ) {
1671 double absValue = fabs ( value );
1673 if ( absValue > largest ) {
1675 positionLargest = put;
1679 }
else if ( mark != FAC_SET ) {
1681 workArea[mark] = value;
1685 temp2[word] = temp2[word] | ( 1 << bit );
1688 thisPivotValue = value;
1692 element[put] = element[startColumnThis];
1693 indexRow[put] = indexRow[startColumnThis];
1694 if ( positionLargest == startColumnThis ) {
1695 positionLargest = put;
1698 element[startColumnThis] = thisPivotValue;
1699 indexRow[startColumnThis] = iPivotRow;
1702 numberInColumn[iColumn] = put - startColumnThis;
1703 int * numberInColumnPlus = numberInColumnPlus_.array();
1704 numberInColumnPlus[iColumn]++;
1705 startColumn[iColumn]++;
1707 int next = nextColumn[iColumn];
1710 space = startColumn[next] - put - numberInColumnPlus[next];
1712 if ( numberDoColumn > space ) {
1714 if ( !getColumnSpace ( iColumn, numberDoColumn ) ) {
1718 positionLargest = positionLargest + startColumn[iColumn] - startColumnThis;
1719 startColumnThis = startColumn[iColumn];
1720 put = startColumnThis + numberInColumn[iColumn];
1722 double tolerance = zeroTolerance_;
1724 int *nextCount = nextCount_.array();
1725 for ( j = 0; j < numberDoColumn; j++ ) {
1726 value = workArea[j] - thisPivotValue * multipliersL[j];
1727 double absValue = fabs ( value );
1729 if ( absValue > tolerance ) {
1731 element[put] = value;
1732 indexRow[put] = indexL[j];
1733 if ( absValue > largest ) {
1735 positionLargest = put;
1744 if ( temp2[word] & ( 1 << bit ) ) {
1751 while ( indexColumn[where] != iColumn ) {
1755 if ( where >= end ) {
1759 indexColumn[where] = indexColumn[end - 1];
1760 numberInRow[iRow]--;
1766 temp2[word] = temp2[word] | ( 1 << bit );
1770 numberInColumn[iColumn] = put - startColumnThis;
1772 if ( positionLargest >= 0 ) {
1773 value = element[positionLargest];
1774 iRow = indexRow[positionLargest];
1775 element[positionLargest] = element[startColumnThis];
1776 indexRow[positionLargest] = indexRow[startColumnThis];
1777 element[startColumnThis] = value;
1778 indexRow[startColumnThis] = iRow;
1781 if ( nextCount[iColumn + numberRows_] != -2 ) {
1783 deleteLink ( iColumn + numberRows_ );
1784 addLink ( iColumn + numberRows_, numberInColumn[iColumn] );
1786 temp2 += increment2;
1789 unsigned int *putBase = workArea2;
1794 while ( bigLoops ) {
1798 unsigned int *putThis = putBase;
1799 int iRow = indexL[i];
1805 for ( jColumn = 0; jColumn < numberDoRow; jColumn++ ) {
1806 unsigned int test = *putThis;
1808 putThis += increment2;
1809 test = 1 - ( ( test >> bit ) & 1 );
1812 int next = nextRow[iRow];
1815 space = startRow[next] - startRow[iRow];
1816 number += numberInRow[iRow];
1817 if ( space < number ) {
1818 if ( !getRowSpace ( iRow, number ) ) {
1824 next = nextRow[iRow];
1825 number = numberInRow[iRow];
1827 int saveIndex = indexColumn[startRow[next]];
1830 for ( jColumn = 0; jColumn < numberDoRow; jColumn++ ) {
1831 unsigned int test = *putThis;
1833 putThis += increment2;
1834 test = 1 - ( ( test >> bit ) & 1 );
1835 indexColumn[end] = saveColumn[jColumn];
1839 indexColumn[startRow[next]] = saveIndex;
1840 markRow[iRow] = FAC_UNSET;
1841 number = end - startRow[iRow];
1842 numberInRow[iRow] = number;
1843 deleteLink ( iRow );
1844 addLink ( iRow, number );
1850 for ( bit = 0; i < numberDoColumn; i++, bit++ ) {
1851 unsigned int *putThis = putBase;
1852 int iRow = indexL[i];
1858 for ( jColumn = 0; jColumn < numberDoRow; jColumn++ ) {
1859 unsigned int test = *putThis;
1861 putThis += increment2;
1862 test = 1 - ( ( test >> bit ) & 1 );
1865 int next = nextRow[iRow];
1868 space = startRow[next] - startRow[iRow];
1869 number += numberInRow[iRow];
1870 if ( space < number ) {
1871 if ( !getRowSpace ( iRow, number ) ) {
1877 next = nextRow[iRow];
1878 number = numberInRow[iRow];
1882 saveIndex = indexColumn[startRow[next]];
1885 for ( jColumn = 0; jColumn < numberDoRow; jColumn++ ) {
1886 unsigned int test = *putThis;
1888 putThis += increment2;
1889 test = 1 - ( ( test >> bit ) & 1 );
1891 indexColumn[end] = saveColumn[jColumn];
1894 indexColumn[startRow[next]] = saveIndex;
1895 markRow[iRow] = FAC_UNSET;
1896 number = end - startRow[iRow];
1897 numberInRow[iRow] = number;
1898 deleteLink ( iRow );
1899 addLink ( iRow, number );
1901 markRow[iPivotRow] = FAC_UNSET;
1903 deleteLink ( iPivotRow );
1904 deleteLink ( iPivotColumn + numberRows_ );
1905 totalElements_ += added;
bool getColumnSpace(int iColumn, int extraNeeded)
Gets space for one Column with given length, may have to do compression (returns True if successful)...
int numberGoodU_
Number factorized in U (not row singletons)
double slackValue() const
Whether slack value is +1 or -1.
bool collectStatistics_
For statistics.
CoinBigIndex * startColumnL() const
Start of each column in L.
void replaceColumnU(CoinIndexedVector *regionSparse, CoinBigIndex *deleted, int internalPivotRow)
Combines BtranU and delete elements If deleted is NULL then delete elements otherwise store where ele...
int addColumn(CoinBigIndex numberElements, int indicesRow[], double elements[])
Adds one Column to basis, can increase size of basis.
int factorDense()
Does dense phase of factorization return code is <0 error, 0= finished.
double ftranCountAfterL_
Pivot tolerance.
CoinBigIndex totalElements_
Number of elements in U (to go) or while iterating total overall.
CoinBigIndex lengthAreaU() const
Returns length of U area.
int maximumColumnsExtra()
Maximum number of Columns after iterating.
CoinBigIndex numberElementsU() const
Returns number in U area.
CoinBigIndexArrayWithLength startRowL_
Start of each row in L.
void updateColumnTransposeLSparse(CoinIndexedVector *region) const
Updates part of column transpose (BTRANL) when sparse (by Row)
int numberBtranCounts_
Pivot tolerance.
void updateColumnTransposeUSparsish(CoinIndexedVector *region, int smallestIndex) const
Updates part of column transpose (BTRANU) when sparsish, assumes index is sorted i.e.
CoinBigIndex getColumnSpaceIterate(int iColumn, double value, int iRow)
getColumnSpaceIterate.
int addRow(CoinBigIndex numberElements, int indicesColumn[], double elements[])
Adds one Row to basis, can increase size of basis.
void updateColumnTransposePFI(CoinIndexedVector *region) const
Updates part of column transpose PFI (BTRAN) (before rest)
void setBiasLU(int value)
Returns number of dense rows.
int numberForrestTomlin() const
Length of FT vector.
void gutsOfCopy(const CoinFactorization &other)
See if worth going sparse.
int replaceColumn(CoinIndexedVector *regionSparse, int pivotRow, double pivotCheck, bool checkBeforeModifying=false, double acceptablePivot=1.0e-8)
Replaces one Column to basis, returns 0=OK, 1=Probably OK, 2=singular, 3=no room If checkBeforeModify...
int * indexColumnL() const
Index of column in row for L.
double zeroTolerance_
Zero tolerance.
int sparseThreshold_
Below this use sparse technology - if 0 then no L row copy.
CoinIntArrayWithLength saveColumn_
Columns left to do in a single pivot.
int add(CoinBigIndex numberElements, int indicesRow[], int indicesColumn[], double elements[])
Adds given elements to Basis and updates factorization, can increase size of basis.
void clearArrays()
Get rid of all memory.
CoinUnsignedIntArrayWithLength workArea2_
Second work area.
void updateColumnTransposeUDensish(CoinIndexedVector *region, int smallestIndex) const
Updates part of column transpose (BTRANU) when densish, assumes index is sorted i.e.
int * pivotColumn() const
Returns address of pivotColumn region (also used for permuting)
double ftranCountAfterU_
Pivot tolerance.
void checkConsistency()
Checks that row and column copies look OK.
CoinBigIndex lengthR_
Length of R stuff.
bool pivot(int pivotRow, int pivotColumn, CoinBigIndex pivotRowPosition, CoinBigIndex pivotColumnPosition, CoinFactorizationDouble work[], unsigned int workArea2[], int increment2, T markRow[], int largeInteger)
Gets space for a factorization, called by constructors.
int numberTrials_
0 - no increasing rows - no permutations, 1 - no increasing rows but permutations 2 - increasing rows...
CoinBigIndex baseL() const
Base of L.
int deleteColumn(int Row)
Deletes one Column from basis, returns rank.
CoinBigIndex lengthAreaU_
Length of area reserved for U.
void preProcess(int state, int possibleDuplicates=-1)
PreProcesses raw triplet data.
int replaceRow(int whichRow, int numberElements, const int indicesColumn[], const double elements[])
Replaces one Row in basis, At present assumes just a singleton on row is in basis returns 0=OK...
void addLink(int index, int count)
Adds a link in chain of equal counts.
CoinBigIndex numberL() const
Number in L.
CoinIntArrayWithLength indexColumnU_
Base address for U (may change)
CoinFactorizationDouble * elementR_
Elements of R.
CoinIntArrayWithLength nextRow_
Next Row in memory order.
bool pivotRowSingleton(int pivotRow, int pivotColumn)
Does one pivot on Row Singleton in factorization.
double btranCountAfterR_
Pivot tolerance.
int numberColumns() const
Total number of columns in factorization.
void gutsOfDestructor(int type=1)
The real work of constructors etc 0 just scalars, 1 bit normal.
#define COINFACTORIZATION_BITS_PER_INT
int numberColumns_
Number of Columns in factorization.
int * indexRowU() const
Row indices of U.
int biggerDimension_
Larger of row and column size.
double CoinFactorizationDouble
int sparseThreshold2_
And one for "sparsish".
CoinBigIndex lengthU_
Base of U is always 0.
bool getRowSpace(int iRow, int extraNeeded)
Gets space for one Row with given length, may have to do compression (returns True if successful)...
void updateColumnTransposeRSparse(CoinIndexedVector *region) const
Updates part of column transpose (BTRANR) when sparse.
CoinBigIndex numberL_
Number in L.
double ftranCountAfterR_
Pivot tolerance.
int persistenceFlag_
Array persistence flag If 0 then as now (delete/new) 1 then only do arrays if bigger needed 2 as 1 bu...
CoinIntArrayWithLength indexColumnL_
Index of column in row for L.
int sparseThreshold() const
get sparse threshold
int deleteRow(int Row)
Deletes one Row from basis, returns rank.
int * array() const
Get Array.
int updateColumnUDensish(double *COIN_RESTRICT region, int *COIN_RESTRICT regionIndex) const
Updates part of column (FTRANU)
int * indexRowL() const
Row indices of L.
double ftranAverageAfterU_
Pivot tolerance.
void setPersistenceFlag(int value)
Returns number of dense rows.
CoinFactorizationDoubleArrayWithLength elementU_
Elements of U.
CoinIntArrayWithLength sparse_
Sparse regions.
CoinBigIndex numberElementsL() const
Returns number in L area.
void updateColumnTransposeUByColumn(CoinIndexedVector *region, int smallestIndex) const
Updates part of column transpose (BTRANU) by column assumes index is sorted i.e.
CoinFactorizationDoubleArrayWithLength workArea_
First work area.
Sparse Matrix Base Class.
CoinBigIndex maximumU_
Maximum space used in U.
CoinIntArrayWithLength permute_
Permutation vector for pivot row order.
CoinBigIndex numberCompressions_
Number of compressions done.
double ftranAverageAfterL_
While these are average ratios collected over last period.
bool forrestTomlin() const
true if Forrest Tomlin update, false if PFI
void updateColumnUSparse(CoinIndexedVector *regionSparse, int *indexIn) const
Updates part of column (FTRANU) when sparse.
void setNumberRows(int value)
Set number of Rows after factorization.
CoinIntArrayWithLength lastCount_
Previous Row/Column with count.
CoinBigIndex numberElementsR() const
Returns number in R area.
bool reorderU()
Reorders U so contiguous and in order (if there is space) Returns true if it could.
CoinFactorization()
Default constructor.
bool collectStatistics() const
For statistics.
void updateColumnTransposeUSparse(CoinIndexedVector *region) const
Updates part of column transpose (BTRANU) when sparse, assumes index is sorted i.e.
double adjustedAreaFactor() const
Returns areaFactor but adjusted for dense.
bool spaceForForrestTomlin() const
True if FT update and space.
CoinIntArrayWithLength numberInColumnPlus_
Number in each Column including pivoted.
int updateColumn(CoinIndexedVector *regionSparse, CoinIndexedVector *regionSparse2, bool noPermute=false) const
This version has same effect as above with FTUpdate==false so number returned is always >=0...
void areaFactor(double value)
Returns status.
CoinBigIndexArrayWithLength startRowU_
Start of each Row as pointer.
bool pivotOneOtherRow(int pivotRow, int pivotColumn)
Pivots when just one other row so faster?
void goSparse()
makes a row copy of L for speed and to allow very sparse problems
int numberColumnsExtra_
Number of Columns after iterating.
double ftranCountInput_
Below are all to collect.
CoinBigIndex factorElements_
Number of elements after factorization.
CoinBigIndex lengthAreaL_
Length of area reserved for L.
void updateColumnUSparsish(CoinIndexedVector *regionSparse, int *indexIn) const
Updates part of column (FTRANU) when sparsish.
CoinFactorizationDouble * elementByRowL() const
Elements in L (row copy)
void updateColumnLDensish(CoinIndexedVector *region, int *indexIn) const
Updates part of column (FTRANL) when densish.
int persistenceFlag() const
Array persistence flag If 0 then as now (delete/new) 1 then only do arrays if bigger needed 2 as 1 bu...
int maximumPivots_
Maximum number of pivots before factorization.
int maximumColumnsExtra_
Maximum number of Columns after iterating.
CoinFactorizationDoubleArrayWithLength pivotRegion_
Inverses of pivot values.
CoinIntArrayWithLength pivotColumn_
Pivot order for each Column.
void updateColumnTransposeU(CoinIndexedVector *region, int smallestIndex) const
Updates part of column transpose (BTRANU), assumes index is sorted i.e.
CoinBigIndexArrayWithLength startColumnR_
Start of columns for R.
CoinFactorizationDouble * elementU() const
Elements of U.
void updateColumnTransposeLDensish(CoinIndexedVector *region) const
Updates part of column transpose (BTRANL) when densish by column.
CoinIntArrayWithLength indexRowL_
Row indices of L.
double btranAverageAfterR_
Pivot tolerance.
double * denseArea_
Dense area.
CoinIntArrayWithLength nextColumn_
Next Column in memory order.
void gutsOfInitialize(int type)
1 bit - tolerances etc, 2 more, 4 dummy arrays
int maximumPivots() const
Maximum number of pivots between factorizations.
int biasLU() const
L to U bias 0 - U bias, 1 - some U bias, 2 some L bias, 3 L bias.
bool getColumnSpaceIterateR(int iColumn, double value, int iRow)
getColumnSpaceIterateR.
void updateColumnTransposeL(CoinIndexedVector *region) const
Updates part of column transpose (BTRANL)
CoinIntArrayWithLength numberInRow_
Number in each Row.
void setNumberElementsU(CoinBigIndex value)
Setss number in U area.
void sort() const
Debug - sort so can compare.
CoinFactorizationDouble * array() const
Get Array.
#define COINFACTORIZATION_MASK_PER_INT
void updateColumnTransposeR(CoinIndexedVector *region) const
Updates part of column transpose (BTRANR)
CoinBigIndex * array() const
Get Array.
CoinFactorizationDoubleArrayWithLength elementL_
Elements of L.
friend void CoinFactorizationUnitTest(const std::string &mpsDir)
#define COINFACTORIZATION_SHIFT_PER_INT
int updateColumnFT(CoinIndexedVector *regionSparse, CoinIndexedVector *regionSparse2)
Updates one column (FTRAN) from regionSparse2 Tries to do FT update number returned is negative if no...
int * indexRowR_
Row indices for R.
int maximumRowsExtra() const
Maximum of Rows after iterating.
CoinBigIndex lengthAreaR_
length of area reserved for R
double slackValue_
Whether slack value is +1 or -1.
double areaFactor() const
Whether larger areas needed.
double btranCountAfterL_
Pivot tolerance.
void checkSparse()
See if worth going sparse.
int * numberInColumn() const
Number of entries in each column.
int * permute() const
Returns address of permute region.
int numberSlacks_
Number of slacks at beginning of U.
void resetStatistics()
Reset all sparsity etc statistics.
int * numberInRow() const
Number of entries in each row.
void updateTwoColumnsUDensish(int &numberNonZero1, double *COIN_RESTRICT region1, int *COIN_RESTRICT index1, int &numberNonZero2, double *COIN_RESTRICT region2, int *COIN_RESTRICT index2) const
Updates part of 2 columns (FTRANU) real work.
CoinBigIndexArrayWithLength startColumnU_
Start of each column in U.
void setCollectStatistics(bool onOff) const
For statistics.
void updateColumnRFT(CoinIndexedVector *region, int *indexIn)
Updates part of column (FTRANR) with FT update.
CoinIntArrayWithLength firstCount_
First Row/Column with count of k, can tell which by offset - Rows then Columns.
void getAreas(int numberRows, int numberColumns, CoinBigIndex maximumL, CoinBigIndex maximumU)
Gets space for a factorization, called by constructors.
int numberElements() const
Total number of elements in factorization.
double getAccuracyCheck() const
Returns status.
double btranCountInput_
Pivot tolerance.
double btranCountAfterU_
Pivot tolerance.
int factorSparseSmall()
Does sparse phase of factorization (for smaller problems) return code is <0 error, 0= finished.
CoinIntArrayWithLength markRow_
Marks rows to be updated.
~CoinFactorization()
Destructor.
int factorize(const CoinPackedMatrix &matrix, int rowIsBasic[], int columnIsBasic[], double areaFactor=0.0)
When part of LP - given by basic variables.
CoinFactorizationDouble * pivotRegion() const
Returns address of pivot region.
void cleanup()
Cleans up at end of factorization.
CoinIntArrayWithLength pivotRowL_
Pivots for L.
CoinIntArrayWithLength lastRow_
Previous Row in memory order.
int numberPivots_
Number pivots since last factorization.
int * permuteBack() const
Returns address of permuteBack region.
CoinBigIndex baseL_
Base of L.
int denseThreshold_
Dense threshold.
CoinBigIndexArrayWithLength startColumnL_
Start of each column in L.
int numberDense() const
Returns number of dense rows.
CoinIntArrayWithLength nextCount_
Next Row/Column with count.
CoinBigIndex * startColumnU() const
Start of each column in U.
int factor()
Does most of factorization.
CoinBigIndex * startRowL() const
Start of each row in L.
void separateLinks(int count, bool rowsFirst)
Separate out links with same row/column count.
void updateColumnL(CoinIndexedVector *region, int *indexIn) const
Updates part of column (FTRANL)
int status_
Status of factorization.
void updateColumnTransposeLByRow(CoinIndexedVector *region) const
Updates part of column transpose (BTRANL) when densish by row.
int numberRowsExtra() const
Number of Rows after iterating.
int replaceColumnPFI(CoinIndexedVector *regionSparse, int pivotRow, double alpha)
Replaces one Column to basis for PFI returns 0=OK, 1=Probably OK, 2=singular, 3=no room...
int factorSparseLarge()
Does sparse phase of factorization (for larger problems) return code is <0 error, 0= finished...
int numberFtranCounts_
We can roll over factorizations.
int pivots() const
Returns number of pivots since factorization.
void setPivots(int value)
Sets number of pivots since factorization.
CoinIntArrayWithLength numberInColumn_
Number in each Column.
int updateTwoColumnsFT(CoinIndexedVector *regionSparse1, CoinIndexedVector *regionSparse2, CoinIndexedVector *regionSparse3, bool noPermuteRegion3=false)
Updates one column (FTRAN) from region2 Tries to do FT update number returned is negative if no room...
void updateColumnR(CoinIndexedVector *region) const
Updates part of column (FTRANR) without FT update.
double maximumCoefficient() const
Returns maximum absolute value in factorization.
double areaFactor_
How much to multiply areas by.
void updateColumnU(CoinIndexedVector *region, int *indexIn) const
Updates part of column (FTRANU)
bool getRowSpaceIterate(int iRow, int extraNeeded)
Gets space for one Row with given length while iterating, may have to do compression (returns True if...
int numberRows_
Number of Rows in factorization.
int biasLU_
L to U bias 0 - U bias, 1 - some U bias, 2 some L bias, 3 L bias.
double btranAverageAfterU_
Pivot tolerance.
int factorSparse()
Does sparse phase of factorization return code is <0 error, 0= finished.
int status() const
Returns status.
CoinBigIndex numberCompressions() const
Number of compressions done.
int numberGoodColumns() const
Number of good columns in factorization.
void setDenseThreshold(int value)
Sets dense threshold.
CoinBigIndexArrayWithLength convertRowToColumnU_
Converts rows to columns in U.
int checkPivot(double saveFromU, double oldPivot) const
Returns accuracy status of replaceColumn returns 0=OK, 1=Probably OK, 2=singular. ...
void updateColumnPFI(CoinIndexedVector *regionSparse) const
Updates part of column PFI (FTRAN) (after rest)
int numberRows() const
Number of Rows after factorization.
void emptyRows(int numberToEmpty, const int which[])
Takes out all entries for given rows.
This deals with Factorization and Updates.
int numberGoodL_
Number factorized in L.
double pivotTolerance() const
Pivot tolerance.
double btranAverageAfterL_
Pivot tolerance.
CoinIntArrayWithLength permuteBack_
DePermutation vector for pivot row order.
int restoreFactorization(const char *file, bool factor=false)
Debug - restore from file - 0 if no error on file.
double pivotTolerance_
Pivot tolerance.
int factorizePart1(int numberRows, int numberColumns, CoinBigIndex estimateNumberElements, int *indicesRow[], int *indicesColumn[], CoinFactorizationDouble *elements[], double areaFactor=0.0)
Two part version for maximum flexibility This part creates arrays for user to fill.
void updateColumnTransposeRDensish(CoinIndexedVector *region) const
Updates part of column transpose (BTRANR) when dense.
double relaxCheck_
Relax check on accuracy in replaceColumn.
int denseThreshold() const
Gets dense threshold.
CoinBigIndex lengthAreaL() const
Returns length of L area.
void almostDestructor()
Delete all stuff (leaves as after CoinFactorization())
CoinFactorizationDouble * version.
void setStatus(int value)
Sets status.
CoinIntArrayWithLength indexRowU_
Row indices of U.
bool doForrestTomlin_
true if Forrest Tomlin update, false if PFI
CoinIntArrayWithLength lastColumn_
Previous Column in memory order.
void relaxAccuracyCheck(double value)
Allows change of pivot accuracy check 1.0 == none >1.0 relaxed.
CoinBigIndex lengthL_
Length of L.
int messageLevel_
Detail in messages.
int saveFactorization(const char *file) const
Debug - save on file - 0 if no error.
void show_self() const
Debug show object (shows one representation)
int maximumRowsExtra_
Maximum number of Rows after iterating.
double zeroTolerance() const
Zero tolerance.
int numberDense_
Number of dense rows.
int messageLevel() const
Level of detail of messages.
int factorizePart2(int permutation[], int exactNumberElements)
This is part two of factorization Arrays belong to factorization and were returned by part 1 If statu...
double ftranAverageAfterR_
Pivot tolerance.
int numberRowsExtra_
Number of Rows after iterating.
void updateColumnLSparse(CoinIndexedVector *region, int *indexIn) const
Updates part of column (FTRANL) when sparse.
CoinIntArrayWithLength pivotColumnBack_
Inverse Pivot order for each Column.
void deleteLink(int index)
Deletes a link in chain of equal counts.
CoinFactorizationDoubleArrayWithLength elementByRowL_
Elements in L (row copy)
bool pivotColumnSingleton(int pivotRow, int pivotColumn)
Does one pivot on Column Singleton in factorization.
int * densePermute_
Dense permutation.
CoinFactorization & operator=(const CoinFactorization &other)
= copy
void updateColumnLSparsish(CoinIndexedVector *region, int *indexIn) const
Updates part of column (FTRANL) when sparsish.
int * pivotColumnBack() const
Returns address of pivotColumnBack region (also used for permuting) Now uses firstCount to save memor...
double conditionNumber() const
Condition number - product of pivots after factorization.
void updateColumnTransposeLSparsish(CoinIndexedVector *region) const
Updates part of column transpose (BTRANL) when sparsish by row.
int updateColumnTranspose(CoinIndexedVector *regionSparse, CoinIndexedVector *regionSparse2) const
Updates one column (BTRAN) from regionSparse2 regionSparse starts as zero and is zero at end Note - i...
void setForrestTomlin(bool value)
Returns status.