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-2016 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 "spxdefines.h"
23 #include "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
86  SPxWeightPR( const SPxWeightPR& old)
87  : SPxPricer(old)
88  , cPenalty(old.cPenalty)
89  , rPenalty(old.rPenalty)
90  , leavePenalty(old.leavePenalty)
91  , objlength(old.objlength)
92  {
93  if (old.penalty == old.rPenalty.get_const_ptr())
94  {
95  penalty = rPenalty.get_const_ptr();
96  coPenalty = cPenalty.get_const_ptr();
97  }
98  else if (old.penalty == old.cPenalty.get_const_ptr())
99  {
100  penalty = cPenalty.get_const_ptr();
101  coPenalty = rPenalty.get_const_ptr();
102  }
103  // otherwise, old.penalty and old.coPenalty are not set and do not have to be copied
104  }
105  /// assignment operator
107  {
108  if(this != &rhs)
109  {
111  cPenalty = rhs.cPenalty;
112  rPenalty = rhs.rPenalty;
113  leavePenalty = rhs.leavePenalty;
114  objlength = rhs.objlength;
115  if (rhs.penalty == rhs.rPenalty.get_const_ptr())
116  {
117  penalty = rPenalty.get_const_ptr();
118  coPenalty = cPenalty.get_const_ptr();
119  }
120  else if (rhs.penalty == rhs.cPenalty.get_const_ptr())
121  {
122  penalty = cPenalty.get_const_ptr();
123  coPenalty = rPenalty.get_const_ptr();
124  }
125  // otherwise, old.penalty and old.coPenalty are not set and do not have to be copied
126  }
127 
128  return *this;
129  }
130  /// destructor
131  virtual ~SPxWeightPR()
132  {}
133  /// clone function for polymorphism
134  inline virtual SPxPricer* clone() const
135  {
136  return new SPxWeightPR(*this);
137  }
138  //@}
139 
140  //-------------------------------------
141  /**@name Access / modification */
142  //@{
143  /// sets the solver
144  virtual void load(SPxSolver* base);
145  /// set entering/leaving algorithm
146  void setType(SPxSolver::Type tp);
147  /// set row/column representation
149  ///
150  virtual int selectLeave();
151  ///
152  virtual SPxId selectEnter();
153  /// \p n vectors have been added to the loaded LP.
154  virtual void addedVecs (int n);
155  /// \p n covectors have been added to the loaded LP.
156  virtual void addedCoVecs(int n);
157  /// \p the i'th vector has been removed from the loaded LP.
158  virtual void removedVec(int i);
159  /// \p the i'th covector has been removed from the loaded LP.
160  virtual void removedCoVec(int i);
161  /// \p n vectors have been removed from the loaded LP.
162  virtual void removedVecs(const int perm[]);
163  /// \p n covectors have been removed from the loaded LP.
164  virtual void removedCoVecs(const int perm[]);
165  //@}
166 
167  //-------------------------------------
168  /**@name Consistency check */
169  //@{
170  /// checks for consistency
171  virtual bool isConsistent() const;
172  //@}
173 };
174 } // namespace soplex
175 #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
virtual SPxPricer * clone() const
clone function for polymorphism
Definition: spxweightpr.h:134
Representation
LP basis representation.
Definition: spxsolver.h:105
SPxPricer & operator=(const SPxPricer &rhs)
assignment operator
Definition: spxpricer.h:382
const R * get_const_ptr() const
Conversion to C-style pointer.
Definition: vectorbase.h:412
void computeCP(int start, int end)
compute weights for columns.
Definition: spxweightpr.cpp:79
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
SOPLEX_DEBUG.
Definition: spxdefines.h:200
Weighted pricing.Class SPxWeightPR is an implemantation class of SPxPricer that uses weights for colu...
Definition: spxweightpr.h:41
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:131
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.
Sequential object-oriented SimPlex.SPxSolver is an LP solver class using the revised Simplex algorith...
Definition: spxsolver.h:84
virtual bool isConsistent() const
checks for consistency
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:62
virtual int selectLeave()
SPxWeightPR & operator=(const SPxWeightPR &rhs)
assignment operator
Definition: spxweightpr.h:106
void setRep(SPxSolver::Representation rep)
set row/column representation
Definition: spxweightpr.cpp:25
virtual void load(SPxSolver *base)
sets the solver
Definition: spxweightpr.cpp:88
SPxWeightPR()
default constructor
Definition: spxweightpr.h:79
DVector rPenalty
row penalties
Definition: spxweightpr.h:51