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-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 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  /// assignment operator
119  SPxId& operator=(const SPxId& id)
120  {
121  if(this != &id)
123 
124  return *this;
125  }
126  /// assignment operator
127  SPxId& operator=(const SPxColId& cid)
128  {
129  DataKey::operator= (cid);
130  info = COL_ID;
131  return *this;
132  }
133  /// assignment operator
134  SPxId& operator=(const SPxRowId& rid)
135  {
136  DataKey::operator= (rid);
137  info = ROW_ID;
138  return *this;
139  }
140  //@}
141 
142  //--------------------------------
143  /**@name Access / modification */
144  //@{
145  /// returns the type of the id.
146  inline Type type() const
147  {
148  return info ? (info < 0 ? ROW_ID : COL_ID) : INVALID;
149  }
150  /// returns TRUE iff the id is a valid column or row identifier.
151  inline bool isValid() const
152  {
153  return info != 0;
154  }
155  /// makes the id invalid.
156  inline void inValidate()
157  {
158  info = 0;
159  }
160  /// is id a row id?
161  inline bool isSPxRowId() const
162  {
163  return info < 0;
164  }
165  /// is id a column id?
166  inline bool isSPxColId() const
167  {
168  return info > 0;
169  }
170  //@}
171 
172  //------------------------------------
173  /**@name Comparison of Ids */
174  //@{
175  /// equality operator.
176  int operator==(const SPxId& id) const
177  {
178  return (this == &id);
179  }
180  /// inequality operator.
181  int operator!=(const SPxId& id) const
182  {
183  return (this != &id);
184  }
185  /// less then operator
186  bool operator<(const SPxId& id) const
187  {
188  return getIdx() < id.getIdx();
189  }
190  //@}
191 };
192 
193 
194 } // namespace soplex
195 #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:156
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:186
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:1136
SPxId & operator=(const SPxColId &cid)
assignment operator
Definition: spxid.h:127
int getIdx() const
gets the index number (idx) of the DataKey.
Definition: datakey.h:97
bool isSPxColId() const
is id a column id?
Definition: spxid.h:166
SPxId & operator=(const SPxId &id)
assignment operator
Definition: spxid.h:119
int info
user information to store values -1, 0, +1
Definition: datakey.h:55
DataKey & operator=(const DataKey &rhs)
Assignment operator.
Definition: datakey.h:76
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:181
bool isSPxRowId() const
is id a row id?
Definition: spxid.h:161
bool isValid() const
returns TRUE iff the id is a valid column or row identifier.
Definition: spxid.h:151
Type type() const
returns the type of the id.
Definition: spxid.h:146
int operator==(const SPxId &id) const
equality operator.
Definition: spxid.h:176
SPxId & operator=(const SPxRowId &rid)
assignment operator
Definition: spxid.h:134
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