Scippy

SoPlex

Sequential object-oriented simPlex

spxautopr.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 spxautopr.h
17  * @brief Auto pricer.
18  */
19 #ifndef _SPXAUTOPR_H_
20 #define _SPXAUTOPR_H_
21 
22 #include <assert.h>
23 
24 #include "soplex/spxpricer.h"
25 #include "soplex/spxdevexpr.h"
26 #include "soplex/spxsteeppr.h"
27 #include "soplex/spxsteepexpr.h"
28 
29 
30 namespace soplex
31 {
32 
33 /**@brief Auto pricer.
34  @ingroup Algo
35 
36  This pricer switches between Devex and Steepest edge pricer based on the difficulty of the problem
37  which is determined by the number of iterations.
38 
39  See SPxPricer for a class documentation.
40 */
41 template <class R>
42 class SPxAutoPR : public SPxPricer<R>
43 {
44 private:
45 
46  int switchIters; ///< number of iterations before switching pricers
47  SPxPricer<R>* activepricer; ///< pointer to currently selected pricer
48  SPxDevexPR<R> devex; ///< internal Devex pricer
49  SPxSteepExPR<R> steep; ///< internal Steepest edge pricer
50 
52  type); ///< switches active pricing method
53 
54 public:
55 
56  //-------------------------------------
57  /**@name Constructors / destructors */
58  ///@{
59  /// default constructor
61  : SPxPricer<R>("Auto")
62  , switchIters(10000)
63  , activepricer(&devex)
64  , devex()
65  , steep()
66  {}
67  /// copy constructor
68  SPxAutoPR(const SPxAutoPR& old)
69  : SPxPricer<R>(old)
70  , switchIters(old.switchIters)
71  , devex(old.devex)
72  , steep(old.steep)
73  {
74  assert(old.activepricer == &old.devex || old.activepricer == &old.steep);
75 
76  if(old.activepricer == &old.devex)
77  activepricer = &devex;
78  else
79  activepricer = &steep;
80  }
81  /// assignment operator
83  {
84  if(this != &rhs)
85  {
87  switchIters = rhs.switchIters;
88  devex = rhs.devex;
89  steep = rhs.steep;
90 
91  assert(rhs.activepricer == &rhs.devex || rhs.activepricer == &rhs.steep);
92 
93  if(rhs.activepricer == &rhs.devex)
94  activepricer = &devex;
95  else
96  activepricer = &steep;
97  }
98 
99  return *this;
100  }
101  /// destructor
102  virtual ~SPxAutoPR()
103  {}
104  /// clone function for polymorphism
105  inline virtual SPxPricer<R>* clone() const
106  {
107  return new SPxAutoPR(*this);
108  }
109  ///@}
110 
111  //-------------------------------------
112  /**@name Access / modification */
113  ///@{
114  /// set max number of iterations before switching pricers
115  void setSwitchIters(int iters);
116  /// clear the data
117  void clear();
118  /// set epsilon of internal pricers
119  void setEpsilon(R eps);
120  /// set the solver
121  virtual void load(SPxSolverBase<R>* base);
122  /// set entering/leaving algorithm
123  virtual void setType(typename SPxSolverBase<R>::Type);
124  /// set row/column representation
125  virtual void setRep(typename SPxSolverBase<R>::Representation);
126  ///
127  virtual int selectLeave();
128  ///
129  virtual SPxId selectEnter();
130  ///
131  virtual void left4(int n, SPxId id);
132  ///
133  virtual void entered4(SPxId id, int n);
134  ///@}
135 };
136 } // namespace soplex
137 
138 // For general templated functions
139 #include "spxautopr.hpp"
140 
141 #endif // _SPXAUTOPR_H_
void clear()
clear the data
Representation
LP basis representation.
Definition: spxsolver.h:116
virtual int selectLeave()
void setSwitchIters(int iters)
set max number of iterations before switching pricers
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
virtual void entered4(SPxId id, int n)
Steepest edge pricer.Class SPxSteepExPR implements a steepest edge pricer to be used with SoPlex...
Definition: spxsteepexpr.h:41
Abstract pricer base class.
Sequential object-oriented SimPlex.SPxSolverBase is an LP solver class using the revised Simplex algo...
Definition: spxbasis.h:49
int switchIters
number of iterations before switching pricers
Definition: spxautopr.h:46
SPxAutoPR()
default constructor
Definition: spxautopr.h:60
SPxPricer & operator=(const SPxPricer &rhs)
assignment operator
Definition: spxpricer.h:281
virtual void load(SPxSolverBase< R > *base)
set the solver
Auto pricer.This pricer switches between Devex and Steepest edge pricer based on the difficulty of th...
Definition: spxautopr.h:42
Devex pricer.
SPxDevexPR< R > devex
internal Devex pricer
Definition: spxautopr.h:48
virtual void left4(int n, SPxId id)
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 void setRep(typename SPxSolverBase< R >::Representation)
set row/column representation
virtual ~SPxAutoPR()
destructor
Definition: spxautopr.h:102
virtual SPxPricer< R > * clone() const
clone function for polymorphism
Definition: spxautopr.h:105
Abstract pricer base class.Class SPxPricer is a pure virtual class defining the interface for pricer ...
Definition: spxpricer.h:47
virtual void setType(typename SPxSolverBase< R >::Type)
set entering/leaving algorithm
void setEpsilon(R eps)
set epsilon of internal pricers
Everything should be within this namespace.
SPxSteepExPR< R > steep
internal Steepest edge pricer
Definition: spxautopr.h:49
Steepest edge pricer with exact initialization of weights.
SPxAutoPR(const SPxAutoPR &old)
copy constructor
Definition: spxautopr.h:68
SPxPricer< R > * activepricer
pointer to currently selected pricer
Definition: spxautopr.h:47
bool setActivePricer(typename SPxSolverBase< R >::Type type)
switches active pricing method
Type
Algorithmic type.
Definition: spxsolver.h:135
virtual SPxId selectEnter()
SPxAutoPR & operator=(const SPxAutoPR &rhs)
assignment operator
Definition: spxautopr.h:82