Scippy

SoPlex

Sequential object-oriented simPlex

spxhybridpr.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 spxhybridpr.h
17  * @brief Hybrid pricer.
18  */
19 #ifndef _SPXHYBRIDPR_H_
20 #define _SPXHYBRIDPR_H_
21 
22 #include <assert.h>
23 
24 #include "soplex/spxdefines.h"
25 #include "soplex/spxpricer.h"
26 #include "soplex/spxdevexpr.h"
27 #include "soplex/spxparmultpr.h"
28 #include "soplex/spxsteeppr.h"
29 
30 namespace soplex
31 {
32 
33 /**@brief Hybrid pricer.
34  @ingroup Algo
35 
36  The hybrid pricer for SoPlex tries to guess the best pricing strategy to
37  use for pricing the loaded LP with the loaded algorithm type and basis
38  representation. Currently it does so by switching between SPxSteepPR,
39  SPxDevexPR and SPxParMultPR.
40 
41  See SPxPricer for a class documentation.
42 */
43 template <class R>
44 class SPxHybridPR : public SPxPricer<R>
45 {
46  //-------------------------------------
47  /**@name Data */
48  ///@{
49  /// steepest edge pricer
51  /// partial multiple pricer
53  /// devex pricer
55  /// the currently used pricer
57  /// factor between dim and coDim of the problem to decide about the pricer
59  ///@}
60 
61 public:
62 
63  //-------------------------------------
64  /**@name Access / modification */
65  ///@{
66  /// sets the epsilon
67  virtual void setEpsilon(R eps);
68  /// sets the solver
69  virtual void load(SPxSolverBase<R>* solver);
70  /// clears all pricers and unselects the current pricer
71  virtual void clear();
72  /// sets entering or leaving algorithm
73  virtual void setType(typename SPxSolverBase<R>::Type tp);
74  /// sets row or column representation
75  virtual void setRep(typename SPxSolverBase<R>::Representation rep);
76  /// selects the leaving algorithm
77  virtual int selectLeave();
78  /// selects the entering algorithm
79  virtual SPxId selectEnter();
80  /// calls left4 on the current pricer
81  virtual void left4(int n, SPxId id);
82  /// calls entered4 on the current pricer
83  virtual void entered4(SPxId id, int n);
84  /// calls addedVecs(n) on all pricers
85  virtual void addedVecs(int n);
86  /// calls addedCoVecs(n) on all pricers
87  virtual void addedCoVecs(int n);
88  ///@}
89 
90  //-------------------------------------
91  /**@name Consistency check */
92  ///@{
93  /// consistency check
94  virtual bool isConsistent() const;
95  ///@}
96 
97  //-------------------------------------
98  /**@name Construction / destruction */
99  ///@{
100  /// default constructor
102  : SPxPricer<R>("Hybrid")
103  , thepricer(0)
104  , hybridFactor(3.0) // we want the ParMult pricer
105  {}
106  /// copy constructor
108  : SPxPricer<R>(old)
109  , steep(old.steep)
110  , parmult(old.parmult)
111  , devex(old.devex)
112  , hybridFactor(old.hybridFactor)
113  {
114  if(old.thepricer == &old.steep)
115  {
116  thepricer = &steep;
117  }
118  else if(old.thepricer == &old.parmult)
119  {
120  thepricer = &parmult;
121  }
122  else if(old.thepricer == &old.devex)
123  {
124  thepricer = &devex;
125  }
126  else // old.thepricer should be 0
127  {
128  thepricer = 0;
129  }
130  }
131  /// assignment operator
133  {
134  if(this != &rhs)
135  {
137  steep = rhs.steep;
138  parmult = rhs.parmult;
139  devex = rhs.devex;
140  hybridFactor = rhs.hybridFactor;
141 
142  if(rhs.thepricer == &rhs.steep)
143  {
144  thepricer = &steep;
145  }
146  else if(rhs.thepricer == &rhs.parmult)
147  {
148  thepricer = &parmult;
149  }
150  else if(rhs.thepricer == &rhs.devex)
151  {
152  thepricer = &devex;
153  }
154  else // rhs.thepricer should be 0
155  {
156  thepricer = 0;
157  }
158  }
159 
160  return *this;
161  }
162  /// destructor
163  virtual ~SPxHybridPR()
164  {}
165  /// clone function for polymorphism
166  inline virtual SPxPricer<R>* clone() const
167  {
168  return new SPxHybridPR(*this);
169  }
170  ///@}
171 };
172 
173 } // namespace soplex
174 
175 // For general templated functions
176 #include "spxhybridpr.hpp"
177 #endif // _SPXHYBRIDPR_H_
virtual void setType(typename SPxSolverBase< R >::Type tp)
sets entering or leaving algorithm
Representation
LP basis representation.
Definition: spxsolver.h:116
virtual void clear()
clears all pricers and unselects the current pricer
SPxSteepPR< R > steep
steepest edge pricer
Definition: spxhybridpr.h:50
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
SPxHybridPR & operator=(const SPxHybridPR &rhs)
assignment operator
Definition: spxhybridpr.h:132
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
virtual SPxId selectEnter()
selects the entering algorithm
virtual bool isConsistent() const
consistency check
virtual void entered4(SPxId id, int n)
calls entered4 on the current pricer
virtual SPxSolverBase< R > * solver() const
returns loaded SPxSolverBase object.
Definition: spxpricer.h:128
Devex pricer.
Partial multiple pricing.Class SPxParMultPr is an implementation class for SPxPricer implementing Dan...
Definition: spxparmultpr.h:48
SPxHybridPR(const SPxHybridPR &old)
copy constructor
Definition: spxhybridpr.h:107
Steepest edge pricer.
Generic Ids for LP rows or columns.Both SPxColIds and SPxRowIds may be treated uniformly as SPxIds: ...
Definition: spxid.h:85
virtual SPxPricer< R > * clone() const
clone function for polymorphism
Definition: spxhybridpr.h:166
virtual void setEpsilon(R eps)
sets the epsilon
Abstract pricer base class.Class SPxPricer is a pure virtual class defining the interface for pricer ...
Definition: spxpricer.h:47
virtual void load(SPxSolverBase< R > *solver)
sets the solver
SPxPricer< R > * thepricer
the currently used pricer
Definition: spxhybridpr.h:56
Debugging, floating point type and parameter definitions.
virtual void addedCoVecs(int n)
calls addedCoVecs(n) on all pricers
Hybrid pricer.The hybrid pricer for SoPlex tries to guess the best pricing strategy to use for pricin...
Definition: spxhybridpr.h:44
Everything should be within this namespace.
virtual int selectLeave()
selects the leaving algorithm
Partial multiple pricing.
virtual void left4(int n, SPxId id)
calls left4 on the current pricer
R hybridFactor
factor between dim and coDim of the problem to decide about the pricer
Definition: spxhybridpr.h:58
SPxHybridPR()
default constructor
Definition: spxhybridpr.h:101
virtual void setRep(typename SPxSolverBase< R >::Representation rep)
sets row or column representation
SPxParMultPR< R > parmult
partial multiple pricer
Definition: spxhybridpr.h:52
virtual ~SPxHybridPR()
destructor
Definition: spxhybridpr.h:163
Type
Algorithmic type.
Definition: spxsolver.h:135
virtual void addedVecs(int n)
calls addedVecs(n) on all pricers
Steepest edge pricer.Class SPxSteepPR implements a steepest edge pricer to be used with SoPlex...
Definition: spxsteeppr.h:42
SPxDevexPR< R > devex
devex pricer
Definition: spxhybridpr.h:54