| 848 | } |
| 849 | |
| 850 | HighsDebugStatus HEkk::debugBasisConsistent() const { |
| 851 | // Cheap analysis of a Simplex basis, checking vector sizes, numbers |
| 852 | // of basic/nonbasic variables and non-repetition of basic variables |
| 853 | if (this->options_->highs_debug_level < kHighsDebugLevelCheap) |
| 854 | return HighsDebugStatus::kNotChecked; |
| 855 | HighsDebugStatus return_status = HighsDebugStatus::kOk; |
| 856 | const HighsOptions& options = *(this->options_); |
| 857 | const HighsLp& lp = this->lp_; |
| 858 | const SimplexBasis& basis = this->basis_; |
| 859 | // Check consistency of nonbasicFlag |
| 860 | if (this->debugNonbasicFlagConsistent() == HighsDebugStatus::kLogicalError) { |
| 861 | highsLogDev(options.log_options, HighsLogType::kError, |
| 862 | "nonbasicFlag inconsistent\n"); |
| 863 | return_status = HighsDebugStatus::kLogicalError; |
| 864 | } |
| 865 | const bool right_size = (HighsInt)basis.basicIndex_.size() == lp.num_row_; |
| 866 | // Check consistency of basicIndex |
| 867 | if (!right_size) { |
| 868 | highsLogDev(options.log_options, HighsLogType::kError, |
| 869 | "basicIndex size error\n"); |
| 870 | assert(right_size); |
| 871 | return_status = HighsDebugStatus::kLogicalError; |
| 872 | } |
| 873 | // Use localNonbasicFlag so that duplicate entries in basicIndex can |
| 874 | // be spotted |
| 875 | vector<int8_t> localNonbasicFlag = basis.nonbasicFlag_; |
| 876 | for (HighsInt iRow = 0; iRow < lp.num_row_; iRow++) { |
| 877 | HighsInt iCol = basis.basicIndex_[iRow]; |
| 878 | HighsInt flag = localNonbasicFlag[iCol]; |
| 879 | // Indicate that this column has been found in basicIndex |
| 880 | localNonbasicFlag[iCol] = -1; |
| 881 | if (flag) { |
| 882 | // Nonzero value for localNonbasicFlag entry means that column is either |
| 883 | if (flag == kNonbasicFlagTrue) { |
| 884 | // Nonbasic... |
| 885 | highsLogDev(options.log_options, HighsLogType::kError, |
| 886 | "Entry basicIndex_[%" HIGHSINT_FORMAT |
| 887 | "] = %" HIGHSINT_FORMAT " is not basic\n", |
| 888 | iRow, iCol); |
| 889 | } else { |
| 890 | // .. or is -1 since it has already been found in basicIndex |
| 891 | highsLogDev(options.log_options, HighsLogType::kError, |
| 892 | "Entry basicIndex_[%" HIGHSINT_FORMAT |
| 893 | "] = %" HIGHSINT_FORMAT " is already basic\n", |
| 894 | iRow, iCol); |
| 895 | assert(flag == -1); |
| 896 | } |
| 897 | assert(!flag); |
| 898 | return_status = HighsDebugStatus::kLogicalError; |
| 899 | } |
| 900 | } |
| 901 | return return_status; |
| 902 | } |
| 903 | |
| 904 | HighsDebugStatus HEkk::debugNonbasicFlagConsistent() const { |
| 905 | if (this->options_->highs_debug_level < kHighsDebugLevelCheap) |
no test coverage detected