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 <assert.h>
17 #include <iostream>
18
19 // #define EQ_PREF 1000
20
21 #include "soplex/spxdefines.h"
(1) Event include_recursion: |
#include file "/sapmnt/home1/d029903/my_work/SCIPSoPlex_coverity/scipoptsuite-8.0.1/soplex/src/soplex/spxdantzigpr.h" includes itself: spxdantzigpr.h -> spxdantzigpr.hpp -> spxdantzigpr.h |
(2) Event caretline: |
^ |
22 #include "soplex/spxdantzigpr.h"
23
24 namespace soplex
25 {
26
27 template <class R>
28 int SPxDantzigPR<R>::selectLeave()
29 {
30 assert(this->thesolver != 0);
31
32 if(this->thesolver->sparsePricingLeave)
33 return selectLeaveSparse();
34
35 // const R* up = this->thesolver->ubBound();
36 // const R* low = this->thesolver->lbBound();
37
38 R best = -this->theeps;
39 int n = -1;
40
41 for(int i = this->thesolver->dim() - 1; i >= 0; --i)
42 {
43 R x = this->thesolver->fTest()[i];
44
45 if(x < -this->theeps)
46 {
47 // x *= EQ_PREF * (1 + (up[i] == low[i]));
48 if(x < best)
49 {
50 n = i;
51 best = x;
52 }
53 }
54 }
55
56 return n;
57 }
58
59 template <class R>
60 int SPxDantzigPR<R>::selectLeaveSparse()
61 {
62 assert(this->thesolver != 0);
63
64 R best = -this->theeps;
65 R x;
66 int n = -1;
67 int index;
68
69 for(int i = this->thesolver->infeasibilities.size() - 1; i >= 0; --i)
70 {
71 index = this->thesolver->infeasibilities.index(i);
72 x = this->thesolver->fTest()[index];
73
74 if(x < -this->theeps)
75 {
76 if(x < best)
77 {
78 n = index;
79 best = x;
80 }
81 }
82 else
83 {
84 this->thesolver->infeasibilities.remove(i);
85 assert(this->thesolver->isInfeasible[index] > 0);
86 this->thesolver->isInfeasible[index] = 0;
87 }
88 }
89
90 return n;
91 }
92
93 template <class R>
94 SPxId SPxDantzigPR<R>::selectEnter()
95 {
96 assert(this->thesolver != 0);
97
98 // const SPxBasisBase<R>::Desc& ds = this->thesolver->basis().desc();
99
100 SPxId enterId;
101 enterId = selectEnterX();
102
103 return enterId;
104 }
105
106 template <class R>
107 SPxId SPxDantzigPR<R>::selectEnterX()
108 {
109 SPxId enterId;
110 SPxId enterIdCo;
111 R best;
112 R bestCo;
113
114 best = -this->theeps;
115 bestCo = -this->theeps;
116 enterId = (this->thesolver->sparsePricingEnter) ? selectEnterSparseDim(best,
117 enterId) : selectEnterDenseDim(best, enterId);
118 enterIdCo = (this->thesolver->sparsePricingEnterCo) ? selectEnterSparseCoDim(bestCo,
119 enterId) : selectEnterDenseCoDim(bestCo, enterId);
120
121 // prefer slack indices to reduce nonzeros in basis matrix
122 if(enterId.isValid() && (best > SPARSITY_TRADEOFF * bestCo || !enterIdCo.isValid()))
123 return enterId;
124 else
125 return enterIdCo;
126 }
127
128
129 template <class R>
130 SPxId SPxDantzigPR<R>::selectEnterSparseDim(R& best, SPxId& enterId)
131 {
132 assert(this->thesolver != 0);
133
134 int idx;
135 R x;
136
137 for(int i = this->thesolver->infeasibilities.size() - 1; i >= 0; --i)
138 {
139 idx = this->thesolver->infeasibilities.index(i);
140 x = this->thesolver->coTest()[idx];
141
142 if(x < -this->theeps)
143 {
144 // x *= EQ_PREF * (1 + (ds.coStatus(i) == SPxBasisBase<R>::Desc::P_FREE
145 // || ds.coStatus(i) == SPxBasisBase<R>::Desc::D_FREE));
146 if(x < best)
147 {
148 enterId = this->thesolver->coId(idx);
149 best = x;
150 }
151 }
152 else
153 {
154 this->thesolver->infeasibilities.remove(i);
155
156 assert(this->thesolver->isInfeasible[idx]);
157 this->thesolver->isInfeasible[idx] = 0;
158 }
159 }
160
161 return enterId;
162 }
163
164 template <class R>
165 SPxId SPxDantzigPR<R>::selectEnterSparseCoDim(R& best, SPxId& enterId)
166 {
167 assert(this->thesolver != 0);
168
169 int idx;
170 R x;
171
172 for(int i = this->thesolver->infeasibilitiesCo.size() - 1; i >= 0; --i)
173 {
174 idx = this->thesolver->infeasibilitiesCo.index(i);
175 x = this->thesolver->test()[idx];
176
177 if(x < -this->theeps)
178 {
179 // x *= EQ_PREF * (1 + (ds.coStatus(i) == SPxBasisBase<R>::Desc::P_FREE
180 // || ds.coStatus(i) == SPxBasisBase<R>::Desc::D_FREE));
181 if(x < best)
182 {
183 enterId = this->thesolver->id(idx);
184 best = x;
185 }
186 }
187 else
188 {
189 this->thesolver->infeasibilitiesCo.remove(i);
190 assert(this->thesolver->isInfeasibleCo[idx] > 0);
191 this->thesolver->isInfeasibleCo[idx] = 0;
192 }
193 }
194
195 return enterId;
196 }
197
198 template <class R>
199 SPxId SPxDantzigPR<R>::selectEnterDenseDim(R& best, SPxId& enterId)
200 {
201 assert(this->thesolver != 0);
202
203 R x;
204
205 for(int i = this->thesolver->dim() - 1; i >= 0; --i)
206 {
207 x = this->thesolver->coTest()[i];
208
209 if(x < -this->theeps)
210 {
211 // x *= EQ_PREF * (1 + (ds.coStatus(i) == SPxBasisBase<R>::Desc::P_FREE
212 // || ds.coStatus(i) == SPxBasisBase<R>::Desc::D_FREE));
213 if(x < best)
214 {
215 enterId = this->thesolver->coId(i);
216 best = x;
217 }
218 }
219 }
220
221 return enterId;
222 }
223
224 template <class R>
225 SPxId SPxDantzigPR<R>::selectEnterDenseCoDim(R& best, SPxId& enterId)
226 {
227 assert(this->thesolver != 0);
228
229 R x;
230
231 for(int i = this->thesolver->coDim() - 1; i >= 0; --i)
232 {
233 x = this->thesolver->test()[i];
234
235 if(x < -this->theeps)
236 {
237 // x *= EQ_PREF * (1 + (ds.status(i) == SPxBasisBase<R>::Desc::P_FREE
238 // || ds.status(i) == SPxBasisBase<R>::Desc::D_FREE));
239 if(x < best)
240 {
241 enterId = this->thesolver->id(i);
242 best = x;
243 }
244 }
245 }
246
247 return enterId;
248 }
249
250 } // namespace soplex
251