Scippy

SoPlex

Sequential object-oriented simPlex

spxdevexpr.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 /**@file spxdevexpr.h
17  * @brief Devex pricer.
18  */
19 #ifndef _SPXDEVEXPR_H_
20 #define _SPXDEVEXPR_H_
21 
22 #include <assert.h>
23 
24 #include "soplex/spxdefines.h"
25 #include "soplex/spxpricer.h"
26 
27 namespace soplex
28 {
29 
30 /**@brief Devex pricer.
31  @ingroup Algo
32 
33  The Devex Pricer for SoPlex implements an approximate steepest edge pricing,
34  that does without solving an extra linear system and computing the scalar
35  products.
36 
37  See SPxPricer for a class documentation.
38 
39  @todo There seem to be problems with this pricer especially on the
40  greenbe[ab] problems with the entering algorithm
41  (row representation?).
42 */
43 template <class R>
44 class SPxDevexPR : public SPxPricer<R>
45 {
46 private:
47 
48  //-------------------------------------
49  /**@name Data */
50  ///@{
51  R last; ///< penalty, selected at last iteration.
53  prices; ///< temporary array of precomputed pricing values
55  pricesCo; ///< temporary array of precomputed pricing values
56  DIdxSet bestPrices; ///< set of best pricing candidates
57  DIdxSet bestPricesCo; ///< set of best pricing candidates
58  bool refined; ///< has a refinement step already been tried?
59  ///@}
60 
61  //-------------------------------------
62  /**@name Private helpers */
63  ///@{
64  /// set entering/leaving algorithm
65  void setupWeights(typename SPxSolverBase<R>::Type);
66  /// build up vector of pricing values for later use
67  int buildBestPriceVectorLeave(R feastol);
68  /// internal implementation of SPxPricer::selectLeave()
69  int selectLeaveX(R feastol, int start = 0, int incr = 1);
70  /// implementation of sparse pricing in the leaving Simplex
71  int selectLeaveSparse(R feastol);
72  /// implementation of hyper sparse pricing in the leaving Simplex
73  int selectLeaveHyper(R feastol);
74  /// build up vector of pricing values for later use
75  SPxId buildBestPriceVectorEnterDim(R& best, R feastol);
76  SPxId buildBestPriceVectorEnterCoDim(R& best, R feastol);
77  /// choose the best entering index among columns and rows but prefer sparsity
78  SPxId selectEnterX(R tol);
79  /// implementation of sparse pricing in the entering Simplex (slack variables)
80  SPxId selectEnterSparseDim(R& best, R feastol);
81  /// implementation of sparse pricing in the entering Simplex
82  SPxId selectEnterSparseCoDim(R& best, R feastol);
83  /// SPxPricer::selectEnter() in dense case (slack variabels)
84  SPxId selectEnterDenseDim(R& best, R feastol, int start = 0, int incr = 1);
85  /// SPxPricer::selectEnter() in dense case
86  SPxId selectEnterDenseCoDim(R& best, R feastol, int start = 0, int incr = 1);
87  /// implementation of hyper sparse pricing in the entering Simplex
88  SPxId selectEnterHyperDim(R& best, R feastol);
89  /// implementation of hyper sparse pricing in the entering Simplex
90  SPxId selectEnterHyperCoDim(R& best, R feastol);
91  ///@}
92 
93 public:
94 
95  //-------------------------------------
96  /**@name Construction / destruction */
97  ///@{
98  /// default constructor
100  : SPxPricer<R>("Devex")
101  , last(0)
102  , refined(false)
103  {}
104  /// copy constructor
105  SPxDevexPR(const SPxDevexPR& old)
106  : SPxPricer<R>(old)
107  , last(old.last)
108  , refined(false)
109  {}
110  /// assignment operator
112  {
113  if(this != &rhs)
114  {
116  last = rhs.last;
117  }
118 
119  return *this;
120  }
121  /// destructor
122  virtual ~SPxDevexPR()
123  {}
124  /// clone function for polymorphism
125  inline virtual SPxPricer<R>* clone() const
126  {
127  return new SPxDevexPR(*this);
128  }
129  ///@}
130 
131  //-------------------------------------
132  /**@name Access / modification */
133  ///@{
134  /// sets the solver
135  virtual void load(SPxSolverBase<R>* base);
136  /// set entering/leaving algorithm
137  virtual void setType(typename SPxSolverBase<R>::Type);
138  /// set row/column representation
139  virtual void setRep(typename SPxSolverBase<R>::Representation);
140  ///
141  virtual int selectLeave();
142  ///
143  virtual SPxId selectEnter();
144  ///
145  virtual void left4(int n, SPxId id);
146  ///
147  virtual void entered4(SPxId id, int n);
148  /// \p n vectors have been added to loaded LP.
149  virtual void addedVecs(int n);
150  /// \p n covectors have been added to loaded LP.
151  virtual void addedCoVecs(int n);
152  ///@}
153 
154  //-------------------------------------
155  /**@name Consistency check */
156  ///@{
157  /// consistency check
158  virtual bool isConsistent() const;
159  ///@}
160 };
161 
162 } // namespace soplex
163 
164 #include "spxdevexpr.hpp"
165 
166 #endif // _SPXDEVEXPR_H_
SPxId selectEnterDenseDim(R &best, R feastol, int start=0, int incr=1)
SPxPricer::selectEnter() in dense case (slack variabels)
int selectLeaveX(R feastol, int start=0, int incr=1)
internal implementation of SPxPricer::selectLeave()
virtual void entered4(SPxId id, int n)
Representation
LP basis representation.
Definition: spxsolver.h:116
DIdxSet bestPricesCo
set of best pricing candidates
Definition: spxdevexpr.h:57
SPxId selectEnterHyperDim(R &best, R feastol)
implementation of hyper sparse pricing in the entering Simplex
virtual int selectLeave()
virtual ~SPxDevexPR()
destructor
Definition: spxdevexpr.h:122
Devex pricer.The Devex Pricer for SoPlex implements an approximate steepest edge pricing, that does without solving an extra linear system and computing the scalar products.
Definition: spxdevexpr.h:44
SPxDevexPR()
default constructor
Definition: spxdevexpr.h:99
virtual void addedCoVecs(int n)
n covectors have been added to loaded LP.
void setupWeights(typename SPxSolverBase< R >::Type)
set entering/leaving algorithm
Abstract pricer base class.
Sequential object-oriented SimPlex.SPxSolverBase is an LP solver class using the revised Simplex algo...
Definition: spxbasis.h:49
SPxPricer & operator=(const SPxPricer &rhs)
assignment operator
Definition: spxpricer.h:281
SPxId buildBestPriceVectorEnterCoDim(R &best, R feastol)
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
int selectLeaveSparse(R feastol)
implementation of sparse pricing in the leaving Simplex
SPxDevexPR & operator=(const SPxDevexPR &rhs)
assignment operator
Definition: spxdevexpr.h:111
Array< typename SPxPricer< R >::IdxElement > pricesCo
temporary array of precomputed pricing values
Definition: spxdevexpr.h:55
virtual SPxPricer< R > * clone() const
clone function for polymorphism
Definition: spxdevexpr.h:125
Array< typename SPxPricer< R >::IdxElement > prices
temporary array of precomputed pricing values
Definition: spxdevexpr.h:53
Generic Ids for LP rows or columns.Both SPxColIds and SPxRowIds may be treated uniformly as SPxIds: ...
Definition: spxid.h:85
SPxDevexPR(const SPxDevexPR &old)
copy constructor
Definition: spxdevexpr.h:105
virtual SPxId selectEnter()
SPxId selectEnterSparseCoDim(R &best, R feastol)
implementation of sparse pricing in the entering Simplex
virtual void left4(int n, SPxId id)
int selectLeaveHyper(R feastol)
implementation of hyper sparse pricing in the leaving Simplex
Abstract pricer base class.Class SPxPricer is a pure virtual class defining the interface for pricer ...
Definition: spxpricer.h:47
Dynamic index set.Class DIdxSet provides dynamic IdxSet in the sense, that no restrictions are posed ...
Definition: didxset.h:42
DIdxSet bestPrices
set of best pricing candidates
Definition: spxdevexpr.h:56
SPxId selectEnterX(R tol)
choose the best entering index among columns and rows but prefer sparsity
Debugging, floating point type and parameter definitions.
SPxId selectEnterHyperCoDim(R &best, R feastol)
implementation of hyper sparse pricing in the entering Simplex
SPxId buildBestPriceVectorEnterDim(R &best, R feastol)
build up vector of pricing values for later use
Everything should be within this namespace.
SPxId selectEnterDenseCoDim(R &best, R feastol, int start=0, int incr=1)
SPxPricer::selectEnter() in dense case.
virtual void addedVecs(int n)
n vectors have been added to loaded LP.
R last
penalty, selected at last iteration.
Definition: spxdevexpr.h:51
bool refined
has a refinement step already been tried?
Definition: spxdevexpr.h:58
virtual void load(SPxSolverBase< R > *base)
sets the solver
SPxId selectEnterSparseDim(R &best, R feastol)
implementation of sparse pricing in the entering Simplex (slack variables)
virtual void setType(typename SPxSolverBase< R >::Type)
set entering/leaving algorithm
virtual bool isConsistent() const
consistency check
int buildBestPriceVectorLeave(R feastol)
build up vector of pricing values for later use
Type
Algorithmic type.
Definition: spxsolver.h:135
virtual void setRep(typename SPxSolverBase< R >::Representation)
set row/column representation