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-2017 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 "spxdefines.h"
20 #include "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  if (thesolver->isId(pricSet[i].id))
73  {
75  pricSet[i].test = val = thesolver->computeTest(n);
76  }
77  else
78  pricSet[i].test = val = thesolver->coTest()[n];
79  if (val >= eps)
80  pricSet[i] = pricSet[--used];
81  }
82 
83  while (pricSet.size() - used < partialSize)
84  {
85  best = 0;
86  for (i = 1; i < used; ++i)
87  {
88  if (pricSet[i].test > pricSet[best].test)
89  best = i;
90  }
91  pricSet[best] = pricSet[--used];
92  }
93 
94  do
95  {
96  last = (last + 1) % multiParts;
97  for (i = thesolver->coDim() - last - 1;
98  i >= 0; i -= multiParts)
99  {
101  x = thesolver->computeTest(i);
102  if (x < eps)
103  {
104  pricSet[used].id = thesolver->id(i);
105  pricSet[used].test = x;
106  used++;
107  }
108  }
109 
110  for (i = thesolver->dim() - last - 1;
111  i >= 0; i -= multiParts)
112  {
113  x = thesolver->coTest()[i];
114  if (x < eps)
115  {
116  pricSet[used].id = thesolver->coId(i);
117  pricSet[used].test = x;
118  used++;
119  }
120  }
121  assert(used < pricSet.size());
122  }
123  while (used < min && last != lastlast);
124 
125  if (used > 0)
126  {
127  min = (used + 1);
128  if (min < 1)
129  min = 1;
130  if (min > partialSize)
131  min = partialSize;
132  best = 0;
133  for (i = 1; i < used; ++i)
134  {
135  if (pricSet[i].test < pricSet[best].test)
136  best = i;
137  }
138  id = pricSet[best].id;
139  }
140  return id;
141  }
142 
143  else
144  {
145  assert(thesolver->pricing() == SPxSolver::FULL);
146  Real bestx = -theeps;
147  for (i = thesolver->dim() - 1; i >= 0; --i)
148  {
149  x = thesolver->coTest()[i];
150  // x *= EQ_PREF * (1 + (ds.coStatus(i) == SPxBasis::Desc::P_FREE
151  // || ds.coStatus(i) == SPxBasis::Desc::D_FREE));
152  if (x < bestx)
153  {
154  id = thesolver->coId(i);
155  bestx = thesolver->coTest()[i];
156  }
157  }
158 
159  for (i = thesolver->coDim() - 1; i >= 0; --i)
160  {
161  x = thesolver->test()[i];
162  // x *= EQ_PREF * (1 + (ds.status(i) == SPxBasis::Desc::P_FREE
163  // || ds.status(i) == SPxBasis::Desc::D_FREE));
164  if (x < bestx)
165  {
166  id = thesolver->id(i);
167  bestx = thesolver->test()[i];
168  }
169  }
170 
171  return id;
172  }
173 }
174 
176 {
177  int i, n;
178  Real x;
179  Real best = -theeps;
180  // const Real* up = thesolver->ubBound();
181  // const Real* low = thesolver->lbBound();
182 
183  assert(thesolver != 0);
184  n = -1;
185  for (i = thesolver->dim() - 1; i >= 0; --i)
186  {
187  x = thesolver->fTest()[i];
188  // x *= EQ_PREF * (1 + (up[i] == low[i]));
189  if (x < best)
190  {
191  n = i;
192  best = thesolver->fTest()[i];
193  }
194  }
195 
196  return n;
197 }
198 } // namespace soplex
SPxId coId(int i) const
id of i &#39;th covector.
Definition: spxsolver.h:1098
void reDim(int newdim, const bool setZero=true)
Resets DVectorBase&#39;s dimension to newdim.
Definition: dvectorbase.h:249
const Vector & fTest() const
Violations of fVec.
Definition: spxsolver.h:1366
Type
Algorithmic type.
Definition: spxsolver.h:124
Pricing pricing() const
return current Pricing.
Definition: spxsolver.h:490
int number(const SPxRowId &id) const
Returns the row number of the row with identifier id.
Definition: spxlpbase.h:522
bool isId(const SPxId &p_id) const
Is p_id an SPxId ?
Definition: spxsolver.h:1116
int dim() const
dimension of basis matrix.
Definition: spxsolver.h:1056
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:1079
virtual int selectLeave()
DVector coWeights
store dual norms
Definition: spxsolver.h:433
SPxSolver * thesolver
the solver
Definition: spxpricer.h:56
const Vector & test() const
Violations of pVec.
Definition: spxsolver.h:1512
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:84
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:173
Partial multiple pricing.
Real theeps
violation bound
Definition: spxpricer.h:58
const Vector & coTest() const
violations of coPvec.
Definition: spxsolver.h:1446
Partial pricing.
Definition: spxsolver.h:174
int coDim() const
codimension.
Definition: spxsolver.h:1061
DVector weights
dual pricing norms
Definition: spxsolver.h:432
DataArray< SPxParMultPr_Tmp > pricSet
Definition: spxparmultpr.h:68
bool weightsAreSetup
are the dual norms already set up?
Definition: spxsolver.h:434
Real computeTest(int i)
compute and return test()[i] in ENTERing Simplex.
Definition: enter.cpp:179
void setPricing(Pricing pr)
set FULL or PARTIAL pricing.
Definition: spxsolver.cpp:438