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 59 SPxSteepPR<R> steep; 60 /// partial multiple pricer 61 SPxParMultPR<R> parmult; 62 /// devex pricer 63 SPxDevexPR<R> devex; 64 /// the currently used pricer 65 SPxPricer<R>* thepricer; 66 /// factor between dim and coDim of the problem to decide about the pricer 67 R hybridFactor; 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 110 SPxHybridPR() 111 : SPxPricer<R>("Hybrid") 112 , thepricer(0) 113 , hybridFactor(3.0) // we want the ParMult pricer 114 {} 115 /// copy constructor 116 SPxHybridPR(const SPxHybridPR& old) 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 141 SPxHybridPR& operator=(const SPxHybridPR& rhs) 142 { 143 if(this != &rhs) 144 { 145 SPxPricer<R>::operator=(rhs); 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_ 187