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