Scippy

SoPlex

Sequential object-oriented simPlex

spxid.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 spxid.h
17  * @brief Row and columns Id's \ref soplex::SPxLP "SPxLP".
18  */
19 #ifndef _SPXID_H_
20 #define _SPXID_H_
21 
22 #include <iostream>
23 
24 #include "soplex/datakey.h"
25 
26 namespace soplex
27 {
28 class SPxId;
29 
30 /**@brief Ids for LP columns.
31  * @ingroup Algo
32  *
33  * Class SPxColId provides #DataKey%s for the
34  * column indices of an SPxLP.
35  */
36 class SPxColId : public DataKey
37 {
38 public:
39  /// default constructor.
41  {}
42  /// copy constructor from DataKey.
43  explicit SPxColId(const DataKey& p_key);
44  /// copy constructor from SPxId.
45  explicit SPxColId(const SPxId& p_key);
46 };
47 
48 
49 /**@brief Ids for LP rows.
50  * @ingroup Algo
51  *
52  * Class SPxRowId provides #DataKey%s for the row
53  * indices of an SPxLP.
54  */
55 class SPxRowId : public DataKey
56 {
57 public:
58  /// default constructor.
60  {}
61  /// copy constructor from DataKey.
62  explicit SPxRowId(const DataKey& p_key);
63  /// copy constructor from SPxId.
64  explicit SPxRowId(const SPxId& p_key);
65 };
66 
67 /**@brief Generic Ids for LP rows or columns.
68  * @ingroup Algo
69  *
70  * Both \ref soplex::SPxColId "SPxColIds" and \ref soplex::SPxRowId
71  * "SPxRowIds" may be treated uniformly as #SPxId%s:
72  *
73  * Rows and columns are numbered from 0 to num()-1 and 0 to dim()-1
74  * respectively. These numbers may be used to select individual rows or
75  * columns. However, these numbers may change if other rows or columns are
76  * added or removed.
77  *
78  * Further, each row or column of the problem matrix is assigned a \ref
79  * soplex::SPxRowId "SPxRowId" or \ref soplex::SPxColId "SPxColId",
80  * respectively. They are be used to select individual rows or columns just
81  * like numbers. In contrast to row and column numbers, ids remain unchanged
82  * for the time a row or column belongs to a SPxLP, no matter what other
83  * rows or columns are added to it or removed from it.
84  */
85 class SPxId : public DataKey
86 {
87  friend std::ostream& operator<<(std::ostream& os, const SPxId& id);
88 
89 public:
90 
91  //--------------------------------
92  /**@name Types */
93  ///@{
94  /// type of the id.
95  enum Type
96  {
97  ROW_ID = -1, ///< row identifier.
98  INVALID = 0, ///< invalid id.
99  COL_ID = 1 ///< column identifier.
100  };
101  ///@}
102 
103  //------------------------------------
104  /**@name Construction / destruction */
105  ///@{
106  /// default constructor. Constructs an invalid id.
108  : DataKey(INVALID, -1)
109  {}
110  /// constructs an id out of a column identifier \p cid.
111  explicit SPxId(const SPxColId& cid)
112  : DataKey(COL_ID, cid.idx)
113  {}
114  /// constructs an id out of a row identifier \p rid.
115  explicit SPxId(const SPxRowId& rid)
116  : DataKey(ROW_ID, rid.idx)
117  {}
118 
119  /// assignment operator
120  SPxId& operator=(const SPxColId& cid)
121  {
122  DataKey::operator= (cid);
123  info = COL_ID;
124  return *this;
125  }
126  /// assignment operator
127  SPxId& operator=(const SPxRowId& rid)
128  {
129  DataKey::operator= (rid);
130  info = ROW_ID;
131  return *this;
132  }
133  ///@}
134 
135  //--------------------------------
136  /**@name Access / modification */
137  ///@{
138  /// returns the type of the id.
139  inline Type type() const
140  {
141  return info ? (info < 0 ? ROW_ID : COL_ID) : INVALID;
142  }
143  /// returns TRUE iff the id is a valid column or row identifier.
144  inline bool isValid() const
145  {
146  return info != 0;
147  }
148  /// makes the id invalid.
149  inline void inValidate()
150  {
151  info = 0;
152  }
153  /// is id a row id?
154  inline bool isSPxRowId() const
155  {
156  return info < 0;
157  }
158  /// is id a column id?
159  inline bool isSPxColId() const
160  {
161  return info > 0;
162  }
163  ///@}
164 
165  //------------------------------------
166  /**@name Comparison of Ids */
167  ///@{
168  /// equality operator.
169  int operator==(const SPxId& id) const
170  {
171  return (this == &id);
172  }
173  /// inequality operator.
174  int operator!=(const SPxId& id) const
175  {
176  return (this != &id);
177  }
178  /// less then operator
179  bool operator<(const SPxId& id) const
180  {
181  return getIdx() < id.getIdx();
182  }
183  ///@}
184 };
185 
186 
187 } // namespace soplex
188 #endif // _SPXID_H_
Entry identifier class for items of a DataSet.
Type
type of the id.
Definition: spxid.h:95
void inValidate()
makes the id invalid.
Definition: spxid.h:149
SPxId(const SPxRowId &rid)
constructs an id out of a row identifier rid.
Definition: spxid.h:115
Ids for LP columns.Class SPxColId provides DataKeys for the column indices of an SPxLP.
Definition: spxid.h:36
bool operator<(const SPxId &id) const
less then operator
Definition: spxid.h:179
SPxRowId()
default constructor.
Definition: spxid.h:59
SPxColId()
default constructor.
Definition: spxid.h:40
Entry identifier class for items of a DataSet.Every item in a DataSet is assigned a DataKey by which ...
Definition: datakey.h:46
Generic Ids for LP rows or columns.Both SPxColIds and SPxRowIds may be treated uniformly as SPxIds: ...
Definition: spxid.h:85
std::ostream & operator<<(std::ostream &s, const VectorBase< R > &vec)
Output operator.
Definition: basevectors.h:1134
SPxId & operator=(const SPxColId &cid)
assignment operator
Definition: spxid.h:120
int getIdx() const
gets the index number (idx) of the DataKey.
Definition: datakey.h:82
bool isSPxColId() const
is id a column id?
Definition: spxid.h:159
int info
user information to store values -1, 0, +1
Definition: datakey.h:55
SPxId()
default constructor. Constructs an invalid id.
Definition: spxid.h:107
Everything should be within this namespace.
int operator!=(const SPxId &id) const
inequality operator.
Definition: spxid.h:174
bool isSPxRowId() const
is id a row id?
Definition: spxid.h:154
bool isValid() const
returns TRUE iff the id is a valid column or row identifier.
Definition: spxid.h:144
Type type() const
returns the type of the id.
Definition: spxid.h:139
int operator==(const SPxId &id) const
equality operator.
Definition: spxid.h:169
SPxId & operator=(const SPxRowId &rid)
assignment operator
Definition: spxid.h:127
Ids for LP rows.Class SPxRowId provides DataKeys for the row indices of an SPxLP. ...
Definition: spxid.h:55
int idx
(locally) unique key index
Definition: datakey.h:56
SPxId(const SPxColId &cid)
constructs an id out of a column identifier cid.
Definition: spxid.h:111