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 
11 #ifndef HIGHS_MIP_SOLVER_DATA_H_
12 #define HIGHS_MIP_SOLVER_DATA_H_
13 
14 #include <vector>
15 
16 #include "mip/HighsCliqueTable.h"
17 #include "mip/HighsCutPool.h"
18 #include "mip/HighsDomain.h"
19 #include "mip/HighsImplications.h"
20 #include "mip/HighsLpRelaxation.h"
21 #include "mip/HighsNodeQueue.h"
22 #include "mip/HighsPseudocost.h"
23 #include "mip/HighsSearch.h"
24 #include "mip/HighsSeparation.h"
25 #include "util/HighsTimer.h"
26 
27 #ifdef HIGHS_DEBUGSOL
28 extern std::vector<double> highsDebugSolution;
29 #endif
30 
31 struct HighsMipSolverData {
32   HighsMipSolver& mipsolver;
33   HighsCutPool cutpool;
34   HighsDomain domain;
35   HighsLpRelaxation lp;
36   HighsPseudocost pseudocost;
37   HighsCliqueTable cliquetable;
38   HighsImplications implications;
39   struct Substitution {
40     int substcol;
41     int staycol;
42     double scale;
43     double offset;
44   };
45   std::vector<Substitution> substitutions;
46 
47   struct ModelCleanup {
48     ModelCleanup(HighsMipSolver& mipsolver);
49 
50     std::vector<double> origsol;
51     std::vector<HighsSubstitution> substitutionStack;
52 
53     HighsLp cleanedUpModel;
54 
55     void recoverSolution(const std::vector<double>& reducedSol);
56 
57     const HighsLp* origmodel;
58     std::vector<int> rIndex;
59     std::vector<int> cIndex;
60   };
61 
62   bool cliquesExtracted;
63   bool rowMatrixSet;
64   bool tryProbing;
65   std::unique_ptr<ModelCleanup> modelcleanup;
66 
67   std::vector<int> ARstart_;
68   std::vector<int> ARindex_;
69   std::vector<double> ARvalue_;
70   std::vector<double> maxAbsRowCoef;
71   std::vector<uint8_t> rowintegral;
72   double objintscale;
73 
74   double feastol;
75   double epsilon;
76   double heuristic_effort;
77   size_t dispfreq;
78   std::vector<double> firstlpsol;
79   std::vector<double> rootlpsol;
80   double firstlpsolobj;
81   HighsBasis firstrootbasis;
82   double rootlpsolobj;
83 
84   HighsCDouble pruned_treeweight;
85   size_t maxrootlpiters;
86   size_t num_nodes;
87   size_t last_displeave;
88   size_t num_leaves;
89   size_t total_lp_iterations;
90   size_t heuristic_lp_iterations;
91   size_t sepa_lp_iterations;
92   size_t sb_lp_iterations;
93   size_t num_disp_lines;
94 
95   double lower_bound;
96   double upper_bound;
97   double upper_limit;
98   std::vector<double> incumbent;
99 
100   HighsNodeQueue nodequeue;
101 
HighsMipSolverDataHighsMipSolverData102   HighsMipSolverData(HighsMipSolver& mipsolver)
103       : mipsolver(mipsolver),
104         cutpool(mipsolver.numCol(), 10),
105         domain(mipsolver, cutpool),
106         lp(mipsolver),
107         pseudocost(mipsolver.numCol()),
108         cliquetable(mipsolver.numCol()),
109         implications(domain, cliquetable) {}
110 
111   void init();
112   void basisTransfer();
113   void checkObjIntegrality();
114   void cliqueExtraction();
115   void runSetup();
116   void runProbing();
117   void evaluateRootNode();
118   void addIncumbent(const std::vector<double>& sol, double solobj, char source);
119 
120   const std::vector<double>& getSolution() const;
121 
122   void printDisplayLine(char first = ' ');
123 
getRowHighsMipSolverData124   void getRow(int row, int& rowlen, const int*& rowinds,
125               const double*& rowvals) const {
126     int start = ARstart_[row];
127     rowlen = ARstart_[row + 1] - start;
128     rowinds = ARindex_.data() + start;
129     rowvals = ARvalue_.data() + start;
130   }
131 
132   bool checkLimits() const;
133 };
134 
135 #endif