12 #ifndef CoinFactorization_H
13 #define CoinFactorization_H
90 int rowIsBasic[],
int columnIsBasic[] ,
107 const int indicesRow[],
108 const int indicesColumn[],
const double elements[] ,
119 int * indicesColumn[],
136 inline int status ( )
const {
275 #ifndef COIN_FAST_CODE
379 bool checkBeforeModifying=
false,
380 double acceptablePivot=1.0e-8);
387 int internalPivotRow);
388 #ifdef ABC_USE_COIN_FACTORIZATION
392 int already=0)
const;
410 int checkReplacePart2 (
int pivotRow,
414 double acceptablePivot = 1.0e-8);
455 void updateColumnTransposeCpu (
CoinIndexedVector & regionSparse,
int whichCpu)
const;
463 inline bool wantsTableauColumn()
const
466 inline double minimumPivotTolerance ( )
const {
469 inline void minimumPivotTolerance (
double value )
472 inline void setParallelMode(
int value)
473 { parallelMode_=value;}
475 inline void setSolveMode(
int value)
476 { parallelMode_ &= 3;parallelMode_ |= (value<<2);}
478 inline int solveMode()
const
479 {
return parallelMode_ >> 2;}
502 bool noPermute=
false)
const;
511 bool noPermuteRegion3=
false) ;
543 int indicesColumn[],
double elements[] );
548 int indicesRow[],
double elements[] );
553 int indicesColumn[],
double elements[] );
563 int replaceRow (
int whichRow,
int numberElements,
564 const int indicesColumn[],
const double elements[] );
566 void emptyRows(
int numberToEmpty,
const int which[]);
572 #if 0 //def CLP_FACTORIZATION_INSTRUMENT
607 int possibleDuplicates = -1 );
669 inline void addLink (
int index,
int count ) {
673 int next = firstCount[count];
674 lastCount[index] = -2 - count;
677 firstCount[count] = index;
678 nextCount[index] = -1;
680 firstCount[count] = index;
681 nextCount[index] = next;
682 lastCount[next] = index;
689 int next = nextCount[index];
690 int last = lastCount[index];
692 nextCount[last] = next;
694 int count = -last - 2;
696 firstCount[count] = next;
699 lastCount[next] = last;
701 nextCount[index] = -2;
702 lastCount[index] = -2;
730 int * indexIn)
const;
733 int * indexIn)
const;
739 int & numberNonZero1,
742 int & numberNonZero2,
756 int smallestIndex)
const;
760 int smallestIndex)
const;
764 int smallestIndex)
const;
771 int smallestIndex)
const;
796 int pivotRow,
double alpha);
800 int checkPivot(
double saveFromU,
double oldPivot)
const;
803 #define COINFACTORIZATION_BITS_PER_INT 64
804 #define COINFACTORIZATION_SHIFT_PER_INT 6
805 #define COINFACTORIZATION_MASK_PER_INT 0x3f
807 #define COINFACTORIZATION_BITS_PER_INT 32
808 #define COINFACTORIZATION_SHIFT_PER_INT 5
809 #define COINFACTORIZATION_MASK_PER_INT 0x1f
811 template <
class T>
inline bool
817 unsigned int workArea2[],
836 int numberInPivotRow = numberInRow[pivotRow] - 1;
838 int numberInPivotColumn = numberInColumn[
pivotColumn] - 1;
839 CoinBigIndex endColumn = startColumn + numberInPivotColumn + 1;
844 if ( pivotColumnPosition < 0 ) {
845 for ( pivotColumnPosition = startRow; pivotColumnPosition < endRow; pivotColumnPosition++ ) {
846 int iColumn = indexColumnU[pivotColumnPosition];
847 if ( iColumn != pivotColumn ) {
848 saveColumn[put++] = iColumn;
854 for (
CoinBigIndex i = startRow ; i < pivotColumnPosition ; i++ ) {
855 saveColumn[put++] = indexColumnU[i];
858 assert (pivotColumnPosition<endRow);
859 assert (indexColumnU[pivotColumnPosition]==pivotColumn);
860 pivotColumnPosition++;
861 for ( ; pivotColumnPosition < endRow; pivotColumnPosition++ ) {
862 saveColumn[put++] = indexColumnU[pivotColumnPosition];
865 int next = nextRow[pivotRow];
866 int last = lastRow[pivotRow];
868 nextRow[last] = next;
869 lastRow[next] = last;
871 lastRow[pivotRow] = -2;
872 numberInRow[pivotRow] = 0;
879 printf(
"more memory needed in middle of invert\n");
890 if ( pivotRowPosition < 0 ) {
891 for ( pivotRowPosition = startColumn; pivotRowPosition < endColumn; pivotRowPosition++ ) {
892 int iRow = indexRowU[pivotRowPosition];
893 if ( iRow != pivotRow ) {
895 elementL[l] = elementU[pivotRowPosition];
896 markRow[iRow] =
static_cast<T
>(l - lSave);
903 while ( indexColumnU[where] != pivotColumn ) {
907 if ( where >= end ) {
911 indexColumnU[where] = indexColumnU[end - 1];
920 for ( i = startColumn; i < pivotRowPosition; i++ ) {
921 int iRow = indexRowU[i];
923 markRow[iRow] =
static_cast<T
>(l - lSave);
925 elementL[l] = elementU[i];
932 while ( indexColumnU[where] != pivotColumn ) {
936 if ( where >= end ) {
940 indexColumnU[where] = indexColumnU[end - 1];
942 assert (numberInRow[iRow]>=0);
945 assert (pivotRowPosition<endColumn);
946 assert (indexRowU[pivotRowPosition]==pivotRow);
952 for ( ; pivotRowPosition < endColumn; pivotRowPosition++ ) {
953 int iRow = indexRowU[pivotRowPosition];
955 markRow[iRow] =
static_cast<T
>(l - lSave);
957 elementL[l] = elementU[pivotRowPosition];
964 while ( indexColumnU[where] != pivotColumn ) {
968 if ( where >= end ) {
972 indexColumnU[where] = indexColumnU[end - 1];
974 assert (numberInRow[iRow]>=0);
976 markRow[pivotRow] =
static_cast<T
>(largeInteger);
980 int *indexL = &indexRowL[lSave];
986 for ( j = 0; j < numberInPivotColumn; j++ ) {
987 multipliersL[j] *= pivotMultiplier;
991 for ( iErase = 0; iErase < increment2 * numberInPivotRow;
993 workArea2[iErase] = 0;
995 CoinBigIndex added = numberInPivotRow * numberInPivotColumn;
996 unsigned int *temp2 = workArea2;
1001 for ( jColumn = 0; jColumn < numberInPivotRow; jColumn++ ) {
1002 int iColumn = saveColumn[jColumn];
1004 CoinBigIndex endColumn = startColumn + numberInColumn[iColumn];
1005 int iRow = indexRowU[startColumn];
1014 int mark = markRow[iRow];
1016 if ( mark == largeInteger+1 ) {
1017 largest = fabs ( value );
1018 positionLargest = put;
1020 checkLargest =
false;
1024 checkLargest =
true;
1025 if ( mark != largeInteger ) {
1031 temp2[word] = temp2[word] | ( 1 << bit );
1034 thisPivotValue = value;
1038 for ( i = startColumn + 1; i < endColumn; i++ ) {
1039 iRow = indexRowU[i];
1040 value = elementU[i];
1041 int mark = markRow[iRow];
1043 if ( mark == largeInteger+1 ) {
1045 indexRowU[put] = iRow;
1046 elementU[put] = value;
1047 if ( checkLargest ) {
1048 double absValue = fabs ( value );
1050 if ( absValue > largest ) {
1052 positionLargest = put;
1056 }
else if ( mark != largeInteger ) {
1062 temp2[word] = temp2[word] | ( 1 << bit );
1065 thisPivotValue = value;
1069 elementU[put] = elementU[startColumn];
1070 indexRowU[put] = indexRowU[startColumn];
1071 if ( positionLargest == startColumn ) {
1072 positionLargest = put;
1075 elementU[startColumn] = thisPivotValue;
1076 indexRowU[startColumn] = pivotRow;
1079 numberInColumn[iColumn] = put - startColumn;
1081 numberInColumnPlus[iColumn]++;
1082 startColumnU[iColumn]++;
1084 int next = nextColumn[iColumn];
1087 space = startColumnU[next] - put - numberInColumnPlus[next];
1089 if ( numberInPivotColumn > space ) {
1095 if (positionLargest >= 0)
1096 positionLargest = positionLargest + startColumnU[iColumn] - startColumn;
1097 startColumn = startColumnU[iColumn];
1098 put = startColumn + numberInColumn[iColumn];
1103 for ( j = 0; j < numberInPivotColumn; j++ ) {
1104 value = work[j] - thisPivotValue * multipliersL[j];
1105 double absValue = fabs ( value );
1107 if ( absValue > tolerance ) {
1110 elementU[put] = value;
1111 indexRowU[put] = indexL[j];
1112 if ( absValue > largest ) {
1114 positionLargest = put;
1123 if ( temp2[word] & ( 1 << bit ) ) {
1130 while ( indexColumnU[where] != iColumn ) {
1134 if ( where >= end ) {
1138 indexColumnU[where] = indexColumnU[end - 1];
1139 numberInRow[iRow]--;
1145 temp2[word] = temp2[word] | ( 1 << bit );
1149 numberInColumn[iColumn] = put - startColumn;
1151 if ( positionLargest >= 0 ) {
1152 value = elementU[positionLargest];
1153 iRow = indexRowU[positionLargest];
1154 elementU[positionLargest] = elementU[startColumn];
1155 indexRowU[positionLargest] = indexRowU[startColumn];
1156 elementU[startColumn] = value;
1157 indexRowU[startColumn] = iRow;
1165 temp2 += increment2;
1168 unsigned int *putBase = workArea2;
1173 while ( bigLoops ) {
1177 unsigned int *putThis = putBase;
1178 int iRow = indexL[i];
1184 for ( jColumn = 0; jColumn < numberInPivotRow; jColumn++ ) {
1185 unsigned int test = *putThis;
1187 putThis += increment2;
1188 test = 1 - ( ( test >> bit ) & 1 );
1191 int next = nextRow[iRow];
1194 space = startRowU[next] - startRowU[iRow];
1195 number += numberInRow[iRow];
1196 if ( space < number ) {
1203 next = nextRow[iRow];
1204 number = numberInRow[iRow];
1206 int saveIndex = indexColumnU[startRowU[next]];
1209 for ( jColumn = 0; jColumn < numberInPivotRow; jColumn++ ) {
1210 unsigned int test = *putThis;
1212 putThis += increment2;
1213 test = 1 - ( ( test >> bit ) & 1 );
1214 indexColumnU[end] = saveColumn[jColumn];
1218 indexColumnU[startRowU[next]] = saveIndex;
1219 markRow[iRow] =
static_cast<T
>(largeInteger+1);
1220 number = end - startRowU[iRow];
1221 numberInRow[iRow] = number;
1229 for ( bit = 0; i < numberInPivotColumn; i++, bit++ ) {
1230 unsigned int *putThis = putBase;
1231 int iRow = indexL[i];
1237 for ( jColumn = 0; jColumn < numberInPivotRow; jColumn++ ) {
1238 unsigned int test = *putThis;
1240 putThis += increment2;
1241 test = 1 - ( ( test >> bit ) & 1 );
1244 int next = nextRow[iRow];
1247 space = startRowU[next] - startRowU[iRow];
1248 number += numberInRow[iRow];
1249 if ( space < number ) {
1256 next = nextRow[iRow];
1257 number = numberInRow[iRow];
1261 saveIndex = indexColumnU[startRowU[next]];
1264 for ( jColumn = 0; jColumn < numberInPivotRow; jColumn++ ) {
1265 unsigned int test = *putThis;
1267 putThis += increment2;
1268 test = 1 - ( ( test >> bit ) & 1 );
1270 indexColumnU[end] = saveColumn[jColumn];
1273 indexColumnU[startRowU[next]] = saveIndex;
1274 markRow[iRow] =
static_cast<T
>(largeInteger+1);
1275 number = end - startRowU[iRow];
1276 numberInRow[iRow] = number;
1280 markRow[pivotRow] =
static_cast<T
>(largeInteger+1);
1299 #ifndef COIN_FAST_CODE
1304 #define slackValue_ -1.0
1534 #define collectStatistics_ 1
1564 #ifdef ABC_USE_COIN_FACTORIZATION
1571 #ifdef COIN_HAS_LAPACK
1572 #ifndef COIN_FACTORIZATION_DENSE_CODE
1573 #define COIN_FACTORIZATION_DENSE_CODE 1
1576 #ifdef COIN_FACTORIZATION_DENSE_CODE
1581 typedef const int cipfint;
1586 #ifdef UGLY_COIN_FACTOR_CODING
1587 #define FAC_UNSET (FAC_SET+1)
1591 CoinBigIndex startColumnThis = startColumn[iPivotColumn];
1592 CoinBigIndex endColumn = startColumnThis + numberDoColumn + 1;
1596 if ( pivotColumnPosition < 0 ) {
1597 for ( pivotColumnPosition = startRowThis; pivotColumnPosition < endRow; pivotColumnPosition++ ) {
1598 int iColumn = indexColumn[pivotColumnPosition];
1599 if ( iColumn != iPivotColumn ) {
1600 saveColumn[put++] = iColumn;
1606 for (
CoinBigIndex i = startRowThis ; i < pivotColumnPosition ; i++ ) {
1607 saveColumn[put++] = indexColumn[i];
1610 assert (pivotColumnPosition<endRow);
1611 assert (indexColumn[pivotColumnPosition]==iPivotColumn);
1612 pivotColumnPosition++;
1613 for ( ; pivotColumnPosition < endRow; pivotColumnPosition++ ) {
1614 saveColumn[put++] = indexColumn[pivotColumnPosition];
1617 int next = nextRow[iPivotRow];
1618 int last = lastRow[iPivotRow];
1620 nextRow[last] = next;
1621 lastRow[next] = last;
1622 nextRow[iPivotRow] = numberGoodU_;
1623 lastRow[iPivotRow] = -2;
1624 numberInRow[iPivotRow] = 0;
1629 if ( l + numberDoColumn > lengthAreaL_ ) {
1631 if ((messageLevel_&4)!=0)
1632 printf(
"more memory needed in middle of invert\n");
1639 startColumnL[numberGoodL_] = l;
1641 startColumnL[numberGoodL_] = l + numberDoColumn;
1642 lengthL_ += numberDoColumn;
1643 if ( pivotRowPosition < 0 ) {
1644 for ( pivotRowPosition = startColumnThis; pivotRowPosition < endColumn; pivotRowPosition++ ) {
1645 int iRow = indexRow[pivotRowPosition];
1646 if ( iRow != iPivotRow ) {
1647 indexRowL[l] = iRow;
1648 elementL[l] = element[pivotRowPosition];
1649 markRow[iRow] = l - lSave;
1656 while ( indexColumn[where] != iPivotColumn ) {
1660 if ( where >= end ) {
1664 indexColumn[where] = indexColumn[end - 1];
1665 numberInRow[iRow]--;
1673 for ( i = startColumnThis; i < pivotRowPosition; i++ ) {
1674 int iRow = indexRow[i];
1676 markRow[iRow] = l - lSave;
1677 indexRowL[l] = iRow;
1678 elementL[l] = element[i];
1685 while ( indexColumn[where] != iPivotColumn ) {
1689 if ( where >= end ) {
1693 indexColumn[where] = indexColumn[end - 1];
1694 numberInRow[iRow]--;
1695 assert (numberInRow[iRow]>=0);
1698 assert (pivotRowPosition<endColumn);
1699 assert (indexRow[pivotRowPosition]==iPivotRow);
1703 pivotRegion_.array()[numberGoodU_] = pivotMultiplier;
1705 for ( ; pivotRowPosition < endColumn; pivotRowPosition++ ) {
1706 int iRow = indexRow[pivotRowPosition];
1708 markRow[iRow] = l - lSave;
1709 indexRowL[l] = iRow;
1710 elementL[l] = element[pivotRowPosition];
1717 while ( indexColumn[where] != iPivotColumn ) {
1721 if ( where >= end ) {
1725 indexColumn[where] = indexColumn[end - 1];
1726 numberInRow[iRow]--;
1727 assert (numberInRow[iRow]>=0);
1729 markRow[iPivotRow] = FAC_SET;
1731 numberInColumn[iPivotColumn] = 0;
1733 int *indexL = &indexRowL[lSave];
1739 for ( j = 0; j < numberDoColumn; j++ ) {
1740 multipliersL[j] *= pivotMultiplier;
1744 for ( iErase = 0; iErase < increment2 * numberDoRow;
1746 workArea2[iErase] = 0;
1749 unsigned int *temp2 = workArea2;
1750 int * nextColumn = nextColumn_.array();
1754 for ( jColumn = 0; jColumn < numberDoRow; jColumn++ ) {
1755 int iColumn = saveColumn[jColumn];
1757 CoinBigIndex endColumn = startColumnThis + numberInColumn[iColumn];
1758 int iRow = indexRow[startColumnThis];
1767 int mark = markRow[iRow];
1769 if ( mark == FAC_UNSET ) {
1770 largest = fabs ( value );
1771 positionLargest = put;
1773 checkLargest =
false;
1777 checkLargest =
true;
1778 if ( mark != FAC_SET ) {
1780 workArea[mark] = value;
1784 temp2[word] = temp2[word] | ( 1 << bit );
1787 thisPivotValue = value;
1791 for ( i = startColumnThis + 1; i < endColumn; i++ ) {
1794 int mark = markRow[iRow];
1796 if ( mark == FAC_UNSET ) {
1798 indexRow[put] = iRow;
1799 element[put] = value;
1800 if ( checkLargest ) {
1801 double absValue = fabs ( value );
1803 if ( absValue > largest ) {
1805 positionLargest = put;
1809 }
else if ( mark != FAC_SET ) {
1811 workArea[mark] = value;
1815 temp2[word] = temp2[word] | ( 1 << bit );
1818 thisPivotValue = value;
1822 element[put] = element[startColumnThis];
1823 indexRow[put] = indexRow[startColumnThis];
1824 if ( positionLargest == startColumnThis ) {
1825 positionLargest = put;
1828 element[startColumnThis] = thisPivotValue;
1829 indexRow[startColumnThis] = iPivotRow;
1832 numberInColumn[iColumn] = put - startColumnThis;
1833 int * numberInColumnPlus = numberInColumnPlus_.array();
1834 numberInColumnPlus[iColumn]++;
1835 startColumn[iColumn]++;
1837 int next = nextColumn[iColumn];
1840 space = startColumn[next] - put - numberInColumnPlus[next];
1842 if ( numberDoColumn > space ) {
1844 if ( !getColumnSpace ( iColumn, numberDoColumn ) ) {
1848 positionLargest = positionLargest + startColumn[iColumn] - startColumnThis;
1849 startColumnThis = startColumn[iColumn];
1850 put = startColumnThis + numberInColumn[iColumn];
1852 double tolerance = zeroTolerance_;
1854 int *nextCount = nextCount_.array();
1855 for ( j = 0; j < numberDoColumn; j++ ) {
1856 value = workArea[j] - thisPivotValue * multipliersL[j];
1857 double absValue = fabs ( value );
1859 if ( absValue > tolerance ) {
1861 element[put] = value;
1862 indexRow[put] = indexL[j];
1863 if ( absValue > largest ) {
1865 positionLargest = put;
1874 if ( temp2[word] & ( 1 << bit ) ) {
1881 while ( indexColumn[where] != iColumn ) {
1885 if ( where >= end ) {
1889 indexColumn[where] = indexColumn[end - 1];
1890 numberInRow[iRow]--;
1896 temp2[word] = temp2[word] | ( 1 << bit );
1900 numberInColumn[iColumn] = put - startColumnThis;
1902 if ( positionLargest >= 0 ) {
1903 value = element[positionLargest];
1904 iRow = indexRow[positionLargest];
1905 element[positionLargest] = element[startColumnThis];
1906 indexRow[positionLargest] = indexRow[startColumnThis];
1907 element[startColumnThis] = value;
1908 indexRow[startColumnThis] = iRow;
1911 if ( nextCount[iColumn + numberRows_] != -2 ) {
1913 deleteLink ( iColumn + numberRows_ );
1914 addLink ( iColumn + numberRows_, numberInColumn[iColumn] );
1916 temp2 += increment2;
1919 unsigned int *putBase = workArea2;
1924 while ( bigLoops ) {
1928 unsigned int *putThis = putBase;
1929 int iRow = indexL[i];
1935 for ( jColumn = 0; jColumn < numberDoRow; jColumn++ ) {
1936 unsigned int test = *putThis;
1938 putThis += increment2;
1939 test = 1 - ( ( test >> bit ) & 1 );
1942 int next = nextRow[iRow];
1945 space = startRow[next] - startRow[iRow];
1946 number += numberInRow[iRow];
1947 if ( space < number ) {
1948 if ( !getRowSpace ( iRow, number ) ) {
1954 next = nextRow[iRow];
1955 number = numberInRow[iRow];
1957 int saveIndex = indexColumn[startRow[next]];
1960 for ( jColumn = 0; jColumn < numberDoRow; jColumn++ ) {
1961 unsigned int test = *putThis;
1963 putThis += increment2;
1964 test = 1 - ( ( test >> bit ) & 1 );
1965 indexColumn[end] = saveColumn[jColumn];
1969 indexColumn[startRow[next]] = saveIndex;
1970 markRow[iRow] = FAC_UNSET;
1971 number = end - startRow[iRow];
1972 numberInRow[iRow] = number;
1973 deleteLink ( iRow );
1974 addLink ( iRow, number );
1980 for ( bit = 0; i < numberDoColumn; i++, bit++ ) {
1981 unsigned int *putThis = putBase;
1982 int iRow = indexL[i];
1988 for ( jColumn = 0; jColumn < numberDoRow; jColumn++ ) {
1989 unsigned int test = *putThis;
1991 putThis += increment2;
1992 test = 1 - ( ( test >> bit ) & 1 );
1995 int next = nextRow[iRow];
1998 space = startRow[next] - startRow[iRow];
1999 number += numberInRow[iRow];
2000 if ( space < number ) {
2001 if ( !getRowSpace ( iRow, number ) ) {
2007 next = nextRow[iRow];
2008 number = numberInRow[iRow];
2012 saveIndex = indexColumn[startRow[next]];
2015 for ( jColumn = 0; jColumn < numberDoRow; jColumn++ ) {
2016 unsigned int test = *putThis;
2018 putThis += increment2;
2019 test = 1 - ( ( test >> bit ) & 1 );
2021 indexColumn[end] = saveColumn[jColumn];
2024 indexColumn[startRow[next]] = saveIndex;
2025 markRow[iRow] = FAC_UNSET;
2026 number = end - startRow[iRow];
2027 numberInRow[iRow] = number;
2028 deleteLink ( iRow );
2029 addLink ( iRow, number );
2031 markRow[iPivotRow] = FAC_UNSET;
2033 deleteLink ( iPivotRow );
2034 deleteLink ( iPivotColumn + numberRows_ );
2035 totalElements_ += added;
CoinBigIndex * array() const
Get Array.
CoinBigIndexArrayWithLength startRowU_
Start of each Row as pointer.
CoinBigIndex numberL_
Number in L.
CoinBigIndex factorElements_
Number of elements after factorization.
#define COINFACTORIZATION_BITS_PER_INT
CoinFactorizationDouble * elementU() const
Elements of U.
bool getColumnSpaceIterateR(int iColumn, double value, int iRow)
getColumnSpaceIterateR.
CoinIntArrayWithLength nextColumn_
Next Column in memory order.
bool pivotOneOtherRow(int pivotRow, int pivotColumn)
Pivots when just one other row so faster?
CoinBigIndex * startRowL() const
Start of each row in L.
CoinFactorizationDoubleArrayWithLength pivotRegion_
Inverses of pivot values.
void setPivots(int value)
Sets number of pivots since factorization.
void separateLinks(int count, bool rowsFirst)
Separate out links with same row/column count.
bool doForrestTomlin_
true if Forrest Tomlin update, false if PFI
CoinFactorizationDouble * pivotRegion() const
Returns address of pivot region.
int addColumn(CoinBigIndex numberElements, int indicesRow[], double elements[])
Adds one Column to basis, can increase size of basis.
void updateColumnTransposeLDensish(CoinIndexedVector *region) const
Updates part of column transpose (BTRANL) when densish by column.
int numberFtranCounts_
We can roll over factorizations.
int numberPivots_
Number pivots since last factorization.
void updateColumnTransposeRSparse(CoinIndexedVector *region) const
Updates part of column transpose (BTRANR) when sparse.
double areaFactor() const
Whether larger areas needed.
int numberDense() const
Returns number of dense rows.
double btranAverageAfterU_
int maximumRowsExtra_
Maximum number of Rows after iterating.
int status() const
Returns status.
int denseThreshold() const
Gets dense threshold.
int maximumColumnsExtra()
Maximum number of Columns after iterating.
int sparseThreshold_
Below this use sparse technology - if 0 then no L row copy.
int * indexColumnL() const
Index of column in row for L.
void deleteLink(int index)
Deletes a link in chain of equal counts.
void checkSparse()
See if worth going sparse.
int * pivotColumn() const
Returns address of pivotColumn region (also used for permuting)
CoinBigIndex lengthAreaL() const
Returns length of L area.
CoinIntArrayWithLength lastColumn_
Previous Column in memory order.
CoinFactorizationDoubleArrayWithLength elementL_
Elements of L.
void setNumberRows(int value)
Set number of Rows after factorization.
bool collectStatistics() const
For statistics.
void setForrestTomlin(bool value)
void updateColumnTransposeUSparsish(CoinIndexedVector *region, int smallestIndex) const
Updates part of column transpose (BTRANU) when sparsish, assumes index is sorted i.e.
int status_
Status of factorization.
#define COINFACTORIZATION_SHIFT_PER_INT
void updateColumnTransposeR(CoinIndexedVector *region) const
Updates part of column transpose (BTRANR)
CoinIntArrayWithLength pivotRowL_
Pivots for L.
CoinBigIndex * startColumnL() const
Start of each column in L.
bool pivotRowSingleton(int pivotRow, int pivotColumn)
Does one pivot on Row Singleton in factorization.
void relaxAccuracyCheck(double value)
Allows change of pivot accuracy check 1.0 == none >1.0 relaxed.
void sort() const
Debug - sort so can compare.
int numberRows() const
Number of Rows after factorization.
~CoinFactorization()
Destructor.
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...
double maximumCoefficient() const
Returns maximum absolute value in factorization.
int * permute() const
Returns address of permute region.
int numberGoodU_
Number factorized in U (not row singletons)
CoinFactorization()
Default constructor.
int deleteRow(int Row)
Deletes one Row from basis, returns rank.
CoinBigIndexArrayWithLength startColumnR_
Start of columns for R.
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.
double btranAverageAfterR_
double * denseArea_
Dense area.
CoinIntArrayWithLength markRow_
Marks rows to be updated.
int numberRowsExtra() const
Number of Rows after iterating.
void gutsOfInitialize(int type)
1 bit - tolerances etc, 2 more, 4 dummy arrays
bool pivot(int pivotRow, int pivotColumn, CoinBigIndex pivotRowPosition, CoinBigIndex pivotColumnPosition, CoinFactorizationDouble work[], unsigned int workArea2[], int increment2, T markRow[], int largeInteger)
int numberElements() const
Total number of elements in factorization.
void updateColumnTransposeLByRow(CoinIndexedVector *region) const
Updates part of column transpose (BTRANL) when densish 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...
int updateColumnFT(CoinIndexedVector *regionSparse, CoinIndexedVector *regionSparse2)
Updates one column (FTRAN) from regionSparse2 Tries to do FT update number returned is negative if no...
void updateColumnL(CoinIndexedVector *region, int *indexIn) const
Updates part of column (FTRANL)
int numberColumns() const
Total number of columns in factorization.
double relaxCheck_
Relax check on accuracy in replaceColumn.
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.
void cleanup()
Cleans up at end of factorization.
double ftranAverageAfterR_
CoinBigIndex lengthR_
Length of R stuff.
bool getRowSpaceIterate(int iRow, int extraNeeded)
Gets space for one Row with given length while iterating, may have to do compression (returns True i...
int * numberInRow() const
Number of entries in each row.
int restoreFactorization(const char *file, bool factor=false)
Debug - restore from file - 0 if no error on file.
CoinFactorization & operator=(const CoinFactorization &other)
= copy
int * pivotColumnBack() const
Returns address of pivotColumnBack region (also used for permuting) Now uses firstCount to save memor...
void updateColumnTransposeRDensish(CoinIndexedVector *region) const
Updates part of column transpose (BTRANR) when dense.
CoinBigIndex * startColumnU() const
Start of each column in U.
int checkPivot(double saveFromU, double oldPivot) const
Returns accuracy status of replaceColumn returns 0=OK, 1=Probably OK, 2=singular. ...
double zeroTolerance() const
Zero tolerance.
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...
CoinBigIndex maximumU_
Maximum space used in U.
void updateColumnTransposeLSparse(CoinIndexedVector *region) const
Updates part of column transpose (BTRANL) when sparse (by Row)
double * denseAreaAddress_
Dense area - actually used (for alignment etc)
CoinBigIndex lengthU_
Base of U is always 0.
void updateColumnPFI(CoinIndexedVector *regionSparse) const
Updates part of column PFI (FTRAN) (after rest)
double pivotTolerance_
Pivot tolerance.
#define collectStatistics_
For statistics.
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...
int saveFactorization(const char *file) const
Debug - save on file - 0 if no error.
void gutsOfCopy(const CoinFactorization &other)
int * numberInColumn() const
Number of entries in each column.
int factorSparse()
Does sparse phase of factorization return code is <0 error, 0= finished.
int numberRowsExtra_
Number of Rows after iterating.
CoinBigIndex lengthL_
Length of L.
CoinIntArrayWithLength numberInColumn_
Number in each Column.
void updateColumnLSparse(CoinIndexedVector *region, int *indexIn) const
Updates part of column (FTRANL) when sparse.
int sparseThreshold() const
get sparse threshold
int persistenceFlag_
Array persistence flag If 0 then as now (delete/new) 1 then only do arrays if bigger needed 2 as 1 bu...
int factor()
Does most of factorization.
void setPersistenceFlag(int value)
int numberGoodColumns() const
Number of good columns in factorization.
CoinFactorizationDouble * array() const
Get Array.
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...
double CoinFactorizationDouble
int numberDense_
Number of dense rows.
void updateColumnLSparsish(CoinIndexedVector *region, int *indexIn) const
Updates part of column (FTRANL) when sparsish.
void addLink(int index, int count)
Adds a link in chain of equal counts.
void gutsOfDestructor(int type=1)
The real work of constructors etc 0 just scalars, 1 bit normal.
int deleteColumn(int Row)
Deletes one Column from basis, returns rank.
int * densePermute_
Dense permutation.
void updateColumnTransposePFI(CoinIndexedVector *region) const
Updates part of column transpose PFI (BTRAN) (before rest)
int messageLevel() const
Level of detail of messages.
CoinBigIndex numberElementsL() const
Returns number in L area.
double getAccuracyCheck() const
void setBiasLU(int value)
int pivots() const
Returns number of pivots since factorization.
CoinIntArrayWithLength nextCount_
Next Row/Column with count.
CoinBigIndexArrayWithLength startRowL_
Start of each row in L.
bool pivotColumnSingleton(int pivotRow, int pivotColumn)
Does one pivot on Column Singleton in factorization.
void updateColumnTransposeLSparsish(CoinIndexedVector *region) const
Updates part of column transpose (BTRANL) when sparsish by row.
CoinIntArrayWithLength lastRow_
Previous Row in memory order.
CoinBigIndexArrayWithLength startColumnL_
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 denseThreshold_
Dense threshold.
void almostDestructor()
Delete all stuff (leaves as after CoinFactorization())
friend void CoinFactorizationUnitTest(const std::string &mpsDir)
#define COINFACTORIZATION_MASK_PER_INT
CoinIntArrayWithLength firstCount_
First Row/Column with count of k, can tell which by offset - Rows then Columns.
int * lastRow() const
Returns address of lastRow region.
void setNumberElementsU(CoinBigIndex value)
Setss number in U area.
CoinIntArrayWithLength sparse_
Sparse regions.
CoinFactorizationDouble * elementR_
Elements of R.
CoinBigIndex lengthAreaU_
Length of area reserved for U.
void updateColumnTransposeL(CoinIndexedVector *region) const
Updates part of column transpose (BTRANL)
void updateColumnRFT(CoinIndexedVector *region, int *indexIn)
Updates part of column (FTRANR) with FT update.
int * indexRowL() const
Row indices of L.
void setStatus(int value)
Sets status.
CoinBigIndex getColumnSpaceIterate(int iColumn, double value, int iRow)
getColumnSpaceIterate.
double ftranAverageAfterU_
CoinBigIndex lengthAreaR_
length of area reserved for R
double ftranAverageAfterL_
While these are average ratios collected over last period.
CoinIntArrayWithLength pivotColumn_
Pivot order for each Column.
void show_self() const
Debug show object (shows one representation)
double zeroTolerance_
Zero tolerance.
int biggerDimension_
Larger of row and column size.
int addRow(CoinBigIndex numberElements, int indicesColumn[], double elements[])
Adds one Row to basis, can increase size of basis.
int biasLU_
L to U bias 0 - U bias, 1 - some U bias, 2 some L bias, 3 L bias.
void resetStatistics()
Reset all sparsity etc statistics.
void areaFactor(double value)
CoinBigIndex lengthAreaU() const
Returns length of U area.
int maximumPivots() const
Maximum number of pivots between factorizations.
double adjustedAreaFactor() const
Returns areaFactor but adjusted for dense.
int factorSparseLarge()
Does sparse phase of factorization (for larger problems) return code is <0 error, 0= finished...
CoinBigIndex numberL() const
Number in L.
double ftranCountInput_
Below are all to collect.
int numberTrials_
0 - no increasing rows - no permutations, 1 - no increasing rows but permutations 2 - increasing rows...
CoinBigIndexArrayWithLength convertRowToColumnU_
Converts rows to columns in U.
void updateColumnUSparsish(CoinIndexedVector *regionSparse, int *indexIn) const
Updates part of column (FTRANU) when sparsish.
CoinIntArrayWithLength nextRow_
Next Row in memory order.
CoinFactorizationDoubleArrayWithLength elementU_
Elements of U.
double slackValue() const
Whether slack value is +1 or -1.
Sparse Matrix Base Class.
int factorizePart2(int permutation[], int exactNumberElements)
This is part two of factorization Arrays belong to factorization and were returned by part 1 If statu...
int numberColumns_
Number of Columns in factorization.
CoinIntArrayWithLength indexColumnU_
Base address for U (may change)
void updateColumnUSparse(CoinIndexedVector *regionSparse, int *indexIn) const
Updates part of column (FTRANU) when sparse.
CoinFactorizationDoubleArrayWithLength workArea_
First work area.
CoinIntArrayWithLength saveColumn_
Columns left to do in a single pivot.
int * indexRowR_
Row indices for R.
void clearArrays()
Get rid of all memory.
double btranAverageAfterL_
void updateColumnTransposeUDensish(CoinIndexedVector *region, int smallestIndex) const
Updates part of column transpose (BTRANU) when densish, assumes index is sorted i.e.
int factorDense()
Does dense phase of factorization return code is <0 error, 0= finished.
CoinIntArrayWithLength numberInColumnPlus_
Number in each Column including pivoted.
int updateColumnUDensish(double *COIN_RESTRICT region, int *COIN_RESTRICT regionIndex) const
Updates part of column (FTRANU)
CoinIntArrayWithLength pivotColumnBack_
Inverse Pivot order for each Column.
CoinBigIndexArrayWithLength startColumnU_
Start of each column in U.
CoinBigIndex baseL_
Base of L.
CoinBigIndex numberElementsU() const
Returns number in U area.
CoinIntArrayWithLength permuteBack_
DePermutation vector for pivot row order.
double slackValue_
Whether slack value is +1 or -1.
void goSparse()
makes a row copy of L for speed and to allow very sparse problems
CoinFactorizationDouble * version.
CoinIntArrayWithLength indexColumnL_
Index of column in row for L.
CoinIntArrayWithLength indexRowL_
Row indices of L.
CoinBigIndex numberCompressions_
Number of compressions done.
CoinBigIndex lengthAreaL_
Length of area reserved for L.
CoinIntArrayWithLength permute_
Permutation vector for pivot row order.
int add(CoinBigIndex numberElements, int indicesRow[], int indicesColumn[], double elements[])
Adds given elements to Basis and updates factorization, can increase size of basis.
void updateColumnTransposeUSparse(CoinIndexedVector *region) const
Updates part of column transpose (BTRANU) when sparse, assumes index is sorted i.e.
int * indexRowU() const
Row indices of U.
CoinUnsignedIntArrayWithLength workArea2_
Second work area.
This deals with Factorization and Updates.
bool getColumnSpace(int iColumn, int extraNeeded)
Gets space for one Column with given length, may have to do compression (returns True if successful)...
void updateColumnR(CoinIndexedVector *region) const
Updates part of column (FTRANR) without FT update.
double areaFactor_
How much to multiply areas by.
void checkConsistency()
Checks that row and column copies look OK.
CoinBigIndex totalElements_
Number of elements in U (to go) or while iterating total overall.
int * array() const
Get Array.
void updateColumnU(CoinIndexedVector *region, int *indexIn) const
Updates part of column (FTRANU)
void updateColumnTransposeU(CoinIndexedVector *region, int smallestIndex) const
Updates part of column transpose (BTRANU), assumes index is sorted i.e.
int numberSlacks_
Number of slacks at beginning of U.
int numberColumnsExtra_
Number of Columns after iterating.
void getAreas(int numberRows, int numberColumns, CoinBigIndex maximumL, CoinBigIndex maximumU)
Gets space for a factorization, called by constructors.
CoinIntArrayWithLength numberInRow_
Number in each Row.
int numberForrestTomlin() const
Length of FT vector.
void setDenseThreshold(int value)
Sets dense threshold.
int messageLevel_
Detail in messages.
CoinIntArrayWithLength lastCount_
Previous Row/Column with count.
void updateColumnTransposeUByColumn(CoinIndexedVector *region, int smallestIndex) const
Updates part of column transpose (BTRANU) by column assumes index is sorted i.e.
CoinFactorizationDouble * elementByRowL() const
Elements in L (row copy)
int maximumPivots_
Maximum number of pivots before factorization.
bool spaceForForrestTomlin() const
True if FT update and space.
bool reorderU()
Reorders U so contiguous and in order (if there is space) Returns true if it could.
void preProcess(int state, int possibleDuplicates=-1)
PreProcesses raw triplet data.
int maximumColumnsExtra_
Maximum number of Columns after iterating.
int maximumRowsExtra() const
Maximum of Rows after iterating.
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 biasLU() const
L to U bias 0 - U bias, 1 - some U bias, 2 some L bias, 3 L bias.
int sparseThreshold2_
And one for "sparsish".
int numberGoodL_
Number factorized in L.
double conditionNumber() const
Condition number - product of pivots after factorization.
double pivotTolerance() const
Pivot tolerance.
CoinFactorizationDoubleArrayWithLength elementByRowL_
Elements in L (row copy)
int numberRows_
Number of Rows in factorization.
void setCollectStatistics(bool onOff) const
For statistics.
void updateColumnLDensish(CoinIndexedVector *region, int *indexIn) const
Updates part of column (FTRANL) when densish.
CoinBigIndex numberCompressions() const
Number of compressions done.
CoinBigIndex baseL() const
Base of L.
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...
int factorSparseSmall()
Does sparse phase of factorization (for smaller problems) return code is <0 error, 0= finished.
CoinIntArrayWithLength indexRowU_
Row indices of U.
bool forrestTomlin() const
true if Forrest Tomlin update, false if PFI
void emptyRows(int numberToEmpty, const int which[])
Takes out all entries for given rows.
int factorize(const CoinPackedMatrix &matrix, int rowIsBasic[], int columnIsBasic[], double areaFactor=0.0)
When part of LP - given by basic variables.
bool getRowSpace(int iRow, int extraNeeded)
Gets space for one Row with given length, may have to do compression (returns True if successful)...
CoinBigIndex numberElementsR() const
Returns number in R area.
int * permuteBack() const
Returns address of permuteBack region.