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