1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /*                                                                       */
3 /*    This file is part of the HiGHS linear optimization suite           */
4 /*                                                                       */
5 /*    Written and engineered 2008-2021 at the University of Edinburgh    */
6 /*                                                                       */
7 /*    Available as open-source under the MIT License                     */
8 /*                                                                       */
9 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
10 /**@file lp_data/HSimplexDebug.h
11  * @brief
12  * @author Julian Hall, Ivet Galabova, Qi Huangfu and Michael Feldmeier
13  */
14 #ifndef SIMPLEX_HSIMPLEXDEBUG_H_
15 #define SIMPLEX_HSIMPLEXDEBUG_H_
16 
17 #include <set>
18 
19 #include "lp_data/HighsModelObject.h"
20 #include "lp_data/HighsOptions.h"
21 #include "simplex/SimplexConst.h"
22 
23 HighsDebugStatus debugSimplexLp(const HighsModelObject& highs_model_object);
24 
25 HighsDebugStatus debugSimplexBasisCorrect(
26     const HighsModelObject& highs_model_object);
27 
28 HighsDebugStatus debugBasisConsistent(const HighsOptions& options,
29                                       const HighsLp& simplex_lp,
30                                       const SimplexBasis& simplex_basis);
31 
32 HighsDebugStatus debugBasisRightSize(const HighsOptions& options,
33                                      const HighsLp& simplex_lp,
34                                      const SimplexBasis& simplex_basis);
35 
36 HighsDebugStatus debugSimplexInfoBasisRightSize(
37     const HighsModelObject& highs_model_object);
38 
39 HighsDebugStatus debugComputePrimal(const HighsModelObject& highs_model_object,
40                                     const std::vector<double>& primal_rhs);
41 
42 HighsDebugStatus debugComputeDual(const HighsModelObject& highs_model_object,
43                                   const std::vector<double>& previous_dual,
44                                   const std::vector<double>& basic_costs,
45                                   const std::vector<double>& row_dual);
46 
47 HighsDebugStatus debugSimplexDualFeasibility(
48     const HighsModelObject& highs_model_object, const std::string message,
49     const bool force = false);
50 
51 HighsDebugStatus debugUpdatedObjectiveValue(
52     HighsModelObject& highs_model_object, const SimplexAlgorithm algorithm,
53     const int phase, const std::string message, const bool force = false);
54 
55 HighsDebugStatus debugUpdatedObjectiveValue(
56     const HighsModelObject& highs_model_object,
57     const SimplexAlgorithm algorithm);
58 
59 HighsDebugStatus debugFixedNonbasicMove(
60     const HighsModelObject& highs_model_object);
61 HighsDebugStatus debugNonbasicMove(const HighsModelObject& highs_model_object);
62 HighsDebugStatus debugBasisCondition(const HighsModelObject& highs_model_object,
63                                      const std::string message);
64 HighsDebugStatus debugCleanup(HighsModelObject& highs_model_object,
65                               const std::vector<double>& original_dual);
66 HighsDebugStatus debugFreeListNumEntries(
67     const HighsModelObject& highs_model_object, const std::set<int>& freeList);
68 
69 HighsDebugStatus debugDualChuzcFail(
70     const HighsOptions& options, const int workCount,
71     const std::vector<std::pair<int, double>>& workData, const double* workDual,
72     const double selectTheta, const double remainTheta);
73 
74 void debugDualChuzcWorkDataAndGroupReport(
75     const HighsModelObject& highs_model_object, const double workDelta,
76     const double workTheta, const std::string message,
77     const int report_workCount,
78     const std::vector<std::pair<int, double>>& report_workData,
79     const std::vector<int>& report_workGroup);
80 HighsDebugStatus debugDualChuzcWorkDataAndGroup(
81     const HighsModelObject& highs_model_object, const double workDelta,
82     const double workTheta, const int workCount, const int alt_workCount,
83     const int breakIndex, const int alt_breakIndex,
84     const std::vector<std::pair<int, double>>& workData,
85     const std::vector<std::pair<int, double>>& sorted_workData,
86     const std::vector<int>& workGroup, const std::vector<int>& alt_workGroup);
87 
88 HighsDebugStatus debugSimplexBasicSolution(
89     const string message, const HighsModelObject& highs_model_object);
90 
91 HighsDebugStatus debugSimplexHighsSolutionDifferences(
92     const HighsModelObject& highs_model_object);
93 
94 HighsDebugStatus debugAssessSolutionNormDifference(const HighsOptions& options,
95                                                    const std::string type,
96                                                    const double difference);
97 
98 HighsDebugStatus debugNonbasicFlagConsistent(const HighsOptions& options,
99                                              const HighsLp& simplex_lp,
100                                              const SimplexBasis& simplex_basis);
101 
102 HighsDebugStatus debugOkForSolve(const HighsModelObject& highs_model_object,
103                                  const int phase);
104 
105 // Methods below are not called externally
106 
107 bool debugWorkArraysOk(const HighsModelObject& highs_model_object,
108                        const int phase);
109 
110 bool debugOneNonbasicMoveVsWorkArraysOk(
111     const HighsModelObject& highs_model_object, const int var);
112 
113 bool debugAllNonbasicMoveVsWorkArraysOk(
114     const HighsModelObject& highs_model_object);
115 
116 void debugReportReinvertOnNumericalTrouble(
117     const std::string method_name, const HighsModelObject& highs_model_object,
118     const double numerical_trouble_measure, const double alpha_from_col,
119     const double alpha_from_row, const double numerical_trouble_tolerance,
120     const bool reinvert);
121 #endif  // SIMPLEX_HSIMPLEXDEBUG_H_
122