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