Scippy

SoPlex

Sequential object-oriented simPlex

spxsteeppr.h
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-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 
17 /**@file spxsteeppr.h
18  * @brief Steepest edge pricer.
19  */
20 #ifndef _SPXSTEEPPR_H_
21 #define _SPXSTEEPPR_H_
22 
23 
24 #include <assert.h>
25 
26 #include "soplex/spxdefines.h"
27 #include "soplex/spxpricer.h"
28 #include "soplex/random.h"
29 
30 namespace soplex
31 {
32 
33 /**@brief Steepest edge pricer.
34  @ingroup Algo
35 
36  Class SPxSteepPR implements a steepest edge pricer to be used with
37  SoPlex.
38 
39  See SPxPricer for a class documentation.
40 */
41 template <class R>
42 class SPxSteepPR : public SPxPricer<R>
43 {
44 public:
45 
46  //-------------------------------------
47  /**@name Types */
48  ///@{
49  /// How to setup the direction multipliers.
50  /** Possible settings are #EXACT for starting with exactly computed
51  values, or #DEFAULT for starting with multipliers set to 1. The
52  latter is the default.
53  */
54  enum Setup
55  {
56  EXACT, ///< starting with exactly computed values
57  DEFAULT ///< starting with multipliers set to 1
58  };
59  ///@}
60  /// setup steepest edge weights
61  void setupWeights(typename SPxSolverBase<R>::Type type);
62 
63 private:
64 
65  //-------------------------------------
66  /**@name Data */
67  ///@{
68  /// working vector
70  /// working vector
72  /// temporary array of precomputed pricing values
74  /// temporary array of precomputed pricing values
76  /// array of best pricing candidates
78  /// array of best pricing candidates
80  ///
81  R pi_p;
82  /// setup type.
84  /// has a refinement step already been tried?
85  bool refined;
86  ///@}
87 
88  //-------------------------------------
89  /// prepare data structures for hyper sparse pricing
90  int buildBestPriceVectorLeave(R feastol);
91  /// implementation of full pricing
92  int selectLeaveX(R tol);
93  /// implementation of sparse pricing in the leaving Simplex
94  int selectLeaveSparse(R tol);
95  /// implementation of hyper sparse pricing in the leaving Simplex
96  int selectLeaveHyper(R tol);
97  /// build up vector of pricing values for later use
98  SPxId buildBestPriceVectorEnterDim(R& best, R feastol);
99  SPxId buildBestPriceVectorEnterCoDim(R& best, R feastol);
100  /// choose the best entering index among columns and rows but prefer sparsity
101  SPxId selectEnterX(R tol);
102  /// implementation of sparse pricing for the entering Simplex (slack variables)
103  SPxId selectEnterSparseDim(R& best, R tol);
104  /// implementation of sparse pricing for the entering Simplex
105  SPxId selectEnterSparseCoDim(R& best, R tol);
106  /// implementation of selectEnter() in dense case (slack variables)
107  SPxId selectEnterDenseDim(R& best, R tol);
108  /// implementation of selectEnter() in dense case
109  SPxId selectEnterDenseCoDim(R& best, R tol);
110  /// implementation of hyper sparse pricing in the entering Simplex
111  SPxId selectEnterHyperDim(R& best, R feastol);
112  /// implementation of hyper sparse pricing in the entering Simplex
113  SPxId selectEnterHyperCoDim(R& best, R feastol);
114 
115 public:
116 
117  //-------------------------------------
118  /**@name Construction / destruction */
119  ///@{
120  ///
121  SPxSteepPR(const char* name = "Steep", Setup mode = DEFAULT)
122  : SPxPricer<R>(name)
123  , workVec(0)
124  , workRhs(0)
125  , pi_p(1.0)
126  , setup(mode)
127  , refined(false)
128  {
129  assert(isConsistent());
130  }
131  /// copy constructor
132  SPxSteepPR(const SPxSteepPR& old)
133  : SPxPricer<R>(old)
134  , workVec(old.workVec)
135  , workRhs(old.workRhs)
136  , pi_p(old.pi_p)
137  , setup(old.setup)
138  , refined(old.refined)
139  {
140  assert(isConsistent());
141  }
142  /// assignment operator
144  {
145  if(this != &rhs)
146  {
148  workVec = rhs.workVec;
149  workRhs = rhs.workRhs;
150  pi_p = rhs.pi_p;
151  setup = rhs.setup;
152  refined = rhs.refined;
153 
154  assert(isConsistent());
155  }
156 
157  return *this;
158  }
159  /// destructor
160  virtual ~SPxSteepPR()
161  {}
162  /// clone function for polymorphism
163  inline virtual SPxPricer<R>* clone() const
164  {
165  return new SPxSteepPR(*this);
166  }
167  ///@}
168 
169  //-------------------------------------
170  /**@name Access / modification */
171  ///@{
172  /// sets the solver
173  virtual void load(SPxSolverBase<R>* base);
174  /// clear solver and preferences
175  virtual void clear();
176  /// set entering/leaving algorithm
177  virtual void setType(typename SPxSolverBase<R>::Type);
178  /// set row/column representation
179  virtual void setRep(typename SPxSolverBase<R>::Representation rep);
180  ///
181  virtual int selectLeave();
182  ///
183  virtual void left4(int n, SPxId id);
184  ///
185  virtual SPxId selectEnter();
186  ///
187  virtual void entered4(SPxId id, int n);
188  /// \p n vectors have been added to loaded LP.
189  virtual void addedVecs(int n);
190  /// \p n covectors have been added to loaded LP.
191  virtual void addedCoVecs(int n);
192  /// \p the i'th vector has been removed from the loaded LP.
193  virtual void removedVec(int i);
194  /// \p the i'th covector has been removed from the loaded LP.
195  virtual void removedCoVec(int i);
196  /// \p n vectors have been removed from loaded LP.
197  virtual void removedVecs(const int perm[]);
198  /// \p n covectors have been removed from loaded LP.
199  virtual void removedCoVecs(const int perm[]);
200  ///@}
201 
202  //-------------------------------------
203  /**@name Consistency check */
204  ///@{
205  ///
206  virtual bool isConsistent() const;
207  ///@}
208 };
209 
210 } // namespace soplex
211 #endif // _SPXSTEEPPR_H_
Random numbers.
Representation
LP basis representation.
Definition: spxsolver.h:116
virtual void removedVecs(const int perm[])
n vectors have been removed from loaded LP.
virtual void left4(int n, SPxId id)
SPxId selectEnterHyperCoDim(R &best, R feastol)
implementation of hyper sparse pricing in the entering Simplex
SPxSteepPR(const SPxSteepPR &old)
copy constructor
Definition: spxsteeppr.h:132
SPxSteepPR(const char *name="Steep", Setup mode=DEFAULT)
Definition: spxsteeppr.h:121
DIdxSet bestPrices
array of best pricing candidates
Definition: spxsteeppr.h:77
Abstract pricer base class.
Sequential object-oriented SimPlex.SPxSolverBase is an LP solver class using the revised Simplex algo...
Definition: spxbasis.h:49
Setup
How to setup the direction multipliers.
Definition: spxsteeppr.h:54
SPxPricer & operator=(const SPxPricer &rhs)
assignment operator
Definition: spxpricer.h:281
Safe arrays of arbitrary types.Class Array provides safe arrays of arbitrary type. Array elements are accessed just like ordinary C++ array elements by means of the index operator[](). Safety is provided by.
Definition: array.h:63
starting with multipliers set to 1
Definition: spxsteeppr.h:57
SPxId selectEnterX(R tol)
choose the best entering index among columns and rows but prefer sparsity
virtual void addedCoVecs(int n)
n covectors have been added to loaded LP.
SPxSteepPR & operator=(const SPxSteepPR &rhs)
assignment operator
Definition: spxsteeppr.h:143
SPxId buildBestPriceVectorEnterDim(R &best, R feastol)
build up vector of pricing values for later use
SPxId selectEnterHyperDim(R &best, R feastol)
implementation of hyper sparse pricing in the entering Simplex
int selectLeaveSparse(R tol)
implementation of sparse pricing in the leaving Simplex
Semi sparse vector.This class implements semi-sparse vectors. Such are VectorBases where the indices ...
Definition: dsvectorbase.h:29
Generic Ids for LP rows or columns.Both SPxColIds and SPxRowIds may be treated uniformly as SPxIds: ...
Definition: spxid.h:85
int selectLeaveHyper(R tol)
implementation of hyper sparse pricing in the leaving Simplex
virtual void setRep(typename SPxSolverBase< R >::Representation rep)
set row/column representation
bool refined
has a refinement step already been tried?
Definition: spxsteeppr.h:85
int buildBestPriceVectorLeave(R feastol)
prepare data structures for hyper sparse pricing
SPxId buildBestPriceVectorEnterCoDim(R &best, R feastol)
virtual void addedVecs(int n)
n vectors have been added to loaded LP.
Abstract pricer base class.Class SPxPricer is a pure virtual class defining the interface for pricer ...
Definition: spxpricer.h:47
virtual void clear()
clear solver and preferences
starting with exactly computed values
Definition: spxsteeppr.h:56
virtual void load(SPxSolverBase< R > *base)
sets the solver
Dynamic index set.Class DIdxSet provides dynamic IdxSet in the sense, that no restrictions are posed ...
Definition: didxset.h:42
virtual ~SPxSteepPR()
destructor
Definition: spxsteeppr.h:160
virtual void setType(typename SPxSolverBase< R >::Type)
set entering/leaving algorithm
DIdxSet bestPricesCo
array of best pricing candidates
Definition: spxsteeppr.h:79
SPxId selectEnterSparseDim(R &best, R tol)
implementation of sparse pricing for the entering Simplex (slack variables)
void setupWeights(typename SPxSolverBase< R >::Type type)
setup steepest edge weights
Debugging, floating point type and parameter definitions.
virtual SPxId selectEnter()
virtual void removedCoVec(int i)
the i&#39;th covector has been removed from the loaded LP.
virtual void entered4(SPxId id, int n)
Array< typename SPxPricer< R >::IdxElement > pricesCo
temporary array of precomputed pricing values
Definition: spxsteeppr.h:75
Everything should be within this namespace.
SPxId selectEnterDenseCoDim(R &best, R tol)
implementation of selectEnter() in dense case
virtual SPxPricer< R > * clone() const
clone function for polymorphism
Definition: spxsteeppr.h:163
virtual void removedCoVecs(const int perm[])
n covectors have been removed from loaded LP.
virtual bool isConsistent() const
virtual int selectLeave()
SPxId selectEnterDenseDim(R &best, R tol)
implementation of selectEnter() in dense case (slack variables)
Array< typename SPxPricer< R >::IdxElement > prices
temporary array of precomputed pricing values
Definition: spxsteeppr.h:73
SSVectorBase< R > workVec
working vector
Definition: spxsteeppr.h:69
int selectLeaveX(R tol)
implementation of full pricing
Setup setup
setup type.
Definition: spxsteeppr.h:83
virtual void removedVec(int i)
the i&#39;th vector has been removed from the loaded LP.
Type
Algorithmic type.
Definition: spxsolver.h:135
SPxId selectEnterSparseCoDim(R &best, R tol)
implementation of sparse pricing for the entering Simplex
Steepest edge pricer.Class SPxSteepPR implements a steepest edge pricer to be used with SoPlex...
Definition: spxsteeppr.h:42
SSVectorBase< R > workRhs
working vector
Definition: spxsteeppr.h:71