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 
37  last = 0;
38  min = partialSize / 2;
39 }
40 
42 {
43  thesolver = p_solver;
45  pricSet.reSize(10 * partialSize);
46 }
47 
49 {
50  SPxId id;
51  Real x;
52  int i;
53  int best = -1;
54  // const SPxBasis::Desc& ds = thesolver->basis().desc();
55 
56  assert(thesolver != 0);
57  int lastlast = -1;
58 
60  {
61  Real val;
62  Real eps = -theeps;
63  lastlast = last;
64 
65  for (i = used - 1; i >= 0; --i)
66  {
67  int n = thesolver->number(pricSet[i].id);
68  if (thesolver->isId(pricSet[i].id))
69  {
71  pricSet[i].test = val = thesolver->computeTest(n);
72  }
73  else
74  pricSet[i].test = val = thesolver->coTest()[n];
75  if (val >= eps)
76  pricSet[i] = pricSet[--used];
77  }
78 
79  while (pricSet.size() - used < partialSize)
80  {
81  best = 0;
82  for (i = 1; i < used; ++i)
83  {
84  if (pricSet[i].test > pricSet[best].test)
85  best = i;
86  }
87  pricSet[best] = pricSet[--used];
88  }
89 
90  do
91  {
92  last = (last + 1) % multiParts;
93  for (i = thesolver->coDim() - last - 1;
94  i >= 0; i -= multiParts)
95  {
97  x = thesolver->computeTest(i);
98  if (x < eps)
99  {
100  pricSet[used].id = thesolver->id(i);
101  pricSet[used].test = x;
102  used++;
103  }
104  }
105 
106  for (i = thesolver->dim() - last - 1;
107  i >= 0; i -= multiParts)
108  {
109  x = thesolver->coTest()[i];
110  if (x < eps)
111  {
112  pricSet[used].id = thesolver->coId(i);
113  pricSet[used].test = x;
114  used++;
115  }
116  }
117  assert(used < pricSet.size());
118  }
119  while (used < min && last != lastlast);
120 
121  if (used > 0)
122  {
123  min = (used + 1);
124  if (min < 1)
125  min = 1;
126  if (min > partialSize)
127  min = partialSize;
128  best = 0;
129  for (i = 1; i < used; ++i)
130  {
131  if (pricSet[i].test < pricSet[best].test)
132  best = i;
133  }
134  id = pricSet[best].id;
135  }
136  return id;
137  }
138 
139  else
140  {
141  assert(thesolver->pricing() == SPxSolver::FULL);
142  Real bestx = -theeps;
143  for (i = thesolver->dim() - 1; i >= 0; --i)
144  {
145  x = thesolver->coTest()[i];
146  // x *= EQ_PREF * (1 + (ds.coStatus(i) == SPxBasis::Desc::P_FREE
147  // || ds.coStatus(i) == SPxBasis::Desc::D_FREE));
148  if (x < bestx)
149  {
150  id = thesolver->coId(i);
151  bestx = thesolver->coTest()[i];
152  }
153  }
154 
155  for (i = thesolver->coDim() - 1; i >= 0; --i)
156  {
157  x = thesolver->test()[i];
158  // x *= EQ_PREF * (1 + (ds.status(i) == SPxBasis::Desc::P_FREE
159  // || ds.status(i) == SPxBasis::Desc::D_FREE));
160  if (x < bestx)
161  {
162  id = thesolver->id(i);
163  bestx = thesolver->test()[i];
164  }
165  }
166 
167  return id;
168  }
169 }
170 
172 {
173  int i, n;
174  Real x;
175  Real best = -theeps;
176  // const Real* up = thesolver->ubBound();
177  // const Real* low = thesolver->lbBound();
178 
179  assert(thesolver != 0);
180  n = -1;
181  for (i = thesolver->dim() - 1; i >= 0; --i)
182  {
183  x = thesolver->fTest()[i];
184  // x *= EQ_PREF * (1 + (up[i] == low[i]));
185  if (x < best)
186  {
187  n = i;
188  best = thesolver->fTest()[i];
189  }
190  }
191 
192  return n;
193 }
194 } // namespace soplex
SPxId coId(int i) const
id of i &#39;th covector.
Definition: spxsolver.h:1089
const Vector & fTest() const
Violations of fVec.
Definition: spxsolver.h:1357
Type
Algorithmic type.
Definition: spxsolver.h:124
Pricing pricing() const
return current Pricing.
Definition: spxsolver.h:481
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:1107
int dim() const
dimension of basis matrix.
Definition: spxsolver.h:1047
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:215
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:1070
virtual int selectLeave()
SPxSolver * thesolver
the solver
Definition: spxpricer.h:56
const Vector & test() const
Violations of pVec.
Definition: spxsolver.h:1503
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:1437
Partial pricing.
Definition: spxsolver.h:174
int coDim() const
codimension.
Definition: spxsolver.h:1052
DataArray< SPxParMultPr_Tmp > pricSet
Definition: spxparmultpr.h:68
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:437