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 #include <iostream> 26 27 #include "soplex/spxdefines.h" 28 #include "soplex/spxout.h" 29 30 namespace soplex 31 { 32 template <class R> 33 bool SPxHybridPR<R>::isConsistent() const 34 { 35 #ifdef ENABLE_CONSISTENCY_CHECKS 36 37 if(this->_tolerances == nullptr) 38 return SPX_MSG_INCONSISTENT("SPxHybridPR"); 39 40 if(this->thesolver != 0 && 41 (this->thesolver != steep.solver() || 42 this->thesolver != devex.solver() || 43 this->thesolver != parmult.solver())) 44 return SPX_MSG_INCONSISTENT("SPxHybridPR"); 45 46 return steep.isConsistent() 47 && devex.isConsistent() 48 && parmult.isConsistent(); 49 #else 50 return true; 51 #endif 52 } 53 54 template <class R> 55 void SPxHybridPR<R>::load(SPxSolverBase<R>* p_solver) 56 { 57 steep.load(p_solver); 58 devex.load(p_solver); 59 parmult.load(p_solver); 60 this->thesolver = p_solver; 61 setType(p_solver->type()); 62 } 63 64 template <class R> 65 void SPxHybridPR<R>::clear() 66 { 67 steep.clear(); 68 devex.clear(); 69 parmult.clear(); 70 this->thesolver = 0; 71 } 72 73 template <class R> 74 void SPxHybridPR<R>::setPricingTolerance(R tol) 75 { 76 steep.setPricingTolerance(tol); 77 devex.setPricingTolerance(tol); 78 parmult.setPricingTolerance(tol); 79 } 80 81 template <class R> 82 void SPxHybridPR<R>::setType(typename SPxSolverBase<R>::Type tp) 83 { 84 if(tp == SPxSolverBase<R>::LEAVE) 85 { 86 thepricer = &steep; 87 this->thesolver->setPricing(SPxSolverBase<R>::FULL); 88 } 89 else 90 { 91 if(this->thesolver->dim() > hybridFactor * this->thesolver->coDim()) 92 { 93 /**@todo I changed from devex to steepest edge pricing here 94 * because of numerical difficulties, this should be 95 * investigated. 96 */ 97 // thepricer = &devex; 98 thepricer = &steep; 99 this->thesolver->setPricing(SPxSolverBase<R>::FULL); 100 } 101 else 102 { 103 thepricer = &parmult; 104 this->thesolver->setPricing(SPxSolverBase<R>::PARTIAL); 105 } 106 } 107 108 SPX_MSG_INFO1((*this->thesolver->spxout), (*this->thesolver->spxout) << "IPRHYB01 switching to " 109 << thepricer->getName() << std::endl;) 110 111 thepricer->setType(tp); 112 } 113 114 template <class R> 115 void SPxHybridPR<R>::setRep(typename SPxSolverBase<R>::Representation rep) 116 { 117 steep.setRep(rep); 118 devex.setRep(rep); 119 parmult.setRep(rep); 120 } 121 122 template <class R> 123 int SPxHybridPR<R>::selectLeave() 124 { 125 return thepricer->selectLeave(); 126 } 127 128 template <class R> 129 void SPxHybridPR<R>::left4(int n, SPxId id) 130 { 131 thepricer->left4(n, id); 132 } 133 134 template <class R> 135 SPxId SPxHybridPR<R>::selectEnter() 136 { 137 return thepricer->selectEnter(); 138 } 139 140 template <class R> 141 void SPxHybridPR<R>::entered4(SPxId id, int n) 142 { 143 thepricer->entered4(id, n); 144 } 145 146 template <class R> 147 void SPxHybridPR<R>::addedVecs(int n) 148 { 149 steep.addedVecs(n); 150 devex.addedVecs(n); 151 parmult.addedVecs(n); 152 } 153 154 template <class R> 155 void SPxHybridPR<R>::addedCoVecs(int n) 156 { 157 steep.addedCoVecs(n); 158 devex.addedCoVecs(n); 159 parmult.addedCoVecs(n); 160 } 161 162 } // namespace soplex 163