Scippy

SoPlex

Sequential object-oriented simPlex

spxdantzigpr.cpp
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the class library */
4 /* SoPlex --- the Sequential object-oriented simPlex. */
5 /* */
6 /* Copyright (C) 1996-2019 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"
22 #include "soplex/spxdantzigpr.h"
23 
24 namespace soplex
25 {
26 
28 {
29  assert(thesolver != 0);
30 
32  return selectLeaveSparse();
33 
34  // const Real* up = thesolver->ubBound();
35  // const Real* low = thesolver->lbBound();
36 
37  Real best = -theeps;
38  int n = -1;
39 
40  for(int i = thesolver->dim() - 1; i >= 0; --i)
41  {
42  Real x = thesolver->fTest()[i];
43 
44  if(x < -theeps)
45  {
46  // x *= EQ_PREF * (1 + (up[i] == low[i]));
47  if(x < best)
48  {
49  n = i;
50  best = x;
51  }
52  }
53  }
54 
55  return n;
56 }
57 
59 {
60  assert(thesolver != 0);
61 
62  Real best = -theeps;
63  Real x;
64  int n = -1;
65  int index;
66 
67  for(int i = thesolver->infeasibilities.size() - 1; i >= 0; --i)
68  {
69  index = thesolver->infeasibilities.index(i);
70  x = thesolver->fTest()[index];
71 
72  if(x < -theeps)
73  {
74  if(x < best)
75  {
76  n = index;
77  best = x;
78  }
79  }
80  else
81  {
83  assert(thesolver->isInfeasible[index] > 0);
84  thesolver->isInfeasible[index] = 0;
85  }
86  }
87 
88  return n;
89 }
90 
91 
93 {
94  assert(thesolver != 0);
95 
96  // const SPxBasis::Desc& ds = thesolver->basis().desc();
97 
98  SPxId enterId;
99  enterId = selectEnterX();
100 
101  return enterId;
102 }
103 
105 {
106  SPxId enterId;
107  SPxId enterIdCo;
108  Real best;
109  Real bestCo;
110 
111  best = -theeps;
112  bestCo = -theeps;
114  enterId) : selectEnterDenseDim(best, enterId);
115  enterIdCo = (thesolver->sparsePricingEnterCo) ? selectEnterSparseCoDim(bestCo,
116  enterId) : selectEnterDenseCoDim(bestCo, enterId);
117 
118  // prefer slack indices to reduce nonzeros in basis matrix
119  if(enterId.isValid() && (best > SPARSITY_TRADEOFF * bestCo || !enterIdCo.isValid()))
120  return enterId;
121  else
122  return enterIdCo;
123 }
124 
125 
127 {
128  assert(thesolver != 0);
129 
130  int idx;
131  Real x;
132 
133  for(int i = thesolver->infeasibilities.size() - 1; i >= 0; --i)
134  {
135  idx = thesolver->infeasibilities.index(i);
136  x = thesolver->coTest()[idx];
137 
138  if(x < -theeps)
139  {
140  // x *= EQ_PREF * (1 + (ds.coStatus(i) == SPxBasis::Desc::P_FREE
141  // || ds.coStatus(i) == SPxBasis::Desc::D_FREE));
142  if(x < best)
143  {
144  enterId = thesolver->coId(idx);
145  best = x;
146  }
147  }
148  else
149  {
151 
152  assert(thesolver->isInfeasible[idx]);
153  thesolver->isInfeasible[idx] = 0;
154  }
155  }
156 
157  return enterId;
158 }
159 
161 {
162  assert(thesolver != 0);
163 
164  int idx;
165  Real x;
166 
167  for(int i = thesolver->infeasibilitiesCo.size() - 1; i >= 0; --i)
168  {
170  x = thesolver->test()[idx];
171 
172  if(x < -theeps)
173  {
174  // x *= EQ_PREF * (1 + (ds.coStatus(i) == SPxBasis::Desc::P_FREE
175  // || ds.coStatus(i) == SPxBasis::Desc::D_FREE));
176  if(x < best)
177  {
178  enterId = thesolver->id(idx);
179  best = x;
180  }
181  }
182  else
183  {
185  assert(thesolver->isInfeasibleCo[idx] > 0);
186  thesolver->isInfeasibleCo[idx] = 0;
187  }
188  }
189 
190  return enterId;
191 }
192 
194 {
195  assert(thesolver != 0);
196 
197  Real x;
198 
199  for(int i = thesolver->dim() - 1; i >= 0; --i)
200  {
201  x = thesolver->coTest()[i];
202 
203  if(x < -theeps)
204  {
205  // x *= EQ_PREF * (1 + (ds.coStatus(i) == SPxBasis::Desc::P_FREE
206  // || ds.coStatus(i) == SPxBasis::Desc::D_FREE));
207  if(x < best)
208  {
209  enterId = thesolver->coId(i);
210  best = x;
211  }
212  }
213  }
214 
215  return enterId;
216 }
217 
219 {
220  assert(thesolver != 0);
221 
222  Real x;
223 
224  for(int i = thesolver->coDim() - 1; i >= 0; --i)
225  {
226  x = thesolver->test()[i];
227 
228  if(x < -theeps)
229  {
230  // x *= EQ_PREF * (1 + (ds.status(i) == SPxBasis::Desc::P_FREE
231  // || ds.status(i) == SPxBasis::Desc::D_FREE));
232  if(x < best)
233  {
234  enterId = thesolver->id(i);
235  best = x;
236  }
237  }
238  }
239 
240  return enterId;
241 }
242 
243 } // namespace soplex
virtual int selectLeave()
SPxId coId(int i) const
id of i &#39;th covector.
Definition: spxsolver.h:1117
SPxId selectEnterDenseDim(Real &best, SPxId &id)
const Vector & fTest() const
Violations of fVec.
Definition: spxsolver.h:1385
bool sparsePricingLeave
These values enable or disable sparse pricing.
Definition: spxsolver.h:448
bool sparsePricingEnterCo
true if sparsePricing is turned on in the entering Simplex
Definition: spxsolver.h:450
SPxId selectEnterSparseDim(Real &best, SPxId &id)
DataArray< int > isInfeasible
0: index not violated, 1: index violated, 2: index violated and among candidate list ...
Definition: spxsolver.h:443
int dim() const
dimension of basis matrix.
Definition: spxsolver.h:1075
Dantzig pricer.
Generic Ids for LP rows or columns.Both SPxColIds and SPxRowIds may be treated uniformly as SPxIds: ...
Definition: spxid.h:85
void remove(int n, int m)
removes indices at position numbers n through m.
Definition: idxset.cpp:51
virtual SPxId selectEnter()
double Real
Definition: spxdefines.h:218
int size() const
returns the number of used indices.
Definition: idxset.h:124
SPxId id(int i) const
id of i &#39;th vector.
Definition: spxsolver.h:1098
SPxId selectEnterDenseCoDim(Real &best, SPxId &id)
SPxSolver * thesolver
the solver
Definition: spxpricer.h:56
bool sparsePricingEnter
true if sparsePricing is turned on in the entering Simplex for slack variables
Definition: spxsolver.h:449
const Vector & test() const
Violations of pVec.
Definition: spxsolver.h:1531
Debugging, floating point type and parameter definitions.
DIdxSet infeasibilities
Definition: spxsolver.h:429
Everything should be within this namespace.
#define SPARSITY_TRADEOFF
Definition: spxsolver.h:42
Real theeps
violation bound
Definition: spxpricer.h:58
const Vector & coTest() const
violations of coPvec.
Definition: spxsolver.h:1465
bool isValid() const
returns TRUE iff the id is a valid column or row identifier.
Definition: spxid.h:151
DataArray< int > isInfeasibleCo
0: index not violated, 1: index violated, 2: index violated and among candidate list ...
Definition: spxsolver.h:445
int coDim() const
codimension.
Definition: spxsolver.h:1080
SPxId selectEnterSparseCoDim(Real &best, SPxId &id)
int index(int n) const
access n &#39;th index.
Definition: idxset.h:118
DIdxSet infeasibilitiesCo
Definition: spxsolver.h:432