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-2024 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
39namespace 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*/
50template <class R>
51class SPxAutoPR : public SPxPricer<R>
52{
53private:
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
63public:
64
65 //-------------------------------------
66 /**@name Constructors / destructors */
67 ///@{
68 /// default constructor
70 : SPxPricer<R>("Auto")
71 , switchIters(10000)
73 , devex()
74 , steep()
75 {}
76 /// copy constructor
77 SPxAutoPR(const SPxAutoPR& old)
78 : SPxPricer<R>(old)
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)
87 else
89 }
90 /// assignment operator
92 {
93 if(this != &rhs)
94 {
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)
104 else
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
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
135 ///
136 virtual int selectLeave();
137 ///
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_
Auto pricer.
Definition: spxautopr.h:52
SPxAutoPR(const SPxAutoPR &old)
copy constructor
Definition: spxautopr.h:77
virtual SPxPricer< R > * clone() const
clone function for polymorphism
Definition: spxautopr.h:114
int switchIters
number of iterations before switching pricers
Definition: spxautopr.h:55
void setSwitchIters(int iters)
set max number of iterations before switching pricers
SPxAutoPR & operator=(const SPxAutoPR &rhs)
assignment operator
Definition: spxautopr.h:91
SPxPricer< R > * activepricer
pointer to currently selected pricer
Definition: spxautopr.h:56
virtual ~SPxAutoPR()
destructor
Definition: spxautopr.h:111
virtual void entered4(SPxId id, int n)
SPxDevexPR< R > devex
internal Devex pricer
Definition: spxautopr.h:57
bool setActivePricer(typename SPxSolverBase< R >::Type type)
switches active pricing method
virtual void load(SPxSolverBase< R > *base)
set the solver
void setPricingTolerance(R tol)
set tolerances of internal pricers
SPxAutoPR()
default constructor
Definition: spxautopr.h:69
virtual void setType(typename SPxSolverBase< R >::Type)
set entering/leaving algorithm
virtual void setRep(typename SPxSolverBase< R >::Representation)
set row/column representation
void clear()
clear the data
virtual void left4(int n, SPxId id)
virtual int selectLeave()
SPxSteepExPR< R > steep
internal Steepest edge pricer
Definition: spxautopr.h:58
virtual SPxId selectEnter()
Devex pricer.
Definition: spxdevexpr.h:54
Generic Ids for LP rows or columns.
Definition: spxid.h:95
Abstract pricer base class.
Definition: spxpricer.h:57
SPxPricer & operator=(const SPxPricer &rhs)
assignment operator
Definition: spxpricer.h:298
Sequential object-oriented SimPlex.
Definition: spxsolver.h:104
Type
Algorithmic type.
Definition: spxsolver.h:143
Representation
LP basis representation.
Definition: spxsolver.h:124
Steepest edge pricer.
Definition: spxsteepexpr.h:51
Everything should be within this namespace.
Devex pricer.
Abstract pricer base class.
Steepest edge pricer with exact initialization of weights.
Steepest edge pricer.