Toggle navigation
SCIP Optimization Suite
SCIP
SoPlex
ZIMPL
UG
GCG
Documentation
SoPlex 6.0.3
SoPlex 5.0.2
SoPlex 4.0.2
SoPlex 3.1.0
SoPlex 3.0.1
SoPlex 2.2.1
SoPlex
Sequential object-oriented simPlex
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
soplex-repo
src
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-2015 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.
40
SPxColId
()
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.
59
SPxRowId
()
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.
107
SPxId
()
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_