Scippy

SoPlex

Sequential object-oriented simPlex

spxweightpr.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-2019 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 spxweightpr.h
17  * @brief Weighted pricing.
18  */
19 #ifndef _SPXWEIGHTPR_H_
20 #define _SPXWEIGHTPR_H_
21 
22 #include "soplex/spxdefines.h"
23 #include "soplex/spxpricer.h"
24 
25 namespace soplex
26 {
27 
28 /**@brief Weighted pricing.
29  @ingroup Algo
30 
31  Class SPxWeightPR is an implemantation class of SPxPricer that uses
32  weights for columns and rows for selecting the Simplex pivots. The weights
33  are computed by methods #computeCP() and #computeRP() which may be
34  overridden by derived classes.
35 
36  The weights are interpreted as follows: The higher a value is, the more
37  likely the corresponding row or column is set on one of its bounds.
38 
39  See SPxPricer for a class documentation.
40 */
41 class SPxWeightPR : public SPxPricer
42 {
43 private:
44 
45  //-------------------------------------
46  /**@name Data */
47  //@{
48  /// column penalties
50  /// row penalties
52  /// penalties for leaving alg
54  ///
55  const Real* penalty;
56  ///
57  const Real* coPenalty;
58  /// length of objective vector.
60  //@}
61 
62  //-------------------------------------
63  /**@name Private helpers */
64  //@{
65  /// compute leave penalties.
66  void computeLeavePenalty(int start, int end);
67  /// compute weights for columns.
68  void computeCP(int start, int end);
69  /// compute weights for rows.
70  void computeRP(int start, int end);
71  //@}
72 
73 public:
74 
75  //-------------------------------------
76  /**@name Construction / destruction */
77  //@{
78  /// default constructor
80  : SPxPricer("Weight")
81  , penalty(0)
82  , coPenalty(0)
83  , objlength(0)
84  {}
85  /// copy constructor
87  : SPxPricer(old)
88  , cPenalty(old.cPenalty)
89  , rPenalty(old.rPenalty)
90  , leavePenalty(old.leavePenalty)
91  , penalty(0)
92  , coPenalty(0)
93  , objlength(old.objlength)
94  {
95  if(old.penalty == old.rPenalty.get_const_ptr())
96  {
97  penalty = rPenalty.get_const_ptr();
98  coPenalty = cPenalty.get_const_ptr();
99  }
100  else if(old.penalty == old.cPenalty.get_const_ptr())
101  {
102  penalty = cPenalty.get_const_ptr();
103  coPenalty = rPenalty.get_const_ptr();
104  }
105 
106  // otherwise, old.penalty and old.coPenalty are not set and do not have to be copied
107  }
108  /// assignment operator
110  {
111  if(this != &rhs)
112  {
114  cPenalty = rhs.cPenalty;
115  rPenalty = rhs.rPenalty;
116  leavePenalty = rhs.leavePenalty;
117  objlength = rhs.objlength;
118 
119  if(rhs.penalty == rhs.rPenalty.get_const_ptr())
120  {
121  penalty = rPenalty.get_const_ptr();
122  coPenalty = cPenalty.get_const_ptr();
123  }
124  else if(rhs.penalty == rhs.cPenalty.get_const_ptr())
125  {
126  penalty = cPenalty.get_const_ptr();
127  coPenalty = rPenalty.get_const_ptr();
128  }
129 
130  // otherwise, old.penalty and old.coPenalty are not set and do not have to be copied
131  }
132 
133  return *this;
134  }
135  /// destructor
136  virtual ~SPxWeightPR()
137  {}
138  /// clone function for polymorphism
139  inline virtual SPxPricer* clone() const
140  {
141  return new SPxWeightPR(*this);
142  }
143  //@}
144 
145  //-------------------------------------
146  /**@name Access / modification */
147  //@{
148  /// sets the solver
149  virtual void load(SPxSolver* base);
150  /// set entering/leaving algorithm
151  void setType(SPxSolver::Type tp);
152  /// set row/column representation
154  ///
155  virtual int selectLeave();
156  ///
157  virtual SPxId selectEnter();
158  /// \p n vectors have been added to the loaded LP.
159  virtual void addedVecs(int n);
160  /// \p n covectors have been added to the loaded LP.
161  virtual void addedCoVecs(int n);
162  /// \p the i'th vector has been removed from the loaded LP.
163  virtual void removedVec(int i);
164  /// \p the i'th covector has been removed from the loaded LP.
165  virtual void removedCoVec(int i);
166  /// \p n vectors have been removed from the loaded LP.
167  virtual void removedVecs(const int perm[]);
168  /// \p n covectors have been removed from the loaded LP.
169  virtual void removedCoVecs(const int perm[]);
170  //@}
171 
172  //-------------------------------------
173  /**@name Consistency check */
174  //@{
175  /// checks for consistency
176  virtual bool isConsistent() const;
177  //@}
178 };
179 } // namespace soplex
180 #endif // _SPXWEIGHTPR_H_
Type
Algorithmic type.
Definition: spxsolver.h:124
const Real * penalty
Definition: spxweightpr.h:55
Abstract pricer base class.
void setType(SPxSolver::Type tp)
set entering/leaving algorithm
Definition: spxweightpr.cpp:39
Representation
LP basis representation.
Definition: spxsolver.h:105
SPxPricer & operator=(const SPxPricer &rhs)
assignment operator
Definition: spxpricer.h:277
void computeCP(int start, int end)
compute weights for columns.
Definition: spxweightpr.cpp:80
const R * get_const_ptr() const
Conversion to C-style pointer.
Definition: vectorbase.h:455
const Real * coPenalty
Definition: spxweightpr.h:57
Generic Ids for LP rows or columns.Both SPxColIds and SPxRowIds may be treated uniformly as SPxIds: ...
Definition: spxid.h:85
double Real
Definition: spxdefines.h:218
Weighted pricing.Class SPxWeightPR is an implemantation class of SPxPricer that uses weights for colu...
Definition: spxweightpr.h:41
virtual SPxPricer * clone() const
clone function for polymorphism
Definition: spxweightpr.h:139
SPxWeightPR(const SPxWeightPR &old)
copy constructor
Definition: spxweightpr.h:86
virtual void removedVecs(const int perm[])
n vectors have been removed from the loaded LP.
DVector cPenalty
column penalties
Definition: spxweightpr.h:49
virtual void addedVecs(int n)
n vectors have been added to the loaded LP.
virtual void removedCoVecs(const int perm[])
n covectors have been removed from the loaded LP.
virtual ~SPxWeightPR()
destructor
Definition: spxweightpr.h:136
Abstract pricer base class.Class SPxPricer is a pure virtual class defining the interface for pricer ...
Definition: spxpricer.h:46
virtual void removedCoVec(int i)
the i'th covector has been removed from the loaded LP.
virtual SPxId selectEnter()
virtual void removedVec(int i)
the i'th vector has been removed from the loaded LP.
DVector leavePenalty
penalties for leaving alg
Definition: spxweightpr.h:53
Debugging, floating point type and parameter definitions.
virtual bool isConsistent() const
checks for consistency
Sequential object-oriented SimPlex.SPxSolver is an LP solver class using the revised Simplex algorith...
Definition: spxsolver.h:85
Everything should be within this namespace.
virtual void addedCoVecs(int n)
n covectors have been added to the loaded LP.
void computeLeavePenalty(int start, int end)
compute leave penalties.
Definition: spxweightpr.cpp:48
Real objlength
length of objective vector.
Definition: spxweightpr.h:59
void computeRP(int start, int end)
compute weights for rows.
Definition: spxweightpr.cpp:63
virtual int selectLeave()
SPxWeightPR & operator=(const SPxWeightPR &rhs)
assignment operator
Definition: spxweightpr.h:109
void setRep(SPxSolver::Representation rep)
set row/column representation
Definition: spxweightpr.cpp:25
virtual void load(SPxSolver *base)
sets the solver
Definition: spxweightpr.cpp:89
SPxWeightPR()
default constructor
Definition: spxweightpr.h:79
DVector rPenalty
row penalties
Definition: spxweightpr.h:51