MCPcopy Create free account
hub / github.com/ERGO-Code/HiGHS / analyseMatrixSparsity

Function analyseMatrixSparsity

highs/util/HighsUtils.cpp:561–697  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

559}
560
561void analyseMatrixSparsity(const HighsLogOptions& log_options,
562 const char* message, HighsInt numCol,
563 HighsInt numRow, const std::vector<HighsInt>& Astart,
564 const std::vector<HighsInt>& Aindex) {
565 if (numCol == 0) return;
566 std::vector<HighsInt> rowCount;
567 std::vector<HighsInt> colCount;
568
569 rowCount.assign(numRow, 0);
570 colCount.resize(numCol);
571
572 for (HighsInt col = 0; col < numCol; col++) {
573 colCount[col] = Astart[col + 1] - Astart[col];
574 for (HighsInt el = Astart[col]; el < Astart[col + 1]; el++)
575 rowCount[Aindex[el]]++;
576 }
577 analyseVectorValues(&log_options, "Column counts", numCol, colCount);
578 analyseVectorValues(&log_options, "Row counts", numRow, rowCount);
579
580 const HighsInt maxCat = 10;
581 std::vector<HighsInt> CatV;
582 std::vector<HighsInt> rowCatK;
583 std::vector<HighsInt> colCatK;
584 CatV.resize(maxCat + 1);
585 rowCatK.assign(maxCat + 1, 0);
586 colCatK.assign(maxCat + 1, 0);
587
588 CatV[1] = 1;
589 for (HighsInt cat = 2; cat < maxCat + 1; cat++) {
590 CatV[cat] = 2 * CatV[cat - 1];
591 }
592
593 HighsInt maxRowCount = 0;
594 HighsInt maxColCount = 0;
595 for (HighsInt col = 0; col < numCol; col++) {
596 maxColCount = std::max(colCount[col], maxColCount);
597 HighsInt fdCat = maxCat;
598 for (HighsInt cat = 0; cat < maxCat - 1; cat++) {
599 if (colCount[col] < CatV[cat + 1]) {
600 fdCat = cat;
601 break;
602 }
603 }
604 colCatK[fdCat]++;
605 }
606
607 for (HighsInt row = 0; row < numRow; row++) {
608 maxRowCount = std::max(rowCount[row], maxRowCount);
609 HighsInt fdCat = maxCat;
610 for (HighsInt cat = 0; cat < maxCat - 1; cat++) {
611 if (rowCount[row] < CatV[cat + 1]) {
612 fdCat = cat;
613 break;
614 }
615 }
616 rowCatK[fdCat]++;
617 }
618

Callers 1

analyseLpFunction · 0.85

Calls 3

analyseVectorValuesFunction · 0.85
highsLogDevFunction · 0.85
resizeMethod · 0.45

Tested by

no test coverage detected