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-2023 Zuse Institute Berlin (ZIB) */
7 /* */
8 /* Licensed under the Apache License, Version 2.0 (the "License"); */
9 /* you may not use this file except in compliance with the License. */
10 /* You may obtain a copy of the License at */
11 /* */
12 /* http://www.apache.org/licenses/LICENSE-2.0 */
13 /* */
14 /* Unless required by applicable law or agreed to in writing, software */
15 /* distributed under the License is distributed on an "AS IS" BASIS, */
16 /* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
17 /* See the License for the specific language governing permissions and */
18 /* limitations under the License. */
19 /* */
20 /* You should have received a copy of the Apache-2.0 license */
21 /* along with SoPlex; see the file LICENSE. If not email to soplex@zib.de. */
22 /* */
23 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
24 
25 /**@file spxhybridpr.h
26  * @brief Hybrid pricer.
27  */
28 #ifndef _SPXHYBRIDPR_H_
29 #define _SPXHYBRIDPR_H_
30 
31 #include <assert.h>
32 
33 #include "soplex/spxdefines.h"
34 #include "soplex/spxpricer.h"
35 #include "soplex/spxdevexpr.h"
36 #include "soplex/spxparmultpr.h"
37 #include "soplex/spxsteeppr.h"
38 
39 namespace soplex
40 {
41 
42 /**@brief Hybrid pricer.
43  @ingroup Algo
44 
45  The hybrid pricer for SoPlex tries to guess the best pricing strategy to
46  use for pricing the loaded LP with the loaded algorithm type and basis
47  representation. Currently it does so by switching between SPxSteepPR,
48  SPxDevexPR and SPxParMultPR.
49 
50  See SPxPricer for a class documentation.
51 */
52 template <class R>
53 class SPxHybridPR : public SPxPricer<R>
54 {
55  //-------------------------------------
56  /**@name Data */
57  ///@{
58  /// steepest edge pricer
60  /// partial multiple pricer
62  /// devex pricer
64  /// the currently used pricer
66  /// factor between dim and coDim of the problem to decide about the pricer
68  ///@}
69 
70 public:
71 
72  //-------------------------------------
73  /**@name Access / modification */
74  ///@{
75  /// sets the epsilon
76  virtual void setPricingTolerance(R tol);
77  /// sets the solver
78  virtual void load(SPxSolverBase<R>* solver);
79  /// clears all pricers and unselects the current pricer
80  virtual void clear();
81  /// sets entering or leaving algorithm
82  virtual void setType(typename SPxSolverBase<R>::Type tp);
83  /// sets row or column representation
84  virtual void setRep(typename SPxSolverBase<R>::Representation rep);
85  /// selects the leaving algorithm
86  virtual int selectLeave();
87  /// selects the entering algorithm
88  virtual SPxId selectEnter();
89  /// calls left4 on the current pricer
90  virtual void left4(int n, SPxId id);
91  /// calls entered4 on the current pricer
92  virtual void entered4(SPxId id, int n);
93  /// calls addedVecs(n) on all pricers
94  virtual void addedVecs(int n);
95  /// calls addedCoVecs(n) on all pricers
96  virtual void addedCoVecs(int n);
97  ///@}
98 
99  //-------------------------------------
100  /**@name Consistency check */
101  ///@{
102  /// consistency check
103  virtual bool isConsistent() const;
104  ///@}
105 
106  //-------------------------------------
107  /**@name Construction / destruction */
108  ///@{
109  /// default constructor
111  : SPxPricer<R>("Hybrid")
112  , thepricer(0)
113  , hybridFactor(3.0) // we want the ParMult pricer
114  {}
115  /// copy constructor
117  : SPxPricer<R>(old)
118  , steep(old.steep)
119  , parmult(old.parmult)
120  , devex(old.devex)
121  , hybridFactor(old.hybridFactor)
122  {
123  if(old.thepricer == &old.steep)
124  {
125  thepricer = &steep;
126  }
127  else if(old.thepricer == &old.parmult)
128  {
129  thepricer = &parmult;
130  }
131  else if(old.thepricer == &old.devex)
132  {
133  thepricer = &devex;
134  }
135  else // old.thepricer should be 0
136  {
137  thepricer = 0;
138  }
139  }
140  /// assignment operator
142  {
143  if(this != &rhs)
144  {
146  steep = rhs.steep;
147  parmult = rhs.parmult;
148  devex = rhs.devex;
149  hybridFactor = rhs.hybridFactor;
150 
151  if(rhs.thepricer == &rhs.steep)
152  {
153  thepricer = &steep;
154  }
155  else if(rhs.thepricer == &rhs.parmult)
156  {
157  thepricer = &parmult;
158  }
159  else if(rhs.thepricer == &rhs.devex)
160  {
161  thepricer = &devex;
162  }
163  else // rhs.thepricer should be 0
164  {
165  thepricer = 0;
166  }
167  }
168 
169  return *this;
170  }
171  /// destructor
172  virtual ~SPxHybridPR()
173  {}
174  /// clone function for polymorphism
175  inline virtual SPxPricer<R>* clone() const
176  {
177  return new SPxHybridPR(*this);
178  }
179  ///@}
180 };
181 
182 } // namespace soplex
183 
184 // For general templated functions
185 #include "spxhybridpr.hpp"
186 #endif // _SPXHYBRIDPR_H_
virtual void setType(typename SPxSolverBase< R >::Type tp)
sets entering or leaving algorithm
Representation
LP basis representation.
Definition: spxsolver.h:125
virtual void clear()
clears all pricers and unselects the current pricer
SPxSteepPR< R > steep
steepest edge pricer
Definition: spxhybridpr.h:59
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:53
SPxHybridPR & operator=(const SPxHybridPR &rhs)
assignment operator
Definition: spxhybridpr.h:141
Abstract pricer base class.
Sequential object-oriented SimPlex.SPxSolverBase is an LP solver class using the revised Simplex algo...
Definition: spxbasis.h:58
SPxPricer & operator=(const SPxPricer &rhs)
assignment operator
Definition: spxpricer.h:298
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 void setPricingTolerance(R tol)
sets the epsilon
virtual SPxSolverBase< R > * solver() const
returns loaded SPxSolverBase object.
Definition: spxpricer.h:139
Devex pricer.
Partial multiple pricing.Class SPxParMultPr is an implementation class for SPxPricer implementing Dan...
Definition: spxparmultpr.h:57
SPxHybridPR(const SPxHybridPR &old)
copy constructor
Definition: spxhybridpr.h:116
Steepest edge pricer.
Generic Ids for LP rows or columns.Both SPxColIds and SPxRowIds may be treated uniformly as SPxIds: ...
Definition: spxid.h:94
virtual SPxPricer< R > * clone() const
clone function for polymorphism
Definition: spxhybridpr.h:175
Abstract pricer base class.Class SPxPricer is a pure virtual class defining the interface for pricer ...
Definition: spxpricer.h:56
virtual void load(SPxSolverBase< R > *solver)
sets the solver
SPxPricer< R > * thepricer
the currently used pricer
Definition: spxhybridpr.h:65
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:53
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:67
SPxHybridPR()
default constructor
Definition: spxhybridpr.h:110
virtual void setRep(typename SPxSolverBase< R >::Representation rep)
sets row or column representation
SPxParMultPR< R > parmult
partial multiple pricer
Definition: spxhybridpr.h:61
virtual ~SPxHybridPR()
destructor
Definition: spxhybridpr.h:172
Type
Algorithmic type.
Definition: spxsolver.h:144
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:51
SPxDevexPR< R > devex
devex pricer
Definition: spxhybridpr.h:63