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