Scippy

SoPlex

Sequential object-oriented simPlex

lpcolbase.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-2022 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 lpcolbase.h
17  * @brief LP column.
18  */
19 #ifndef _LPCOLBASE_H_
20 #define _LPCOLBASE_H_
21 
22 #include <assert.h>
23 
24 #include "soplex/spxdefines.h"
25 #include "soplex/basevectors.h"
26 
27 namespace soplex
28 {
29 /**@brief LP column.
30  * @ingroup Algo
31  *
32  * Class LPColBase provides a datatype for storing the column of an LP a the form similar to
33  * \f[
34  * \begin{array}{rl}
35  * \hbox{max} & c^T x \\
36  * \hbox{s.t.} & Ax \le b \\
37  * & l \le x \le u
38  * \end{array}
39  * \f]
40  * Hence, an LPColBase consists of an objective value, a column DSVector and an upper and lower bound to the corresponding
41  * variable, which may include \f$\pm\infty\f$. However, it depends on the LP code to use, what values are actually
42  * treated as \f$\infty\f$.
43  */
44 template < class R >
45 class LPColBase
46 {
47  template < class S > friend class LPColBase;
48 
49 private:
50 
51  // ------------------------------------------------------------------------------------------------------------------
52  /**@name Data */
53  ///@{
54 
55  R up; ///< upper bound
56  R low; ///< lower bound
57  R object; ///< objective value
58  DSVectorBase<R> vec; ///< the column vector
59 
60  ///@}
61 
62 public:
63 
64  // ------------------------------------------------------------------------------------------------------------------
65  /**@name Construction / destruction */
66  ///@{
67 
68  /// Default constructor.
69  /** Construct LPColBase with a column vector ready for taking \p defDim nonzeros.
70  */
71  explicit LPColBase<R>(int defDim = 0)
72  : up(R(infinity)), low(0), object(0), vec(defDim)
73  {
74  assert(isConsistent());
75  }
76 
77  /// Initializing constructor.
78  /* Construct LPColBase with the given objective value \p obj, a column %vector \p vec, upper bound \p upper and
79  * lower bound \p lower.
80  */
81  LPColBase<R>(const R& p_obj, const SVectorBase<R>& p_vector, const R& p_upper, const R& p_lower)
82  : up(p_upper), low(p_lower), object(p_obj), vec(p_vector)
83  {
84  assert(isConsistent());
85  }
86 
87  /// Copy constructor.
89  : up(old.up), low(old.low), object(old.object), vec(old.vec)
90  {
91  assert(isConsistent());
92  }
93 
94  /// Copy constructor.
95  template < class S >
97  : up(old.up), low(old.low), object(old.object), vec(old.vec)
98  {
99  assert(isConsistent());
100  }
101 
102  /// Destructor.
104  {}
105 
106  ///@}
107 
108  // ------------------------------------------------------------------------------------------------------------------
109  /**@name Access / modification */
110  ///@{
111 
112  /// Gets objective value.
113  R obj() const
114  {
115  return object;
116  }
117 
118  /// Sets objective value.
119  void setObj(const R& p_object)
120  {
121  object = p_object;
122  }
123 
124  /// Gets upper bound.
125  R upper() const
126  {
127  return up;
128  }
129 
130  /// Sets upper bound.
131  void setUpper(const R& p_up)
132  {
133  up = p_up;
134  }
135 
136  /// Gets lower bound.
137  R lower() const
138  {
139  return low;
140  }
141  /// Sets lower bound.
142  void setLower(const R& p_low)
143  {
144  low = p_low;
145  }
146 
147  /// Gets constraint column vector.
148  const SVectorBase<R>& colVector() const
149  {
150  return vec;
151  }
152 
153  /// Sets constraint column vector.
154  void setColVector(const SVectorBase<R>& p_vec)
155  {
156  vec = p_vec;
157  }
158 
159  ///@}
160 
161  // ------------------------------------------------------------------------------------------------------------------
162  /**@name Consistency check */
163  ///@{
164 
165  /// Checks consistency.
166  bool isConsistent() const
167  {
168 #ifdef ENABLE_CONSISTENCY_CHECKS
169  return vec.isConsistent();
170 #else
171  return true;
172 #endif
173  }
174 
175  ///@}
176 };
177 } // namespace soplex
178 #endif // _LPCOLBASE_H_
R low
lower bound
Definition: lpcolbase.h:56
THREADLOCAL const Real infinity
Definition: spxdefines.cpp:32
Dynamic sparse vectors.Class DSVectorBase implements dynamic sparse vectors, i.e. SVectorBases with a...
Definition: dsvectorbase.h:43
void setLower(const R &p_low)
Sets lower bound.
Definition: lpcolbase.h:142
R obj() const
Gets objective value.
Definition: lpcolbase.h:113
R object
objective value
Definition: lpcolbase.h:57
void setUpper(const R &p_up)
Sets upper bound.
Definition: lpcolbase.h:131
R lower() const
Gets lower bound.
Definition: lpcolbase.h:137
bool isConsistent() const
Checks consistency.
Definition: lpcolbase.h:166
const SVectorBase< R > & colVector() const
Gets constraint column vector.
Definition: lpcolbase.h:148
bool isConsistent() const
Consistency check.
Definition: dsvectorbase.h:294
Debugging, floating point type and parameter definitions.
DSVectorBase< R > vec
the column vector
Definition: lpcolbase.h:58
Collection of dense, sparse, and semi-sparse vectors.
Everything should be within this namespace.
~LPColBase()
Destructor.
Definition: lpcolbase.h:103
void setObj(const R &p_object)
Sets objective value.
Definition: lpcolbase.h:119
R upper() const
Gets upper bound.
Definition: lpcolbase.h:125
R up
upper bound
Definition: lpcolbase.h:55
Sparse vectors.Class SVectorBase provides packed sparse vectors. Such are a sparse vectors...
Definition: ssvectorbase.h:34
void setColVector(const SVectorBase< R > &p_vec)
Sets constraint column vector.
Definition: lpcolbase.h:154
LP column.Class LPColBase provides a datatype for storing the column of an LP a the form similar to ...
Definition: lpcolbase.h:45