Scippy

SoPlex

Sequential object-oriented simPlex

spxparmultpr.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 #include "soplex/spxdefines.h"
20 #include "soplex/spxparmultpr.h"
21 
22 namespace soplex
23 {
24 
26 {
27  if(tp == SPxSolver::ENTER)
28  {
29  used = 0;
31  }
32  else
33  {
35  }
36 
39  thesolver->weightsAreSetup = false;
40 
41  last = 0;
42  min = partialSize / 2;
43 }
44 
46 {
47  thesolver = p_solver;
49  pricSet.reSize(10 * partialSize);
50 }
51 
53 {
54  SPxId id;
55  Real x;
56  int i;
57  int best = -1;
58  // const SPxBasis::Desc& ds = thesolver->basis().desc();
59 
60  assert(thesolver != 0);
61  int lastlast = -1;
62 
64  {
65  Real val;
66  Real eps = -theeps;
67  lastlast = last;
68 
69  for(i = used - 1; i >= 0; --i)
70  {
71  int n = thesolver->number(pricSet[i].id);
72 
73  if(thesolver->isId(pricSet[i].id))
74  {
76  pricSet[i].test = val = thesolver->computeTest(n);
77  }
78  else
79  pricSet[i].test = val = thesolver->coTest()[n];
80 
81  if(val >= eps)
82  pricSet[i] = pricSet[--used];
83  }
84 
85  while(pricSet.size() - used < partialSize)
86  {
87  best = 0;
88 
89  for(i = 1; i < used; ++i)
90  {
91  if(pricSet[i].test > pricSet[best].test)
92  best = i;
93  }
94 
95  pricSet[best] = pricSet[--used];
96  }
97 
98  do
99  {
100  last = (last + 1) % multiParts;
101 
102  for(i = thesolver->coDim() - last - 1;
103  i >= 0; i -= multiParts)
104  {
106  x = thesolver->computeTest(i);
107 
108  if(x < eps)
109  {
110  pricSet[used].id = thesolver->id(i);
111  pricSet[used].test = x;
112  used++;
113  }
114  }
115 
116  for(i = thesolver->dim() - last - 1;
117  i >= 0; i -= multiParts)
118  {
119  x = thesolver->coTest()[i];
120 
121  if(x < eps)
122  {
123  pricSet[used].id = thesolver->coId(i);
124  pricSet[used].test = x;
125  used++;
126  }
127  }
128 
129  assert(used < pricSet.size());
130  }
131  while(used < min && last != lastlast);
132 
133  if(used > 0)
134  {
135  min = (used + 1);
136 
137  if(min < 1)
138  min = 1;
139 
140  if(min > partialSize)
141  min = partialSize;
142 
143  best = 0;
144 
145  for(i = 1; i < used; ++i)
146  {
147  if(pricSet[i].test < pricSet[best].test)
148  best = i;
149  }
150 
151  id = pricSet[best].id;
152  }
153 
154  return id;
155  }
156 
157  else
158  {
159  assert(thesolver->pricing() == SPxSolver::FULL);
160  Real bestx = -theeps;
161 
162  for(i = thesolver->dim() - 1; i >= 0; --i)
163  {
164  x = thesolver->coTest()[i];
165 
166  // x *= EQ_PREF * (1 + (ds.coStatus(i) == SPxBasis::Desc::P_FREE
167  // || ds.coStatus(i) == SPxBasis::Desc::D_FREE));
168  if(x < bestx)
169  {
170  id = thesolver->coId(i);
171  bestx = thesolver->coTest()[i];
172  }
173  }
174 
175  for(i = thesolver->coDim() - 1; i >= 0; --i)
176  {
177  x = thesolver->test()[i];
178 
179  // x *= EQ_PREF * (1 + (ds.status(i) == SPxBasis::Desc::P_FREE
180  // || ds.status(i) == SPxBasis::Desc::D_FREE));
181  if(x < bestx)
182  {
183  id = thesolver->id(i);
184  bestx = thesolver->test()[i];
185  }
186  }
187 
188  return id;
189  }
190 }
191 
193 {
194  int i, n;
195  Real x;
196  Real best = -theeps;
197  // const Real* up = thesolver->ubBound();
198  // const Real* low = thesolver->lbBound();
199 
200  assert(thesolver != 0);
201  n = -1;
202 
203  for(i = thesolver->dim() - 1; i >= 0; --i)
204  {
205  x = thesolver->fTest()[i];
206 
207  // x *= EQ_PREF * (1 + (up[i] == low[i]));
208  if(x < best)
209  {
210  n = i;
211  best = thesolver->fTest()[i];
212  }
213  }
214 
215  return n;
216 }
217 } // namespace soplex
SPxId coId(int i) const
id of i &#39;th covector.
Definition: spxsolver.h:1117
void reDim(int newdim, const bool setZero=true)
Resets DVectorBase&#39;s dimension to newdim.
Definition: dvectorbase.h:253
const Vector & fTest() const
Violations of fVec.
Definition: spxsolver.h:1385
Type
Algorithmic type.
Definition: spxsolver.h:124
Pricing pricing() const
return current Pricing.
Definition: spxsolver.h:518
int number(const SPxRowId &id) const
Returns the row number of the row with identifier id.
Definition: spxlpbase.h:527
bool isId(const SPxId &p_id) const
Is p_id an SPxId ?
Definition: spxsolver.h:1135
int dim() const
dimension of basis matrix.
Definition: spxsolver.h:1075
Entering Simplex.
Definition: spxsolver.h:134
Generic Ids for LP rows or columns.Both SPxColIds and SPxRowIds may be treated uniformly as SPxIds: ...
Definition: spxid.h:85
double Real
Definition: spxdefines.h:218
virtual void load(SPxSolver *solver)
set the solver
virtual SPxId selectEnter()
SPxId id(int i) const
id of i &#39;th vector.
Definition: spxsolver.h:1098
virtual int selectLeave()
DVector coWeights
store dual norms
Definition: spxsolver.h:460
SPxSolver * thesolver
the solver
Definition: spxpricer.h:56
const Vector & test() const
Violations of pVec.
Definition: spxsolver.h:1531
virtual void setType(SPxSolver::Type tp)
set entering or leaving algorithm
Debugging, floating point type and parameter definitions.
Sequential object-oriented SimPlex.SPxSolver is an LP solver class using the revised Simplex algorith...
Definition: spxsolver.h:85
Full pricing.
Definition: spxsolver.h:160
Everything should be within this namespace.
int partialSize
Set size for partial pricing.
Definition: spxparmultpr.h:78
Real computePvec(int i)
compute and return pVec()[i].
Definition: enter.cpp:183
Partial multiple pricing.
Real theeps
violation bound
Definition: spxpricer.h:58
const Vector & coTest() const
violations of coPvec.
Definition: spxsolver.h:1465
Partial pricing.
Definition: spxsolver.h:174
int coDim() const
codimension.
Definition: spxsolver.h:1080
DVector weights
dual pricing norms
Definition: spxsolver.h:459
DataArray< SPxParMultPr_Tmp > pricSet
Definition: spxparmultpr.h:68
bool weightsAreSetup
are the dual norms already set up?
Definition: spxsolver.h:461
Real computeTest(int i)
compute and return test()[i] in ENTERing Simplex.
Definition: enter.cpp:189
void setPricing(Pricing pr)
set FULL or PARTIAL pricing.
Definition: spxsolver.cpp:445