Go to the documentation of this file.
12 #ifndef CoinFactorization_H
13 #define CoinFactorization_H
14 #define EXTRA_U_SPACE 4
89 int rowIsBasic[],
int columnIsBasic[],
106 const int indicesRow[],
107 const int indicesColumn[],
const double elements[],
116 int estimateNumberElements,
118 int *indicesColumn[],
323 #ifndef COIN_FAST_CODE
461 bool checkBeforeModifying =
false,
462 double acceptablePivot = 1.0e-8);
469 int internalPivotRow);
470 #ifdef ABC_USE_COIN_FACTORIZATION
474 int already = 0)
const;
492 int checkReplacePart2(
int pivotRow,
496 double acceptablePivot = 1.0e-8);
537 void updateColumnTransposeCpu(
CoinIndexedVector ®ionSparse,
int whichCpu)
const;
545 inline bool wantsTableauColumn()
const
550 inline double minimumPivotTolerance()
const
554 inline void minimumPivotTolerance(
double value)
559 inline void setParallelMode(
int value)
561 parallelMode_ = value;
564 inline void setSolveMode(
int value)
567 parallelMode_ |= (value << 2);
570 inline int solveMode()
const
572 return parallelMode_ >> 2;
579 #if ABOCA_LITE_FACTORIZATION
604 bool noPermute =
false)
const;
613 bool noPermuteRegion3 =
false);
659 int indicesColumn[],
double elements[]);
664 int indicesRow[],
double elements[]);
669 int indicesColumn[],
double elements[]);
680 const int indicesColumn[],
const double elements[]);
682 void emptyRows(
int numberToEmpty,
const int which[]);
688 #if 0 //def CLP_FACTORIZATION_INSTRUMENT
725 int possibleDuplicates = -1);
793 int next = firstCount[count];
794 lastCount[index] = -2 - count;
797 firstCount[count] = index;
798 nextCount[index] = -1;
800 firstCount[count] = index;
801 nextCount[index] = next;
802 lastCount[next] = index;
811 int next = nextCount[index];
812 int last = lastCount[index];
814 nextCount[last] = next;
816 int count = -last - 2;
818 firstCount[count] = next;
821 lastCount[next] = last;
823 nextCount[index] = -2;
824 lastCount[index] = -2;
878 int smallestIndex)
const;
882 int smallestIndex)
const;
886 int smallestIndex)
const;
893 int smallestIndex)
const;
919 int pivotRow,
double alpha);
924 int checkPivot(
double saveFromU,
double oldPivot)
const;
927 #define COINFACTORIZATION_BITS_PER_INT 64
928 #define COINFACTORIZATION_SHIFT_PER_INT 6
929 #define COINFACTORIZATION_MASK_PER_INT 0x3f
931 #define COINFACTORIZATION_BITS_PER_INT 32
932 #define COINFACTORIZATION_SHIFT_PER_INT 5
933 #define COINFACTORIZATION_MASK_PER_INT 0x1f
939 int pivotRowPosition,
940 int pivotColumnPosition,
942 unsigned int workArea2[],
964 int endColumn = startColumn + numberInPivotColumn + 1;
966 int startRow = startRowU[pivotRow];
967 int endRow = startRow + numberInPivotRow + 1;
969 if (pivotColumnPosition < 0) {
970 for (pivotColumnPosition = startRow; pivotColumnPosition < endRow; pivotColumnPosition++) {
971 int iColumn = indexColumnU[pivotColumnPosition];
973 saveColumn[put++] = iColumn;
979 for (
int i = startRow; i < pivotColumnPosition; i++) {
980 saveColumn[put++] = indexColumnU[i];
983 assert(pivotColumnPosition < endRow);
984 assert(indexColumnU[pivotColumnPosition] ==
pivotColumn);
985 pivotColumnPosition++;
986 for (; pivotColumnPosition < endRow; pivotColumnPosition++) {
987 saveColumn[put++] = indexColumnU[pivotColumnPosition];
990 int next = nextRow[pivotRow];
993 nextRow[last] = next;
1004 printf(
"more memory needed in middle of invert\n");
1015 if (pivotRowPosition < 0) {
1016 for (pivotRowPosition = startColumn; pivotRowPosition < endColumn; pivotRowPosition++) {
1018 if (iRow != pivotRow) {
1020 elementL[l] =
elementU[pivotRowPosition];
1021 markRow[iRow] =
static_cast< T
>(l - lSave);
1024 int start = startRowU[iRow];
1036 indexColumnU[where] = indexColumnU[end - 1];
1045 for (i = startColumn; i < pivotRowPosition; i++) {
1048 markRow[iRow] =
static_cast< T
>(l - lSave);
1053 int start = startRowU[iRow];
1065 indexColumnU[where] = indexColumnU[end - 1];
1070 assert(pivotRowPosition < endColumn);
1071 assert(
indexRowU[pivotRowPosition] == pivotRow);
1077 for (; pivotRowPosition < endColumn; pivotRowPosition++) {
1080 markRow[iRow] =
static_cast< T
>(l - lSave);
1082 elementL[l] =
elementU[pivotRowPosition];
1085 int start = startRowU[iRow];
1097 indexColumnU[where] = indexColumnU[end - 1];
1101 markRow[pivotRow] =
static_cast< T
>(largeInteger);
1111 for (j = 0; j < numberInPivotColumn; j++) {
1112 multipliersL[j] *= pivotMultiplier;
1116 for (iErase = 0; iErase < increment2 * numberInPivotRow;
1118 workArea2[iErase] = 0;
1120 int added = numberInPivotRow * numberInPivotColumn;
1121 unsigned int *temp2 = workArea2;
1126 for (jColumn = 0; jColumn < numberInPivotRow; jColumn++) {
1127 int iColumn = saveColumn[jColumn];
1133 int put = startColumn;
1134 int positionLargest = -1;
1139 int mark = markRow[iRow];
1141 if (mark == largeInteger + 1) {
1142 largest = fabs(value);
1143 positionLargest = put;
1145 checkLargest =
false;
1149 checkLargest =
true;
1150 if (mark != largeInteger) {
1156 temp2[word] = temp2[word] | (1 << bit);
1159 thisPivotValue = value;
1163 for (i = startColumn + 1; i < endColumn; i++) {
1166 int mark = markRow[iRow];
1168 if (mark == largeInteger + 1) {
1173 double absValue = fabs(value);
1175 if (absValue > largest) {
1177 positionLargest = put;
1181 }
else if (mark != largeInteger) {
1187 temp2[word] = temp2[word] | (1 << bit);
1190 thisPivotValue = value;
1196 if (positionLargest == startColumn) {
1197 positionLargest = put;
1200 elementU[startColumn] = thisPivotValue;
1206 numberInColumnPlus[iColumn]++;
1209 int next = nextColumn[iColumn];
1212 space =
startColumnU[next] - put - numberInColumnPlus[next];
1214 if (numberInPivotColumn > space) {
1220 if (positionLargest >= 0)
1221 positionLargest = positionLargest +
startColumnU[iColumn] - startColumn;
1228 for (j = 0; j < numberInPivotColumn; j++) {
1229 value = work[j] - thisPivotValue * multipliersL[j];
1230 double absValue = fabs(value);
1232 if (absValue > tolerance) {
1237 if (absValue > largest) {
1239 positionLargest = put;
1248 if (temp2[word] & (1 << bit)) {
1251 int start = startRowU[iRow];
1255 while (indexColumnU[where] != iColumn) {
1263 indexColumnU[where] = indexColumnU[end - 1];
1270 temp2[word] = temp2[word] | (1 << bit);
1276 if (positionLargest >= 0) {
1290 temp2 += increment2;
1293 unsigned int *putBase = workArea2;
1302 unsigned int *putThis = putBase;
1303 int iRow = indexL[i];
1309 for (jColumn = 0; jColumn < numberInPivotRow; jColumn++) {
1310 unsigned int test = *putThis;
1312 putThis += increment2;
1313 test = 1 - ((test >> bit) & 1);
1316 int next = nextRow[iRow];
1319 space = startRowU[next] - startRowU[iRow];
1321 if (space < number) {
1328 next = nextRow[iRow];
1330 int end = startRowU[iRow] + number;
1331 int saveIndex = indexColumnU[startRowU[next]];
1334 for (jColumn = 0; jColumn < numberInPivotRow; jColumn++) {
1335 unsigned int test = *putThis;
1337 putThis += increment2;
1338 test = 1 - ((test >> bit) & 1);
1339 indexColumnU[end] = saveColumn[jColumn];
1343 indexColumnU[startRowU[next]] = saveIndex;
1344 markRow[iRow] =
static_cast< T
>(largeInteger + 1);
1345 number = end - startRowU[iRow];
1354 for (bit = 0; i < numberInPivotColumn; i++, bit++) {
1355 unsigned int *putThis = putBase;
1356 int iRow = indexL[i];
1362 for (jColumn = 0; jColumn < numberInPivotRow; jColumn++) {
1363 unsigned int test = *putThis;
1365 putThis += increment2;
1366 test = 1 - ((test >> bit) & 1);
1369 int next = nextRow[iRow];
1372 space = startRowU[next] - startRowU[iRow];
1374 if (space < number) {
1381 next = nextRow[iRow];
1383 int end = startRowU[iRow] + number;
1386 saveIndex = indexColumnU[startRowU[next]];
1389 for (jColumn = 0; jColumn < numberInPivotRow; jColumn++) {
1390 unsigned int test = *putThis;
1392 putThis += increment2;
1393 test = 1 - ((test >> bit) & 1);
1395 indexColumnU[end] = saveColumn[jColumn];
1398 indexColumnU[startRowU[next]] = saveIndex;
1399 markRow[iRow] =
static_cast< T
>(largeInteger + 1);
1400 number = end - startRowU[iRow];
1405 markRow[pivotRow] =
static_cast< T
>(largeInteger + 1);
1423 #ifndef COIN_FAST_CODE
1428 #define slackValue_ -1.0
1658 #define collectStatistics_ 1
1678 #if ABOCA_LITE_FACTORIZATION
1692 #ifdef ABC_USE_COIN_FACTORIZATION
1699 #ifdef INTEL_COMPILER
1700 #define COIN_FACTORIZATION_DENSE_CODE 3
1702 #ifdef COIN_HAS_LAPACK
1703 #ifndef COIN_FACTORIZATION_DENSE_CODE
1704 #define COIN_FACTORIZATION_DENSE_CODE 1
1707 #ifdef COIN_FACTORIZATION_DENSE_CODE
1712 typedef const int cipfint;
1717 #ifdef UGLY_COIN_FACTOR_CODING
1718 #define FAC_UNSET (FAC_SET + 1)
1722 int startColumnThis = startColumn[iPivotColumn];
1723 int endColumn = startColumnThis + numberDoColumn + 1;
1725 int startRowThis = startRow[iPivotRow];
1726 int endRow = startRowThis + numberDoRow + 1;
1727 if (pivotColumnPosition < 0) {
1728 for (pivotColumnPosition = startRowThis; pivotColumnPosition < endRow; pivotColumnPosition++) {
1729 int iColumn = indexColumn[pivotColumnPosition];
1730 if (iColumn != iPivotColumn) {
1731 saveColumn[put++] = iColumn;
1737 for (
int i = startRowThis; i < pivotColumnPosition; i++) {
1738 saveColumn[put++] = indexColumn[i];
1741 assert(pivotColumnPosition < endRow);
1742 assert(indexColumn[pivotColumnPosition] == iPivotColumn);
1743 pivotColumnPosition++;
1744 for (; pivotColumnPosition < endRow; pivotColumnPosition++) {
1745 saveColumn[put++] = indexColumn[pivotColumnPosition];
1748 int next = nextRow[iPivotRow];
1749 int last = lastRow[iPivotRow];
1751 nextRow[last] = next;
1752 lastRow[next] = last;
1753 nextRow[iPivotRow] = numberGoodU_;
1754 lastRow[iPivotRow] = -2;
1755 numberInRow[iPivotRow] = 0;
1760 if (l + numberDoColumn > lengthAreaL_) {
1762 if ((messageLevel_ & 4) != 0)
1763 printf(
"more memory needed in middle of invert\n");
1769 int *startColumnL = startColumnL_.array();
1770 startColumnL[numberGoodL_] = l;
1772 startColumnL[numberGoodL_] = l + numberDoColumn;
1773 lengthL_ += numberDoColumn;
1774 if (pivotRowPosition < 0) {
1775 for (pivotRowPosition = startColumnThis; pivotRowPosition < endColumn; pivotRowPosition++) {
1776 int iRow = indexRow[pivotRowPosition];
1777 if (iRow != iPivotRow) {
1778 indexRowL[l] = iRow;
1779 elementL[l] = element[pivotRowPosition];
1780 markRow[iRow] = l - lSave;
1783 int start = startRow[iRow];
1784 int end = start + numberInRow[iRow];
1787 while (indexColumn[where] != iPivotColumn) {
1795 indexColumn[where] = indexColumn[end - 1];
1796 numberInRow[iRow]--;
1804 for (i = startColumnThis; i < pivotRowPosition; i++) {
1805 int iRow = indexRow[i];
1807 markRow[iRow] = l - lSave;
1808 indexRowL[l] = iRow;
1809 elementL[l] = element[i];
1812 int start = startRow[iRow];
1813 int end = start + numberInRow[iRow];
1816 while (indexColumn[where] != iPivotColumn) {
1824 indexColumn[where] = indexColumn[end - 1];
1825 numberInRow[iRow]--;
1826 assert(numberInRow[iRow] >= 0);
1829 assert(pivotRowPosition < endColumn);
1830 assert(indexRow[pivotRowPosition] == iPivotRow);
1834 pivotRegion_.array()[numberGoodU_] = pivotMultiplier;
1836 for (; pivotRowPosition < endColumn; pivotRowPosition++) {
1837 int iRow = indexRow[pivotRowPosition];
1839 markRow[iRow] = l - lSave;
1840 indexRowL[l] = iRow;
1841 elementL[l] = element[pivotRowPosition];
1844 int start = startRow[iRow];
1845 int end = start + numberInRow[iRow];
1848 while (indexColumn[where] != iPivotColumn) {
1856 indexColumn[where] = indexColumn[end - 1];
1857 numberInRow[iRow]--;
1858 assert(numberInRow[iRow] >= 0);
1860 markRow[iPivotRow] = FAC_SET;
1862 numberInColumn[iPivotColumn] = 0;
1864 int *indexL = &indexRowL[lSave];
1870 for (j = 0; j < numberDoColumn; j++) {
1871 multipliersL[j] *= pivotMultiplier;
1875 for (iErase = 0; iErase < increment2 * numberDoRow;
1877 workArea2[iErase] = 0;
1879 int added = numberDoRow * numberDoColumn;
1880 unsigned int *temp2 = workArea2;
1881 int *nextColumn = nextColumn_.array();
1885 for (jColumn = 0; jColumn < numberDoRow; jColumn++) {
1886 int iColumn = saveColumn[jColumn];
1887 int startColumnThis = startColumn[iColumn];
1888 int endColumn = startColumnThis + numberInColumn[iColumn];
1889 int iRow = indexRow[startColumnThis];
1892 int put = startColumnThis;
1893 int positionLargest = -1;
1898 int mark = markRow[iRow];
1900 if (mark == FAC_UNSET) {
1901 largest = fabs(value);
1902 positionLargest = put;
1904 checkLargest =
false;
1908 checkLargest =
true;
1909 if (mark != FAC_SET) {
1911 workArea[mark] = value;
1915 temp2[word] = temp2[word] | (1 << bit);
1918 thisPivotValue = value;
1922 for (i = startColumnThis + 1; i < endColumn; i++) {
1925 int mark = markRow[iRow];
1927 if (mark == FAC_UNSET) {
1929 indexRow[put] = iRow;
1930 element[put] = value;
1932 double absValue = fabs(value);
1934 if (absValue > largest) {
1936 positionLargest = put;
1940 }
else if (mark != FAC_SET) {
1942 workArea[mark] = value;
1946 temp2[word] = temp2[word] | (1 << bit);
1949 thisPivotValue = value;
1953 element[put] = element[startColumnThis];
1954 indexRow[put] = indexRow[startColumnThis];
1955 if (positionLargest == startColumnThis) {
1956 positionLargest = put;
1959 element[startColumnThis] = thisPivotValue;
1960 indexRow[startColumnThis] = iPivotRow;
1963 numberInColumn[iColumn] = put - startColumnThis;
1964 int *numberInColumnPlus = numberInColumnPlus_.array();
1965 numberInColumnPlus[iColumn]++;
1966 startColumn[iColumn]++;
1968 int next = nextColumn[iColumn];
1971 space = startColumn[next] - put - numberInColumnPlus[next];
1973 if (numberDoColumn > space) {
1975 if (!getColumnSpace(iColumn, numberDoColumn)) {
1979 positionLargest = positionLargest + startColumn[iColumn] - startColumnThis;
1980 startColumnThis = startColumn[iColumn];
1981 put = startColumnThis + numberInColumn[iColumn];
1983 double tolerance = zeroTolerance_;
1985 int *nextCount = nextCount_.array();
1986 for (j = 0; j < numberDoColumn; j++) {
1987 value = workArea[j] - thisPivotValue * multipliersL[j];
1988 double absValue = fabs(value);
1990 if (absValue > tolerance) {
1992 element[put] = value;
1993 indexRow[put] = indexL[j];
1994 if (absValue > largest) {
1996 positionLargest = put;
2005 if (temp2[word] & (1 << bit)) {
2008 int start = startRow[iRow];
2009 int end = start + numberInRow[iRow];
2012 while (indexColumn[where] != iColumn) {
2020 indexColumn[where] = indexColumn[end - 1];
2021 numberInRow[iRow]--;
2027 temp2[word] = temp2[word] | (1 << bit);
2031 numberInColumn[iColumn] = put - startColumnThis;
2033 if (positionLargest >= 0) {
2034 value = element[positionLargest];
2035 iRow = indexRow[positionLargest];
2036 element[positionLargest] = element[startColumnThis];
2037 indexRow[positionLargest] = indexRow[startColumnThis];
2038 element[startColumnThis] = value;
2039 indexRow[startColumnThis] = iRow;
2042 if (nextCount[iColumn + numberRows_] != -2) {
2044 deleteLink(iColumn + numberRows_);
2045 addLink(iColumn + numberRows_, numberInColumn[iColumn]);
2047 temp2 += increment2;
2050 unsigned int *putBase = workArea2;
2059 unsigned int *putThis = putBase;
2060 int iRow = indexL[i];
2066 for (jColumn = 0; jColumn < numberDoRow; jColumn++) {
2067 unsigned int test = *putThis;
2069 putThis += increment2;
2070 test = 1 - ((test >> bit) & 1);
2073 int next = nextRow[iRow];
2076 space = startRow[next] - startRow[iRow];
2077 number += numberInRow[iRow];
2078 if (space < number) {
2079 if (!getRowSpace(iRow, number)) {
2085 next = nextRow[iRow];
2086 number = numberInRow[iRow];
2087 int end = startRow[iRow] + number;
2088 int saveIndex = indexColumn[startRow[next]];
2091 for (jColumn = 0; jColumn < numberDoRow; jColumn++) {
2092 unsigned int test = *putThis;
2094 putThis += increment2;
2095 test = 1 - ((test >> bit) & 1);
2096 indexColumn[end] = saveColumn[jColumn];
2100 indexColumn[startRow[next]] = saveIndex;
2101 markRow[iRow] = FAC_UNSET;
2102 number = end - startRow[iRow];
2103 numberInRow[iRow] = number;
2105 addLink(iRow, number);
2111 for (bit = 0; i < numberDoColumn; i++, bit++) {
2112 unsigned int *putThis = putBase;
2113 int iRow = indexL[i];
2119 for (jColumn = 0; jColumn < numberDoRow; jColumn++) {
2120 unsigned int test = *putThis;
2122 putThis += increment2;
2123 test = 1 - ((test >> bit) & 1);
2126 int next = nextRow[iRow];
2129 space = startRow[next] - startRow[iRow];
2130 number += numberInRow[iRow];
2131 if (space < number) {
2132 if (!getRowSpace(iRow, number)) {
2138 next = nextRow[iRow];
2139 number = numberInRow[iRow];
2140 int end = startRow[iRow] + number;
2143 saveIndex = indexColumn[startRow[next]];
2146 for (jColumn = 0; jColumn < numberDoRow; jColumn++) {
2147 unsigned int test = *putThis;
2149 putThis += increment2;
2150 test = 1 - ((test >> bit) & 1);
2152 indexColumn[end] = saveColumn[jColumn];
2155 indexColumn[startRow[next]] = saveIndex;
2156 markRow[iRow] = FAC_UNSET;
2157 number = end - startRow[iRow];
2158 numberInRow[iRow] = number;
2160 addLink(iRow, number);
2162 markRow[iPivotRow] = FAC_UNSET;
2164 deleteLink(iPivotRow);
2165 deleteLink(iPivotColumn + numberRows_);
2166 totalElements_ += added;
int deleteRow(int Row)
Deletes one Row from basis, returns rank.
int add(int numberElements, int indicesRow[], int indicesColumn[], double elements[])
Adds given elements to Basis and updates factorization, can increase size of basis.
bool pivotRowSingleton(int pivotRow, int pivotColumn)
Does one pivot on Row Singleton in factorization.
void checkConsistency()
Checks that row and column copies look OK.
void relaxAccuracyCheck(double value)
Allows change of pivot accuracy check 1.0 == none >1.0 relaxed.
void setNumberElementsU(int value)
Setss number in U area.
void gutsOfInitialize(int type)
1 bit - tolerances etc, 2 more, 4 dummy arrays
CoinIntArrayWithLength numberInRow_
Number in each Row.
int numberColumnsExtra_
Number of Columns after iterating.
void cleanup()
Cleans up at end of factorization.
int maximumPivots_
Maximum number of pivots before factorization.
int lengthAreaL() const
Returns length of L area.
int lengthAreaR_
length of area reserved for R
int numberGoodColumns() const
Number of good columns in factorization.
double pivotTolerance() const
Pivot tolerance.
void updateColumnTransposeRDensish(CoinIndexedVector *region) const
Updates part of column transpose (BTRANR) when dense.
void updateColumnTransposeLDensish(CoinIndexedVector *region) const
Updates part of column transpose (BTRANL) when densish by column.
double adjustedAreaFactor() const
Returns areaFactor but adjusted for dense.
void setDenseThreshold(int value)
Sets dense threshold.
double relaxCheck_
Relax check on accuracy in replaceColumn.
CoinIntArrayWithLength startRowU_
Start of each Row as pointer.
double conditionNumber() const
Condition number - product of pivots after factorization.
void replaceColumnU(CoinIndexedVector *regionSparse, int *deleted, int internalPivotRow)
Combines BtranU and delete elements If deleted is NULL then delete elements otherwise store where ele...
void updateColumnTransposeUSparse(CoinIndexedVector *region) const
Updates part of column transpose (BTRANU) when sparse, assumes index is sorted i.e.
int addColumn(int numberElements, int indicesRow[], double elements[])
Adds one Column to basis, can increase size of basis.
int updateColumnFT(CoinIndexedVector *regionSparse, CoinIndexedVector *regionSparse2)
Updates one column (FTRAN) from regionSparse2 Tries to do FT update number returned is negative if no...
CoinFactorizationDoubleArrayWithLength elementByRowL_
Elements in L (row copy)
CoinIntArrayWithLength lastCount_
Previous Row/Column with count.
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 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.
int factorSparseSmall()
Does sparse phase of factorization (for smaller problems) return code is <0 error,...
int numberGoodL_
Number factorized in L.
void setCollectStatistics(bool onOff) const
For statistics.
int factorizePart1(int numberRows, int numberColumns, int 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.
int factorize(const CoinPackedMatrix &matrix, int rowIsBasic[], int columnIsBasic[], double areaFactor=0.0)
When part of LP - given by basic variables.
bool spaceForForrestTomlin() const
True if FT update and space.
CoinIntArrayWithLength numberInColumn_
Number in each Column.
int restoreFactorization(const char *file, bool factor=false)
Debug - restore from file - 0 if no error on file.
#define COINFACTORIZATION_SHIFT_PER_INT
void updateTwoColumnsTranspose(CoinIndexedVector *regionSparse, CoinIndexedVector *regionSparse2, CoinIndexedVector *regionSparse3, int type) const
Updates two columns (BTRAN) from regionSparse2 and 3 regionSparse starts as zero and is zero at end N...
int maximumPivots() const
Maximum number of pivots between factorizations.
#define COINFACTORIZATION_BITS_PER_INT
int * startColumnL() const
Start of each column in L.
int sparseThreshold() const
get sparse threshold
int factor()
Does most of factorization.
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.
CoinIntArrayWithLength startRowL_
Start of each row in L.
void setPersistenceFlag(int value)
double zeroTolerance() const
Zero tolerance.
void getAreas(int numberRows, int numberColumns, int maximumL, int maximumU)
Gets space for a factorization, called by constructors.
CoinFactorizationDouble * elementByRowL() const
Elements in L (row copy)
void gutsOfCopy(const CoinFactorization &other)
CoinFactorizationDoubleArrayWithLength pivotRegion_
Inverses of pivot values.
int numberPivots_
Number pivots since last factorization.
#define collectStatistics_
For statistics.
int numberRowsExtra() const
Number of Rows after iterating.
int maximumRowsExtra_
Maximum number of Rows after iterating.
int totalElements_
Number of elements in U (to go) or while iterating total overall.
CoinFactorizationDouble * array() const
Get Array.
int sparseThreshold_
Below this use sparse technology - if 0 then no L row copy.
int numberL() const
Number in L.
int numberElementsR() const
Returns number in R area.
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 numberCompressions_
Number of compressions done.
int numberRows() const
Number of Rows after factorization.
int getColumnSpaceIterate(int iColumn, double value, int iRow)
getColumnSpaceIterate.
CoinIntArrayWithLength firstCount_
First Row/Column with count of k, can tell which by offset - Rows then Columns.
int numberElementsL() const
Returns number in L area.
void updateColumnUSparse(CoinIndexedVector *regionSparse, int *indexIn) const
Updates part of column (FTRANU) when sparse.
void almostDestructor()
Delete all stuff (leaves as after CoinFactorization())
CoinIntArrayWithLength startColumnL_
Start of each column in L.
bool doForrestTomlin_
true if Forrest Tomlin update, false if PFI
void setPivots(int value)
Sets number of pivots since factorization.
CoinIntArrayWithLength lastRow_
Previous Row in memory order.
int lengthAreaL_
Length of area reserved for L.
int updateColumnUDensish(double *COIN_RESTRICT region, int *COIN_RESTRICT regionIndex) const
Updates part of column (FTRANU)
void setForrestTomlin(bool value)
double * denseAreaAddress_
Dense area - actually used (for alignment etc)
int denseThreshold_
Dense threshold.
void setStatus(int value)
Sets status.
void updateColumnL(CoinIndexedVector *region, int *indexIn) const
Updates part of column (FTRANL)
void deleteLink(int index)
Deletes a link in chain of equal counts.
CoinIntArrayWithLength lastColumn_
Previous Column in memory order.
CoinFactorizationDoubleArrayWithLength elementL_
Elements of L.
void updateColumnU(CoinIndexedVector *region, int *indexIn) const
Updates part of column (FTRANU)
double areaFactor() const
Whether larger areas needed.
int * array() const
Get Array.
double ftranAverageAfterU_
double btranAverageAfterU_
int numberForrestTomlin() const
Length of FT vector.
int maximumColumnsExtra()
Maximum number of Columns after iterating.
int * pivotColumnBack() const
Returns address of pivotColumnBack region (also used for permuting) Now uses firstCount to save memor...
int * numberInColumn() const
Number of entries in each column.
int checkPivot(double saveFromU, double oldPivot) const
Returns accuracy status of replaceColumn returns 0=OK, 1=Probably OK, 2=singular.
friend void CoinFactorizationUnitTest(const std::string &mpsDir)
void show_self() const
Debug show object (shows one representation)
int biasLU_
L to U bias 0 - U bias, 1 - some U bias, 2 some L bias, 3 L bias.
void updateColumnTransposeUByColumn(CoinIndexedVector *region, int smallestIndex) const
Updates part of column transpose (BTRANU) by column assumes index is sorted i.e.
void updateColumnTransposeL(CoinIndexedVector *region) const
Updates part of column transpose (BTRANL)
void updateColumnTransposeUSparsish(CoinIndexedVector *region, int smallestIndex) const
Updates part of column transpose (BTRANU) when sparsish, assumes index is sorted i....
void updateColumnLSparsish(CoinIndexedVector *region, int *indexIn) const
Updates part of column (FTRANL) when sparsish.
double zeroTolerance_
Zero tolerance.
void updateColumnTransposeRSparse(CoinIndexedVector *region) const
Updates part of column transpose (BTRANR) when sparse.
CoinFactorizationDoubleArrayWithLength elementU_
Elements of U.
CoinIntArrayWithLength pivotRowL_
Pivots for L.
CoinFactorizationDouble * elementR_
Elements of R.
~CoinFactorization()
Destructor.
This deals with Factorization and Updates.
int numberTrials_
0 - no increasing rows - no permutations, 1 - no increasing rows but permutations 2 - increasing rows
CoinFactorizationDoubleArrayWithLength workArea_
First work area.
void resetStatistics()
Reset all sparsity etc statistics.
int factorSparseLarge()
Does sparse phase of factorization (for larger problems) return code is <0 error, 0= finished.
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.
CoinFactorization()
Default constructor.
int numberGoodU_
Number factorized in U (not row singletons)
bool collectStatistics() const
For statistics.
double ftranAverageAfterR_
int lengthR_
Length of R stuff.
int * indexRowR_
Row indices for R.
double CoinFactorizationDouble
int * indexRowL() const
Row indices of L.
#define COINFACTORIZATION_MASK_PER_INT
int factorDense()
Does dense phase of factorization return code is <0 error, 0= finished.
double btranAverageAfterL_
void updateColumnTransposeR(CoinIndexedVector *region) const
Updates part of column transpose (BTRANR)
int * permuteBack() const
Returns address of permuteBack region.
void updateColumnLDensish(CoinIndexedVector *region, int *indexIn) const
Updates part of column (FTRANL) when densish.
CoinIntArrayWithLength permuteBack_
DePermutation vector for pivot row order.
int saveFactorization(const char *file) const
Debug - save on file - 0 if no error.
CoinFactorization & operator=(const CoinFactorization &other)
= copy
CoinIntArrayWithLength indexColumnU_
Base address for U (may change)
void updateOneColumnTranspose(CoinIndexedVector *regionWork, int &statistics) const
Part of twocolumnsTranspose.
int lengthAreaU() const
Returns length of U area.
int updateColumnTranspose(CoinIndexedVector *regionSparse, CoinIndexedVector *regionSparse2) const
Updates one column (BTRAN) from regionSparse2 regionSparse starts as zero and is zero at end Note - i...
CoinIntArrayWithLength pivotColumnBack_
Inverse Pivot order for each Column.
int numberCompressions() const
Number of compressions done.
CoinIntArrayWithLength indexRowL_
Row indices of L.
double getAccuracyCheck() const
double maximumCoefficient() const
Returns maximum absolute value in factorization.
double slackValue_
Whether slack value is +1 or -1.
double pivotTolerance_
Pivot tolerance.
CoinIntArrayWithLength indexColumnL_
Index of column in row for L.
bool getColumnSpace(int iColumn, int extraNeeded)
Gets space for one Column with given length, may have to do compression (returns True if successful),...
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 permute_
Permutation vector for pivot row order.
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 numberRowsExtra_
Number of Rows after iterating.
int numberDense() const
Returns number of dense rows.
int * densePermute_
Dense permutation.
int factorSparse()
Does sparse phase of factorization return code is <0 error, 0= finished.
int * lastRow() const
Returns address of lastRow region.
int * permute() const
Returns address of permute region.
void updateColumnTransposeUDensish(CoinIndexedVector *region, int smallestIndex) const
Updates part of column transpose (BTRANU) when densish, assumes index is sorted i....
void updateColumnPFI(CoinIndexedVector *regionSparse) const
Updates part of column PFI (FTRAN) (after rest)
int numberElementsU() const
Returns number in U area.
int * indexColumnL() const
Index of column in row for L.
int deleteColumn(int Row)
Deletes one Column from basis, returns rank.
int numberDense_
Number of dense rows.
int messageLevel_
Detail in messages.
void updateColumnTransposeLSparsish(CoinIndexedVector *region) const
Updates part of column transpose (BTRANL) when sparsish by row.
int addRow(int numberElements, int indicesColumn[], double elements[])
Adds one Row to basis, can increase size of basis.
int factorElements_
Number of elements after factorization.
CoinIntArrayWithLength startColumnR_
Start of columns for R.
void setBiasLU(int value)
CoinIntArrayWithLength nextCount_
Next Row/Column with count.
void addLink(int index, int count)
Adds a link in chain of equal counts.
int status() const
Returns status.
int sparseThreshold2_
And one for "sparsish".
int maximumRowsExtra() const
Maximum of Rows after iterating.
Sparse Matrix Base Class.
void preProcess(int state, int possibleDuplicates=-1)
PreProcesses raw triplet data.
int * indexRowU() const
Row indices of U.
void updateColumnR(CoinIndexedVector *region) const
Updates part of column (FTRANR) without FT update.
int lengthAreaU_
Length of area reserved for U.
void gutsOfDestructor(int type=1)
The real work of constructors etc 0 just scalars, 1 bit normal.
CoinIntArrayWithLength indexRowU_
Row indices of U.
CoinFactorizationDouble * version.
int pivots() const
Returns number of pivots since factorization.
bool reorderU()
Reorders U so contiguous and in order (if there is space) Returns true if it could.
int numberColumns() const
Total number of columns in factorization.
CoinIntArrayWithLength startColumnU_
Start of each column in U.
void emptyRows(int numberToEmpty, const int which[])
Takes out all entries for given rows.
bool pivotColumnSingleton(int pivotRow, int pivotColumn)
Does one pivot on Column Singleton in factorization.
int maximumColumnsExtra_
Maximum number of Columns after iterating.
void updateColumnRFT(CoinIndexedVector *region, int *indexIn)
Updates part of column (FTRANR) with FT update.
CoinFactorizationDouble * elementU() const
Elements of U.
int * startRowL() const
Start of each row in L.
bool getRowSpace(int iRow, int extraNeeded)
Gets space for one Row with given length, may have to do compression (returns True if successful),...
void sort() const
Debug - sort so can compare.
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 messageLevel() const
Level of detail of messages.
void areaFactor(double value)
int * pivotColumn() const
Returns address of pivotColumn region (also used for permuting)
int maximumU_
Maximum space used in U.
CoinIntArrayWithLength sparse_
Sparse regions.
bool getColumnSpaceIterateR(int iColumn, double value, int iRow)
getColumnSpaceIterateR.
int numberElements() const
Total number of elements in factorization.
CoinFactorizationDouble * pivotRegion() const
Returns address of pivot region.
double ftranAverageAfterL_
While these are average ratios collected over last period.
double ftranCountInput_
Below are all to collect.
double * denseArea_
Dense area.
void updateColumnUSparsish(CoinIndexedVector *regionSparse, int *indexIn) const
Updates part of column (FTRANU) when sparsish.
void updateColumnTransposeU(CoinIndexedVector *region, int smallestIndex) const
Updates part of column transpose (BTRANU), assumes index is sorted i.e.
bool pivotOneOtherRow(int pivotRow, int pivotColumn)
Pivots when just one other row so faster?
int biggerDimension_
Larger of row and column size.
CoinIntArrayWithLength pivotColumn_
Pivot order for each Column.
int factorizePart2(int permutation[], int exactNumberElements)
This is part two of factorization Arrays belong to factorization and were returned by part 1 If statu...
CoinIntArrayWithLength nextColumn_
Next Column in memory order.
int lengthU_
Base of U is always 0.
int numberColumns_
Number of Columns in factorization.
CoinIntArrayWithLength nextRow_
Next Row in memory order.
CoinIntArrayWithLength convertRowToColumnU_
Converts rows to columns in U.
CoinIntArrayWithLength numberInColumnPlus_
Number in each Column including pivoted.
void updateColumnLSparse(CoinIndexedVector *region, int *indexIn) const
Updates part of column (FTRANL) when sparse.
bool pivot(int pivotRow, int pivotColumn, int pivotRowPosition, int pivotColumnPosition, CoinFactorizationDouble work[], unsigned int workArea2[], int increment2, T markRow[], int largeInteger)
void checkSparse()
See if worth going sparse.
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.
void updateColumnTransposeLByRow(CoinIndexedVector *region) const
Updates part of column transpose (BTRANL) when densish by row.
CoinIntArrayWithLength saveColumn_
Columns left to do in a single pivot.
int * numberInRow() const
Number of entries in each row.
double slackValue() const
Whether slack value is +1 or -1.
void separateLinks(int count, bool rowsFirst)
Separate out links with same row/column count.
int baseL() const
Base of L.
void clearArrays()
Get rid of all memory.
int numberFtranCounts_
We can roll over factorizations.
bool forrestTomlin() const
true if Forrest Tomlin update, false if PFI
CoinUnsignedIntArrayWithLength workArea2_
Second work area.
void updateColumnTransposeLSparse(CoinIndexedVector *region) const
Updates part of column transpose (BTRANL) when sparse (by Row)
int * startColumnU() const
Start of each column in U.
void updateColumnTransposePFI(CoinIndexedVector *region) const
Updates part of column transpose PFI (BTRAN) (before rest)
void goSparse()
makes a row copy of L for speed and to allow very sparse problems
double btranAverageAfterR_
double areaFactor_
How much to multiply areas by.
void setNumberRows(int value)
Set number of Rows after factorization.
int denseThreshold() const
Gets dense threshold.
CoinIntArrayWithLength markRow_
Marks rows to be updated.
int status_
Status of factorization.
int numberSlacks_
Number of slacks at beginning of U.