-
Notifications
You must be signed in to change notification settings - Fork 0
/
SimplexBasis.cpp
83 lines (71 loc) · 1.76 KB
/
SimplexBasis.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include "SimplexBasis.h"
SimplexBasisHandler::SimplexBasisHandler() {
}
SimplexBasisHandler::SimplexBasisHandler(SimplexBasisPtr & data) :_data(data) {
}
SimplexBasisHandler::~SimplexBasisHandler() {
}
/*!
* \brief Stream output overloading for vector of IntVector
*
* \param stream : stream output
*
* \param rhs : vector of IntVector
*/
bool SimplexBasisHandler::operator<(SimplexBasisHandler const & other) const
{
return((get_row() < other.get_row()) || ((get_row() == other.get_row()) && (get_col() < other.get_col())));
}
/*!
* \brief Get basis status of the column in constraint matrix
*/
IntVector & SimplexBasisHandler::get_col() {
return _data->second;
}
/*!
* \brief Get basis status of each variable in the matrix
*/
IntVector & SimplexBasisHandler::get_row() {
return _data->first;
}
/*!
* \brief Get basis status of the column in constraint matrix
*/
IntVector const & SimplexBasisHandler::get_col() const {
return _data->second;
}
/*!
* \brief Get basis status of each variable in the matrix
*/
IntVector const & SimplexBasisHandler::get_row() const {
return _data->first;
}
/*!
* \brief Print function for simplex basis
*
* \param stream : stream output
*/
void SimplexBasisHandler::print(std::ostream & stream)const {
std::stringstream buffer;
buffer << "Rows : (";
for (int i(0); i < get_row().size(); i++) {
buffer << get_row()[i] << " ";
}
buffer << ") || Cols : (";
for (int i(0); i < get_col().size(); i++) {
buffer << get_col()[i] << " ";
}
buffer << ")";
stream << buffer.str();
}
/*!
* \brief Stream output overloading for simplex basis
*
* \param stream : stream output
*
* \param rhs : simplex basis to print
*/
std::ostream & operator<<(std::ostream & stream, SimplexBasisHandler const & rhs) {
rhs.print(stream);
return stream;
}