SoPlex
Toggle main menu visibility
Loading...
Searching...
No Matches
src
soplex
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-2026 Zuse Institute Berlin (ZIB) */
7
/* */
8
/* Licensed under the Apache License, Version 2.0 (the "License"); */
9
/* you may not use this file except in compliance with the License. */
10
/* You may obtain a copy of the License at */
11
/* */
12
/* http://www.apache.org/licenses/LICENSE-2.0 */
13
/* */
14
/* Unless required by applicable law or agreed to in writing, software */
15
/* distributed under the License is distributed on an "AS IS" BASIS, */
16
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
17
/* See the License for the specific language governing permissions and */
18
/* limitations under the License. */
19
/* */
20
/* You should have received a copy of the Apache-2.0 license */
21
/* along with SoPlex; see the file LICENSE. If not email to soplex@zib.de. */
22
/* */
23
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
24
25
/**@file spxid.h
26
* @brief Row and columns Id's \ref soplex::SPxLP "SPxLP".
27
*/
28
#ifndef _SPXID_H_
29
#define _SPXID_H_
30
31
#include <iostream>
32
33
#include "
soplex/datakey.h
"
34
35
namespace
soplex
36
{
37
class
SPxId
;
38
39
/**@brief Ids for LP columns.
40
* @ingroup Algo
41
*
42
* Class SPxColId provides #DataKey%s for the
43
* column indices of an SPxLP.
44
*/
45
class
SPxColId
:
public
DataKey
46
{
47
public
:
48
/// default constructor.
49
SPxColId
()
50
{}
51
/// copy constructor from DataKey.
52
explicit
SPxColId
(
const
DataKey
& p_key);
53
/// copy constructor from SPxId.
54
explicit
SPxColId
(
const
SPxId
& p_key);
55
};
56
57
58
/**@brief Ids for LP rows.
59
* @ingroup Algo
60
*
61
* Class SPxRowId provides #DataKey%s for the row
62
* indices of an SPxLP.
63
*/
64
class
SPxRowId
:
public
DataKey
65
{
66
public
:
67
/// default constructor.
68
SPxRowId
()
69
{}
70
/// copy constructor from DataKey.
71
explicit
SPxRowId
(
const
DataKey
& p_key);
72
/// copy constructor from SPxId.
73
explicit
SPxRowId
(
const
SPxId
& p_key);
74
};
75
76
/**@brief Generic Ids for LP rows or columns.
77
* @ingroup Algo
78
*
79
* Both \ref soplex::SPxColId "SPxColIds" and \ref soplex::SPxRowId
80
* "SPxRowIds" may be treated uniformly as #SPxId%s:
81
*
82
* Rows and columns are numbered from 0 to num()-1 and 0 to dim()-1
83
* respectively. These numbers may be used to select individual rows or
84
* columns. However, these numbers may change if other rows or columns are
85
* added or removed.
86
*
87
* Further, each row or column of the problem matrix is assigned a \ref
88
* soplex::SPxRowId "SPxRowId" or \ref soplex::SPxColId "SPxColId",
89
* respectively. They are be used to select individual rows or columns just
90
* like numbers. In contrast to row and column numbers, ids remain unchanged
91
* for the time a row or column belongs to a SPxLP, no matter what other
92
* rows or columns are added to it or removed from it.
93
*/
94
class
SPxId
:
public
DataKey
95
{
96
friend
std::ostream&
operator<<
(std::ostream& os,
const
SPxId
&
id
);
97
98
public
:
99
100
//--------------------------------
101
/**@name Types */
102
///@{
103
/// type of the id.
104
enum
Type
105
{
106
ROW_ID
= -1,
///< row identifier.
107
INVALID
= 0,
///< invalid id.
108
COL_ID
= 1
///< column identifier.
109
};
110
///@}
111
112
//------------------------------------
113
/**@name Construction / destruction */
114
///@{
115
/// default constructor. Constructs an invalid id.
116
SPxId
()
117
:
DataKey
(
INVALID
, -1)
118
{}
119
/// constructs an id out of a column identifier \p cid.
120
explicit
SPxId
(
const
SPxColId
& cid)
121
:
DataKey
(
COL_ID
, cid.
idx
)
122
{}
123
/// constructs an id out of a row identifier \p rid.
124
explicit
SPxId
(
const
SPxRowId
& rid)
125
:
DataKey
(
ROW_ID
, rid.
idx
)
126
{}
127
128
/// assignment operator
129
SPxId
&
operator=
(
const
SPxColId
& cid)
130
{
131
DataKey::operator= (cid);
132
info
=
COL_ID
;
133
return
*
this
;
134
}
135
/// assignment operator
136
SPxId
&
operator=
(
const
SPxRowId
& rid)
137
{
138
DataKey::operator= (rid);
139
info
=
ROW_ID
;
140
return
*
this
;
141
}
142
///@}
143
144
//--------------------------------
145
/**@name Access / modification */
146
///@{
147
/// returns the type of the id.
148
inline
Type
type
()
const
149
{
150
return
info
? (
info
< 0 ?
ROW_ID
:
COL_ID
) :
INVALID
;
151
}
152
/// returns TRUE iff the id is a valid column or row identifier.
153
inline
bool
isValid
()
const
154
{
155
return
info
!= 0;
156
}
157
/// makes the id invalid.
158
inline
void
inValidate
()
159
{
160
info
= 0;
161
}
162
/// is id a row id?
163
inline
bool
isSPxRowId
()
const
164
{
165
return
info
< 0;
166
}
167
/// is id a column id?
168
inline
bool
isSPxColId
()
const
169
{
170
return
info
> 0;
171
}
172
///@}
173
174
//------------------------------------
175
/**@name Comparison of Ids */
176
///@{
177
/// equality operator.
178
int
operator==
(
const
SPxId
&
id
)
const
179
{
180
return
(
this
== &
id
);
181
}
182
/// inequality operator.
183
int
operator!=
(
const
SPxId
&
id
)
const
184
{
185
return
(
this
!= &
id
);
186
}
187
/// less then operator
188
bool
operator<
(
const
SPxId
&
id
)
const
189
{
190
return
getIdx
() <
id
.getIdx();
191
}
192
///@}
193
};
194
195
196
}
// namespace soplex
197
#endif
// _SPXID_H_
soplex::DataKey
Entry identifier class for items of a DataSet.
Definition
datakey.h:56
soplex::DataKey::getIdx
int getIdx() const
gets the index number (idx) of the DataKey.
Definition
datakey.h:91
soplex::DataKey::info
int info
user information to store values -1, 0, +1
Definition
datakey.h:64
soplex::DataKey::DataKey
DataKey()
Default constructor. Constructs an invalid DataKey.
Definition
datakey.h:74
soplex::DataKey::idx
int idx
(locally) unique key index
Definition
datakey.h:65
soplex::SPxColId
Ids for LP columns.
Definition
spxid.h:46
soplex::SPxColId::SPxColId
SPxColId()
default constructor.
Definition
spxid.h:49
soplex::SPxId
Generic Ids for LP rows or columns.
Definition
spxid.h:95
soplex::SPxId::SPxId
SPxId()
default constructor. Constructs an invalid id.
Definition
spxid.h:116
soplex::SPxId::operator<
bool operator<(const SPxId &id) const
less then operator
Definition
spxid.h:188
soplex::SPxId::isSPxColId
bool isSPxColId() const
is id a column id?
Definition
spxid.h:168
soplex::SPxId::Type
Type
type of the id.
Definition
spxid.h:105
soplex::SPxId::ROW_ID
@ ROW_ID
row identifier.
Definition
spxid.h:106
soplex::SPxId::COL_ID
@ COL_ID
column identifier.
Definition
spxid.h:108
soplex::SPxId::INVALID
@ INVALID
invalid id.
Definition
spxid.h:107
soplex::SPxId::operator!=
int operator!=(const SPxId &id) const
inequality operator.
Definition
spxid.h:183
soplex::SPxId::isValid
bool isValid() const
returns TRUE iff the id is a valid column or row identifier.
Definition
spxid.h:153
soplex::SPxId::operator=
SPxId & operator=(const SPxRowId &rid)
assignment operator
Definition
spxid.h:136
soplex::SPxId::SPxId
SPxId(const SPxRowId &rid)
constructs an id out of a row identifier rid.
Definition
spxid.h:124
soplex::SPxId::inValidate
void inValidate()
makes the id invalid.
Definition
spxid.h:158
soplex::SPxId::operator=
SPxId & operator=(const SPxColId &cid)
assignment operator
Definition
spxid.h:129
soplex::SPxId::isSPxRowId
bool isSPxRowId() const
is id a row id?
Definition
spxid.h:163
soplex::SPxId::SPxId
SPxId(const SPxColId &cid)
constructs an id out of a column identifier cid.
Definition
spxid.h:120
soplex::SPxId::type
Type type() const
returns the type of the id.
Definition
spxid.h:148
soplex::SPxId::operator<<
friend std::ostream & operator<<(std::ostream &os, const SPxId &id)
Definition
spxid.cpp:61
soplex::SPxId::operator==
int operator==(const SPxId &id) const
equality operator.
Definition
spxid.h:178
soplex::SPxRowId
Ids for LP rows.
Definition
spxid.h:65
soplex::SPxRowId::SPxRowId
SPxRowId()
default constructor.
Definition
spxid.h:68
datakey.h
Entry identifier class for items of a DataSet.
soplex
Everything should be within this namespace.
Generated by
1.17.0