1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the class library */
4 /* SoPlex --- the Sequential object-oriented simPlex. */
5 /* */
6 /* Copyright (C) 1996-2022 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SoPlex is distributed under the terms of the ZIB Academic Licence. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SoPlex; see the file COPYING. If not email to soplex@zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15
16 #include <iostream>
17
18 #include "soplex/spxdefines.h"
19 #include "soplex/spxbasis.h"
(1) Event include_recursion: |
#include file "/sapmnt/home1/d029903/my_work/SCIPSoPlex_coverity/scipoptsuite-8.0.1/soplex/src/soplex/spxsolver.h" includes itself: spxsolver.h -> spxbasis.h -> spxdesc.hpp -> spxsolver.h |
(2) Event caretline: |
^ |
20 #include "soplex/spxsolver.h"
21
22 namespace soplex
23 {
24
25 template <class R>
26 SPxBasisBase<R>::Desc::Desc(const SPxSolverBase<R>& base)
27 {
28 reSize(base.nRows(), base.nCols());
29
30 if(base.rep() == SPxSolverBase<R>::ROW)
31 {
32 stat = &rowstat;
33 costat = &colstat;
34 }
35 else
36 {
37 assert(base.rep() == SPxSolverBase<R>::COLUMN);
38
39 stat = &colstat;
40 costat = &rowstat;
41 }
42
43 assert(Desc::isConsistent());
44 }
45
46 template <class R>
47 SPxBasisBase<R>::Desc::Desc(const Desc& old)
48 : rowstat(old.rowstat)
49 , colstat(old.colstat)
50 {
51 if(old.stat == &old.rowstat)
52 {
53 assert(old.costat == &old.colstat);
54
55 stat = &rowstat;
56 costat = &colstat;
57 }
58 else
59 {
60 assert(old.costat == &old.rowstat);
61
62 stat = &colstat;
63 costat = &rowstat;
64 }
65
66 assert(Desc::isConsistent());
67 }
68
69 template <class R>
70 typename SPxBasisBase<R>::Desc& SPxBasisBase<R>::Desc::operator=(const typename
71 SPxBasisBase<R>::Desc& rhs)
72 {
73 if(this != &rhs)
74 {
75 rowstat = rhs.rowstat;
76 colstat = rhs.colstat;
77
78 if(rhs.stat == &rhs.rowstat)
79 {
80 assert(rhs.costat == &rhs.colstat);
81
82 stat = &rowstat;
83 costat = &colstat;
84 }
85 else
86 {
87 assert(rhs.costat == &rhs.rowstat);
88
89 stat = &colstat;
90 costat = &rowstat;
91 }
92
93 assert(Desc::isConsistent());
94 }
95
96 return *this;
97 }
98
99 template <class R>
100 void SPxBasisBase<R>::Desc::reSize(int rowDim, int colDim)
101 {
102
103 assert(rowDim >= 0);
104 assert(colDim >= 0);
105
106 int noldrows = rowstat.size();
107 int noldcols = colstat.size();
108
109 rowstat.reSize(rowDim);
110 colstat.reSize(colDim);
111
112 for(int i = rowDim - 1; i >= noldrows; i--)
113 rowstat[i] = D_UNDEFINED;
114
115 for(int i = colDim - 1; i >= noldcols; i--)
116 colstat[i] = D_UNDEFINED;
117 }
118
119 template <class R>
120 void SPxBasisBase<R>::Desc::dump() const
121 {
122 int i;
123
124 // Dump regardless of the verbosity level if this method is called.
125
126 std::cout << "DBDESC01 column status: ";
127
128 for(i = 0; i < nCols(); i++)
129 std::cout << static_cast<int>(colStatus(i));
130
131 std::cout << std::endl;
132
133 std::cout << "DBDESC02 row status: ";
134
135 for(i = 0; i < nRows(); i++)
136 std::cout << static_cast<int>(rowStatus(i));
137
138 std::cout << std::endl;
139 }
140
141 template <class R>
142 bool SPxBasisBase<R>::Desc::isConsistent() const
143 {
144 #ifdef ENABLE_CONSISTENCY_CHECKS
145 return rowstat.isConsistent() && colstat.isConsistent();
146 #else
147 return true;
148 #endif
149 }
150
151 template <class R>
152 std::ostream& operator<<(std::ostream& os, const typename SPxBasisBase<R>::Desc::Status& stat)
153 {
154 char text;
155
156 switch(stat)
157 {
158 case SPxBasisBase<R>::Desc::P_ON_LOWER :
159 text = 'L';
160 break;
161
162 case SPxBasisBase<R>::Desc::P_ON_UPPER :
163 text = 'U';
164 break;
165
166 case SPxBasisBase<R>::Desc::P_FREE :
167 text = 'F';
168 break;
169
170 case SPxBasisBase<R>::Desc::P_FIXED :
171 text = 'X';
172 break;
173
174 case SPxBasisBase<R>::Desc::D_FREE :
175 text = 'f';
176 break;
177
178 case SPxBasisBase<R>::Desc::D_ON_UPPER :
179 text = 'u';
180 break;
181
182 case SPxBasisBase<R>::Desc::D_ON_LOWER :
183 text = 'l';
184 break;
185
186 case SPxBasisBase<R>::Desc::D_ON_BOTH :
187 text = 'x';
188 break;
189
190 case SPxBasisBase<R>::Desc::D_UNDEFINED :
191 text = '.';
192 break;
193
194 default :
195 os << std::endl << "Invalid status <" << int(stat) << ">" << std::endl;
196 throw SPxInternalCodeException("XSPXDE01 This should never happen.");
197 }
198
199 os << text;
200
201 return os;
202 }
203
204 } // namespace soplex
205