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-2017 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  , 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  // otherwise, old.penalty and old.coPenalty are not set and do not have to be copied
106  }
107  /// assignment operator
109  {
110  if(this != &rhs)
111  {
113  cPenalty = rhs.cPenalty;
114  rPenalty = rhs.rPenalty;
115  leavePenalty = rhs.leavePenalty;
116  objlength = rhs.objlength;
117  if (rhs.penalty == rhs.rPenalty.get_const_ptr())
118  {
119  penalty = rPenalty.get_const_ptr();
120  coPenalty = cPenalty.get_const_ptr();
121  }
122  else if (rhs.penalty == rhs.cPenalty.get_const_ptr())
123  {
124  penalty = cPenalty.get_const_ptr();
125  coPenalty = rPenalty.get_const_ptr();
126  }
127  // otherwise, old.penalty and old.coPenalty are not set and do not have to be copied
128  }
129 
130  return *this;
131  }
132  /// destructor
133  virtual ~SPxWeightPR()
134  {}
135  /// clone function for polymorphism
136  inline virtual SPxPricer* clone() const
137  {
138  return new SPxWeightPR(*this);
139  }
140  //@}
141 
142  //-------------------------------------
143  /**@name Access / modification */
144  //@{
145  /// sets the solver
146  virtual void load(SPxSolver* base);
147  /// set entering/leaving algorithm
148  void setType(SPxSolver::Type tp);
149  /// set row/column representation
151  ///
152  virtual int selectLeave();
153  ///
154  virtual SPxId selectEnter();
155  /// \p n vectors have been added to the loaded LP.
156  virtual void addedVecs (int n);
157  /// \p n covectors have been added to the loaded LP.
158  virtual void addedCoVecs(int n);
159  /// \p the i'th vector has been removed from the loaded LP.
160  virtual void removedVec(int i);
161  /// \p the i'th covector has been removed from the loaded LP.
162  virtual void removedCoVec(int i);
163  /// \p n vectors have been removed from the loaded LP.
164  virtual void removedVecs(const int perm[]);
165  /// \p n covectors have been removed from the loaded LP.
166  virtual void removedCoVecs(const int perm[]);
167  //@}
168 
169  //-------------------------------------
170  /**@name Consistency check */
171  //@{
172  /// checks for consistency
173  virtual bool isConsistent() const;
174  //@}
175 };
176 } // namespace soplex
177 #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:382
void computeCP(int start, int end)
compute weights for columns.
Definition: spxweightpr.cpp:79
const R * get_const_ptr() const
Conversion to C-style pointer.
Definition: vectorbase.h:453
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:215
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:136
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:133
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:84
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:108
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